00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: IMDSim.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.25 $ $Date: 2019/01/17 21:20:59 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * A class to handle the low-level setup and teardown of interactive MD 00019 * simulations. 00020 ***************************************************************************/ 00021 #ifndef IMD_SIM_H 00022 #define IMD_SIM_H 00023 00024 #include "imd.h" 00025 00027 class IMDSim { 00028 public: 00031 enum IMDStates {IMDOFFLINE,IMDSTARTING,IMDRUNNING,IMDPAUSED}; 00032 00034 IMDSim(const char *, int); 00035 virtual ~IMDSim(); 00036 00037 int isConnected() const { return sock != 0; } 00038 int getSimState() const { return simstate; } 00039 int next_ts_available() const { return new_coords_ready; } 00040 00042 virtual void update() {} 00043 00046 virtual void get_next_ts(float *, IMDEnergies *) = 0; 00047 virtual void send_forces(int, int *, float *) = 0; 00048 00049 virtual void pause() {} 00050 virtual void unpause() {} 00051 00052 virtual void detach() {} 00053 virtual void kill() {} 00054 virtual void set_transrate(int) {} 00055 00056 protected: 00057 void *sock; 00058 int new_coords_ready; 00059 int numcoords; 00060 int simstate; 00061 int need2flip; 00062 00063 void disconnect(); 00064 static void swap4_aligned(void *data, long ndata); 00065 00066 private: 00067 void handshake(); 00068 }; 00069 00070 #endif