Replica Exchange Molecular Dynamics
Anji Babu Kapakayala
Department of Chemistry
Indian Institute of Technology Kanpur, India
March 13, 2019
This tutorial comes in three parts. In the ﬁrst, the theory behind REMD
simulations will be brieﬂy described. Then we will look at how to perform t-
REMD on alanine dipeptide in vacuum condition with 4 replica between 300
K and 1000 K using gromacs package patched with plumed. the AMBER14SB
force ﬁeld will be used and each replica will run for 2 ns. Finally, we will analyze
the output ﬁles and construct free energy. This tutorial assumes that the reader
is comfortable with basic usage of Gromacs, Plumed and Linux commands.
Conformational sampling to simulate protein folding, drug binding processes us-
ing molecular dynamics is hampered by the slow barrier crossing conformational
transitions. To overcome this, several enhanced sampling methods have been
devised. Among these, global tempering approaches enhances the sampling of
all the degrees of freedom of the system. Parallel tempering replica exchange
molecular dynamics is a widely used global tempering method, where several
copies of the system are simulated at diﬀerent temperatures simultaneously and
independently, while exchange of coordinates between two adjacent replicas is
attempted after certain time intervals based on metropolis criteria. In this
manner, high temperature replicas deliver new conformations to the lower tem-
perature replicas which are otherwise very rarely sampled at low-temperatures.
In REMD, the exchange of adjacent replica will be attempted based on metropo-
lis criterion with following acceptance probability:
p(i−→ j) = min(1, e−∆)(1)
where U(Ri) and U(Rj) are the potential energies of replica iand jat temper-
atures βiand βjrespectively, where β=1
Schematic of Replica Exchange Molecular Dynamics(REMD) Simulation.
Things to be noted before starting REMD Simulation:
There are number of inter-connected issues to be considered while setting
up the simulation.
1. What range of temperatures do we need to span?
2. How many replicas do we need?
3. What exchange probability is needed?
Temperatures should be distributed across all the replicas in a geometric
progression which means keep the exchange rate constant across the tempera-
ture range. Depending on the number of processors available and the range of
temperature to sample, choose a exponential distribution:
Where, cis the desire acceptance ratio and T0is the starting temperature,
these two parameters can be tuned to obtain reasonable temperature intervals.
The exponential allows the increase in temperature intervals. As distribution
of total energy increases with temperature and thus exchange rate increases. In
the case of larger systems you may have to use large range of temperatures in
such scenario it is wise to use below link to get temperature range: Temperature
Generator for REMD:(http://folding.bmc.uu.se/remd/).
The literature suggest that an exchange acceptance probability is around 0.2
(i.e 20%) is a good idea. You will have to experiment with the number of repli-
cas you want to use to span the desired temperature range with 0.2 exchange
In this tutorial we will use only 4 replicas with temperatures 300, 366, 547,
996. These temperatures gives reasonable exchange probabilities as we are deal-
ing with alanine di-peptide in vacuum conditions. Whereas you might need to
use more number of replicas when you are looking for larger systems in explicit
2 Setting up REMD Simulation:
Note: To run the REMD simulations smoothly we will have to install gromacs
with mpi version and should be patched with plumed(optional).
In this part, we will build the initial structures using gmx2pdb tool and
perform REMD Simulation after short minimization and equilibration steps.
2.1 Preparation of Starting Structure
The necessary steps for preparing the starting structure is dependent of whether
you want to use explit solvent or vacuum or implicit solvent model. As in
this tutorial we will be preparing alanine di-peptide in vacuum conditions, the
preparation of initial structure are limited to generation of gromacs topology
(topol.top) and coordinates (conf.gro) ﬁles.
2.1.1 Topology Generation
The below command will generate the topology and coordinate ﬁles, by
default they are topol.top,conf.gro and porse.itp ﬁle (which is used
for positions restraints). During this step gromacs command will prompt
for choosing the force ﬁeld and solvent model. Choose the option for
AMBER14SB force ﬁelds and option None for the solvent model, as we
don’t required the solvent model for the vacuum simulations.
gmx pdb2gmx -f ala-dipeptide.pdb -ter -ignh
2.2 Energy Minimization
min.mdp:Input ﬁle for gromacs minimization in vacuum condition.
The above input(min.mdp) is to run 50000 steps of energy minimization
using the steepest descent algorithm for the vacuum condition. (refer
input parameter section of gromacs manual for the more details.) Now,
run these gromacs commands to perform the minimization run:
gmx grompp -f min.mdp -p topol.top -c conf.gro -o min.tpr
gmx mdrun -v -deﬀnm min
2.3 Equilibration of all the Replica
In principle, we will have to equilibrate the initial structure at every tem-
perature before starting the REMD simulation. As we are running vacuum
simulation this step can be skipped.
You can use this nvt.mdp ﬁle as input for the equilibration runs.
nvt.mdp:Input ﬁle for gromacs equilibration in vacuum condition.
You need to prepare 4 nvt.mdp ﬁles (nvt0.mdp, nvt1.mdp, nvt2.mdp and
nvt3.mdp) for the respective temperature replica. In the above nvt.mdp
ﬁle modify ref t tag for diﬀerent temperatures. And copy the mini.gro
from the minimization run and use this command to run Equilibration:
gmx grompp -f nvt.mdp -p topol.top -c mini.gro -o nvt.tpr
gmx mdrun -v -deﬀnm nvt
2.4 REMD Simulation
We will be running REMD simulation using 4 replica with temperature
range 300, 366, 547, 996. We have to prepare the input ﬁles as said above.
Prepare 4 sets of inputs
[ala0.gro, nvt0.mdp] corresponds to ref t=300
[ala1.gro, nvt1.mdp] corresponds to ref t=366
[ala2.gro, nvt2.mdp] corresponds to ref t=547
[ala3.gro, nvt3.mdp] corresponds to ref t=996
For temperature-REMD we need to run a number of simulations that can
communicate. This is done via mdrun -multi option in gromacs, and
-replex tag also needs to be used to provide desired exchange frequency.
Construct 4 *.tpr ﬁles using above gromacs command.
we can also write a small shell script to do that using loops: submit.sh
for i in 0 1 2 3;do
gmx grompp -f nvt$i.mdp -p topol.top -c mini.gro -o remd$i.tpr
mpirun -np 4 gmx mpi mdrun -v -deﬀnm remd -multi 4 -replex
2.4.1 REMD with Plumed
In the case of using plumed you will have to give additional -plumed
tag in the command and make sure gromacs is patched with plumed and
you place plumed input ﬁle (plumed.dat) in the same working directory.
Whereas the plumed input for alanine di-peptide phi psi as collective
# set up two variables for Phi and Psi dihedral angles
phi: TORSION ATOMS=5,7,9,15
psi: TORSION ATOMS=7,9,15,17
# monitor the two variables
PRINT STRIDE=10 ARG=phi,psi FILE=COLVAR
And the submit script will look like: (submit.sh)
for i in 0 1 2 3;do
gmx grompp -f nvt$i.mdp -p topol.top -c mini.gro -o remd$i.tpr
mpirun -np 4 gmx mpi mdrun -v -deﬀnm remd -plumed
plumed.dat -multi 4 -replex 100
-np = No of processors used
-multi= Instruct the program to preform multi (4) runs
-replex = Instruct the system to attend an exchange at every 100 steps.
3 Post Processing & Analysis:
3.1 Observing Replica Exchange Statistics
You can ﬁnd the replica exchange statistics such as exchange probabilities
and the exchanges of replica involved in every 100 steps in the remd$i.log
grep -A9 ”average probabilities” *.log
The output of this command should print as bellow.
Log::Replica exchange statistics extracted from log ﬁles.
In the above replica exchange statistics, the exchanges were accepted with
an exchange probability 0.5 (i.e 50%). In case you could ﬁnd those prob-
abilities as 0.0, which means that, your chosen temperature range may
not be suﬃcient enough for the potential energy overlap to accept the ex-
changes with reasonable exchange probability. In such scenario, you might
need to go back and repeat the simulations with reasonable temperature
3.2 Concatenate the trajectories
By concatenating all the log ﬁles into single log ﬁle (REMD.log) and by
using gromacs built-in tool demux.pl will generate the replica index.xvg
and replica temp.xvg ﬁles. We need a trajectory with continuous co-
ordinates despite the jumps in the ensemble space due to attempted ex-
changes. This trajectory can be generated using gmx trjcat tool with
-demux tag and above index ﬁles.
You can use the below commands to do this:
# Concatenate log ﬁles
cat *.log >REMD.log
# De-multiplexing a REMD trajectory
gmx trjcat -f *.xtc -demux replica index.xvg
3.3 Checking Potential Energy Overlap
As we have discussed above (referring Schematic of REMD) the metropo-
lis criteria is dependent of the potential energy deference of the replicas
(∆U(R)). Which means that to make sure the adjacent replicas to be
sampled the continuous coordinates their potential energy distributions
should overlap else the metropolis criteria will reject the exchange.
And also make a note that checking distributions of potential energy over-
lap is the wise idea to check whether the taken temperature range is re-
quired enough or not. See the PE overlap of 4 replica:
Fig:4:Overlap of distributions of potential energy of each replica.
You can get the potential energy of each replica with time using gmx
energy tool and then you can use xmgrace or self written program to
get the distribution of it.
# Choose potential energy on screen to print data into ﬁle
gmx energy -f remd.edr -s remd.tpr -o PE.xvg
3.4 Construction of FES
In the case of using PLUMED, you can see the COLVAR.$i ﬁles for thr
respective temperature replica. you can plot the CV values with time to
check their evaluation. Gnuplot commands to plot CV v/s Time of 300
K replica are as follows:
# Open Gnuplot on terminal
plot ”COLVAR.0” u 1:2 w l lw 2 title”PHI”
plot ”COLVAR.0” u 1:3 w l lw 2 title”PSI”
Whereas, the 1D free energy surface along Phi and Psi of the replica at
300 K, can be constructed using plumed in-built tool sum hills with fol-
# Construct FES using sum hills
plumed sum hills –histo COLVAR.0 –idw phi –sigma 0.2 –kt
2.5 –outhisto fes phi.dat
plumed sum hills –histo COLVAR.0 –idw psi –sigma 0.2 –kt 2.5
–outhisto fes psi.dat
sum hills is the plumed biult-in tool which can be used to post process the
existing HILLS or COLVAR ﬁles produced by plumed. Refer the plumed
website2,3for the more details about sum hills.
–histo = Calculates the histogram (i.e Probability P(s) ) of the given
CV with given ﬁle name COLVAR.
–idw = Speciﬁes the variables to be used for calculating the histogram.
-sigma = Specify the bin width while binning histogram.
–kt = The Temperature of system in the energy units (kJ mol−1). In
the above case kt = 2.5 (kJmol−1) is corresponds to 300 K
–outhisto = Specify the ﬁle name to write the histogram data.
These command will produce the following ﬁgures:
Fig:5:Free energy along Phi.
Fig:6:Free energy along Psi.
2-D Free Energy:
The 2D free energy surface(Fig.7) can also be constructed using same
plumed sum hills tool.
# Construct 2D FES using sum hills
mv COLVAR.0 COLVAR
plumed sum hills –histo COLVAR –sigma 0.2,0.2 –kt 2.5
–outhisto fes 2D.dat
Fig:7. 2D FES (k J mol-1) of Alanine di-peptide corresponding
to the replica at 300 K produced from 2ns REMD simulation
To be conclude we have discussed the underlying theory of REMD and set-
ting up the simulations along with using the post processing commands
and tools. A shell script to run this complete tutorial by using ala di-
pep.pdb as input, can be found at Nisanth Nair Research Group Github
1. Sugita, Y.; Okamoto, Y. Chem. Phys. Lett. 1999, 314 (1–2),
2. Plumed: [http://www.plumed.org/]
3. More about sum hills: Click here
4. Nisanth Nair Research Group (GitHub Page): Click here.
@−−−−−−−−T heE nd −−−−−−−@