Gromacs  2021.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
gmx::ImdSession::Impl Class Reference
+ Collaboration diagram for gmx::ImdSession::Impl:


Implementation type for the IMD session.


Make this class (or one extracted from it) model IForceProvider.

Use RAII for files and allocations

Public Member Functions

 Impl (const MDLogger &mdlog)
void prepareMasterSocket ()
 Prepare the socket on the MASTER.
void disconnectClient ()
 Disconnect the client.
void issueFatalError (const char *msg)
 Prints an error message and disconnects the client. More...
bool tryConnect ()
 Check whether we got an incoming connection.
void blockConnect ()
 Wrap imd_tryconnect in order to make it blocking. More...
void prepareVmdForces ()
 Make sure that our array holding the forces received via IMD is large enough.
void readVmdForces ()
 Reads forces received via IMD.
void prepareMDForces ()
 Prepares the MD force arrays.
void copyToMDForces ()
 Copy IMD forces to MD forces. More...
bool bForcesChanged () const
 Return true if any of the forces or indices changed.
void keepOldValues ()
 Update the old_f_ind and old_forces arrays to contain the current values.
void outputForces (double time)
 Write the applied pull forces to logfile. More...
void syncNodes (const t_commrec *cr, double t)
 Synchronize the nodes.
void readCommand ()
 Reads header from the client and decides what to do.
void openOutputFile (const char *fn, int nat_total, const gmx_output_env_t *oenv, StartingBehavior startingBehavior)
 Open IMD output file and write header information. More...
void prepareMoleculesInImdGroup (const gmx_mtop_t *top_global)
 Creates the molecule start-end position array of molecules in the IMD group.
void removeMolecularShifts (const matrix box)
 Removes shifts of molecules diffused outside of the box.
void prepareForPositionAssembly (const t_commrec *cr, const rvec x[])
 Initialize arrays used to assemble the positions from the other nodes.
bool run (int64_t step, bool bNS, const matrix box, const rvec x[], double t)
 Interact with any connected VMD session.

Public Attributes

bool sessionPossible = false
 True if tpr and mdrun input combine to permit IMD sessions.
FILE * outf = nullptr
 Output file for IMD data, mainly forces.
int nat = 0
 Number of atoms that can be pulled via IMD.
int nat_loc = 0
 Part of the atoms that are local.
int * ind = nullptr
 Global indices of the IMD atoms.
int * ind_loc = nullptr
 Local indices of the IMD atoms.
int nalloc_loc = 0
 Allocation size for ind_loc.
rvec * xa = nullptr
 Positions for all IMD atoms assembled on the master node.
ivec * xa_shifts = nullptr
 Shifts for all IMD atoms, to make molecule(s) whole.
ivec * xa_eshifts = nullptr
 Extra shifts since last DD step.
rvec * xa_old = nullptr
 Old positions for all IMD atoms on master.
int * xa_ind = nullptr
 Position of each local atom in the collective array.
int nstimd = 1
 Global IMD frequency, known to all ranks.
int nstimd_new = 1
 New frequency from IMD client, master only.
int defaultNstImd = -1
 Default IMD frequency when disconnected.
int port = 0
 Port to use for network socket.
IMDSocketsocket = nullptr
 The IMD socket on the master node.
IMDSocketclientsocket = nullptr
 The IMD socket on the client.
int length = 0
 Length we got with last header.
bool bWConnect = false
 Shall we block and wait for connection?
bool bTerminated = false
 Set if MD is terminated.
bool bTerminatable = false
 Set if MD can be terminated.
bool bConnected = false
 Set if connection is present.
bool bNewForces = false
 Set if we received new forces.
bool bForceActivated = false
 Set if pulling from VMD is allowed.
IMDEnergyBlockenergies = nullptr
 Pointer to energies we send back.
int32_t vmd_nforces = 0
 Number of VMD forces.
int32_t * vmd_f_ind = nullptr
 VMD forces indices.
float * vmd_forces = nullptr
 The VMD forces flat in memory.
int nforces = 0
 Number of actual MD forces; this gets communicated to the clients.
int * f_ind = nullptr
 Force indices.
rvec * f = nullptr
 The IMD pulling forces.
char * forcesendbuf = nullptr
 Buffer for force sending.
char * coordsendbuf = nullptr
 Buffer for coordinate sending.
char * energysendbuf = nullptr
 Send buffer for energies.
rvec * sendxbuf = nullptr
 Buffer to make molecules whole before sending.
t_block mols
 Molecules block in IMD group.
int old_nforces = 0
 Old value for nforces.
int * old_f_ind = nullptr
 Old values for force indices.
rvec * old_forces = nullptr
 Old values for IMD pulling forces.
const MDLoggermdlog
const t_commrec * cr = nullptr
 Commmunication object.
gmx_wallcycle * wcycle = nullptr
 Wallcycle counting manager.
gmx_enerdata_tenerd = nullptr
 Energy output handler.

Member Function Documentation

void gmx::ImdSession::Impl::blockConnect ( )

Wrap imd_tryconnect in order to make it blocking.

Used when the simulation should wait for an incoming connection.

void gmx::ImdSession::Impl::copyToMDForces ( )

Copy IMD forces to MD forces.

Do conversion from Cal->Joule and from Angstrom -> nm and from a pointer array to arrays to 3*N array.

void gmx::ImdSession::Impl::issueFatalError ( const char *  msg)

Prints an error message and disconnects the client.

Does not terminate mdrun!

void gmx::ImdSession::Impl::openOutputFile ( const char *  fn,
int  nat_total,
const gmx_output_env_t *  oenv,
const gmx::StartingBehavior  startingBehavior 

Open IMD output file and write header information.

Call on master only.

void gmx::ImdSession::Impl::outputForces ( double  time)

Write the applied pull forces to logfile.

Call on master only!

The documentation for this class was generated from the following file: