Interactive Molecular Dynamics with GROMACS

Interactive Molecular Dynamics (IMD) allows users to monitor and interact with a running molecular dynamics (MD) simulation. To achieve this, we implemented the IMD protocol [1] in GROMACS 5.0. The user can interact with the simulation by pulling on atoms, residues or fragments with a mouse or force-feedback devices.

Features

IMD allows monitoring of and interaction with running simulations. The first NAMD / VMD implementation of IMD goes back to 2001. IMD is included in GROMACS from version 5.0 on. We also provide a patch for the 4.6 version (see below). Features of our implementation are:

  • Clean Interface: Only 4 hooks within the MD loop
  • Correct PBC treatment, molecules are made whole as in input .tpr
  • IMD group can be set to interact with, transmit and display only a subset of atoms
  • Negligible impact on performance (particularly when client is disconnected)
  • also runs on Windows

Flowchart of the GROMACS IMD implementation and the communication with a VMD client.

Installation

The easiest way to use IMD with GROMACS is to download a 5.x version, see www.gromacs.org. Alternatively, the github repository http://github.com/martinhoefling/gromacs contains a release-4-6-imd branch with an IMD-enabled GROMACS 4.6. It can be build as described on http://www.gromacs.org/Developer_Zone/Git.

Simulation input preparation

The GROMACS implementation allows transmission and interaction with a part of the running simulation only, e.g. in cases where no water molecules should be transmitted or pulled. The group is specified via the IMD-group .mdp option. When IMD-group is empty, the IMD protocol is disabled and cannot be enabled via the switches in mdrun. To interact with the entire system, IMD-group has to be set to System. When using grompp, a .gro file to be used with VMD is written out (-imd switch of grompp).

Starting the simulation

Communication between VMD and GROMACS is achieved via TCP sockets and thus enables controlling an mdrun running locally or on a remote cluster. The port for the connection can be specified with the -imdport switch of mdrun, 8888 is the default. Every N steps, the client receives the applied forces from the VMD client and sends the new positions to the client. The frequency for communication with the client can be set in VMD. By default, the simulation starts and runs even if no IMD client is connected. This behavior is changed by the -imdwait switch of mdrun. After startup and whenever the client has disconnected, the integration stops until reconnection of the client. When the -imdterm switch is used, the simulation can be terminated pressing the stop button in VMD. Finally, to turn on interaction with the simulation (i.e. pulling from VMD) the -imdpull switch has to be used. Therefore, a simulation can only be monitored but not influenced from the VMD client when none of -imdwait, -imdterm or -imdpull are set. However, since the IMD protocol requires no authentication, it is not advisable to run simulations on a host directly reachable from an insecure environment. Secure shell forwarding of TCP can be used to connect to running simulations not directly reachable from the interacting host.

Connecting from VMD

In VMD, first the structure corresponding to the IMD group has to be loaded (File → New Molecule ...). Then the IMD connection window has to be used (Extensions → Simulation → IMD Connect (NAMD)). In the IMD connection window, hostname and port have to be specified and followed by pressing Connect. Detach Sim allows disconnecting without terminating the simulation, while Stop Sim ends the simulation on the next neighbor searching step (if allowed by -imdterm). The timestep transfer rate allows adjusting the communication frequency between simulation and IMD client. Setting the keep rate loads every Nth frame into VMD instead of discarding them when a new one is received. The displayed energies are in SI units in contrast to energies displayed from NAMD simulations.

Example application: Interactive Streptavidin-Biotin unbinding with GROMACS

To run the example, please download the Streptavidin-Biotin GROMACS input files (see download box on the right).

tar -xvzf imdexample.tgz

cd imdexample/

source /path/to/your/gromacs/installation/bin/GMXRC

gmx grompp -f md.mdp -c npt.gro -maxwarn 1

The GROMACS preprocessor will write out the file imdgroup.gro that we will use as input for VMD:

vmd imdgroup.gro

For a representation of the Streptavidin-Biotin complex similar to the picture on the right, choose

Graphics→Representations
Selected Atoms: all
Coloring Method→Index
Drawing Method→New Cartoon

Create Rep

Selected Atoms: resname BTN
Drawing Method→VDW
Coloring Method→Type

To start the molecular dynamics simulation, type

gmx mdrun -s topol.tpr -imdwait -imdpull -imdterm

GROMACS should now print on the command line:

IMD: Enabled. This simulation will accept incoming IMD connections.
IMD: Pausing simulation while no IMD connection present (-imdwait).
IMD: Allow termination of the simulation from IMD client (-imdterm).
IMD: Pulling from IMD remote is enabled (-imdpull).
IMD: Turning on IMD - port for incoming requests is 8888.
IMD: Setting up incoming socket.
IMD: Listening for IMD connection on port 8888.
IMD: Will wait until I have a connection and IMD_GO orders.

So go to your VMD client, choose

Extensions→Simulation→IMD connect (NAMD)

and type into the fields of the pop-up window:

Hostname: localhost
Port: 8888

Then, click on the Connect button to signal GROMACS to start the simulation. Depending on the computing power of your workstation (or cluster if your are running on one instead), you may want to set the Timestep transfer rate to 1 or some higher value.

With

Mouse→Force→Residue (or Atom)

you can now pull the Biotin molecule out of the Streptavidin binding pocket. Afterwards, you may want to try to get it in again!

Go to Editor View