To create, maintain, and access a connection to a molecular dynamics simulation running on a remote computer (which may just happen to be the same computer running VMD), the objects illustrated in figure 4 are used.
The Remote object is used to encapsulate the functionality for initializing, accessing, and controlling a remote simulation. This object contains all the data necessary to create a new simulation or to attach to an already-running simulation. It also contains member functions for querying whether a simulation may be run on another computer, for retrieving the list of available MD programs or jobs on that computer, for obtaining and modifying parameters necessary to start a new job, and for actually starting, attaching to, or stopping an MD simulation.
There are three phases in the task of displaying a molecule in VMD which is being simulated by a separate MD process; they must be accomplished in this order:
As mentioned, once the connection is established and the structure sent over the network to VMD, a new Molecule can be created. At the very beginning of the procedure just outlined for creating a connection, an instance of a Remote is created to proceed through the phases. After this is complete and the connection is successful, the Remote instance is given to a new MoleculeRemote object, which uses the data in Remote to construct a new molecule in VMD just as if the data were being read from a file. If another simulation is to be started or attached to, another Remote instance must be created. Any number of simulations may be attached to by VMD during a single session, even all the same time. However, there can only be one Remote object being used to initialize a new connection at any one time. Thus, there is one global instance of a Remote object, referred to by the global variable remote; this is used for setting up a simulation, and if the setup is successful the instance is used to create a new MoleculeRemote, after which a brand new instance of a Remote is created and assigned to remote.
MoleculeRemote acts very much like a MoleculeFile, except structure data is retrieved from the provided Remote instance. It also provides a version of the prepare virtual routine (originally defined in the Displayable class). When prepare is called, the MoleculeRemote checks for and processes any new data is available from the remote connection (i.e., new coordinate sets recently computed by the simulation). It also maintains any special items used for graphical display of the simulation, for example the DrawPatch object. DrawPatch is a Displayable, and is used to graphically depict the shape and status (via different coloring schemes) of the volumes of space in which the molecule moves in the simulation. This acts very much like DrawMolItem, by being a child Displayable to the MoleculeRemote which creates it.
The final object used specifically for remote simulation control is the RemoteList, which functions very much like a MoleculeList but which instead keeps a list of MoleculeRemote pointers. If a molecule is read from just some data files, it is stored by the MoleculeList but not the RemoteList (since it is not from a remote connection). If the molecule is from a remote simulation, the pointer to the molecule is stored by both MoleculeList (as a Molecule * pointer) and RemoteList (as a MoleculeRemote * pointer). This allows VMD to distinguish which molecule is part of a presently or previously active simulation. Even if the simulation is terminated, the reference in RemoteList is maintained since the molecule was at some point part of a simulation.