Gromacs  2024.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Enumerations | Functions | Variables
#include "gmxpre.h"
#include "imd.h"
#include "config.h"
#include <cerrno>
#include <cstring>
#include "gromacs/commandline/filenm.h"
#include "gromacs/domdec/domdec_struct.h"
#include "gromacs/domdec/ga2la.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/xvgr.h"
#include "gromacs/gmxlib/network.h"
#include "gromacs/imd/imdsocket.h"
#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/broadcaststructs.h"
#include "gromacs/mdlib/groupcoord.h"
#include "gromacs/mdlib/sighandler.h"
#include "gromacs/mdlib/stat.h"
#include "gromacs/mdrunutility/handlerestart.h"
#include "gromacs/mdrunutility/multisim.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/mdtypes/enerdata.h"
#include "gromacs/mdtypes/imdmodule.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/mdtypes/mdrunoptions.h"
#include "gromacs/mdtypes/state.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/timing/wallcycle.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/enumerationhelpers.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/logger.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
+ Include dependency graph for imd.cpp:


Implements Interactive Molecular Dynamics.

Re-implementation of basic IMD functions to work with VMD, see imdsocket.h for references to the IMD API.

Martin Hoefling, Carsten Kutzner


struct  gmx::IMDEnergyBlock
 IMD (interactive molecular dynamics) energy record. More...
struct  gmx::IMDHeader
 IMD (interactive molecular dynamics) communication structure. More...
class  gmx::ImdSession::Impl
 Implementation type for the IMD session. More...
class  gmx::InteractiveMolecularDynamics
 Implement interactive molecular dynamics. More...


enum  gmx::IMDMessageType : int {
  gmx::IMDMessageType::Disconnect, gmx::IMDMessageType::Energies, gmx::IMDMessageType::FCoords, gmx::IMDMessageType::Go,
  gmx::IMDMessageType::Handshake, gmx::IMDMessageType::Kill, gmx::IMDMessageType::Mdcomm, gmx::IMDMessageType::Pause,
  gmx::IMDMessageType::TRate, gmx::IMDMessageType::IOerror, gmx::IMDMessageType::Count
 Enum for types of IMD messages. More...


std::unique_ptr< IMDModule > gmx::createInteractiveMolecularDynamicsModule ()
 Creates a module for interactive molecular dynamics.
static const char * gmx::enumValueToString (IMDMessageType enumValue)
 Names of the IMDType for error messages.
static void gmx::fill_header (IMDHeader *header, IMDMessageType type, int32_t length)
 Fills the header with message and the length argument.
static void gmx::swap_header (IMDHeader *header)
 Swaps the endianess of the header.
static int32_t gmx::imd_read_multiple (IMDSocket *socket, char *datptr, int32_t toread)
 Reads multiple bytes from socket.
static int32_t gmx::imd_write_multiple (IMDSocket *socket, const char *datptr, int32_t towrite)
 Writes multiple bytes to socket in analogy to imd_read_multiple.
static int gmx::imd_handshake (IMDSocket *socket)
 Handshake with IMD client.
static int gmx::imd_send_energies (IMDSocket *socket, const IMDEnergyBlock *energies, char *buffer)
 Send energies using the energy block and the send buffer.
static IMDMessageType gmx::imd_recv_header (IMDSocket *socket, int32_t *length)
 Receive IMD header from socket, sets the length and returns the IMD message.
static bool gmx::imd_recv_mdcomm (IMDSocket *socket, int32_t nforces, int32_t *forcendx, float *forces)
 Receive force indices and forces. More...
void gmx::write_IMDgroup_to_file (bool bIMD, t_inputrec *ir, const t_state *state, const gmx_mtop_t &sys, int nfile, const t_filenm fnm[])
 Writes out the group of atoms selected for interactive manipulation. More...
static int gmx::imd_send_rvecs (IMDSocket *socket, int nat, rvec *x, char *buffer)
 Send positions from rvec. More...
static bool gmx::rvecs_differ (const rvec v1, const rvec v2)
 Returns true if any component of the two rvecs differs.
static void gmx::shift_positions (const matrix box, rvec x[], const ivec is, int nr)
 Copied and modified from groupcoord.c shift_positions_group().
static void gmx::imd_check_integrator_parallel (const t_inputrec *ir, const t_commrec *cr)
 Check for non-working integrator / parallel options.
std::unique_ptr< ImdSession > gmx::makeImdSession (const t_inputrec *ir, const t_commrec *cr, gmx_wallcycle *wcycle, gmx_enerdata_t *enerd, const gmx_multisim_t *ms, const gmx_mtop_t &top_global, const MDLogger &mdlog, gmx::ArrayRef< const gmx::RVec > coords, int nfile, const t_filenm fnm[], const gmx_output_env_t *oenv, const ImdOptions &options, StartingBehavior startingBehavior)
 Makes and returns an initialized IMD session, which may be inactive. More...


constexpr int gmx::c_loopWait = 1
 How long shall we wait in seconds until we check for a connection again?
constexpr int gmx::c_connectWait = 1
 How long shall we check for the IMD_GO?
constexpr int gmx::c_headerSize = 8
 IMD Header Size.
constexpr int gmx::c_protocolVersion = 2
 IMD Protocol Version.