A Quick Guide to Temperature Replica Exchange Molecular Dynamics

Dec 17, 2023·
Yassir Boulaamane
Yassir Boulaamane
· 3 min read

One thermostat at 300 K will sit in the basin where you started. Temperature replica exchange runs copies of the same system on a temperature ladder and swaps neighbors so that a barrier crossed at high temperature can appear in the 300 K ensemble.

The example is eight replicas from 300 K to 370 K, in 10 K steps, exchanging every 1000 steps. The .mdp files are not pasted here. Only the temperatures and the mdrun line are.

Eight temperatures, exchanges, then the 300 K ensembleA ladder from 300 K to 370 K in 10 K steps. Neighboring replicas attempt a swap every 1000 steps. After demux, analysis uses the 300 K trajectory. The acceptance target in this note is 20 to 30 percent.Hot replicas cross. You analyze 300 K.Swap neighbors every 1000 steps. Aim for 20–30% accepted.300310320330340350360370demux, then the 300 K frames
Figure 1. The ladder is the eight temperatures in the example, 300 K through 370 K. Exchanges are attempted between neighbors. The trajectory you interpret is the one demultiplexed at the low temperature, not a splice of every replica.

Why a ladder

A rugged landscape traps a single 300 K run. A hotter replica crosses barriers more often. Swaps are accepted or rejected so that each temperature still samples the Boltzmann distribution at that temperature. In a protein–ligand system the states you are usually missing are induced fit, an alternate loop, a cryptic pocket, or a folding event. Short dynamics of a small molecule often do not need this.

The acceptance probability

For replicas \( i \) and \( j \), the swap probability \( P \) is the Metropolis form recorded for this method:

P = min(1, exp[(1/Ti - 1/Tj) * (Ej - Ei)])

Ti and Tj are the temperatures. Ei and Ej are the potential energies. Spacing that is too wide kills the acceptance. Spacing that is too tight spends replicas without helping. This note aims at a 20–30% acceptance rate.

Eight GROMACS inputs

Create md_300.mdp through md_370.mdp with the temperature each replica should hold. Then grompp each one. -maxwarn 1 is part of the recorded command.

gmx grompp -f md_300.mdp -o topol_300.tpr -c conf.gro -p topol.top -maxwarn 1
gmx grompp -f md_310.mdp -o topol_310.tpr -c conf.gro -p topol.top -maxwarn 1
gmx grompp -f md_370.mdp -o topol_370.tpr -c conf.gro -p topol.top -maxwarn 1

The middle temperatures follow the same pattern. The run itself:

mpirun -np 8 gmx_mpi mdrun -multi 8 -replex 1000 -s topol_.tpr -deffnm remd

-multi 8 is the eight replicas. -replex 1000 attempts an exchange every 1000 steps. -s topol_.tpr matches the shared prefix of the .tpr files. One rank per replica is the cost model here.

Demux before you analyze

mdrun -replex writes trajectories that follow a rank, not a temperature. Demultiplex, then take the frames that sat at 300 K.

gmx demux -f remd0.xtc -demux replica_index.xvg

Equilibrate every replica before the exchange run. Analyze the lowest temperature. The hotter trajectories are the mechanism that feeds it, not a second ensemble to mix into the same plot.