2 % This file is part of the GROMACS molecular simulation package.
4 % Copyright (c) 2013,2014, by the GROMACS development team, led by
5 % Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 % and including many others, as listed in the AUTHORS file in the
7 % top-level source directory and at http://www.gromacs.org.
9 % GROMACS is free software; you can redistribute it and/or
10 % modify it under the terms of the GNU Lesser General Public License
11 % as published by the Free Software Foundation; either version 2.1
12 % of the License, or (at your option) any later version.
14 % GROMACS is distributed in the hope that it will be useful,
15 % but WITHOUT ANY WARRANTY; without even the implied warranty of
16 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 % Lesser General Public License for more details.
19 % You should have received a copy of the GNU Lesser General Public
20 % License along with GROMACS; if not, see
21 % http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 % Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 % If you want to redistribute modifications to GROMACS, please
25 % consider that scientific software is very special. Version
26 % control is crucial - bugs must be traceable. We will be happy to
27 % consider code for inclusion in the official distribution, but
28 % derived work must not be called official GROMACS. Details are found
29 % in the README & COPYING files - if they are missing, get the
30 % official version at http://www.gromacs.org.
32 % To help us fund GROMACS development, we humbly ask that you cite
33 % the research papers on the package. Check out http://www.gromacs.org.
35 \newcommand{\nproc}{\mbox{$M$
}}
36 \newcommand{\natom}{\mbox{$N$
}}
37 \newcommand{\nx}{\mbox{$n_x$
}}
38 \newcommand{\ny}{\mbox{$n_y$
}}
39 \newcommand{\nz}{\mbox{$n_z$
}}
40 \newcommand{\nsgrid}{NS grid
}
41 \newcommand{\fftgrid}{FFT grid
}
42 \newcommand{\dgrid}{\mbox{$
\delta_{grid
}$
}}
43 \newcommand{\bfv}[1]{{\mbox{\boldmath{$
#1$
}}}}
44 % non-italicized boldface for math (e.g. matrices)
45 \newcommand{\bfm}[1]{{\bf #1}}
46 \newcommand{\dt}{\Delta t
}
47 \newcommand{\rv}{\bfv{r
}}
48 \newcommand{\vv}{\bfv{v
}}
49 \newcommand{\F}{\bfv{F
}}
50 \newcommand{\pb}{\bfv{p
}}
51 \newcommand{\veps}{v_
{\epsilon}}
52 \newcommand{\peps}{p_
{\epsilon}}
53 \newcommand{\sinhx}[1]{\frac{\sinh{\left(
#1\right)
}}{#1}}
56 \section{Introduction
}
57 In this chapter we first give describe some general concepts used in
58 {\gromacs}:
{\em periodic boundary conditions
} (
\secref{pbc
})
59 and the
{\em group concept
} (
\secref{groupconcept
}). The MD algorithm is
60 described in
\secref{MD
}: first a global form of the algorithm is
61 given, which is refined in subsequent subsections. The (simple) EM
62 (Energy Minimization) algorithm is described in
\secref{EM
}. Some
63 other algorithms for special purpose dynamics are described after
66 %\ifthenelse{\equal{\gmxlite}{1}}{}{
67 %In the final \secref{par} of this chapter a few principles are
68 %given on which parallelization of {\gromacs} is based. The
69 %parallelization is hardly visible for the user and is therefore not
71 %} % Brace matches ifthenelse test for gmxlite
73 A few issues are of general interest. In all cases the
{\em system
}
74 must be defined, consisting of molecules. Molecules again consist of
75 particles with defined interaction functions. The detailed
76 description of the
{\em topology
} of the molecules and of the
{\em force
77 field
} and the calculation of forces is given in
78 \chref{ff
}. In the present chapter we describe
79 other aspects of the algorithm, such as pair list generation, update of
80 velocities and positions, coupling to external temperature and
81 pressure, conservation of constraints.
82 \ifthenelse{\equal{\gmxlite}{1}}{}{
83 The
{\em analysis
} of the data generated by an MD simulation is treated in
\chref{analysis
}.
84 } % Brace matches ifthenelse test for gmxlite
86 \section{Periodic boundary conditions
\index{periodic boundary conditions
}}
89 \centerline{\includegraphics[width=
9cm
]{plots/pbctric
}}
90 \caption {Periodic boundary conditions in two dimensions.
}
93 The classical way to minimize edge effects in a finite system is to
94 apply
{\em periodic boundary conditions
}. The atoms of the system to
95 be simulated are put into a space-filling box, which is surrounded by
96 translated copies of itself (
\figref{pbc
}). Thus there are no
97 boundaries of the system; the artifact caused by unwanted boundaries
98 in an isolated cluster is now replaced by the artifact of periodic
99 conditions. If the system is crystalline, such boundary conditions are
100 desired (although motions are naturally restricted to periodic motions
101 with wavelengths fitting into the box). If one wishes to simulate
102 non-periodic systems, such as liquids or solutions, the periodicity by
103 itself causes errors. The errors can be evaluated by comparing various
104 system sizes; they are expected to be less severe than the errors
105 resulting from an unnatural boundary with vacuum.
107 There are several possible shapes for space-filling unit cells. Some,
108 like the
{\em \normindex{rhombic dodecahedron
}} and the
109 {\em \normindex{truncated octahedron
}}~
\cite{Adams79
} are closer to being a sphere
110 than a cube is, and are therefore better suited to the
111 study of an approximately spherical macromolecule in solution, since
112 fewer solvent molecules are required to fill the box given a minimum
113 distance between macromolecular images. At the same time, rhombic
114 dodecahedra and truncated octahedra are special cases of
{\em triclinic
}
115 unit cells
\index{triclinic unit cell
}; the most general space-filling unit cells
116 that comprise all possible space-filling shapes~
\cite{Bekker95
}.
117 For this reason,
{\gromacs} is based on the triclinic unit cell.
119 {\gromacs} uses periodic boundary conditions, combined with the
{\em
120 \normindex{minimum image convention
}}: only one -- the nearest -- image of each
121 particle is considered for short-range non-bonded interaction terms.
122 For long-range electrostatic interactions this is not always accurate
123 enough, and
{\gromacs} therefore also incorporates lattice sum methods
124 such as Ewald Sum, PME and PPPM.
126 {\gromacs} supports triclinic boxes of any shape.
127 The simulation box (unit cell) is defined by the
3 box vectors
128 $
{\bf a
}$,$
{\bf b
}$ and $
{\bf c
}$.
129 The box vectors must satisfy the following conditions:
135 \label{eqn:box_shift1
}
136 a_x>
0,~~~~b_y>
0,~~~~c_z>
0
139 \label{eqn:box_shift2
}
140 |b_x|
\leq \frac{1}{2} \, a_x,~~~~
141 |c_x|
\leq \frac{1}{2} \, a_x,~~~~
142 |c_y|
\leq \frac{1}{2} \, b_y
144 Equations
\ref{eqn:box_rot
} can always be satisfied by rotating the box.
145 Inequalities (
\ref{eqn:box_shift1
}) and (
\ref{eqn:box_shift2
}) can always be
146 satisfied by adding and subtracting box vectors.
148 Even when simulating using a triclinic box,
{\gromacs} always keeps the
149 particles in a brick-shaped volume for efficiency,
150 as illustrated in
\figref{pbc
} for a
2-dimensional system.
151 Therefore, from the output trajectory it might seem that the simulation was
152 done in a rectangular box. The program
{\tt trjconv
} can be used to convert
153 the trajectory to a different unit-cell representation.
155 It is also possible to simulate without periodic boundary conditions,
156 but it is usually more efficient to simulate an isolated cluster of molecules
157 in a large periodic box, since fast grid searching can only be used
158 in a periodic system.
162 \includegraphics[width=
5cm
]{plots/rhododec
}
163 ~~~~
\includegraphics[width=
5cm
]{plots/truncoct
}
165 \caption {A rhombic dodecahedron and truncated octahedron
166 (arbitrary orientations).
}
167 \label{fig:boxshapes
}
170 \subsection{Some useful box types
}
173 \begin{tabular
}{|c|c|c|ccc|ccc|
}
175 box type & image & box &
\multicolumn{3}{c|
}{box vectors
} &
\multicolumn{3}{c|
}{box vector angles
} \\
176 & distance & volume & ~
{\bf a
}~ &
{\bf b
} &
{\bf c
} &
177 $
\angle{\bf bc
}$ & $
\angle{\bf ac
}$ & $
\angle{\bf ab
}$ \\
179 & & & $d$ &
0 &
0 & & & \\
180 cubic & $d$ & $d^
3$ &
0 & $d$ &
0 & $
90^
\circ$ & $
90^
\circ$ & $
90^
\circ$ \\
181 & & &
0 &
0 & $d$ & & & \\
183 rhombic & & & $d$ &
0 & $
\frac{1}{2}\,d$ & & & \\
184 dodecahedron & $d$ & $
\frac{1}{2}\sqrt{2}\,d^
3$ &
0 & $d$ & $
\frac{1}{2}\,d$ & $
60^
\circ$ & $
60^
\circ$ & $
90^
\circ$ \\
185 (xy-square) & & $
0.707\,d^
3$ &
0 &
0 & $
\frac{1}{2}\sqrt{2}\,d$ & & & \\
187 rhombic & & & $d$ & $
\frac{1}{2}\,d$ & $
\frac{1}{2}\,d$ & & & \\
188 dodecahedron & $d$ & $
\frac{1}{2}\sqrt{2}\,d^
3$ &
0 & $
\frac{1}{2}\sqrt{3}\,d$ & $
\frac{1}{6}\sqrt{3}\,d$ & $
60^
\circ$ & $
60^
\circ$ & $
60^
\circ$ \\
189 (xy-hexagon) & & $
0.707\,d^
3$ &
0 &
0 & $
\frac{1}{3}\sqrt{6}\,d$ & & & \\
191 truncated & & & $d$ & $
\frac{1}{3}\,d$ & $-
\frac{1}{3}\,d$ & & &\\
192 octahedron & $d$ & $
\frac{4}{9}\sqrt{3}\,d^
3$ &
0 & $
\frac{2}{3}\sqrt{2}\,d$ & $
\frac{1}{3}\sqrt{2}\,d$ & $
71.53^
\circ$ & $
109.47^
\circ$ & $
71.53^
\circ$ \\
193 & & $
0.770\,d^
3$ &
0 &
0 & $
\frac{1}{3}\sqrt{6}\,d$ & & & \\
197 \caption{The cubic box, the rhombic
\normindex{dodecahedron
} and the truncated
198 \normindex{octahedron
}.
}
201 The three most useful box types for simulations of solvated systems
202 are described in
\tabref{boxtypes
}. The rhombic dodecahedron
203 (
\figref{boxshapes
}) is the smallest and most regular space-filling
204 unit cell. Each of the
12 image cells is at the same distance. The
205 volume is
71\% of the volume of a cube having the same image
206 distance. This saves about
29\% of CPU-time when simulating a
207 spherical or flexible molecule in solvent. There are two different
208 orientations of a rhombic dodecahedron that satisfy equations
209 \ref{eqn:box_rot
},
\ref{eqn:box_shift1
} and
\ref{eqn:box_shift2
}.
210 The program
{\tt editconf
} produces the orientation
211 which has a square intersection with the xy-plane. This orientation
212 was chosen because the first two box vectors coincide with the x and
213 y-axis, which is easier to comprehend. The other orientation can be
214 useful for simulations of membrane proteins. In this case the
215 cross-section with the xy-plane is a hexagon, which has an area which
216 is
14\% smaller than the area of a square with the same image
217 distance. The height of the box ($c_z$) should be changed to obtain
218 an optimal spacing. This box shape not only saves CPU time, it
219 also results in a more uniform arrangement of the proteins.
221 \subsection{Cut-off restrictions
}
222 The
\normindex{minimum image convention
} implies that the cut-off radius used to
223 truncate non-bonded interactions may not exceed half the shortest box
226 \label{eqn:physicalrc
}
227 R_c <
\half \min(\|
{\bf a
}\|,\|
{\bf b
}\|,\|
{\bf c
}\|),
229 because otherwise more than one image would be within the cut-off distance
230 of the force. When a macromolecule, such as a protein, is studied in
231 solution, this restriction alone is not sufficient: in principle, a single
232 solvent molecule should not be able
233 to `see' both sides of the macromolecule. This means that the length of
234 each box vector must exceed the length of the macromolecule in the
235 direction of that edge
{\em plus
} two times the cut-off radius $R_c$.
236 It is, however, common to compromise in this respect, and make the solvent
237 layer somewhat smaller in order to reduce the computational cost.
238 For efficiency reasons the cut-off with triclinic boxes is more restricted.
239 For grid search the extra restriction is weak:
242 R_c <
\min(a_x,b_y,c_z)
244 For simple search the extra restriction is stronger:
247 R_c <
\half \min(a_x,b_y,c_z)
250 Each unit cell (cubic, rectangular or triclinic)
251 is surrounded by
26 translated images. A
252 particular image can therefore always be identified by an index pointing to one
253 of
27 {\em translation vectors
} and constructed by applying a
254 translation with the indexed vector (see
\ssecref{forces
}).
255 Restriction (
\ref{eqn:gridrc
}) ensures that only
26 images need to be
258 %\ifthenelse{\equal{\gmxlite}{1}}{}{
259 \section{The group concept
}
260 \label{sec:groupconcept
}\index{group
}
261 The
{\gromacs} MD and analysis programs use user-defined
{\em groups
} of
262 atoms to perform certain actions on. The maximum number of groups is
263 256, but each atom can only belong to six different groups, one
264 each of the following:
266 \item[\swapindex{temperature-coupling
}{group
}]
267 The
\normindex{temperature coupling
} parameters (reference
268 temperature, time constant, number of degrees of freedom, see
269 \ssecref{update
}) can be defined for each T-coupling group
270 separately. For example, in a solvated macromolecule the solvent (that
271 tends to generate more heating by force and integration errors) can be
272 coupled with a shorter time constant to a bath than is a macromolecule,
273 or a surface can be kept cooler than an adsorbing molecule. Many
274 different T-coupling groups may be defined. See also center of mass
277 \item[\swapindex{freeze
}{group
}\index{frozen atoms
}]
278 Atoms that belong to a freeze group are kept stationary in the
279 dynamics. This is useful during equilibration,
{\eg} to avoid badly
280 placed solvent molecules giving unreasonable kicks to protein atoms,
281 although the same effect can also be obtained by putting a restraining
282 potential on the atoms that must be protected. The freeze option can
283 be used, if desired, on just one or two coordinates of an atom,
284 thereby freezing the atoms in a plane or on a line. When an atom is
285 partially frozen, constraints will still be able to move it, even in a
286 frozen direction. A fully frozen atom can not be moved by constraints.
287 Many freeze groups can be defined. Frozen coordinates are unaffected
288 by pressure scaling; in some cases this can produce unwanted results,
289 particularly when constraints are also used (in this case you will
290 get very large pressures). Accordingly, it is recommended to avoid
291 combining freeze groups with constraints and pressure coupling. For the
292 sake of equilibration it could suffice to start with freezing in a
293 constant volume simulation, and afterward use position restraints in
294 conjunction with constant pressure.
296 \item[\swapindex{accelerate
}{group
}]
297 On each atom in an ``accelerate group'' an acceleration
298 $
\ve{a
}^g$ is imposed. This is equivalent to an external
299 force. This feature makes it possible to drive the system into a
300 non-equilibrium state and enables the performance of
301 \swapindex{non-equilibrium
}{MD
} and hence to obtain transport properties.
303 \item[\swapindex{energy-monitor
}{group
}]
304 Mutual interactions between all energy-monitor groups are compiled
305 during the simulation. This is done separately for Lennard-Jones and
306 Coulomb terms. In principle up to
256 groups could be defined, but
307 that would lead to
256$
\times$
256 items! Better use this concept
310 All non-bonded interactions between pairs of energy-monitor groups can
311 be excluded
\index{exclusions
}
312 \ifthenelse{\equal{\gmxlite}{1}}
314 {(see
\secref{mdpopt
}).
}
315 Pairs of particles from excluded pairs of energy-monitor groups
316 are not put into the pair list.
317 This can result in a significant speedup
318 for simulations where interactions within or between parts of the system
321 \item[\swapindex{center of mass
}{group
}\index{removing COM motion
}]
322 In
\gromacs\ the center of mass (COM) motion can be removed, for
323 either the complete system or for groups of atoms. The latter is
324 useful,
{\eg} for systems where there is limited friction (
{\eg} gas
325 systems) to prevent center of mass motion to occur. It makes sense to
326 use the same groups for temperature coupling and center of mass motion
329 \item[\swapindex{Compressed position output
}{group
}]
331 In order to further reduce the size of the compressed trajectory file
332 (
{\tt .xtc
{\index{XTC
}}} or
{\tt .tng
{\index{TNG
}}}), it is possible
333 to store only a subset of all particles. All x-compression groups that
334 are specified are saved, the rest are not. If no such groups are
335 specified, than all atoms are saved to the compressed trajectory file.
338 The use of groups in
{\gromacs} tools is described in
339 \secref{usinggroups
}.
340 %} % Brace matches ifthenelse test for gmxlite
342 \section{Molecular Dynamics
}
346 \addtolength{\fboxsep}{0.5cm
}
347 \begin{shadowenv
}[12cm
]
348 {\large \bf THE GLOBAL MD ALGORITHM
}
349 \rule{\textwidth}{2pt
} \\
350 {\bf 1. Input initial conditions
}\\
[2ex
]
351 Potential interaction $V$ as a function of atom positions\\
352 Positions $
\ve{r
}$ of all atoms in the system\\
353 Velocities $
\ve{v
}$ of all atoms in the system \\
355 \rule{\textwidth}{1pt
}\\
356 {\bf repeat
2,
3,
4} for the required number of steps:\\
357 \rule{\textwidth}{1pt
}\\
358 {\bf 2. Compute forces
} \\
[1ex
]
359 The force on any atom \\
[1ex
]
360 $
\ve{F
}_i = -
\displaystyle\frac{\partial V
}{\partial \ve{r
}_i
}$ \\
[1ex
]
361 is computed by calculating the force between non-bonded atom pairs: \\
362 $
\ve{F
}_i =
\sum_j \ve{F
}_
{ij
}$ \\
363 plus the forces due to bonded interactions (which may depend on
1,
2,
364 3, or
4 atoms), plus restraining and/or external forces. \\
365 The potential and kinetic energies and the pressure tensor may be computed. \\
367 {\bf 3. Update configuration
} \\
[1ex
]
368 The movement of the atoms is simulated by numerically solving Newton's
369 equations of motion \\
[1ex
]
371 \frac {\de^
2\ve{r
}_i
}{\de t^
2} =
\frac{\ve{F
}_i
}{m_i
} $ \\
374 \frac{\de\ve{r
}_i
}{\de t
} =
\ve{v
}_i ; \;\;
375 \frac{\de\ve{v
}_i
}{\de t
} =
\frac{\ve{F
}_i
}{m_i
} $ \\
[1ex
]
377 {\bf 4.
} if required:
{\bf Output step
} \\
378 write positions, velocities, energies, temperature, pressure, etc. \\
380 \caption{The global MD algorithm
}
384 A global flow scheme for MD is given in
\figref{global
}. Each
385 MD or EM run requires as input a set of initial coordinates and --
386 optionally -- initial velocities of all particles involved. This
387 chapter does not describe how these are obtained; for the setup of an
388 actual MD run check the online manual at
{\wwwpage}.
390 \subsection{Initial conditions
}
391 \subsubsection{Topology and force field
}
392 The system topology, including a description of the force field, must
394 \ifthenelse{\equal{\gmxlite}{1}}
396 {Force fields and topologies are described in
\chref{ff
}
397 and
\ref{ch:top
}, respectively.
}
398 All this information is static; it is never modified during the run.
400 \subsubsection{Coordinates and velocities
}
402 \centerline{\includegraphics[width=
8cm
]{plots/maxwell
}}
403 \caption{A Maxwell-Boltzmann velocity distribution, generated from
408 Then, before a run starts, the box size and the coordinates and
409 velocities of all particles are required. The box size and shape is
410 determined by three vectors (nine numbers) $
\ve{b
}_1,
\ve{b
}_2,
\ve{b
}_3$,
411 which represent the three basis vectors of the periodic box.
413 If the run starts at $t=t_0$, the coordinates at $t=t_0$ must be
414 known. The
{\em leap-frog algorithm
}, the default algorithm used to
415 update the time step with $
\Dt$ (see
\ssecref{update
}), also requires
416 that the velocities at $t=t_0 -
\hDt$ are known. If velocities are not
417 available, the program can generate initial atomic velocities
418 $v_i, i=
1\ldots 3N$ with a
\index{Maxwell-Boltzmann distribution
}
419 (
\figref{maxwell
}) at a given absolute temperature $T$:
421 p(v_i) =
\sqrt{\frac{m_i
}{2 \pi kT
}}\exp\left(-
\frac{m_i v_i^
2}{2kT
}\right)
423 where $k$ is Boltzmann's constant (see
\chref{defunits
}).
424 To accomplish this, normally distributed random numbers are generated
425 by adding twelve random numbers $R_k$ in the range $
0 \le R_k <
1$ and
426 subtracting
6.0 from their sum. The result is then multiplied by the
427 standard deviation of the velocity distribution $
\sqrt{kT/m_i
}$. Since
428 the resulting total energy will not correspond exactly to the required
429 temperature $T$, a correction is made: first the center-of-mass motion
430 is removed and then all velocities are scaled so that the total
431 energy corresponds exactly to $T$ (see
\eqnref{E-T
}).
432 % Why so complicated? What's wrong with Box-Mueller transforms?
434 \subsubsection{Center-of-mass motion
\index{removing COM motion
}}
435 The
\swapindex{center-of-mass
}{velocity
} is normally set to zero at
436 every step; there is (usually) no net external force acting on the
437 system and the center-of-mass velocity should remain constant. In
438 practice, however, the update algorithm introduces a very slow change in
439 the center-of-mass velocity, and therefore in the total kinetic energy of
440 the system -- especially when temperature coupling is used. If such
441 changes are not quenched, an appreciable center-of-mass motion
442 can develop in long runs, and the temperature will be
443 significantly misinterpreted. Something similar may happen due to overall
444 rotational motion, but only when an isolated cluster is simulated. In
445 periodic systems with filled boxes, the overall rotational motion is
446 coupled to other degrees of freedom and does not cause such problems.
449 \subsection{Neighbor searching
\swapindexquiet{neighbor
}{searching
}}
451 As mentioned in
\chref{ff
}, internal forces are
452 either generated from fixed (static) lists, or from dynamic lists.
453 The latter consist of non-bonded interactions between any pair of particles.
454 When calculating the non-bonded forces, it is convenient to have all
455 particles in a rectangular box.
456 As shown in
\figref{pbc
}, it is possible to transform a
457 triclinic box into a rectangular box.
458 The output coordinates are always in a rectangular box, even when a
459 dodecahedron or triclinic box was used for the simulation.
460 Equation
\ref{eqn:box_rot
} ensures that we can reset particles
461 in a rectangular box by first shifting them with
462 box vector $
{\bf c
}$, then with $
{\bf b
}$ and finally with $
{\bf a
}$.
463 Equations
\ref{eqn:box_shift2
},
\ref{eqn:physicalrc
} and
\ref{eqn:gridrc
}
464 ensure that we can find the
14 nearest triclinic images within
465 a linear combination that does not involve multiples of box vectors.
467 \subsubsection{Pair lists generation
}
468 The non-bonded pair forces need to be calculated only for those pairs
469 $i,j$ for which the distance $r_
{ij
}$ between $i$ and the
470 \swapindex{nearest
}{image
}
471 of $j$ is less than a given cut-off radius $R_c$. Some of the particle
472 pairs that fulfill this criterion are excluded, when their interaction
473 is already fully accounted for by bonded interactions.
{\gromacs}
474 employs a
{\em pair list
} that contains those particle pairs for which
475 non-bonded forces must be calculated. The pair list contains atoms
476 $i$, a displacement vector for atom $i$, and all particles $j$ that
477 are within
\verb'rlist' of this particular image of atom $i$. The
478 list is updated every
\verb'nstlist' steps, where
\verb'nstlist' is
479 typically
10. There is an option to calculate the total non-bonded
480 force on each particle due to all particle in a shell around the
481 list cut-off,
{\ie} at a distance between
\verb'rlist' and
482 \verb'rlistlong'. This force is calculated during the pair list update
483 and retained during
\verb'nstlist' steps.
485 To make the
\normindex{neighbor list
}, all particles that are close
486 (
{\ie} within the neighbor list cut-off) to a given particle must be found.
487 This searching, usually called neighbor search (NS) or pair search,
488 involves periodic boundary conditions and determining the
{\em image
}
489 (see
\secref{pbc
}). The search algorithm is $O(N)$, although a simpler
490 $O(N^
2)$ algorithm is still available under some conditions.
492 \subsubsection{\normindex{Cut-off schemes
}: group versus Verlet
}
493 From version
4.6,
{\gromacs} supports two different cut-off scheme
494 setups: the original one based on atom groups and one using a Verlet
495 buffer. There are some important differences that affect results,
496 performance and feature support. The group scheme can be made to work
497 (almost) like the Verlet scheme, but this will lead to a decrease in
498 performance. The group scheme is especially fast for water molecules,
499 which are abundant in many simulations, but on the most recent x86
500 processors, this advantage is negated by the better instruction-level
501 parallelism available in the Verlet-scheme implementation. The group
502 scheme is deprecated in version
5.0, and will be removed in a future
505 In the group scheme, a neighbor list is generated consisting of pairs
506 of groups of at least one atom. These groups were originally
507 \swapindex{charge
}{group
}s
\ifthenelse{\equal{\gmxlite}{1}}{}{(see
508 \secref{chargegroup
})
}, but with a proper treatment of long-range
509 electrostatics, performance is their only advantage. A pair of groups
510 is put into the neighbor list when their center of geometry is within
511 the cut-off distance. Interactions between all atom pairs (one from
512 each charge group) are calculated for a certain number of MD steps,
513 until the neighbor list is updated. This setup is efficient, as the
514 neighbor search only checks distance between charge group pair, not
515 atom pairs (saves a factor of $
3 \times 3 =
9$ with a three-atom water
516 model) and the non-bonded force kernels can be optimized for, say, a
517 water molecule ``group''. Without explicit buffering, this setup leads
518 to energy drift as some atom pairs which are within the cut-off don't
519 interact and some outside the cut-off do interact. This can be caused
522 \item atoms moving across the cut-off between neighbor search steps, and/or
523 \item for charge groups consisting of more than one atom, atom pairs
524 moving in/out of the cut-off when their charge group center of
525 geometry distance is outside/inside of the cut-off.
527 Explicitly adding a buffer to the neighbor list will remove such
528 artifacts, but this comes at a high computational cost. How severe the
529 artifacts are depends on the system, the properties in which you are
530 interested, and the cut-off setup.
532 The Verlet cut-off scheme uses a buffered pair list by default. It
533 also uses clusters of atoms, but these are not static as in the group
534 scheme. Rather, the clusters are defined spatially and consist of
4 or
535 8 atoms, which is convenient for stream computing, using e.g. SSE, AVX
536 or CUDA on GPUs. At neighbor search steps, a pair list is created
537 with a Verlet buffer, ie. the pair-list cut-off is larger than the
538 interaction cut-off. In the non-bonded force kernels, forces are only
539 added when an atom pair is within the cut-off distance at that
540 particular time step. This ensures that as atoms move between pair
541 search steps, forces between nearly all atoms within the cut-off
542 distance are calculated. We say
{\em nearly
} all atoms, because
543 {\gromacs} uses a fixed pair list update frequency for
544 efficiency. An atom-pair, whose distance was outside the cut-off,
545 could possibly move enough during this fixed number of
546 steps that its distance is now within the cut-off. This
547 small chance results in a small energy drift, and the size of the
548 chance depends on the temperature. When temperature
549 coupling is used, the buffer size can be determined automatically,
550 given a certain tolerance on the energy drift.
552 The
{\tt mdp
} file settings specific to the Verlet scheme are:
554 cutoff-scheme = Verlet
555 verlet-buffer-tolerance =
0.005
557 The Verlet buffer size is determined from the latter option, which is
558 by default set to
0.005 kJ/mol/ps pair energy error per atom. Note that
559 errors in pair energies cancel and the effect on the total energy drift
560 is usually at least an order of magnitude smaller than the tolerance.
561 Furthermore, the drift of the total energy is affected by many other
562 factors; often, the contribution from the constraint algorithm dominates.
564 For constant-energy (NVE) simulations, the buffer size will be
565 inferred from the temperature that corresponds to the velocities
566 (either those generated, if applicable, or those found in the input
567 configuration). Alternatively, the tolerance can be set to -
1 and a
568 buffer set manually by specifying
{\tt rlist
} $>$
{\tt max(rcoulomb,
569 rvdw)
}. The simplest way to get a reasonable buffer size is to use
570 an NVT
{\tt mdp
} file with the target temperature set to what you
571 expect in your NVE simulation, and transfer the buffer size printed by
572 {\tt grompp
} to your NVE
{\tt mdp
} file.
574 The Verlet cut-off scheme is implemented in a very efficient fashion
575 based on clusters of particles. The simplest example is a cluster size
576 of
4 particles. The pair list is then constructed based on cluster
577 pairs. The cluster-pair search is much faster searching based on
578 particle pairs, because $
4 \times 4 =
16$ particle pairs are put in
579 the list at once. The non-bonded force calculation kernel can then
580 calculate all
16 particle-pair interactions at once, which maps nicely
581 to SIMD units which can perform multiple floating operations at once
582 (e.g. SSE, AVX, CUDA on GPUs, BlueGene FPUs). These non-bonded kernels
583 are much faster than the kernels used in the group scheme for most
584 types of systems, except for water molecules on processors with short
585 SIMD widths when not using a buffered pair list. This latter case is
586 common for (bio-)molecular simulations, so for greatest speed, it is
587 worth comparing the performance of both schemes.
589 As the Verlet cut-off scheme was introduced in version
4.6, not
590 all features of the group scheme are supported yet. The Verlet scheme
591 supports a few new features which the group scheme does not support.
592 A list of features not (fully) supported in both cut-off schemes is
593 given in
\tabref{cutoffschemesupport
}.
597 \begin{tabular
}{|l|c|c|
}
599 Non-bonded interaction feature & group & Verlet \\
601 unbuffered cut-off scheme & $
\surd$ & not by default \\
602 exact cut-off & shift/switch & $
\surd$ \\
603 shifted interactions & force+energy & energy \\
604 switched potential & $
\surd$ & $
\surd$ \\
605 switched forces & $
\surd$ & $
\surd$ \\
606 non-periodic systems & $
\surd$ & Z + walls \\
607 implicit solvent & $
\surd$ & \\
608 free energy perturbed non-bondeds & $
\surd$ & $
\surd$ \\
609 group energy contributions & $
\surd$ & CPU (not on GPU) \\
610 energy group exclusions & $
\surd$ & \\
611 AdResS multi-scale & $
\surd$ & \\
612 OpenMP multi-threading & only PME & $
\surd$ \\
613 native GPU support & & $
\surd$ \\
614 Lennard-Jones PME & $
\surd$ & $
\surd$ \\
618 \caption{Differences (only) in the support of non-bonded features
619 between the group and Verlet cut-off schemes.
}
620 \label{tab:cutoffschemesupport
}
623 \ifthenelse{\equal{\gmxlite}{1}}{}{
624 \subsubsection{Energy drift and pair-list buffering
}
625 For a canonical (NVT) ensemble, the average energy error caused by the
626 finite Verlet buffer size can be determined from the atomic
627 displacements and the shape of the potential at the cut-off.
628 %Since we are interested in the small drift regime, we will assume
629 %#that atoms will only move within the cut-off distance in the last step,
630 %$n_\mathrm{ps}-1$, of the pair list update interval $n_\mathrm{ps}$.
631 %Over this number of steps the displacment of an atom with mass $m$
632 The displacement distribution along one dimension for a freely moving
633 particle with mass $m$ over time $t$ at temperature $T$ is Gaussian
634 with zero mean and variance $
\sigma^
2 = t\,k_B T/m$. For the distance
635 between two atoms, the variance changes to $
\sigma^
2 =
\sigma_{12}^
2 =
636 t\,k_B T(
1/m_1+
1/m_2)$. Note that in practice particles usually
637 interact with other particles over time $t$ and therefore the real
638 displacement distribution is much narrower. Given a non-bonded
639 interaction cut-off distance of $r_c$ and a pair-list cut-off
640 $r_
\ell=r_c+r_b$, we can then write the average energy error after
641 time $t$ for pair interactions between one particle of type
1
642 surrounded by particles of type
2 with number density $
\rho_2$, when
643 the inter particle distance changes from $r_0$ to $r_t$, as:
646 \langle \Delta V
\rangle \! &=&
647 \int_{0}^
{r_c
} \int_{r_
\ell}^
\infty 4 \pi r_0^
2 \rho_2 V(r_t) G\!
\left(
\frac{r_t-r_0
}{\sigma}\right) d r_0\, d r_t \\
649 \int_{-
\infty}^
{r_c
} \int_{r_
\ell}^
\infty 4 \pi r_0^
2 \rho_2 \Big[ V'(r_c) (r_t - r_c) +
652 \phantom{\int_{-
\infty}^
{r_c
} \int_{r_
\ell}^
\infty 4 \pi r_0^
2 \rho_2 \Big[}
653 V''(r_c)
\frac{1}{2}(r_t - r_c)^
2 \Big] G\!
\left(
\frac{r_t-r_0
}{\sigma}\right) d r_0 \, d r_t\\
655 4 \pi (r_
\ell+
\sigma)^
2 \rho_2
656 \int_{-
\infty}^
{r_c
} \int_{r_
\ell}^
\infty \Big[ V'(r_c) (r_t - r_c) +
659 \phantom{4 \pi (r_
\ell+
\sigma)^
2 \rho_2 \int_{-
\infty}^
{r_c
} \int_{r_
\ell}^
\infty \Big[}
660 V''(r_c)
\frac{1}{2}(r_t - r_c)^
2 +
663 \phantom{4 \pi (r_
\ell+
\sigma)^
2 \rho_2 \int_{-
\infty}^
{r_c
} \int_{r_
\ell}^
\infty \Big[}
664 V'''(r_c)
\frac{1}{6}(r_t - r_c)^
3 \Big] G\!
\left(
\frac{r_t-r_0
}{\sigma}\right)
667 4 \pi (r_
\ell+
\sigma)^
2 \rho_2 \bigg\
{
668 \frac{1}{2}V'(r_c)
\left[r_b
\sigma G\!
\left(
\frac{r_b
}{\sigma}\right) - (r_b^
2+
\sigma^
2)E\!
\left(
\frac{r_b
}{\sigma}\right)
\right] +
671 \phantom{4 \pi (r_
\ell+
\sigma)^
2 \rho_2 \bigg\
{ }
672 \frac{1}{6}V''(r_c)
\left[ \sigma(r_b^
2+
2\sigma^
2)G\!
\left(
\frac{r_b
}{\sigma}\right) - r_b(r_b^
2+
3\sigma^
2 ) E\!
\left(
\frac{r_b
}{\sigma}\right)
\right] +
675 \phantom{4 \pi (r_
\ell+
\sigma)^
2 \rho_2 \bigg\
{ }
676 \frac{1}{24}V'''(r_c)
\left[ r_b
\sigma(r_b^
2+
5\sigma^
2)G\!
\left(
\frac{r_b
}{\sigma}\right) - (r_b^
4+
6r_b^
2\sigma^
2+
3\sigma^
4 ) E\!
\left(
\frac{r_b
}{\sigma}\right)
\right]
680 where $G$ is a Gaussian distribution with
0 mean and unit variance and
681 $E(x)=
\frac{1}{2}\mathrm{erfc
}(x/
\sqrt{2})$. We always want to achieve
682 small energy error, so $
\sigma$ will be small compared to both $r_c$
683 and $r_
\ell$, thus the approximations in the equations above are good,
684 since the Gaussian distribution decays rapidly. The energy error needs
685 to be averaged over all particle pair types and weighted with the
686 particle counts. In
{\gromacs} we don't allow cancellation of error
687 between pair types, so we average the absolute values. To obtain the
688 average energy error per unit time, it needs to be divided by the
689 neighbor-list life time $t = (
{\tt nstlist
} -
1)
\times{\tt dt
}$. This
690 function can not be inverted analytically, so we use bisection to
691 obtain the buffer size $r_b$ for a target drift. Again we note that
692 in practice the error we usually be much smaller than this estimate,
693 as in the condensed phase particle displacements will be much smaller
694 than for freely moving particles, which is the assumption used here.
696 When (bond) constraints are present, some particles will have fewer
697 degrees of freedom. This will reduce the energy errors. The
698 displacement in an arbitrary direction of a particle with
2 degrees of
699 freedom is not Gaussian, but rather follows the complementary error
701 \frac{\sqrt{\pi}}{2\sqrt{2}\sigma}\,
\mathrm{erfc
}\left(
\frac{|r|
}{\sqrt{2}\,
\sigma}\right)
702 \eeq where $
\sigma^
2$ is again $k_B T/m$. This distribution can no
703 longer be integrated analytically to obtain the energy error. But we
704 can generate a tight upper bound using a scaled and shifted Gaussian
705 distribution (not shown). This Gaussian distribution can then be used
706 to calculate the energy error as described above. We consider
707 particles constrained, i.e. having
2 degrees of freedom or fewer, when
708 they are connected by constraints to particles with a total mass of at
709 least
1.5 times the mass of the particles itself. For a particle with
710 a single constraint this would give a total mass along the constraint
711 direction of at least
2.5, which leads to a reduction in the variance
712 of the displacement along that direction by at least a factor of
6.25.
713 As the Gaussian distribution decays very rapidly, this effectively
714 removes one degree of freedom from the displacement. Multiple
715 constraints would reduce the displacement even more, but as this gets
716 very complex, we consider those as particles with
2 degrees of
719 There is one important implementation detail that reduces the energy
720 errors caused by the finite Verlet buffer list size. The derivation
721 above assumes a particle pair-list. However, the
{\gromacs}
722 implementation uses a cluster pair-list for efficiency. The pair list
723 consists of pairs of clusters of
4 particles in most cases, also
724 called a $
4 \times 4$ list, but the list can also be $
4 \times 8$ (GPU
725 CUDA kernels and AVX
256-bit single precision kernels) or $
4 \times 2$
726 (SSE double-precision kernels). This means that the pair-list is
727 effectively much larger than the corresponding $
1 \times 1$ list. Thus
728 slightly beyond the pair-list cut-off there will still be a large
729 fraction of particle pairs present in the list. This fraction can be
730 determined in a simulation and accurately estimated under some
731 reasonable assumptions. The fraction decreases with increasing
732 pair-list range, meaning that a smaller buffer can be used. For
733 typical all-atom simulations with a cut-off of
0.9 nm this fraction is
734 around
0.9, which gives a reduction in the energy errors of a factor of
735 10. This reduction is taken into account during the automatic Verlet
736 buffer calculation and results in a smaller buffer size.
739 \centerline{\includegraphics[width=
9cm
]{plots/verlet-drift
}}
740 \caption {Energy drift per atom for an SPC/E water system at
300K with
741 a time step of
2 fs and a pair-list update period of
10 steps
742 (pair-list life time:
18 fs). PME was used with
{\tt ewald-rtol
} set
743 to
10$^
{-
5}$; this parameter affects the shape of the potential at
744 the cut-off. Error estimates due to finite Verlet buffer size are
745 shown for a $
1 \times 1$ atom pair list and $
4 \times 4$ atom pair
746 list without and with (dashed line) cancellation of positive and
747 negative errors. Real energy drift is shown for double- and
748 single-precision simulations. Single-precision rounding errors in
749 the SETTLE constraint algorithm cause the drift to become negative
750 at large buffer size. Note that at zero buffer size, the real drift
751 is small because positive (H-H) and negative (O-H) energy errors
753 \label{fig:verletdrift
}
756 In
\figref{verletdrift
} one can see that for small buffer sizes the drift
757 of the total energy is much smaller than the pair energy error tolerance,
758 due to cancellation of errors. For larger buffer size, the error estimate
759 is a factor of
6 higher than drift of the total energy, or alternatively
760 the buffer estimate is
0.024 nm too large. This is because the protons
761 don't move freely over
18 fs, but rather vibrate.
762 %At a buffer size of zero there is cancellation of
763 %drift due to repulsive (H-H) and attractive (O-H) interactions.
765 \subsubsection{Cut-off artifacts and switched interactions
}
766 With the Verlet scheme, the pair potentials are shifted to be zero at
767 the cut-off, which makes the potential the integral of the force.
768 This is only possible in the group scheme if the shape of the potential
769 is such that its value is zero at the cut-off distance.
770 However, there can still be energy drift when the
771 forces are non-zero at the cut-off. This effect is extremely small and
772 often not noticeable, as other integration errors (e.g. from constraints)
774 completely avoid cut-off artifacts, the non-bonded forces can be
775 switched exactly to zero at some distance smaller than the neighbor
776 list cut-off (there are several ways to do this in
{\gromacs}, see
777 \secref{mod_nb_int
}). One then has a buffer with the size equal to the
778 neighbor list cut-off less the longest interaction cut-off.
781 group cut-off scheme, one can also choose to let
{\tt mdrun
} only
782 update the neighbor list when required. That is when one or more
783 particles have moved more than half the buffer size from the center of
784 geometry of the
\swapindex{charge
}{group
} to which they belong (see
785 \secref{chargegroup
}), as determined at the previous neighbor search.
786 This option guarantees that there are no cut-off artifacts.
{\bf
787 Note
} that for larger systems this comes at a high computational
788 cost, since the neighbor list update frequency will be determined by
789 just one or two particles moving slightly beyond the half buffer
790 length (which not even necessarily implies that the neighbor list is
791 invalid), while
99.99\% of the particles are fine.
793 } % Brace matches ifthenelse test for gmxlite
795 \subsubsection{Simple search
\swapindexquiet{simple
}{search
}}
796 Due to
\eqnsref{box_rot
}{simplerc
}, the vector $
\rvij$
797 connecting images within the cut-off $R_c$ can be found by constructing:
799 \ve{r
}''' & = &
\ve{r
}_j-
\ve{r
}_i \\
800 \ve{r
}'' & = &
\ve{r
}''' -
{\bf c
}*
\verb'round'(r'''_z/c_z) \\
801 \ve{r
}' & = &
\ve{r
}'' -
{\bf b
}*
\verb'round'(r''_y/b_y) \\
802 \ve{r
}_
{ij
} & = &
\ve{r
}' -
{\bf a
}*
\verb'round'(r'_x/a_x)
804 When distances between two particles in a triclinic box are needed
805 that do not obey
\eqnref{box_rot
},
806 many shifts of combinations of box vectors need to be considered to find
809 \ifthenelse{\equal{\gmxlite}{1}}{}{
812 \centerline{\includegraphics[width=
8cm
]{plots/nstric
}}
813 \caption {Grid search in two dimensions. The arrows are the box vectors.
}
817 \subsubsection{Grid search
\swapindexquiet{grid
}{search
}}
819 The grid search is schematically depicted in
\figref{grid
}. All
820 particles are put on the
{\nsgrid}, with the smallest spacing $
\ge$
821 $R_c/
2$ in each of the directions. In the direction of each box
822 vector, a particle $i$ has three images. For each direction the image
823 may be -
1,
0 or
1, corresponding to a translation over -
1,
0 or +
1 box
824 vector. We do not search the surrounding
{\nsgrid} cells for neighbors
825 of $i$ and then calculate the image, but rather construct the images
826 first and then search neighbors corresponding to that image of $i$.
827 As
\figref{grid
} shows, some grid cells may be searched more than once
828 for different images of $i$. This is not a problem, since, due to the
829 minimum image convention, at most one image will ``see'' the
830 $j$-particle. For every particle, fewer than
125 (
5$^
3$) neighboring
831 cells are searched. Therefore, the algorithm scales linearly with the
832 number of particles. Although the prefactor is large, the scaling
833 behavior makes the algorithm far superior over the standard $O(N^
2)$
834 algorithm when there are more than a few hundred particles. The
835 grid search is equally fast for rectangular and triclinic boxes. Thus
836 for most protein and peptide simulations the rhombic dodecahedron will
837 be the preferred box shape.
838 } % Brace matches ifthenelse test for gmxlite
840 \ifthenelse{\equal{\gmxlite}{1}}{}{
841 \subsubsection{Charge groups
}
842 \label{sec:chargegroup
}\swapindexquiet{charge
}{group
}%
843 Charge groups were originally introduced to reduce cut-off artifacts
844 of Coulomb interactions. When a plain cut-off is used, significant
845 jumps in the potential and forces arise when atoms with (partial) charges
846 move in and out of the cut-off radius. When all chemical moieties have
847 a net charge of zero, these jumps can be reduced by moving groups
848 of atoms with net charge zero, called charge groups, in and
849 out of the neighbor list. This reduces the cut-off effects from
850 the charge-charge level to the dipole-dipole level, which decay
851 much faster. With the advent of full range electrostatics methods,
852 such as particle-mesh Ewald (
\secref{pme
}), the use of charge groups is
853 no longer required for accuracy. It might even have a slight negative effect
854 on the accuracy or efficiency, depending on how the neighbor list is made
855 and the interactions are calculated.
857 But there is still an important reason for using ``charge groups'': efficiency with the group cut-off scheme.
858 Where applicable, neighbor searching is carried out on the basis of
859 charge groups which are defined in the molecular topology.
860 If the nearest image distance between the
{\em
861 geometrical centers
} of the atoms of two charge groups is less than
862 the cut-off radius, all atom pairs between the charge groups are
863 included in the pair list.
864 The neighbor searching for a water system, for instance,
865 is $
3^
2=
9$ times faster when each molecule is treated as a charge group.
866 Also the highly optimized water force loops (see
\secref{waterloops
})
867 only work when all atoms in a water molecule form a single charge group.
868 Currently the name
{\em neighbor-search group
} would be more appropriate,
869 but the name charge group is retained for historical reasons.
870 When developing a new force field, the advice is to use charge groups
871 of
3 to
4 atoms for optimal performance. For all-atom force fields
872 this is relatively easy, as one can simply put hydrogen atoms, and in some
873 case oxygen atoms, in the same charge group as the heavy atom they
874 are connected to; for example: CH$_3$, CH$_2$, CH, NH$_2$, NH, OH, CO$_2$, CO.
876 With the Verlet cut-off scheme, charge groups are ignored.
878 } % Brace matches ifthenelse test for gmxlite
880 \subsection{Compute forces
}
881 \label{subsec:forces
}
883 \subsubsection{Potential energy
}
884 When forces are computed, the
\swapindex{potential
}{energy
} of each
885 interaction term is computed as well. The total potential energy is
886 summed for various contributions, such as Lennard-Jones, Coulomb, and
887 bonded terms. It is also possible to compute these contributions for
888 {\em energy-monitor groups
} of atoms that are separately defined (see
889 \secref{groupconcept
}).
891 \subsubsection{Kinetic energy and temperature
}
892 The
\normindex{temperature
} is given by the total
893 \swapindex{kinetic
}{energy
} of the $N$-particle system:
895 E_
{kin
} =
\half \sum_{i=
1}^N m_i v_i^
2
897 From this the absolute temperature $T$ can be computed using:
899 \half N_
{\mathrm{df
}} kT = E_
{\mathrm{kin
}}
902 where $k$ is Boltzmann's constant and $N_
{df
}$ is the number of
903 degrees of freedom which can be computed from:
905 N_
{\mathrm{df
}} ~=~
3 N - N_c - N_
{\mathrm{com
}}
907 Here $N_c$ is the number of
{\em \normindex{constraints
}} imposed on the system.
908 When performing molecular dynamics $N_
{\mathrm{com
}}=
3$ additional degrees of
909 freedom must be removed, because the three
910 center-of-mass velocities are constants of the motion, which are usually
911 set to zero. When simulating in vacuo, the rotation around the center of mass
912 can also be removed, in this case $N_
{\mathrm{com
}}=
6$.
913 When more than one temperature-coupling group
\index{temperature-coupling group
} is used, the number of degrees
914 of freedom for group $i$ is:
916 N^i_
{\mathrm{df
}} ~=~ (
3 N^i - N^i_c)
\frac{3 N - N_c - N_
{\mathrm{com
}}}{3 N - N_c
}
919 The kinetic energy can also be written as a tensor, which is necessary
920 for pressure calculation in a triclinic system, or systems where shear
923 {\bf E
}_
{\mathrm{kin
}} =
\half \sum_i^N m_i
\vvi \otimes \vvi
926 \subsubsection{Pressure and virial
}
927 The
\normindex{pressure
}
928 tensor
{\bf P
} is calculated from the difference between
929 kinetic energy $E_
{\mathrm{kin
}}$ and the
\normindex{virial
} $
{\bf \Xi}$:
931 {\bf P
} =
\frac{2}{V
} (
{\bf E
}_
{\mathrm{kin
}}-
{\bf \Xi})
934 where $V$ is the volume of the computational box.
935 The scalar pressure $P$, which can be used for pressure coupling in the case
936 of isotropic systems, is computed as:
938 P =
{\rm trace
}(
{\bf P
})/
3
941 The virial $
{\bf \Xi}$ tensor is defined as:
943 {\bf \Xi} = -
\half \sum_{i<j
} \rvij \otimes \Fvij
947 \ifthenelse{\equal{\gmxlite}{1}}{}{
948 The
{\gromacs} implementation of the virial computation is described
950 } % Brace matches ifthenelse test for gmxlite
953 \subsection{The
\swapindex{leap-frog
}{integrator
}}
954 \label{subsec:update
}
956 \centerline{\includegraphics[width=
8cm
]{plots/leapfrog
}}
957 \caption[The Leap-Frog integration method.
]{The Leap-Frog integration method. The algorithm is called Leap-Frog because $
\ve{r
}$ and $
\ve{v
}$ are leaping
958 like frogs over each other's backs.
}
962 The default MD integrator in
{\gromacs} is the so-called
{\em leap-frog
}
963 algorithm~
\cite{Hockney74
} for the integration of the equations of
964 motion. When extremely accurate integration with temperature
965 and/or pressure coupling is required, the velocity Verlet integrators
966 are also present and may be preferable (see
\ssecref{vverlet
}). The leap-frog
967 algorithm uses positions $
\ve{r
}$ at time $t$ and
968 velocities $
\ve{v
}$ at time $t-
\hDt$; it updates positions and
969 velocities using the forces
970 $
\ve{F
}(t)$ determined by the positions at time $t$ using these relations:
972 \label{eqn:leapfrogv
}
973 \ve{v
}(t+
\hDt) &~=~&
\ve{v
}(t-
\hDt)+
\frac{\Dt}{m
}\ve{F
}(t) \\
974 \ve{r
}(t+
\Dt) &~=~&
\ve{r
}(t)+
\Dt\ve{v
}(t+
\hDt)
976 The algorithm is visualized in
\figref{leapfrog
}.
977 It produces trajectories that are identical to the Verlet~
\cite{Verlet67
} algorithm,
978 whose position-update relation is
980 \ve{r
}(t+
\Dt)~=~
2\ve{r
}(t) -
\ve{r
}(t-
\Dt) +
\frac{1}{m
}\ve{F
}(t)
\Dt^
2+O(
\Dt^
4)
982 The algorithm is of third order in $
\ve{r
}$ and is time-reversible.
983 See ref.~
\cite{Berendsen86b
} for the merits of this algorithm and comparison
984 with other time integration algorithms.
986 The
\swapindex{equations of
}{motion
} are modified for temperature
987 coupling and pressure coupling, and extended to include the
988 conservation of constraints, all of which are described below.
990 \subsection{The
\swapindex{velocity Verlet
}{integrator
}}
991 \label{subsec:vverlet
}
992 The velocity Verlet algorithm~
\cite{Swope82
} is also implemented in
993 {\gromacs}, though it is not yet fully integrated with all sets of
994 options. In velocity Verlet, positions $
\ve{r
}$ and velocities
995 $
\ve{v
}$ at time $t$ are used to integrate the equations of motion;
996 velocities at the previous half step are not required.
\bea
997 \label{eqn:velocityverlet1
}
998 \ve{v
}(t+
\hDt) &~=~&
\ve{v
}(t)+
\frac{\Dt}{2m
}\ve{F
}(t) \\
999 \ve{r
}(t+
\Dt) &~=~&
\ve{r
}(t)+
\Dt\,
\ve{v
}(t+
\hDt) \\
1000 \ve{v
}(t+
\Dt) &~=~&
\ve{v
}(t+
\hDt)+
\frac{\Dt}{2m
}\ve{F
}(t+
\Dt)
1004 \label{eqn:velocityverlet2
}
1005 \ve{r
}(t+
\Dt) &~=~&
\ve{r
}(t)+
\Dt\,
\ve{v
} +
\frac{\Dt^
2}{2m
}\ve{F
}(t) \\
1006 \ve{v
}(t+
\Dt) &~=~&
\ve{v
}(t)+
\frac{\Dt}{2m
}\left[\ve{F
}(t) +
\ve{F
}(t+
\Dt)
\right]
1008 With no temperature or pressure coupling, and with
{\em corresponding
}
1009 starting points, leap-frog and velocity Verlet will generate identical
1010 trajectories, as can easily be verified by hand from the equations
1011 above. Given a single starting file with the
{\em same
} starting
1012 point $
\ve{x
}(
0)$ and $
\ve{v
}(
0)$, leap-frog and velocity Verlet will
1013 {\em not
} give identical trajectories, as leap-frog will interpret the
1014 velocities as corresponding to $t=-
\hDt$, while velocity Verlet will
1015 interpret them as corresponding to the timepoint $t=
0$.
1017 \subsection{Understanding reversible integrators: The Trotter decomposition
}
1018 To further understand the relationship between velocity Verlet and
1019 leap-frog integration, we introduce the reversible Trotter formulation
1020 of dynamics, which is also useful to understanding implementations of
1021 thermostats and barostats in
{\gromacs}.
1023 A system of coupled, first-order differential equations can be evolved
1024 from time $t =
0$ to time $t$ by applying the evolution operator
1026 \Gamma(t) &=&
\exp(iLt)
\Gamma(
0)
\nonumber \\
1027 iL &=&
\dot{\Gamma}\cdot \nabla_{\Gamma},
1029 where $L$ is the Liouville operator, and $
\Gamma$ is the
1030 multidimensional vector of independent variables (positions and
1032 A short-time approximation to the true operator, accurate at time $
\Dt
1033 = t/P$, is applied $P$ times in succession to evolve the system as
1035 \Gamma(t) =
\prod_{i=
1}^P
\exp(iL
\Dt)
\Gamma(
0)
1037 For NVE dynamics, the Liouville operator is
1039 iL =
\sum_{i=
1}^
{N
} \vv_i \cdot \nabla_{\rv_i} +
\sum_{i=
1}^N
\frac{1}{m_i
}\F(r_i)
\cdot \nabla_{\vv_i}.
1041 This can be split into two additive operators
1043 iL_1 &=&
\sum_{i=
1}^N
\frac{1}{m_i
}\F(r_i)
\cdot \nabla_{\vv_i} \nonumber \\
1044 iL_2 &=&
\sum_{i=
1}^
{N
} \vv_i \cdot \nabla_{\rv_i}
1046 Then a short-time, symmetric, and thus reversible approximation of the true dynamics will be
1048 \exp(iL
\Dt) =
\exp(iL_2
\hDt)
\exp(iL_1
\Dt)
\exp(iL_2
\hDt) +
\mathcal{O
}(
\Dt^
3).
1049 \label{eq:NVE_Trotter
}
1051 This corresponds to velocity Verlet integration. The first
1052 exponential term over $
\hDt$ corresponds to a velocity half-step, the
1053 second exponential term over $
\Dt$ corresponds to a full velocity
1054 step, and the last exponential term over $
\hDt$ is the final velocity
1055 half step. For future times $t = n
\Dt$, this becomes
1057 \exp(iLn
\Dt) &
\approx&
\left(
\exp(iL_2
\hDt)
\exp(iL_1
\Dt)
\exp(iL_2
\hDt)
\right)^n
\nonumber \\
1058 &
\approx&
\exp(iL_2
\hDt)
\bigg(
\exp(iL_1
\Dt)
\exp(iL_2
\Dt)
\bigg)^
{n-
1} \nonumber \\
1059 & & \;\;\;\;
\exp(iL_1
\Dt)
\exp(iL_2
\hDt)
1061 This formalism allows us to easily see the difference between the
1062 different flavors of Verlet integrators. The leap-frog integrator can
1063 be seen as starting with Eq.~
\ref{eq:NVE_Trotter
} with the
1064 $
\exp\left(iL_1
\dt\right)$ term, instead of the half-step velocity
1067 \exp(iLn
\dt) &=&
\exp\left(iL_1
\dt\right)
\exp\left(iL_2
\Dt \right) +
\mathcal{O
}(
\Dt^
3).
1069 Here, the full step in velocity is between $t-
\hDt$ and $t+
\hDt$,
1070 since it is a combination of the velocity half steps in velocity
1071 Verlet. For future times $t = n
\Dt$, this becomes
1073 \exp(iLn
\dt) &
\approx&
\bigg(
\exp\left(iL_1
\dt\right)
\exp\left(iL_2
\Dt \right)
\bigg)^
{n
}.
1075 Although at first this does not appear symmetric, as long as the full velocity
1076 step is between $t-
\hDt$ and $t+
\hDt$, then this is simply a way of
1077 starting velocity Verlet at a different place in the cycle.
1079 Even though the trajectory and thus potential energies are identical
1080 between leap-frog and velocity Verlet, the kinetic energy and
1081 temperature will not necessarily be the same. Standard velocity
1082 Verlet uses the velocities at the $t$ to calculate the kinetic energy
1083 and thus the temperature only at time $t$; the kinetic energy is then a sum over all particles
1085 KE_
{\mathrm{full
}}(t) &=&
\sum_i \left(
\frac{1}{2m_i
}\ve{v
}_i(t)
\right)^
2 \nonumber\\
1086 &=&
\sum_i \frac{1}{2m_i
}\left(
\frac{1}{2}\ve{v
}_i(t-
\hDt)+
\frac{1}{2}\ve{v
}_i(t+
\hDt)
\right)^
2,
1088 with the square on the
{\em outside
} of the average. Standard
1089 leap-frog calculates the kinetic energy at time $t$ based on the
1090 average kinetic energies at the timesteps $t+
\hDt$ and $t-
\hDt$, or
1091 the sum over all particles
1093 KE_
{\mathrm{average
}}(t) &=&
\sum_i \frac{1}{2m_i
}\left(
\frac{1}{2}\ve{v
}_i(t-
\hDt)^
2+
\frac{1}{2}\ve{v
}_i(t+
\hDt)^
2\right),
1095 where the square is
{\em inside
} the average.
1097 A non-standard variant of velocity Verlet which averages the kinetic
1098 energies $KE(t+
\hDt)$ and $KE(t-
\hDt)$, exactly like leap-frog, is also
1099 now implemented in
{\gromacs} (as
{\tt .mdp
} file option
{\tt md-vv-avek
}). Without
1100 temperature and pressure coupling, velocity Verlet with
1101 half-step-averaged kinetic energies and leap-frog will be identical up
1102 to numerical precision. For temperature- and pressure-control schemes,
1103 however, velocity Verlet with half-step-averaged kinetic energies and
1104 leap-frog will be different, as will be discussed in the section in
1105 thermostats and barostats.
1107 The half-step-averaged kinetic energy and temperature are slightly more
1108 accurate for a given step size; the difference in average kinetic
1109 energies using the half-step-averaged kinetic energies (
{\em md
} and
1110 {\em md-vv-avek
}) will be closer to the kinetic energy obtained in the
1111 limit of small step size than will the full-step kinetic energy (using
1112 {\em md-vv
}). For NVE simulations, this difference is usually not
1113 significant, since the positions and velocities of the particles are
1114 still identical; it makes a difference in the way the the temperature
1115 of the simulations are
{\em interpreted
}, but
{\em not
} in the
1116 trajectories that are produced. Although the kinetic energy is more
1117 accurate with the half-step-averaged method, meaning that it changes
1118 less as the timestep gets large, it is also more noisy. The RMS deviation
1119 of the total energy of the system (sum of kinetic plus
1120 potential) in the half-step-averaged kinetic energy case will be
1121 higher (about twice as high in most cases) than the full-step kinetic
1122 energy. The drift will still be the same, however, as again, the
1123 trajectories are identical.
1125 For NVT simulations, however, there
{\em will
} be a difference, as
1126 discussed in the section on temperature control, since the velocities
1127 of the particles are adjusted such that kinetic energies of the
1128 simulations, which can be calculated either way, reach the
1129 distribution corresponding to the set temperature. In this case, the
1130 three methods will not give identical results.
1132 Because the velocity and position are both defined at the same time
1133 $t$ the velocity Verlet integrator can be used for some methods,
1134 especially rigorously correct pressure control methods, that are not
1135 actually possible with leap-frog. The integration itself takes
1136 negligibly more time than leap-frog, but twice as many communication
1137 calls are currently required. In most cases, and especially for large
1138 systems where communication speed is important for parallelization and
1139 differences between thermodynamic ensembles vanish in the $
1/N$ limit,
1140 and when only NVT ensembles are required, leap-frog will likely be the
1141 preferred integrator. For pressure control simulations where the fine
1142 details of the thermodynamics are important, only velocity Verlet
1143 allows the true ensemble to be calculated. In either case, simulation
1144 with double precision may be required to get fine details of
1145 thermodynamics correct.
1147 \subsection{Twin-range cut-offs
\index{twin-range!cut-off
}}
1148 To save computation time, slowly varying forces can be calculated
1149 less often than rapidly varying forces. In
{\gromacs}
1150 such a
\normindex{multiple time step
} splitting is possible between
1151 short and long range non-bonded interactions.
1152 In
{\gromacs} versions up to
4.0, an irreversible integration scheme
1153 was used which is also used by the
{\gromos} simulation package:
1154 every $n$ steps the long range forces are determined and these are
1155 then also used (without modification) for the next $n-
1$ integration steps
1156 in
\eqnref{leapfrogv
}. Such an irreversible scheme can result in bad energy
1157 conservation and, possibly, bad sampling.
1158 Since version
4.5, a leap-frog version of the reversible Trotter decomposition scheme~
\cite{Tuckerman1992a
} is used.
1159 In this integrator the long-range forces are determined every $n$ steps
1160 and are then integrated into the velocity in
\eqnref{leapfrogv
} using
1161 a time step of $
\Dt_\mathrm{LR
} = n
\Dt$:
1164 \left\
{ \begin{array
}{lll
} \displaystyle
1165 \ve{v
}(t-
\hDt) +
\frac{1}{m
}\left[\ve{F
}_
\mathrm{SR
}(t) + n
\ve{F
}_
\mathrm{LR
}(t)
\right] \Dt &,&
\mathrm{step
} ~\%~ n =
0 \\
\noalign{\medskip} \displaystyle
1166 \ve{v
}(t-
\hDt) +
\frac{1}{m
}\ve{F
}_
\mathrm{SR
}(t)
\Dt &,&
\mathrm{step
} ~\%~ n
\neq 0 \\
1170 The parameter $n$ is equal to the neighbor list update frequency. In
1171 4.5, the velocity Verlet version of multiple time-stepping is not yet
1174 Several other simulation packages uses multiple time stepping for
1175 bonds and/or the PME mesh forces. In
{\gromacs} we have not implemented
1176 this (yet), since we use a different philosophy. Bonds can be constrained
1177 (which is also a more sound approximation of a physical quantum
1178 oscillator), which allows the smallest time step to be increased
1179 to the larger one. This not only halves the number of force calculations,
1180 but also the update calculations. For even larger time steps, angle vibrations
1181 involving hydrogen atoms can be removed using virtual interaction
1182 \ifthenelse{\equal{\gmxlite}{1}}
1184 {sites (see
\secref{rmfast
}),
}
1185 which brings the shortest time step up to
1186 PME mesh update frequency of a multiple time stepping scheme.
1188 As an example we show the energy conservation for integrating
1189 the equations of motion for SPC/E water at
300 K. To avoid cut-off
1190 effects, reaction-field electrostatics with $
\epsilon_{RF
}=
\infty$ and
1191 shifted Lennard-Jones interactions are used, both with a buffer region.
1192 The long-range interactions were evaluated between
1.0 and
1.4 nm.
1193 In
\figref{leapfrog
} one can see that for electrostatics the Trotter scheme
1194 does an order of magnitude better up to $
\Dt_{LR
}$ =
16 fs.
1195 The electrostatics depends strongly on the orientation of the water molecules,
1196 which changes rapidly.
1197 For Lennard-Jones interactions, the energy drift is linear in $
\Dt_{LR
}$
1198 and roughly two orders of magnitude smaller than for the electrostatics.
1199 Lennard-Jones forces are smaller than Coulomb forces and
1200 they are mainly affected by translation of water molecules, not rotation.
1203 \centerline{\includegraphics[width=
12cm
]{plots/drift-all
}}
1204 \caption{Energy drift per degree of freedom in SPC/E water
1205 with twin-range cut-offs
1206 for reaction field (left) and Lennard-Jones interaction (right)
1207 as a function of the long-range time step length for the irreversible
1208 ``
\gromos'' scheme and a reversible Trotter scheme.
}
1209 \label{fig:twinrangeener
}
1212 \subsection{Temperature coupling
\index{temperature coupling
}}
1213 While direct use of molecular dynamics gives rise to the NVE (constant
1214 number, constant volume, constant energy ensemble), most quantities
1215 that we wish to calculate are actually from a constant temperature
1216 (NVT) ensemble, also called the canonical ensemble.
{\gromacs} can use
1217 the
{\em weak-coupling
} scheme of Berendsen~
\cite{Berendsen84
},
1218 stochastic randomization through the Andersen
1219 thermostat~
\cite{Andersen80
}, the extended ensemble Nos
{\'e
}-Hoover
1220 scheme~
\cite{Nose84,Hoover85
}, or a velocity-rescaling
1221 scheme~
\cite{Bussi2007a
} to simulate constant temperature, with
1222 advantages of each of the schemes laid out below.
1224 There are several other reasons why it might be necessary to control
1225 the temperature of the system (drift during equilibration, drift as a
1226 result of force truncation and integration errors, heating due to
1227 external or frictional forces), but this is not entirely correct to do
1228 from a thermodynamic standpoint, and in some cases only masks the
1229 symptoms (increase in temperature of the system) rather than the
1230 underlying problem (deviations from correct physics in the dynamics).
1231 For larger systems, errors in ensemble averages and structural
1232 properties incurred by using temperature control to remove slow drifts
1233 in temperature appear to be negligible, but no completely
1234 comprehensive comparisons have been carried out, and some caution must
1235 be taking in interpreting the results.
1237 \subsubsection{Berendsen temperature coupling
\pawsindexquiet{Berendsen
}{temperature coupling
}\index{weak coupling
}}
1238 The Berendsen algorithm mimics weak coupling with first-order
1239 kinetics to an external heat bath with given temperature $T_0$.
1240 See ref.~
\cite{Berendsen91
} for a comparison with the
1241 Nos
{\'e
}-Hoover scheme. The effect of this algorithm is
1242 that a deviation of the system temperature from $T_0$ is slowly
1243 corrected according to:
1245 \frac{\de T
}{\de t
} =
\frac{T_0-T
}{\tau}
1246 \label{eqn:Tcoupling
}
1248 which means that a temperature deviation decays exponentially with a
1249 time constant $
\tau$.
1250 This method of coupling has the advantage that the strength of the
1251 coupling can be varied and adapted to the user requirement: for
1252 equilibration purposes the coupling time can be taken quite short
1253 (
{\eg} 0.01 ps), but for reliable equilibrium runs it can be taken much
1254 longer (
{\eg} 0.5 ps) in which case it hardly influences the
1255 conservative dynamics.
1257 The Berendsen thermostat suppresses the fluctuations of the kinetic
1258 energy. This means that one does not generate a proper canonical
1259 ensemble, so rigorously, the sampling will be incorrect. This
1260 error scales with $
1/N$, so for very large systems most ensemble
1261 averages will not be affected significantly, except for the
1262 distribution of the kinetic energy itself. However, fluctuation
1263 properties, such as the heat capacity, will be affected. A similar
1264 thermostat which does produce a correct ensemble is the velocity
1265 rescaling thermostat~
\cite{Bussi2007a
} described below.
1267 The heat flow into or out of the system is affected by scaling the
1268 velocities of each particle every step, or every $n_
\mathrm{TC
}$ steps,
1269 with a time-dependent factor $
\lambda$, given by:
1271 \lambda =
\left[ 1 +
\frac{n_
\mathrm{TC
} \Delta t
}{\tau_T}
1272 \left\
{\frac{T_0
}{T(t -
\hDt)
} -
1 \right\
} \right]^
{1/
2}
1275 The parameter $
\tau_T$ is close, but not exactly equal, to the time constant
1276 $
\tau$ of the temperature coupling (
\eqnref{Tcoupling
}):
1278 \tau =
2 C_V
\tau_T / N_
{df
} k
1280 where $C_V$ is the total heat capacity of the system, $k$ is Boltzmann's
1281 constant, and $N_
{df
}$ is the total number of degrees of freedom. The
1282 reason that $
\tau \neq \tau_T$ is that the kinetic energy change
1283 caused by scaling the velocities is partly redistributed between
1284 kinetic and potential energy and hence the change in temperature is
1285 less than the scaling energy. In practice, the ratio $
\tau /
\tau_T$
1286 ranges from
1 (gas) to
2 (harmonic solid) to
3 (water). When we use
1287 the term ``temperature coupling time constant,'' we mean the parameter
1288 \normindex{$
\tau_T$
}.
1289 {\bf Note
} that in practice the scaling factor $
\lambda$ is limited to
1290 the range of
0.8 $<=
\lambda <=$
1.25, to avoid scaling by very large
1291 numbers which may crash the simulation. In normal use,
1292 $
\lambda$ will always be much closer to
1.0.
1294 \subsubsection{Velocity-rescaling temperature coupling
\pawsindexquiet{velocity-rescaling
}{temperature coupling
}}
1295 The velocity-rescaling thermostat~
\cite{Bussi2007a
} is essentially a Berendsen
1296 thermostat (see above) with an additional stochastic term that ensures
1297 a correct kinetic energy distribution by modifying it according to
1299 \de K = (K_0 - K)
\frac{\de t
}{\tau_T} +
2 \sqrt{\frac{K K_0
}{N_f
}} \frac{\de W
}{\sqrt{\tau_T}},
1300 \label{eqn:vrescale
}
1302 where $K$ is the kinetic energy, $N_f$ the number of degrees of freedom and $
\de W$ a Wiener process.
1303 There are no additional parameters, except for a random seed.
1304 This thermostat produces a correct canonical ensemble and still has
1305 the advantage of the Berendsen thermostat: first order decay of
1306 temperature deviations and no oscillations.
1307 When an $NVT$ ensemble is used, the conserved energy quantity
1308 is written to the energy and log file.
1310 \subsubsection{\normindex{Andersen thermostat
}}
1311 One simple way to maintain a thermostatted ensemble is to take an
1312 $NVE$ integrator and periodically re-select the velocities of the
1313 particles from a Maxwell-Boltzmann distribution.~
\cite{Andersen80
}
1314 This can either be done by randomizing all the velocities
1315 simultaneously (massive collision) every $
\tau_T/
\Dt$ steps (
{\tt andersen-massive
}), or by
1316 randomizing every particle with some small probability every timestep (
{\tt andersen
}),
1317 equal to $
\Dt/
\tau$, where in both cases $
\Dt$ is the timestep and
1318 $
\tau_T$ is a characteristic coupling time scale.
1319 Because of the way constraints operate, all particles in the same
1320 constraint group must be randomized simultaneously. Because of
1321 parallelization issues, the
{\tt andersen
} version cannot currently (
5.0) be
1322 used in systems with constraints.
{\tt andersen-massive
} can be used regardless of constraints.
1323 This thermostat is also currently only possible with velocity Verlet algorithms,
1324 because it operates directly on the velocities at each timestep.
1326 This algorithm completely avoids some of the ergodicity issues of other thermostatting
1327 algorithms, as energy cannot flow back and forth between energetically
1328 decoupled components of the system as in velocity scaling motions.
1329 However, it can slow down the kinetics of system by randomizing
1330 correlated motions of the system, including slowing sampling when
1331 $
\tau_T$ is at moderate levels (less than
10 ps). This algorithm
1332 should therefore generally not be used when examining kinetics or
1333 transport properties of the system.~
\cite{Basconi2013
}
1335 % \ifthenelse{\equal{\gmxlite}{1}}{}{
1336 \subsubsection{Nos
{\'e
}-Hoover temperature coupling
\index{Nose-Hoover temperature coupling@Nos
{\'e
}-Hoover temperature coupling|see
{temperature coupling, Nos
{\'e
}-Hoover
}}{\index{temperature coupling Nose-Hoover@temperature coupling Nos
{\'e
}-Hoover
}}\index{extended ensemble
}}
1338 The Berendsen weak-coupling algorithm is
1339 extremely efficient for relaxing a system to the target temperature,
1340 but once the system has reached equilibrium it might be more
1341 important to probe a correct canonical ensemble. This is unfortunately
1342 not the case for the weak-coupling scheme.
1344 To enable canonical ensemble simulations,
{\gromacs} also supports the
1345 extended-ensemble approach first proposed by Nos
{\'e
}~
\cite{Nose84
}
1346 and later modified by Hoover~
\cite{Hoover85
}. The system Hamiltonian is
1347 extended by introducing a thermal reservoir and a friction term in the
1348 equations of motion. The friction force is proportional to the
1349 product of each particle's velocity and a friction parameter, $
\xi$.
1350 This friction parameter (or ``heat bath'' variable) is a fully
1351 dynamic quantity with its own momentum ($p_
{\xi}$) and equation of
1352 motion; the time derivative is calculated from the difference between
1353 the current kinetic energy and the reference temperature.
1355 In this formulation, the particles' equations of motion in
1356 \figref{global
} are replaced by:
1358 \frac {\de^
2\ve{r
}_i
}{\de t^
2} =
\frac{\ve{F
}_i
}{m_i
} -
1359 \frac{p_
{\xi}}{Q
}\frac{\de \ve{r
}_i
}{\de t
} ,
1360 \label{eqn:NH-eqn-of-motion
}
1361 \eeq where the equation of motion for the heat bath parameter $
\xi$ is:
1362 \beq \frac {\de p_
{\xi}}{\de t
} =
\left( T - T_0
\right).
\eeq The
1363 reference temperature is denoted $T_0$, while $T$ is the current
1364 instantaneous temperature of the system. The strength of the coupling
1365 is determined by the constant $Q$ (usually called the ``mass parameter''
1366 of the reservoir) in combination with the reference
1367 temperature.~
\footnote{Note that some derivations, an alternative
1368 notation $
\xi_{\mathrm{alt
}} = v_
{\xi} = p_
{\xi}/Q$ is used.
}
1370 The conserved quantity for the Nos
{\'e
}-Hoover equations of motion is not
1371 the total energy, but rather
1373 H =
\sum_{i=
1}^
{N
} \frac{\pb_i}{2m_i
} + U
\left(
\rv_1,
\rv_2,
\ldots,
\rv_N\right) +
\frac{p_
{\xi}^
2}{2Q
} + N_fkT
\xi,
1375 where $N_f$ is the total number of degrees of freedom.
1377 In our opinion, the mass parameter is a somewhat awkward way of
1378 describing coupling strength, especially due to its dependence on
1379 reference temperature (and some implementations even include the
1380 number of degrees of freedom in your system when defining $Q$). To
1381 maintain the coupling strength, one would have to change $Q$ in
1382 proportion to the change in reference temperature. For this reason, we
1383 prefer to let the
{\gromacs} user work instead with the period
1384 $
\tau_T$ of the oscillations of kinetic energy between the system and
1385 the reservoir instead. It is directly related to $Q$ and $T_0$ via:
1387 Q =
\frac {\tau_T^
2 T_0
}{4 \pi^
2}.
1389 This provides a much more intuitive way of selecting the
1390 Nos
{\'e
}-Hoover coupling strength (similar to the weak-coupling
1391 relaxation), and in addition $
\tau_T$ is independent of system size
1392 and reference temperature.
1394 It is however important to keep the difference between the
1395 weak-coupling scheme and the Nos
{\'e
}-Hoover algorithm in mind:
1396 Using weak coupling you get a
1397 strongly damped
{\em exponential relaxation
},
1398 while the Nos
{\'e
}-Hoover approach
1399 produces an
{\em oscillatory relaxation
}.
1400 The actual time it takes to relax with Nos
{\'e
}-Hoover coupling is
1401 several times larger than the period of the
1402 oscillations that you select. These oscillations (in contrast
1403 to exponential relaxation) also means that
1404 the time constant normally should be
4--
5 times larger
1405 than the relaxation time used with weak coupling, but your
1408 Nos
{\'e
}-Hoover dynamics in simple systems such as collections of
1409 harmonic oscillators, can be
{\em nonergodic
}, meaning that only a
1410 subsection of phase space is ever sampled, even if the simulations
1411 were to run for infinitely long. For this reason, the Nos
{\'e
}-Hoover
1412 chain approach was developed, where each of the Nos
{\'e
}-Hoover
1413 thermostats has its own Nos
{\'e
}-Hoover thermostat controlling its
1414 temperature. In the limit of an infinite chain of thermostats, the
1415 dynamics are guaranteed to be ergodic. Using just a few chains can
1416 greatly improve the ergodicity, but recent research has shown that the
1417 system will still be nonergodic, and it is still not entirely clear
1418 what the practical effect of this~
\cite{Cooke2008
}. Currently, the
1419 default number of chains is
10, but this can be controlled by the
1420 user. In the case of chains, the equations are modified in the
1421 following way to include a chain of thermostatting
1422 particles~
\cite{Martyna1992
}:
1425 \frac {\de^
2\ve{r
}_i
}{\de t^
2} &~=~&
\frac{\ve{F
}_i
}{m_i
} -
\frac{p_
{{\xi}_1
}}{Q_1
} \frac{\de \ve{r
}_i
}{\de t
} \nonumber \\
1426 \frac {\de p_
{{\xi}_1
}}{\de t
} &~=~&
\left( T - T_0
\right) - p_
{{\xi}_1
} \frac{p_
{{\xi}_2
}}{Q_2
} \nonumber \\
1427 \frac {\de p_
{{\xi}_
{i=
2\ldots N
}}}{\de t
} &~=~&
\left(
\frac{p_
{\xi_{i-
1}}^
2}{Q_
{i-
1}} -kT
\right) - p_
{\xi_i} \frac{p_
{\xi_{i+
1}}}{Q_
{i+
1}} \nonumber \\
1428 \frac {\de p_
{\xi_N}}{\de t
} &~=~&
\left(
\frac{p_
{\xi_{N-
1}}^
2}{Q_
{N-
1}}-kT
\right)
1429 \label{eqn:NH-chain-eqn-of-motion
}
1431 The conserved quantity for Nos
{\'e
}-Hoover chains is
1433 H =
\sum_{i=
1}^
{N
} \frac{\pb_i}{2m_i
} + U
\left(
\rv_1,
\rv_2,
\ldots,
\rv_N\right) +
\sum_{k=
1}^M
\frac{p^
2_
{\xi_k}}{2Q^
{\prime}_k
} + N_fkT
\xi_1 + kT
\sum_{k=
2}^M
\xi_k
1435 The values and velocities of the Nos
{\'e
}-Hoover thermostat variables
1436 are generally not included in the output, as they take up a fair
1437 amount of space and are generally not important for analysis of
1438 simulations, but this can be overridden by defining the environment
1439 variable
{\tt GMX_NOSEHOOVER_CHAINS
}, which will print the values of all
1440 the positions and velocities of all Nos
{\'e
}-Hoover particles in the
1441 chain to the
{\tt .edr
} file. Leap-frog simulations currently can only have
1442 Nos
{\'e
}-Hoover chain lengths of
1, but this will likely be updated in
1445 As described in the integrator section, for temperature coupling, the
1446 temperature that the algorithm attempts to match to the reference
1447 temperature is calculated differently in velocity Verlet and leap-frog
1448 dynamics. Velocity Verlet (
{\em md-vv
}) uses the full-step kinetic
1449 energy, while leap-frog and
{\em md-vv-avek
} use the half-step-averaged
1452 We can examine the Trotter decomposition again to better understand
1453 the differences between these constant-temperature integrators. In
1454 the case of Nos
{\'e
}-Hoover dynamics (for simplicity, using a chain
1455 with $N=
1$, with more details in Ref.~
\cite{Martyna1996
}), we split
1456 the Liouville operator as
1458 iL = iL_1 + iL_2 + iL_
{\mathrm{NHC
}},
1462 iL_1 &=&
\sum_{i=
1}^N
\left[\frac{\pb_i}{m_i
}\right]\cdot \frac{\partial}{\partial \rv_i} \nonumber \\
1463 iL_2 &=&
\sum_{i=
1}^N
\F_i\cdot \frac{\partial}{\partial \pb_i} \nonumber \\
1464 iL_
{\mathrm{NHC
}} &=&
\sum_{i=
1}^N-
\frac{p_
{\xi}}{Q
}\vv_i\cdot \nabla_{\vv_i} +
\frac{p_
{\xi}}{Q
}\frac{\partial }{\partial \xi} +
\left( T - T_0
\right)
\frac{\partial }{\partial p_
{\xi}}
1466 For standard velocity Verlet with Nos
{\'e
}-Hoover temperature control, this becomes
1468 \exp(iL
\dt) &=&
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\exp\left(iL_2
\dt/
2\right)
\nonumber \\
1469 &&
\exp\left(iL_1
\dt\right)
\exp\left(iL_2
\dt/
2\right)
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right) +
\mathcal{O
}(
\Dt^
3).
1471 For half-step-averaged temperature control using
{\em md-vv-avek
},
1472 this decomposition will not work, since we do not have the full step
1473 temperature until after the second velocity step. However, we can
1474 construct an alternate decomposition that is still reversible, by
1475 switching the place of the NHC and velocity portions of the
1478 \exp(iL
\dt) &=&
\exp\left(iL_2
\dt/
2\right)
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\exp\left(iL_1
\dt\right)
\nonumber \\
1479 &&
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\exp\left(iL_2
\dt/
2\right)+
\mathcal{O
}(
\Dt^
3)
1480 \label{eq:half_step_NHC_integrator
}
1482 This formalism allows us to easily see the difference between the
1483 different flavors of velocity Verlet integrator. The leap-frog
1484 integrator can be seen as starting with
1485 Eq.~
\ref{eq:half_step_NHC_integrator
} just before the $
\exp\left(iL_1
1486 \dt\right)$ term, yielding:
1488 \exp(iL
\dt) &=&
\exp\left(iL_1
\dt\right)
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\nonumber \\
1489 &&
\exp\left(iL_2
\dt\right)
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right) +
\mathcal{O
}(
\Dt^
3)
1491 and then using some algebra tricks to solve for some quantities are
1492 required before they are actually calculated~
\cite{Holian95
}.
1496 \subsubsection{Group temperature coupling
}\index{temperature-coupling group
}%
1497 In
{\gromacs} temperature coupling can be performed on groups of
1498 atoms, typically a protein and solvent. The reason such algorithms
1499 were introduced is that energy exchange between different components
1500 is not perfect, due to different effects including cut-offs etc. If
1501 now the whole system is coupled to one heat bath, water (which
1502 experiences the largest cut-off noise) will tend to heat up and the
1503 protein will cool down. Typically
100 K differences can be obtained.
1504 With the use of proper electrostatic methods (PME) these difference
1505 are much smaller but still not negligible. The parameters for
1506 temperature coupling in groups are given in the
{\tt mdp
} file.
1507 Recent investigation has shown that small temperature differences
1508 between protein and water may actually be an artifact of the way
1509 temperature is calculated when there are finite timesteps, and very
1510 large differences in temperature are likely a sign of something else
1511 seriously going wrong with the system, and should be investigated
1512 carefully~
\cite{Eastwood2010
}.
1514 One special case should be mentioned: it is possible to temperature-couple only
1515 part of the system, leaving other parts without temperature
1516 coupling. This is done by specifying $
{-
1}$ for the time constant
1517 $
\tau_T$ for the group that should not be thermostatted. If only
1518 part of the system is thermostatted, the system will still eventually
1519 converge to an NVT system. In fact, one suggestion for minimizing
1520 errors in the temperature caused by discretized timesteps is that if
1521 constraints on the water are used, then only the water degrees of
1522 freedom should be thermostatted, not protein degrees of freedom, as
1523 the higher frequency modes in the protein can cause larger deviations
1524 from the ``true'' temperature, the temperature obtained with small
1525 timesteps~
\cite{Eastwood2010
}.
1527 \subsection{Pressure coupling
\index{pressure coupling
}}
1528 In the same spirit as the temperature coupling, the system can also be
1529 coupled to a ``pressure bath.''
{\gromacs} supports both the Berendsen
1530 algorithm~
\cite{Berendsen84
} that scales coordinates and box vectors
1531 every step, the extended-ensemble Parrinello-Rahman approach~
\cite{Parrinello81,Nose83
}, and for
1532 the velocity Verlet variants, the Martyna-Tuckerman-Tobias-Klein
1533 (MTTK) implementation of pressure
1534 control~
\cite{Martyna1996
}. Parrinello-Rahman and Berendsen can be
1535 combined with any of the temperature coupling methods above; MTTK can
1536 only be used with Nos
{\'e
}-Hoover temperature control.
1538 \subsubsection{Berendsen pressure coupling
\pawsindexquiet{Berendsen
}{pressure coupling
}\index{weak coupling
}}
1539 \label{sec:berendsen_pressure_coupling
}
1540 The Berendsen algorithm rescales the
1541 coordinates and box vectors every step, or every $n_
\mathrm{PC
}$ steps,
1542 with a matrix
{\boldmath $
\mu$
},
1543 which has the effect of a first-order kinetic relaxation of the pressure
1544 towards a given reference pressure $
{\bf P
}_0$ according to
1546 \frac{\de {\bf P
}}{\de t
} =
\frac{{\bf P
}_0-
{\bf P
}}{\tau_p}.
1548 The scaling matrix
{\boldmath $
\mu$
} is given by
1551 =
\delta_{ij
} -
\frac{n_
\mathrm{PC
}\Delta t
}{3\,
\tau_p} \beta_{ij
} \
{P_
{0ij
} - P_
{ij
}(t) \
}.
1554 \index{isothermal compressibility
}
1555 \index{compressibility
}
1556 Here,
{\boldmath $
\beta$
} is the isothermal compressibility of the system.
1557 In most cases this will be a diagonal matrix, with equal elements on the
1558 diagonal, the value of which is generally not known.
1559 It suffices to take a rough estimate because the value of
{\boldmath $
\beta$
}
1560 only influences the non-critical time constant of the
1561 pressure relaxation without affecting the average pressure itself.
1562 For water at
1 atm and
300 K
1563 $
\beta =
4.6 \times 10^
{-
10}$ Pa$^
{-
1} =
4.6 \times 10^
{-
5}$ bar$^
{-
1}$,
1564 which is $
7.6 \times 10^
{-
4}$ MD units (see
\chref{defunits
}).
1565 Most other liquids have similar values.
1566 When scaling completely anisotropically, the system has to be rotated in
1567 order to obey
\eqnref{box_rot
}.
1568 This rotation is approximated in first order in the scaling, which is usually
1569 less than $
10^
{-
4}$. The actual scaling matrix
{\boldmath $
\mu'$
} is
1571 \mbox{\boldmath $
\mu'$
} =
1572 \left(
\begin{array
}{ccc
}
1573 \mu_{xx
} &
\mu_{xy
} +
\mu_{yx
} &
\mu_{xz
} +
\mu_{zx
} \\
1574 0 &
\mu_{yy
} &
\mu_{yz
} +
\mu_{zy
} \\
1578 The velocities are neither scaled nor rotated.
1580 In
{\gromacs}, the Berendsen scaling can also be done isotropically,
1581 which means that instead of $
\ve{P
}$ a diagonal matrix with elements of size
1582 trace$(
\ve{P
})/
3$ is used. For systems with interfaces, semi-isotropic
1583 scaling can be useful.
1584 In this case, the $x/y$-directions are scaled isotropically and the $z$
1585 direction is scaled independently. The compressibility in the $x/y$ or
1586 $z$-direction can be set to zero, to scale only in the other direction(s).
1588 If you allow full anisotropic deformations and use constraints you
1589 might have to scale more slowly or decrease your timestep to avoid
1590 errors from the constraint algorithms. It is important to note that
1591 although the Berendsen pressure control algorithm yields a simulation
1592 with the correct average pressure, it does not yield the exact NPT
1593 ensemble, and it is not yet clear exactly what errors this approximation
1596 % \ifthenelse{\equal{\gmxlite}{1}}{}{
1597 \subsubsection{Parrinello-Rahman pressure coupling
\pawsindexquiet{Parrinello-Rahman
}{pressure coupling
}}
1599 In cases where the fluctuations in pressure or volume are important
1600 {\em per se
} (
{\eg} to calculate thermodynamic properties), especially
1601 for small systems, it may be a problem that the exact ensemble is not
1602 well defined for the weak-coupling scheme, and that it does not
1603 simulate the true NPT ensemble.
1605 {\gromacs} also supports constant-pressure simulations using the
1606 Parrinello-Rahman approach~
\cite{Parrinello81,Nose83
}, which is similar
1607 to the Nos
{\'e
}-Hoover temperature coupling, and in theory gives the
1608 true NPT ensemble. With the Parrinello-Rahman barostat, the box
1609 vectors as represented by the matrix
\ve{b
} obey the matrix equation
1610 of motion
\footnote{The box matrix representation
\ve{b
} in
{\gromacs}
1611 corresponds to the transpose of the box matrix representation
\ve{h
}
1612 in the paper by Nos
{\'e
} and Klein. Because of this, some of our
1613 equations will look slightly different.
}
1615 \frac{\de \ve{b
}^
2}{\de t^
2}= V
\ve{W
}^
{-
1} \ve{b
}'^
{-
1} \left(
\ve{P
} -
\ve{P
}_
{ref
}\right).
1618 The volume of the box is denoted $V$, and $
\ve{W
}$ is a matrix parameter that determines
1619 the strength of the coupling. The matrices
\ve{P
} and
\ve{P
}$_
{ref
}$ are the
1620 current and reference pressures, respectively.
1622 The equations of motion for the particles are also changed, just as
1623 for the Nos
{\'e
}-Hoover coupling. In most cases you would combine the
1624 Parrinello-Rahman barostat with the Nos
{\'e
}-Hoover
1625 thermostat, but to keep it simple we only show the Parrinello-Rahman
1628 \bea \frac {\de^
2\ve{r
}_i
}{\de t^
2} & = &
\frac{\ve{F
}_i
}{m_i
} -
1629 \ve{M
} \frac{\de \ve{r
}_i
}{\de t
} , \\
\ve{M
} & = &
\ve{b
}^
{-
1} \left[
1630 \ve{b
} \frac{\de \ve{b
}'
}{\de t
} +
\frac{\de \ve{b
}}{\de t
} \ve{b
}'
1631 \right] \ve{b
}'^
{-
1}.
\eea The (inverse) mass parameter matrix
1632 $
\ve{W
}^
{-
1}$ determines the strength of the coupling, and how the box
1633 can be deformed. The box restriction (
\ref{eqn:box_rot
}) will be
1634 fulfilled automatically if the corresponding elements of $
\ve{W
}^
{-
1}$
1635 are zero. Since the coupling strength also depends on the size of your
1636 box, we prefer to calculate it automatically in
{\gromacs}. You only
1637 have to provide the approximate isothermal compressibilities
1638 {\boldmath $
\beta$
} and the pressure time constant $
\tau_p$ in the
1639 input file ($L$ is the largest box matrix element):
\beq \left(
1640 \ve{W
}^
{-
1} \right)_
{ij
} =
\frac{4 \pi^
2 \beta_{ij
}}{3 \tau_p^
2 L
}.
1641 \eeq Just as for the Nos
{\'e
}-Hoover thermostat, you should realize
1642 that the Parrinello-Rahman time constant is
{\em not
} equivalent to
1643 the relaxation time used in the Berendsen pressure coupling algorithm.
1644 In most cases you will need to use a
4--
5 times larger time constant
1645 with Parrinello-Rahman coupling. If your pressure is very far from
1646 equilibrium, the Parrinello-Rahman coupling may result in very large
1647 box oscillations that could even crash your run. In that case you
1648 would have to increase the time constant, or (better) use the weak-coupling
1649 scheme to reach the target pressure, and then switch to
1650 Parrinello-Rahman coupling once the system is in equilibrium.
1651 Additionally, using the leap-frog algorithm, the pressure at time $t$
1652 is not available until after the time step has completed, and so the
1653 pressure from the previous step must be used, which makes the algorithm
1654 not directly reversible, and may not be appropriate for high precision
1655 thermodynamic calculations.
1657 \subsubsection{Surface-tension coupling
\pawsindexquiet{surface-tension
}{pressure coupling
}}
1658 When a periodic system consists of more than one phase, separated by
1659 surfaces which are parallel to the $xy$-plane,
1660 the surface tension and the $z$-component of the pressure can be coupled
1661 to a pressure bath. Presently, this only works with the Berendsen
1662 pressure coupling algorithm in
{\gromacs}.
1663 The average surface tension $
\gamma(t)$ can be calculated from
1664 the difference between the normal and the lateral pressure
1667 \frac{1}{n
} \int_0^
{L_z
}
1668 \left\
{ P_
{zz
}(z,t) -
\frac{P_
{xx
}(z,t) + P_
{yy
}(z,t)
}{2} \right\
} \mbox{d
}z \\
1670 \frac{L_z
}{n
} \left\
{ P_
{zz
}(t) -
\frac{P_
{xx
}(t) + P_
{yy
}(t)
}{2} \right\
},
1672 where $L_z$ is the height of the box and $n$ is the number of surfaces.
1673 The pressure in the z-direction is corrected by scaling the height of
1674 the box with $
\mu_{zz
}$
1676 \Delta P_
{zz
} =
\frac{\Delta t
}{\tau_p} \
{ P_
{0zz
} - P_
{zz
}(t) \
}
1679 \mu_{zz
} =
1 +
\beta_{zz
} \Delta P_
{zz
}
1681 This is similar to normal pressure coupling, except that the factor
1682 of $
1/
3$ is missing.
1683 The pressure correction in the $z$-direction is then used to get the
1684 correct convergence for the surface tension to the reference value $
\gamma_0$.
1685 The correction factor for the box length in the $x$/$y$-direction is
1687 \mu_{x/y
} =
1 +
\frac{\Delta t
}{2\,
\tau_p} \beta_{x/y
}
1688 \left(
\frac{n
\gamma_0}{\mu_{zz
} L_z
}
1689 -
\left\
{ P_
{zz
}(t)+
\Delta P_
{zz
} -
\frac{P_
{xx
}(t) + P_
{yy
}(t)
}{2} \right\
}
1692 The value of $
\beta_{zz
}$ is more critical than with normal pressure
1693 coupling. Normally an incorrect compressibility will just scale $
\tau_p$,
1694 but with surface tension coupling it affects the convergence of the surface
1696 When $
\beta_{zz
}$ is set to zero (constant box height), $
\Delta P_
{zz
}$ is also set
1697 to zero, which is necessary for obtaining the correct surface tension.
1699 \subsubsection{MTTK pressure control algorithms
}
1701 As mentioned in the previous section, one weakness of leap-frog
1702 integration is in constant pressure simulations, since the pressure
1703 requires a calculation of both the virial and the kinetic energy at
1704 the full time step; for leap-frog, this information is not available
1705 until
{\em after
} the full timestep. Velocity Verlet does allow the
1706 calculation, at the cost of an extra round of global communication,
1707 and can compute, mod any integration errors, the true NPT ensemble.
1709 The full equations, combining both pressure coupling and temperature
1710 coupling, are taken from Martyna
{\em et al.
}~
\cite{Martyna1996
} and
1711 Tuckerman~
\cite{Tuckerman2006
} and are referred to here as MTTK
1712 equations (Martyna-Tuckerman-Tobias-Klein). We introduce for
1713 convenience $
\epsilon = (
1/
3)
\ln (V/V_0)$, where $V_0$ is a reference
1714 volume. The momentum of $
\epsilon$ is $
\veps = p_
{\epsilon}/W =
1715 \dot{\epsilon} =
\dot{V
}/
3V$, and define $
\alpha =
1 +
3/N_
{dof
}$ (see
1716 Ref~
\cite{Tuckerman2006
})
1718 The isobaric equations are
1720 \dot{\rv}_i &=&
\frac{\pb_i}{m_i
} +
\frac{\peps}{W
} \rv_i \nonumber \\
1721 \frac{\dot{\pb}_i
}{m_i
} &=&
\frac{1}{m_i
}\F_i -
\alpha\frac{\peps}{W
} \frac{\pb_i}{m_i
} \nonumber \\
1722 \dot{\epsilon} &=&
\frac{\peps}{W
} \nonumber \\
1723 \frac{\dot{\peps}}{W
} &=&
\frac{3V
}{W
}(P_
{\mathrm{int
}} - P) + (
\alpha-
1)
\left(
\sum_{n=
1}^N
\frac{\pb_i^
2}{m_i
}\right),\\
1727 P_
{\mathrm{int
}} &=& P_
{\mathrm{kin
}} -P_
{\mathrm{vir
}} =
\frac{1}{3V
}\left[\sum_{i=
1}^N
\left(
\frac{\pb_i^
2}{2m_i
} -
\rv_i \cdot \F_i\
1730 The terms including $
\alpha$ are required to make phase space
1731 incompressible~
\cite{Tuckerman2006
}. The $
\epsilon$ acceleration term
1734 \frac{\dot{\peps}}{W
} &=&
\frac{3V
}{W
}\left(
\alpha P_
{\mathrm{kin
}} - P_
{\mathrm{vir
}} - P
\right)
1736 In terms of velocities, these equations become
1738 \dot{\rv}_i &=&
\vv_i +
\veps \rv_i \nonumber \\
1739 \dot{\vv}_i &=&
\frac{1}{m_i
}\F_i -
\alpha\veps \vv_i \nonumber \\
1740 \dot{\epsilon} &=&
\veps \nonumber \\
1741 \dot{\veps} &=&
\frac{3V
}{W
}(P_
{\mathrm{int
}} - P) + (
\alpha-
1)
\left(
\sum_{n=
1}^N
\frac{1}{2} m_i
\vv_i^
2\right)
\nonumber \\
1742 P_
{\mathrm{int
}} &=& P_
{\mathrm{kin
}} - P_
{\mathrm{vir
}} =
\frac{1}{3V
}\left[\sum_{i=
1}^N
\left(
\frac{1}{2} m_i
\vv_i^
2 -
\rv_i \cdot \F_i\right)
\right]
1744 For these equations, the conserved quantity is
1746 H =
\sum_{i=
1}^
{N
} \frac{\pb_i^
2}{2m_i
} + U
\left(
\rv_1,
\rv_2,
\ldots,
\rv_N\right) +
\frac{p_
\epsilon}{2W
} + PV
1748 The next step is to add temperature control. Adding Nos
{\'e
}-Hoover
1749 chains, including to the barostat degree of freedom, where we use
1750 $
\eta$ for the barostat Nos
{\'e
}-Hoover variables, and $Q^
{\prime}$
1751 for the coupling constants of the thermostats of the barostats, we get
1753 \dot{\rv}_i &=&
\frac{\pb_i}{m_i
} +
\frac{\peps}{W
} \rv_i \nonumber \\
1754 \frac{\dot{\pb}_i
}{m_i
} &=&
\frac{1}{m_i
}\F_i -
\alpha\frac{\peps}{W
} \frac{\pb_i}{m_i
} -
\frac{p_
{\xi_1}}{Q_1
}\frac{\pb_i}{m_i
}\nonumber \\
1755 \dot{\epsilon} &=&
\frac{\peps}{W
} \nonumber \\
1756 \frac{\dot{\peps}}{W
} &=&
\frac{3V
}{W
}(
\alpha P_
{\mathrm{kin
}} - P_
{\mathrm{vir
}} - P) -
\frac{p_
{\eta_1}}{Q^
{\prime}_1
}\peps \nonumber \\
1757 \dot{\xi}_k &=&
\frac{p_
{\xi_k}}{Q_k
} \nonumber \\
1758 \dot{\eta}_k &=&
\frac{p_
{\eta_k}}{Q^
{\prime}_k
} \nonumber \\
1759 \dot{p
}_
{\xi_k} &=& G_k -
\frac{p_
{\xi_{k+
1}}}{Q_
{k+
1}} \;\;\;\; k=
1,
\ldots, M-
1 \nonumber \\
1760 \dot{p
}_
{\eta_k} &=& G^
\prime_k -
\frac{p_
{\eta_{k+
1}}}{Q^
\prime_{k+
1}} \;\;\;\; k=
1,
\ldots, M-
1 \nonumber \\
1761 \dot{p
}_
{\xi_M} &=& G_M
\nonumber \\
1762 \dot{p
}_
{\eta_M} &=& G^
\prime_M,
\nonumber \\
1766 P_
{\mathrm{int
}} &=& P_
{\mathrm{kin
}} - P_
{\mathrm{vir
}} =
\frac{1}{3V
}\left[\sum_{i=
1}^N
\left(
\frac{\pb_i^
2}{2m_i
} -
\rv_i \cdot \F_i\right)
\right] \nonumber \\
1767 G_1 &=&
\sum_{i=
1}^N
\frac{\pb^
2_i
}{m_i
} - N_f kT
\nonumber \\
1768 G_k &=&
\frac{p^
2_
{\xi_{k-
1}}}{2Q_
{k-
1}} - kT \;\; k =
2,
\ldots,M
\nonumber \\
1769 G^
\prime_1 &=&
\frac{\peps^
2}{2W
} - kT
\nonumber \\
1770 G^
\prime_k &=&
\frac{p^
2_
{\eta_{k-
1}}}{2Q^
\prime_{k-
1}} - kT \;\; k =
2,
\ldots,M
1772 The conserved quantity is now
1774 H =
\sum_{i=
1}^
{N
} \frac{\pb_i}{2m_i
} + U
\left(
\rv_1,
\rv_2,
\ldots,
\rv_N\right) +
\frac{p^
2_
\epsilon}{2W
} + PV +
\nonumber \\
1775 \sum_{k=
1}^M
\frac{p^
2_
{\xi_k}}{2Q_k
} +
\sum_{k=
1}^M
\frac{p^
2_
{\eta_k}}{2Q^
{\prime}_k
} + N_fkT
\xi_1 + kT
\sum_{i=
2}^M
\xi_k + kT
\sum_{k=
1}^M
\eta_k
1777 Returning to the Trotter decomposition formalism, for pressure control and temperature control~
\cite{Martyna1996
} we get:
1779 iL = iL_1 + iL_2 + iL_
{\epsilon,
1} + iL_
{\epsilon,
2} + iL_
{\mathrm{NHC-baro
}} + iL_
{\mathrm{NHC
}}
1781 where ``NHC-baro'' corresponds to the Nos
{\`e
}-Hoover chain of the barostat,
1782 and NHC corresponds to the NHC of the particles,
1784 iL_1 &=&
\sum_{i=
1}^N
\left[\frac{\pb_i}{m_i
} +
\frac{\peps}{W
}\rv_i\right]\cdot \frac{\partial}{\partial \rv_i} \\
1785 iL_2 &=&
\sum_{i=
1}^N
\F_i -
\alpha \frac{\peps}{W
}\pb_i \cdot \frac{\partial}{\partial \pb_i} \\
1786 iL_
{\epsilon,
1} &=&
\frac{p_
\epsilon}{W
} \frac{\partial}{\partial \epsilon}\\
1787 iL_
{\epsilon,
2} &=& G_
{\epsilon} \frac{\partial}{\partial p_
\epsilon}
1791 G_
{\epsilon} =
3V
\left(
\alpha P_
{\mathrm{kin
}} - P_
{\mathrm{vir
}} - P
\right)
1793 Using the Trotter decomposition, we get
1795 \exp(iL
\dt) &=&
\exp\left(iL_
{\mathrm{NHC-baro
}}\dt/
2\right)
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\nonumber \nonumber \\
1796 &&
\exp\left(iL_
{\epsilon,
2}\dt/
2\right)
\exp\left(iL_2
\dt/
2\right)
\nonumber \nonumber \\
1797 &&
\exp\left(iL_
{\epsilon,
1}\dt\right)
\exp\left(iL_1
\dt\right)
\nonumber \nonumber \\
1798 &&
\exp\left(iL_2
\dt/
2\right)
\exp\left(iL_
{\epsilon,
2}\dt/
2\right)
\nonumber \nonumber \\
1799 &&
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\exp\left(iL_
{\mathrm{NHC-baro
}}\dt/
2\right) +
\mathcal{O
}(
\dt^
3)
1801 The action of $
\exp\left(iL_1
\dt\right)$ comes from the solution of
1802 the the differential equation
1803 $
\dot{\rv}_i =
\vv_i +
\veps \rv_i$
1804 with $
\vv_i =
\pb_i/m_i$ and $
\veps$ constant with initial condition
1805 $
\rv_i(
0)$, evaluate at $t=
\Delta t$. This yields the evolution
1807 \rv_i(
\dt) =
\rv_i(
0)e^
{\veps \dt} +
\Delta t
\vv_i(
0) e^
{\veps \dt/
2} \sinhx{\veps \dt/
2}.
1809 The action of $
\exp\left(iL_2
\dt/
2\right)$ comes from the solution
1810 of the differential equation $
\dot{\vv}_i =
\frac{\F_i}{m_i
} -
1811 \alpha\veps\vv_i$, yielding
1813 \vv_i(
\dt/
2) =
\vv_i(
0)e^
{-
\alpha\veps \dt/
2} +
\frac{\Delta t
}{2m_i
}\F_i(
0) e^
{-
\alpha\veps \dt/
4}\sinhx{\alpha\veps \dt/
4}.
1815 {\em md-vv-avek
} uses the full step kinetic energies for determining the pressure with the pressure control,
1816 but the half-step-averaged kinetic energy for the temperatures, which can be written as a Trotter decomposition as
1818 \exp(iL
\dt) &=&
\exp\left(iL_
{\mathrm{NHC-baro
}}\dt/
2\right)
\nonumber \exp\left(iL_
{\epsilon,
2}\dt/
2\right)
\exp\left(iL_2
\dt/
2\right)
\nonumber \\
1819 &&
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\exp\left(iL_
{\epsilon,
1}\dt\right)
\exp\left(iL_1
\dt\right)
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\nonumber \\
1820 &&
\exp\left(iL_2
\dt/
2\right)
\exp\left(iL_
{\epsilon,
2}\dt/
2\right)
\exp\left(iL_
{\mathrm{NHC-baro
}}\dt/
2\right) +
\mathcal{O
}(
\dt^
3)
1822 With constraints, the equations become significantly more
1823 complicated, in that each of these equations need to be solved
1824 iteratively for the constraint forces. The discussion of the details of the iteration
1825 is beyond the scope of this manual; readers are encouraged to see the
1826 implementation described in~
\cite{Yu2010
}.
1829 \subsubsection{Infrequent evaluation of temperature and pressure coupling
}
1831 Temperature and pressure control require global communication to
1832 compute the kinetic energy and virial, which can become costly if
1833 performed every step for large systems. We can rearrange the Trotter
1834 decomposition to give alternate symplectic, reversible integrator with
1835 the coupling steps every $n$ steps instead of every steps. These new
1836 integrators will diverge if the coupling time step is too large, as
1837 the auxiliary variable integrations will not converge. However, in
1838 most cases, long coupling times are more appropriate, as they disturb
1839 the dynamics less~
\cite{Martyna1996
}.
1841 Standard velocity Verlet with Nos
{\'e
}-Hoover temperature control has a Trotter expansion
1843 \exp(iL
\dt) &
\approx&
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right)
\exp\left(iL_2
\dt/
2\right)
\nonumber \\
1844 &&
\exp\left(iL_1
\dt\right)
\exp\left(iL_2
\dt/
2\right)
\exp\left(iL_
{\mathrm{NHC
}}\dt/
2\right).
1846 If the Nos
{\'e
}-Hoover chain is sufficiently slow with respect to the motions of the system, we can
1847 write an alternate integrator over $n$ steps for velocity Verlet as
1849 \exp(iL
\dt) &
\approx& (
\exp\left(iL_
{\mathrm{NHC
}}(n
\dt/
2)
\right)
\left[\exp\left(iL_2
\dt/
2\right)
\right.
\nonumber \\
1850 &&
\left.
\exp\left(iL_1
\dt\right)
\exp\left(iL_2
\dt/
2\right)
\right]^n
\exp\left(iL_
{\mathrm{NHC
}}(n
\dt/
2)
\right).
1852 For pressure control, this becomes
1854 \exp(iL
\dt) &
\approx&
\exp\left(iL_
{\mathrm{NHC-baro
}}(n
\dt/
2)
\right)
\exp\left(iL_
{\mathrm{NHC
}}(n
\dt/
2)
\right)
\nonumber \nonumber \\
1855 &&
\exp\left(iL_
{\epsilon,
2}(n
\dt/
2)
\right)
\left[\exp\left(iL_2
\dt/
2\right)
\right.
\nonumber \nonumber \\
1856 &&
\exp\left(iL_
{\epsilon,
1}\dt\right)
\exp\left(iL_1
\dt\right)
\nonumber \nonumber \\
1857 &&
\left.
\exp\left(iL_2
\dt/
2\right)
\right]^n
\exp\left(iL_
{\epsilon,
2}(n
\dt/
2)
\right)
\nonumber \nonumber \\
1858 &&
\exp\left(iL_
{\mathrm{NHC
}}(n
\dt/
2)
\right)
\exp\left(iL_
{\mathrm{NHC-baro
}}(n
\dt/
2)
\right),
1860 where the box volume integration occurs every step, but the auxiliary variable
1861 integrations happen every $n$ steps.
1863 % } % Brace matches ifthenelse test for gmxlite
1866 \subsection{The complete update algorithm
}
1869 \addtolength{\fboxsep}{0.5cm
}
1870 \begin{shadowenv
}[12cm
]
1871 {\large \bf THE UPDATE ALGORITHM
}
1872 \rule{\textwidth}{2pt
} \\
1874 Positions $
\ve{r
}$ of all atoms at time $t$ \\
1875 Velocities $
\ve{v
}$ of all atoms at time $t-
\hDt$ \\
1876 Accelerations $
\ve{F
}/m$ on all atoms at time $t$.\\
1877 (Forces are computed disregarding any constraints)\\
1878 Total kinetic energy and virial at $t-
\Dt$\\
1880 {\bf 1.
} Compute the scaling factors $
\lambda$ and $
\mu$\\
1881 according to
\eqnsref{lambda
}{mu
}\\
1883 {\bf 2.
} Update and scale velocities: $
\ve{v
}' =
\lambda (
\ve{v
} +
1884 \ve{a
} \Delta t)$ \\
1886 {\bf 3.
} Compute new unconstrained coordinates: $
\ve{r
}' =
\ve{r
} +
\ve{v
}'
1889 {\bf 4.
} Apply constraint algorithm to coordinates: constrain($
\ve{r
}^
{'
} \rightarrow \ve{r
}'';
1892 {\bf 5.
} Correct velocities for constraints: $
\ve{v
} = (
\ve{r
}'' -
1893 \ve{r
}) /
\Delta t$ \\
1895 {\bf 6.
} Scale coordinates and box: $
\ve{r
} =
\mu \ve{r
}'';
\ve{b
} =
1898 \caption{The MD update algorithm with the leap-frog integrator
}
1899 \label{fig:complete-update
}
1902 The complete algorithm for the update of velocities and coordinates is
1903 given using leap-frog in
\figref{complete-update
}. The SHAKE algorithm of step
1904 4 is explained below.
1906 {\gromacs} has a provision to ``freeze'' (prevent motion of) selected
1907 particles
\index{frozen atoms
}, which must be defined as a ``
\swapindex{freeze
}{group
}.'' This is implemented
1908 using a
{\em freeze factor $
\ve{f
}_g$
}, which is a vector, and differs for each
1909 freeze group (see
\secref{groupconcept
}). This vector contains only
1910 zero (freeze) or one (don't freeze).
1911 When we take this freeze factor and the external acceleration $
\ve{a
}_h$ into
1912 account the update algorithm for the velocities becomes
1914 \ve{v
}(t+
\hdt)~=~
\ve{f
}_g *
\lambda *
\left[ \ve{v
}(t-
\hdt) +
\frac{\ve{F
}(t)
}{m
}\Delta t +
\ve{a
}_h
\Delta t
\right],
1916 where $g$ and $h$ are group indices which differ per atom.
1918 \subsection{Output step
}
1919 The most important output of the MD run is the
{\em
1920 \swapindex{trajectory
}{file
}}, which contains particle coordinates
1921 and (optionally) velocities at regular intervals.
1922 The trajectory file contains frames that could include positions,
1923 velocities and/or forces, as well as information about the dimensions
1924 of the simulation volume, integration step, integration time, etc. The
1925 interpretation of the time varies with the integrator chosen, as
1926 described above. For Velocity Verlet integrators, velocities labeled
1927 at time $t$ are for that time. For other integrators (e.g. leap-frog,
1928 stochastic dynamics), the velocities labeled at time $t$ are for time
1931 Since the trajectory
1932 files are lengthy, one should not save every step! To retain all
1933 information it suffices to write a frame every
15 steps, since at
1934 least
30 steps are made per period of the highest frequency in the
1935 system, and Shannon's
\normindex{sampling
} theorem states that two samples per
1936 period of the highest frequency in a band-limited signal contain all
1937 available information. But that still gives very long files! So, if
1938 the highest frequencies are not of interest,
10 or
20 samples per ps
1939 may suffice. Be aware of the distortion of high-frequency motions by
1940 the
{\em stroboscopic effect
}, called
{\em aliasing
}: higher frequencies
1941 are mirrored with respect to the sampling frequency and appear as
1944 {\gromacs} can also write reduced-precision coordinates for a subset of
1945 the simulation system to a special compressed trajectory file
1946 format. All the other tools can read and write this format. See
1947 \secref{mdpopt
} for details on how to set up your
{\tt .mdp
} file
1948 to have
{\tt mdrun
} use this feature.
1950 % \ifthenelse{\equal{\gmxlite}{1}}{}{
1951 \section{Shell molecular dynamics
}
1952 {\gromacs} can simulate
\normindex{polarizability
} using the
1953 \normindex{shell model
} of Dick and Overhauser~
\cite{Dick58
}. In such models
1954 a shell particle representing the electronic degrees of freedom is
1955 attached to a nucleus by a spring. The potential energy is minimized with
1956 respect to the shell position at every step of the simulation (see below).
1957 Successful applications of shell models in
{\gromacs} have been published
1958 for $N_2$~
\cite{Jordan95
} and water~
\cite{Maaren2001a
}.
1960 \subsection{Optimization of the shell positions
}
1961 The force
\ve{F
}$_S$ on a shell particle $S$ can be decomposed into two
1964 \ve{F
}_S ~=~
\ve{F
}_
{bond
} +
\ve{F
}_
{nb
}
1966 where
\ve{F
}$_
{bond
}$ denotes the component representing the
1967 polarization energy, usually represented by a harmonic potential and
1968 \ve{F
}$_
{nb
}$ is the sum of Coulomb and van der Waals interactions. If we
1969 assume that
\ve{F
}$_
{nb
}$ is almost constant we can analytically derive the
1970 optimal position of the shell, i.e. where
\ve{F
}$_S$ =
0. If we have the
1971 shell S connected to atom A we have
1973 \ve{F
}_
{bond
} ~=~ k_b
\left(
\ve{x
}_S -
\ve{x
}_A
\right).
1975 In an iterative solver, we have positions
\ve{x
}$_S(n)$ where $n$ is
1976 the iteration count. We now have at iteration $n$
1978 \ve{F
}_
{nb
} ~=~
\ve{F
}_S - k_b
\left(
\ve{x
}_S(n) -
\ve{x
}_A
\right)
1980 and the optimal position for the shells $x_S(n+
1)$ thus follows from
1982 \ve{F
}_S - k_b
\left(
\ve{x
}_S(n) -
\ve{x
}_A
\right) + k_b
\left(
\ve{x
}_S(n+
1) -
\ve{x
}_A
\right) =
0
1986 \Delta \ve{x
}_S =
\ve{x
}_S(n+
1) -
\ve{x
}_S(n)
1990 \Delta \ve{x
}_S =
\ve{F
}_S/k_b
1992 which then yields the algorithm to compute the next trial in the optimization
1995 \ve{x
}_S(n+
1) ~=~
\ve{x
}_S(n) +
\ve{F
}_S/k_b.
1997 % } % Brace matches ifthenelse test for gmxlite
1999 \section{Constraint algorithms
\index{constraint algorithms
}}
2000 Constraints can be imposed in
{\gromacs} using LINCS (default) or
2001 the traditional SHAKE method.
2003 \subsection{\normindex{SHAKE
}}
2004 \label{subsec:SHAKE
}
2005 The SHAKE~
\cite{Ryckaert77
} algorithm changes a set of unconstrained
2006 coordinates $
\ve{r
}^
{'
}$ to a set of coordinates $
\ve{r
}''$ that
2007 fulfill a list of distance constraints, using a set $
\ve{r
}$
2010 {\rm SHAKE
}(
\ve{r
}^
{'
} \rightarrow \ve{r
}'';\,
\ve{r
})
2012 This action is consistent with solving a set of Lagrange multipliers
2013 in the constrained equations of motion. SHAKE needs a
{\em relative tolerance
};
2014 it will continue until all constraints are satisfied within
2015 that relative tolerance. An error message is
2016 given if SHAKE cannot reset the coordinates because the deviation is
2017 too large, or if a given number of iterations is surpassed.
2019 Assume the equations of motion must fulfill $K$ holonomic constraints,
2022 \sigma_k(
\ve{r
}_1
\ldots \ve{r
}_N) =
0; \;\; k=
1 \ldots K.
2024 For example, $(
\ve{r
}_1 -
\ve{r
}_2)^
2 - b^
2 =
0$.
2025 Then the forces are defined as
2027 -
\frac{\partial}{\partial \ve{r
}_i
} \left( V +
\sum_{k=
1}^K
\lambda_k
2030 where $
\lambda_k$ are Lagrange multipliers which must be solved to
2031 fulfill the constraint equations. The second part of this sum
2032 determines the
{\em constraint forces
} $
\ve{G
}_i$, defined by
2034 \ve{G
}_i = -
\sum_{k=
1}^K
\lambda_k \frac{\partial \sigma_k}{\partial
2037 The displacement due to the constraint forces in the leap-frog or
2038 Verlet algorithm is equal to $(
\ve{G
}_i/m_i)(
\Dt)^
2$. Solving the
2039 Lagrange multipliers (and hence the displacements) requires the
2040 solution of a set of coupled equations of the second degree. These are
2041 solved iteratively by SHAKE.
2042 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2043 \label{subsec:SETTLE
}
2044 For the special case of rigid water molecules, that often make up more
2045 than
80\% of the simulation system we have implemented the
2047 algorithm~
\cite{Miyamoto92
} (
\secref{constraints
}).
2049 For velocity Verlet, an additional round of constraining must be
2050 done, to constrain the velocities of the second velocity half step,
2051 removing any component of the velocity parallel to the bond vector.
2052 This step is called RATTLE, and is covered in more detail in the
2053 original Andersen paper~
\cite{Andersen1983a
}.
2055 % } % Brace matches ifthenelse test for gmxlite
2060 \newcommand{\fs}[1]{\begin{equation
} \label{eqn:
#1}}
2061 \newcommand{\fe}{\end{equation
}}
2062 \newcommand{\p}{\partial}
2063 \newcommand{\Bm}{\ve{B
}}
2064 \newcommand{\M}{\ve{M
}}
2065 \newcommand{\iM}{\M^
{-
1}}
2066 \newcommand{\Tm}{\ve{T
}}
2067 \newcommand{\Sm}{\ve{S
}}
2068 \newcommand{\fo}{\ve{f
}}
2069 \newcommand{\con}{\ve{g
}}
2070 \newcommand{\lenc}{\ve{d
}}
2072 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2073 \subsection{\normindex{LINCS
}}
2074 \label{subsec:lincs
}
2076 \subsubsection{The LINCS algorithm
}
2077 LINCS is an algorithm that resets bonds to their correct lengths
2078 after an unconstrained update~
\cite{Hess97
}.
2079 The method is non-iterative, as it always uses two steps.
2080 Although LINCS is based on matrices, no matrix-matrix multiplications are
2081 needed. The method is more stable and faster than SHAKE,
2082 but it can only be used with bond constraints and
2083 isolated angle constraints, such as the proton angle in OH.
2084 Because of its stability, LINCS is especially useful for Brownian dynamics.
2085 LINCS has two parameters, which are explained in the subsection parameters.
2086 The parallel version of LINCS, P-LINCS, is described
2087 in subsection
\ssecref{plincs
}.
2089 \subsubsection{The LINCS formulas
}
2090 We consider a system of $N$ particles, with positions given by a
2091 $
3N$ vector $
\ve{r
}(t)$.
2092 For molecular dynamics the equations of motion are given by Newton's Law
2094 {\de^
2 \ve{r
} \over \de t^
2} =
\iM \ve{F
},
2096 where $
\ve{F
}$ is the $
3N$ force vector
2097 and $
\M$ is a $
3N
\times 3N$ diagonal matrix,
2098 containing the masses of the particles.
2099 The system is constrained by $K$ time-independent constraint equations
2101 g_i(
\ve{r
}) = |
\ve{r
}_
{i_1
}-
\ve{r
}_
{i_2
} | - d_i =
0 ~~~~~~i=
1,
\ldots,K.
2104 In a numerical integration scheme, LINCS is applied after an
2105 unconstrained update, just like SHAKE. The algorithm works in two
2106 steps (see figure
\figref{lincs
}). In the first step, the projections
2107 of the new bonds on the old bonds are set to zero. In the second step,
2108 a correction is applied for the lengthening of the bonds due to
2109 rotation. The numerics for the first step and the second step are very
2110 similar. A complete derivation of the algorithm can be found in
2111 \cite{Hess97
}. Only a short description of the first step is given
2115 \centerline{\includegraphics[height=
50mm
]{plots/lincs
}}
2116 \caption[The three position updates needed for one time step.
]{The
2117 three position updates needed for one time step. The dashed line is
2118 the old bond of length $d$, the solid lines are the new bonds. $l=d
2119 \cos \theta$ and $p=(
2 d^
2 - l^
2)^
{1 \over 2}$.
}
2123 A new notation is introduced for the gradient matrix of the constraint
2124 equations which appears on the right hand side of this equation:
2126 B_
{hi
} =
{\p g_h
\over \p r_i
}
2128 Notice that $
\Bm$ is a $K
\times 3N$ matrix, it contains the directions
2130 The following equation shows how the new constrained coordinates
2131 $
\ve{r
}_
{n+
1}$ are related to the unconstrained coordinates
2132 $
\ve{r
}_
{n+
1}^
{unc
}$ by
2135 \ve{r
}_
{n+
1}=(
\ve{I
}-
\Tm_n \ve{B
}_n)
\ve{r
}_
{n+
1}^
{unc
} +
\Tm_n \lenc=
2137 \ve{r
}_
{n+
1}^
{unc
} -
2138 \iM \Bm_n (
\Bm_n \iM \Bm_n^T)^
{-
1} (
\Bm_n \ve{r
}_
{n+
1}^
{unc
} -
\lenc)
2141 where $
\Tm =
\iM \Bm^T (
\Bm \iM \Bm^T)^
{-
1}$.
2142 The derivation of this equation from
\eqnsref{c1
}{c2
} can be found
2145 This first step does not set the real bond lengths to the prescribed lengths,
2146 but the projection of the new bonds onto the old directions of the bonds.
2147 To correct for the rotation of bond $i$, the projection of the
2148 bond, $p_i$, on the old direction is set to
2150 p_i=
\sqrt{2 d_i^
2 - l_i^
2},
2152 where $l_i$ is the bond length after the first projection.
2153 The corrected positions are
2155 \ve{r
}_
{n+
1}^*=(
\ve{I
}-
\Tm_n \Bm_n)
\ve{r
}_
{n+
1} +
\Tm_n \ve{p
}.
2157 This correction for rotational effects is actually an iterative process,
2158 but during MD only one iteration is applied.
2159 The relative constraint deviation after this procedure will be less than
2160 0.0001 for every constraint.
2161 In energy minimization, this might not be accurate enough, so the number
2162 of iterations is equal to the order of the expansion (see below).
2164 Half of the CPU time goes to inverting the constraint coupling
2165 matrix $
\Bm_n \iM \Bm_n^T$, which has to be done every time step.
2166 This $K
\times K$ matrix
2167 has $
1/m_
{i_1
} +
1/m_
{i_2
}$ on the diagonal.
2168 The off-diagonal elements are only non-zero when two bonds are connected,
2170 $
\cos \phi /m_c$, where $m_c$ is
2171 the mass of the atom connecting the
2172 two bonds and $
\phi$ is the angle between the bonds.
2174 The matrix $
\Tm$ is inverted through a power expansion.
2175 A $K
\times K$ matrix $
\ve{S
}$ is
2176 introduced which is the inverse square root of
2177 the diagonal of $
\Bm_n \iM \Bm_n^T$.
2178 This matrix is used to convert the diagonal elements
2179 of the coupling matrix to one:
2182 (
\Bm_n \iM \Bm_n^T)^
{-
1}
2183 =
\Sm \Sm^
{-
1} (
\Bm_n \iM \Bm_n^T)^
{-
1} \Sm^
{-
1} \Sm \\
[2mm
]
2184 =
\Sm (
\Sm \Bm_n \iM \Bm_n^T
\Sm)^
{-
1} \Sm =
2185 \Sm (
\ve{I
} -
\ve{A
}_n)^
{-
1} \Sm
2188 The matrix $
\ve{A
}_n$ is symmetric and sparse and has zeros on the diagonal.
2189 Thus a simple trick can be used to calculate the inverse:
2191 (
\ve{I
}-
\ve{A
}_n)^
{-
1}=
2192 \ve{I
} +
\ve{A
}_n +
\ve{A
}_n^
2 +
\ve{A
}_n^
3 +
\ldots
2195 This inversion method is only valid if the absolute values of all the
2196 eigenvalues of $
\ve{A
}_n$ are smaller than one.
2197 In molecules with only bond constraints, the connectivity is so low
2198 that this will always be true, even if ring structures are present.
2199 Problems can arise in angle-constrained molecules.
2200 By constraining angles with additional distance constraints,
2201 multiple small ring structures are introduced.
2202 This gives a high connectivity, leading to large eigenvalues.
2203 Therefore LINCS should NOT be used with coupled angle-constraints.
2205 For molecules with all bonds constrained the eigenvalues of $A$
2206 are around
0.4. This means that with each additional order
2207 in the expansion
\eqnref{m3
} the deviations decrease by a factor
0.4.
2208 But for relatively isolated triangles of constraints the largest
2209 eigenvalue is around
0.7.
2210 Such triangles can occur when removing hydrogen angle vibrations
2211 with an additional angle constraint in alcohol groups
2212 or when constraining water molecules with LINCS, for instance
2213 with flexible constraints.
2214 The constraints in such triangles converge twice as slow as
2215 the other constraints. Therefore, starting with
{\gromacs} 4,
2216 additional terms are added to the expansion for such triangles
2218 (
\ve{I
}-
\ve{A
}_n)^
{-
1} \approx
2219 \ve{I
} +
\ve{A
}_n +
\ldots +
\ve{A
}_n^
{N_i
} +
2220 \left(
\ve{A
}^*_n +
\ldots +
{\ve{A
}_n^*
}^
{N_i
} \right)
\ve{A
}_n^
{N_i
}
2222 where $N_i$ is the normal order of the expansion and
2223 $
\ve{A
}^*$ only contains the elements of $
\ve{A
}$ that couple
2224 constraints within rigid triangles, all other elements are zero.
2225 In this manner, the accuracy of angle constraints comes close
2226 to that of the other constraints, while the series of matrix vector
2227 multiplications required for determining the expansion
2228 only needs to be extended for a few constraint couplings.
2229 This procedure is described in the P-LINCS paper
\cite{Hess2008a
}.
2231 \subsubsection{The LINCS Parameters
}
2232 The accuracy of LINCS depends on the number of matrices used
2233 in the expansion
\eqnref{m3
}. For MD calculations a fourth order
2234 expansion is enough. For Brownian dynamics with
2235 large time steps an eighth order expansion may be necessary.
2236 The order is a parameter in the
{\tt *.mdp
} file.
2237 The implementation of LINCS is done in such a way that the
2238 algorithm will never crash. Even when it is impossible to
2239 to reset the constraints LINCS will generate a conformation
2240 which fulfills the constraints as well as possible.
2241 However, LINCS will generate a warning when in one step a bond
2242 rotates over more than a predefined angle.
2243 This angle is set by the user in the
{\tt *.mdp
} file.
2245 % } % Brace matches ifthenelse test for gmxlite
2248 \section{Simulated Annealing
}
2250 The well known
\swapindex{simulated
}{annealing
}
2251 (SA) protocol is supported in
{\gromacs}, and you can even couple multiple
2252 groups of atoms separately with an arbitrary number of reference temperatures
2253 that change during the simulation. The annealing is implemented by simply
2254 changing the current reference temperature for each group in the temperature
2255 coupling, so the actual relaxation and coupling properties depends on the
2256 type of thermostat you use and how hard you are coupling it. Since we are
2257 changing the reference temperature it is important to remember that the system
2258 will NOT instantaneously reach this value - you need to allow for the inherent
2259 relaxation time in the coupling algorithm too. If you are changing the
2260 annealing reference temperature faster than the temperature relaxation you
2261 will probably end up with a crash when the difference becomes too large.
2263 The annealing protocol is specified as a series of corresponding times and
2264 reference temperatures for each group, and you can also choose whether you only
2265 want a single sequence (after which the temperature will be coupled to the
2266 last reference value), or if the annealing should be periodic and restart at
2267 the first reference point once the sequence is completed. You can mix and
2268 match both types of annealing and non-annealed groups in your simulation.
2270 \newcommand{\vrond}{\stackrel{\circ}{\ve{r
}}}
2271 \newcommand{\rond}{\stackrel{\circ}{r
}}
2272 \newcommand{\ruis}{\ve{r
}^G
}
2274 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2275 \section{Stochastic Dynamics
\swapindexquiet{stochastic
}{dynamics
}}
2277 Stochastic or velocity
\swapindex{Langevin
}{dynamics
} adds a friction
2278 and a noise term to Newton's equations of motion, as
2281 m_i
{\de^
2 \ve{r
}_i
\over \de t^
2} =
2282 - m_i
\gamma_i {\de \ve{r
}_i
\over \de t
} +
\ve{F
}_i(
\ve{r
}) +
\vrond_i,
2284 where $
\gamma_i$ is the friction constant $
[1/
\mbox{ps
}]$ and
2285 $
\vrond_i\!\!(t)$ is a noise process with
2286 $
\langle \rond_i\!\!(t)
\rond_j\!\!(t+s)
\rangle =
2287 2 m_i
\gamma_i k_B T
\delta(s)
\delta_{ij
}$.
2288 When $
1/
\gamma_i$ is large compared to the time scales present in the system,
2289 one could see stochastic dynamics as molecular dynamics with stochastic
2290 temperature-coupling. The advantage compared to MD with Berendsen
2291 temperature-coupling is that in case of SD the generated ensemble is known.
2292 For simulating a system in vacuum there is the additional advantage that there is no
2293 accumulation of errors for the overall translational and rotational
2295 When $
1/
\gamma_i$ is small compared to the time scales present in the system,
2296 the dynamics will be completely different from MD, but the sampling is
2299 In
{\gromacs} there are two algorithms to integrate equation (
\ref{SDeq
}):
2300 a simple and efficient one
2301 and a more complex leap-frog algorithm~
\cite{Gunsteren88
}, which is now deprecated.
2302 The accuracy of both integrators is equivalent to the normal MD leap-frog and
2303 Velocity Verlet integrator, except with constraints where the complex
2304 SD integrator samples at a temperature that is slightly too high (although that error is smaller than the one from the Velocity Verlet integrator that uses the kinetic energy from the full-step velocity). The simple integrator is nearly identical to the common way of discretizing the Langevin equation, but the friction and velocity term are applied in an impulse fashion~
\cite{Goga2012
}.
2305 The simple integrator is:
2308 \ve{v
}' &~=~&
\ve{v
}(t-
\hDt) +
\frac{1}{m
}\ve{F
}(t)
\Dt \\
2309 \Delta\ve{v
} &~=~& -
\alpha \,
\ve{v
}'(t+
\hDt) +
\sqrt{\frac{k_B T
}{m
}(
1 -
\alpha^
2)
} \,
\ruis_i \\
2310 \ve{r
}(t+
\Dt) &~=~&
\ve{r
}(t)+
\left(
\ve{v
}' +
\frac{1}{2}\Delta \ve{v
}\right)
\Dt \label{eqn:sd1_x_upd
}\\
2311 \ve{v
}(t+
\hDt) &~=~&
\ve{v
}' +
\Delta \ve{v
} \\
2312 \alpha &~=~&
1 - e^
{-
\gamma \Dt}
2314 where $
\ruis_i$ is Gaussian distributed noise with $
\mu =
0$, $
\sigma =
1$.
2315 The velocity is first updated a full time step without friction and noise to get $
\ve{v
}'$, identical to the normal update in leap-frog. The friction and noise are then applied as an impulse at step $t+
\Dt$. The advantage of this scheme is that the velocity-dependent terms act at the full time step, which makes the correct integration of forces that depend on both coordinates and velocities, such as constraints and dissipative particle dynamics (DPD, not implented yet), straightforward. With constraints, the coordinate update
\eqnref{sd1_x_upd
} is split into a normal leap-frog update and a $
\Delta \ve{v
}$. After both of these updates the constraints are applied to coordinates and velocities.
2317 In the deprecated complex algorithm, four Gaussian random numbers are required
2318 per integration step per degree of freedom, and with constraints the
2319 coordinates need to be constrained twice per integration step.
2320 Depending on the computational cost of the force calculation,
2321 this can take a significant part of the simulation time.
2322 Exact continuation of a stochastic dynamics simulation is not possible,
2323 because the state of the random number generator is not stored.
2325 When using SD as a thermostat, an appropriate value for $
\gamma$ is e.g.
0.5 ps$^
{-
1}$,
2326 since this results in a friction that is lower than the internal friction
2327 of water, while it still provides efficient thermostatting.
2330 \section{Brownian Dynamics
\swapindexquiet{Brownian
}{dynamics
}}
2332 In the limit of high friction, stochastic dynamics reduces to
2333 Brownian dynamics, also called position Langevin dynamics.
2334 This applies to over-damped systems,
2335 {\ie} systems in which the inertia effects are negligible.
2338 {\de \ve{r
}_i
\over \de t
} =
\frac{1}{\gamma_i} \ve{F
}_i(
\ve{r
}) +
\vrond_i
2340 where $
\gamma_i$ is the friction coefficient $
[\mbox{amu/ps
}]$ and
2341 $
\vrond_i\!\!(t)$ is a noise process with
2342 $
\langle \rond_i\!\!(t)
\rond_j\!\!(t+s)
\rangle =
2343 2 \delta(s)
\delta_{ij
} k_B T /
\gamma_i$.
2344 In
{\gromacs} the equations are integrated with a simple, explicit scheme
2346 \ve{r
}_i(t+
\Delta t) =
\ve{r
}_i(t) +
2347 {\Delta t
\over \gamma_i} \ve{F
}_i(
\ve{r
}(t))
2348 +
\sqrt{2 k_B T
{\Delta t
\over \gamma_i}}\,
\ruis_i,
2350 where $
\ruis_i$ is Gaussian distributed noise with $
\mu =
0$, $
\sigma =
1$.
2351 The friction coefficients $
\gamma_i$ can be chosen the same for all
2352 particles or as $
\gamma_i = m_i\,
\gamma_i$, where the friction constants
2353 $
\gamma_i$ can be different for different groups of atoms.
2354 Because the system is assumed to be over-damped, large timesteps
2355 can be used. LINCS should be used for the constraints since SHAKE
2356 will not converge for large atomic displacements.
2357 BD is an option of the
{\tt mdrun
} program.
2358 % } % Brace matches ifthenelse test for gmxlite
2360 \section{Energy Minimization
}
2361 \label{sec:EM
}\index{energy minimization
}%
2362 Energy minimization in
{\gromacs} can be done using steepest descent,
2363 conjugate gradients, or l-bfgs (limited-memory
2364 Broyden-Fletcher-Goldfarb-Shanno quasi-Newtonian minimizer...we
2365 prefer the abbreviation). EM is just an option of the
{\tt mdrun
}
2368 \subsection{Steepest Descent
\index{steepest descent
}}
2369 Although steepest descent is certainly not the most efficient
2370 algorithm for searching, it is robust and easy to implement.
2372 We define the vector $
\ve{r
}$ as the vector of all $
3N$ coordinates.
2373 Initially a maximum displacement $h_0$ (
{\eg} 0.01 nm) must be given.
2375 First the forces $
\ve{F
}$ and potential energy are calculated.
2376 New positions are calculated by
2378 \ve{r
}_
{n+
1} =
\ve{r
}_n +
\frac{\ve{F
}_n
}{\max (|
\ve{F
}_n|)
} h_n,
2380 where $h_n$ is the maximum displacement and $
\ve{F
}_n$ is the force,
2381 or the negative gradient of the potential $V$. The notation $
\max
2382 (|
\ve{F
}_n|)$ means the largest of the absolute values of the force
2383 components. The forces and energy are again computed for the new positions \\
2384 If ($V_
{n+
1} < V_n$) the new positions are accepted and $h_
{n+
1} =
1.2
2386 If ($V_
{n+
1} \geq V_n$) the new positions are rejected and $h_n =
0.2 h_n$.
2388 The algorithm stops when either a user-specified number of force
2389 evaluations has been performed (
{\eg} 100), or when the maximum of the absolute
2390 values of the force (gradient) components is smaller than a specified
2392 Since force truncation produces some noise in the
2393 energy evaluation, the stopping criterion should not be made too tight
2394 to avoid endless iterations. A reasonable value for $
\epsilon$ can be
2395 estimated from the root mean square force $f$ a harmonic oscillator would exhibit at a
2396 temperature $T$. This value is
2398 f =
2 \pi \nu \sqrt{ 2mkT
},
2400 where $
\nu$ is the oscillator frequency, $m$ the (reduced) mass, and
2401 $k$ Boltzmann's constant. For a weak oscillator with a wave number of
2402 100 cm$^
{-
1}$ and a mass of
10 atomic units, at a temperature of
1 K,
2403 $f=
7.7$ kJ~mol$^
{-
1}$~nm$^
{-
1}$. A value for $
\epsilon$ between
1 and
2406 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2407 \subsection{Conjugate Gradient
\index{conjugate gradient
}}
2408 Conjugate gradient is slower than steepest descent in the early stages
2409 of the minimization, but becomes more efficient closer to the energy
2410 minimum. The parameters and stop criterion are the same as for
2411 steepest descent. In
{\gromacs} conjugate gradient can not be used
2412 with constraints, including the SETTLE algorithm for
2413 water~
\cite{Miyamoto92
}, as this has not been implemented. If water is
2414 present it must be of a flexible model, which can be specified in the
2415 {\tt *.mdp
} file by
{\tt define = -DFLEXIBLE
}.
2417 This is not really a restriction, since the accuracy of conjugate
2418 gradient is only required for minimization prior to a normal-mode
2419 analysis, which cannot be performed with constraints. For most other
2420 purposes steepest descent is efficient enough.
2421 % } % Brace matches ifthenelse test for gmxlite
2423 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2424 \subsection{\normindex{L-BFGS
}}
2425 The original BFGS algorithm works by successively creating better
2426 approximations of the inverse Hessian matrix, and moving the system to
2427 the currently estimated minimum. The memory requirements for this are
2428 proportional to the square of the number of particles, so it is not
2429 practical for large systems like biomolecules. Instead, we use the
2430 L-BFGS algorithm of Nocedal~
\cite{Byrd95a,Zhu97a
}, which approximates
2431 the inverse Hessian by a fixed number of corrections from previous
2432 steps. This sliding-window technique is almost as efficient as the
2433 original method, but the memory requirements are much lower -
2434 proportional to the number of particles multiplied with the correction
2435 steps. In practice we have found it to converge faster than conjugate
2436 gradients, but due to the correction steps it is not yet parallelized.
2437 It is also noteworthy that switched or shifted interactions usually
2438 improve the convergence, since sharp cut-offs mean the potential
2439 function at the current coordinates is slightly different from the
2440 previous steps used to build the inverse Hessian approximation.
2441 % } % Brace matches ifthenelse test for gmxlite
2443 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2444 \section{Normal-Mode Analysis
\index{normal-mode analysis
}\index{NMA
}}
2445 Normal-mode analysis~
\cite{Levitt83,Go83,BBrooks83b
}
2446 can be performed using
{\gromacs}, by diagonalization of the mass-weighted
2447 \normindex{Hessian
} $H$:
2449 R^T M^
{-
1/
2} H M^
{-
1/
2} R &=&
\mbox{diag
}(
\lambda_1,
\ldots,
\lambda_{3N
})
2451 \lambda_i &=& (
2 \pi \omega_i)^
2
2453 where $M$ contains the atomic masses, $R$ is a matrix that contains
2454 the eigenvectors as columns, $
\lambda_i$ are the eigenvalues
2455 and $
\omega_i$ are the corresponding frequencies.
2457 First the Hessian matrix, which is a $
3N
\times 3N$ matrix where $N$
2458 is the number of atoms, needs to be calculated:
2460 H_
{ij
} &=&
\frac{\partial^
2 V
}{\partial x_i
\partial x_j
}
2462 where $x_i$ and $x_j$ denote the atomic x, y or z coordinates.
2463 In practice, this equation is not used, but the Hessian is
2464 calculated numerically from the force as:
2467 \frac{f_i(
{\bf x
}+h
{\bf e
}_j) - f_i(
{\bf x
}-h
{\bf e
}_j)
}{2h
}
2469 f_i &=& -
\frac{\partial V
}{\partial x_i
}
2471 where $
{\bf e
}_j$ is the unit vector in direction $j$.
2472 It should be noted that
2473 for a usual normal-mode calculation, it is necessary to completely minimize
2474 the energy prior to computation of the Hessian.
2475 The tolerance required depends on the type of system,
2476 but a rough indication is
0.001 kJ mol$^
{-
1}$.
2477 Minimization should be done with conjugate gradients or L-BFGS in double precision.
2479 A number of
{\gromacs} programs are involved in these
2480 calculations. First, the energy should be minimized using
{\tt mdrun
}.
2481 Then,
{\tt mdrun
} computes the Hessian.
{\bf Note
} that for generating
2482 the run input file, one should use the minimized conformation from
2483 the full precision trajectory file, as the structure file is not
2485 {\tt \normindex{g_nmeig
}} does the diagonalization and
2486 the sorting of the normal modes according to their frequencies.
2487 Both
{\tt mdrun
} and
{\tt g_nmeig
} should be run in double precision.
2488 The normal modes can be analyzed with the program
{\tt g_anaeig
}.
2489 Ensembles of structures at any temperature and for any subset of
2490 normal modes can be generated with
{\tt \normindex{g_nmens
}}.
2491 An overview of normal-mode analysis and the related principal component
2492 analysis (see
\secref{covanal
}) can be found in~
\cite{Hayward95b
}.
2493 % } % Brace matches ifthenelse test for gmxlite
2495 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2497 \section{Free energy calculations
\index{free energy calculations
}}
2499 \subsection{Slow-growth methods
\index{slow-growth methods
}}
2500 Free energy calculations can be performed
2501 in
{\gromacs} using a number of methods, including ``slow-growth.'' An example problem
2502 might be calculating the difference in free energy of binding of an inhibitor
{\bf I
}
2503 to an enzyme
{\bf E
} and to a mutated enzyme
{\bf E$^
{\prime}$
}. It
2504 is not feasible with computer simulations to perform a docking
2505 calculation for such a large complex, or even releasing the inhibitor from
2506 the enzyme in a reasonable amount of computer time with reasonable accuracy.
2507 However, if we consider the free energy cycle in~
\figref{free
}A
2510 \Delta G_1 -
\Delta G_2 =
\Delta G_3 -
\Delta G_4
2513 If we are interested in the left-hand term we can equally well compute
2514 the right-hand term.
2516 \centerline{\includegraphics[width=
6cm,angle=
270]{plots/free1
}\hspace{2cm
}\includegraphics[width=
6cm,angle=
270]{plots/free2
}}
2517 \caption[Free energy cycles.
]{Free energy cycles.
{\bf A:
} to
2518 calculate $
\Delta G_
{12}$, the free energy difference between the
2519 binding of inhibitor
{\bf I
} to enzymes
{\bf E
} respectively
{\bf
2520 E$^
{\prime}$
}.
{\bf B:
} to calculate $
\Delta G_
{12}$, the free energy
2521 difference for binding of inhibitors
{\bf I
} respectively
{\bf I$^
{\prime}$
} to
2526 If we want to compute the difference in free energy of binding of two
2527 inhibitors
{\bf I
} and
{\bf I$^
{\prime}$
} to an enzyme
{\bf E
} (
\figref{free
}B)
2528 we can again use
\eqnref{ddg
} to compute the desired property.
2530 \newcommand{\sA}{^
{\mathrm{A
}}}
2531 \newcommand{\sB}{^
{\mathrm{B
}}}
2532 Free energy differences between two molecular species can
2533 be calculated in
{\gromacs} using the ``slow-growth'' method.
2534 Such free energy differences between different molecular species are
2535 physically meaningless, but they can be used to obtain meaningful
2536 quantities employing a thermodynamic cycle.
2537 The method requires a simulation during which the Hamiltonian of the
2538 system changes slowly from that describing one system (A) to that
2539 describing the other system (B). The change must be so slow that the
2540 system remains in equilibrium during the process; if that requirement
2541 is fulfilled, the change is reversible and a slow-growth simulation from B to A
2542 will yield the same results (but with a different sign) as a slow-growth
2543 simulation from A to B. This is a useful check, but the user should be
2544 aware of the danger that equality of forward and backward growth results does
2545 not guarantee correctness of the results.
2547 The required modification of the Hamiltonian $H$ is realized by making
2548 $H$ a function of a
\textit{coupling parameter
} $
\lambda:
2549 H=H(p,q;
\lambda)$ in such a way that $
\lambda=
0$ describes system A
2550 and $
\lambda=
1$ describes system B:
2552 H(p,q;
0)=H
\sA (p,q);~~~~ H(p,q;
1)=H
\sB (p,q).
2554 In
{\gromacs}, the functional form of the $
\lambda$-dependence is
2555 different for the various force-field contributions and is described
2556 in section
\secref{feia
}.
2558 The Helmholtz free energy $A$ is related to the
2559 partition function $Q$ of an $N,V,T$ ensemble, which is assumed to be
2560 the equilibrium ensemble generated by a MD simulation at constant
2561 volume and temperature. The generally more useful Gibbs free energy
2562 $G$ is related to the partition function $
\Delta$ of an $N,p,T$
2563 ensemble, which is assumed to be the equilibrium ensemble generated by
2564 a MD simulation at constant pressure and temperature:
2566 A(
\lambda) &=& -k_BT
\ln Q \\
2567 Q &=& c
\int\!\!
\int \exp[-
\beta H(p,q;
\lambda)
]\,dp\,dq \\
2568 G(
\lambda) &=& -k_BT
\ln \Delta \\
2569 \Delta &=& c
\int\!\!
\int\!\!
\int \exp[-
\beta H(p,q;
\lambda) -
\beta
2573 where $
\beta =
1/(k_BT)$ and $c = (N! h^
{3N
})^
{-
1}$.
2574 These integrals over phase space cannot be evaluated from a
2575 simulation, but it is possible to evaluate the derivative with
2576 respect to $
\lambda$ as an ensemble average:
2578 \frac{dA
}{d
\lambda} =
\frac{\int\!\!
\int (
\partial H/
\partial
2579 \lambda)
\exp[-
\beta H(p,q;
\lambda)
]\,dp\,dq
}{\int\!\!
\int \exp[-
\beta
2580 H(p,q;
\lambda)
]\,dp\,dq
} =
2581 \left\langle \frac{\partial H
}{\partial \lambda} \right\rangle_{NVT;
\lambda},
2583 with a similar relation for $dG/d
\lambda$ in the $N,p,T$
2584 ensemble. The difference in free energy between A and B can be found
2585 by integrating the derivative over $
\lambda$:
2587 A
\sB(V,T)-A
\sA(V,T) &=&
\int_0^
1 \left\langle \frac{\partial
2588 H
}{\partial \lambda} \right\rangle_{NVT;
\lambda} \,d
\lambda
2590 G
\sB(p,T)-G
\sA(p,T) &=&
\int_0^
1 \left\langle \frac{\partial
2591 H
}{\partial \lambda} \right\rangle_{NpT;
\lambda} \,d
\lambda.
2594 If one wishes to evaluate $G
\sB(p,T)-G
\sA(p,T)$,
2595 the natural choice is a constant-pressure simulation. However, this
2596 quantity can also be obtained from a slow-growth simulation at
2597 constant volume, starting with system A at pressure $p$ and volume $V$
2598 and ending with system B at pressure $p_B$, by applying the following
2599 small (but, in principle, exact) correction:
2602 A
\sB(V)-A
\sA(V) -
\int_p^
{p
\sB}[V
\sB(p')-V
]\,dp'
2604 Here we omitted the constant $T$ from the notation. This correction is
2605 roughly equal to $-
\frac{1}{2} (p
\sB-p)
\Delta V=(
\Delta V)^
2/(
2
2606 \kappa V)$, where $
\Delta V$ is the volume change at $p$ and $
\kappa$
2607 is the isothermal compressibility. This is usually
2608 small; for example, the growth of a water molecule from nothing
2609 in a bath of
1000 water molecules at constant volume would produce an
2610 additional pressure of as much as
22 bar, but a correction to the
2611 Helmholtz free energy of just -
1 kJ mol$^
{-
1}$.
%-20 J/mol.
2613 In Cartesian coordinates, the kinetic energy term in the Hamiltonian
2614 depends only on the momenta, and can be separately integrated and, in
2615 fact, removed from the equations. When masses do not change, there is
2616 no contribution from the kinetic energy at all; otherwise the
2617 integrated contribution to the free energy is $-
\frac{3}{2} k_BT
\ln
2618 (m
\sB/m
\sA)$.
{\bf Note
} that this is only true in the absence of constraints.
2620 \subsection{Thermodynamic integration
\index{thermodynamic integration
}\index{BAR
}\index{Bennett's acceptance ratio
}}
2621 {\gromacs} offers the possibility to integrate eq.~
\ref{eq:delA
} or
2622 eq.
\ref{eq:delG
} in one simulation over the full range from A to
2623 B. However, if the change is large and insufficient sampling can be
2624 expected, the user may prefer to determine the value of $
\langle
2625 dG/d
\lambda \rangle$ accurately at a number of well-chosen
2626 intermediate values of $
\lambda$. This can easily be done by setting
2627 the stepsize
{\tt delta_lambda
} to zero. Each simulation can be
2628 equilibrated first, and a proper error estimate can be made for each
2629 value of $dG/d
\lambda$ from the fluctuation of $
\partial H/
\partial
2630 \lambda$. The total free energy change is then determined afterward
2631 by an appropriate numerical integration procedure.
2633 {\gromacs} now also supports the use of Bennett's Acceptance Ratio~
\cite{Bennett1976
}
2634 for calculating values of $
\Delta$G for transformations from state A to state B using
2635 the program
{\tt \normindex{g_bar
}}. The same data can also be used to calculate free
2636 energies using MBAR~
\cite{Shirts2008
}, though the analysis currently requires external tools from
2637 the external
{\tt pymbar
} package, at https://SimTK.org/home/pymbar.
2639 The $
\lambda$-dependence for the force-field contributions is
2640 described in detail in section
\secref{feia
}.
2641 % } % Brace matches ifthenelse test for gmxlite
2643 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2644 \section{Replica exchange
\index{replica exchange
}}
2645 Replica exchange molecular dynamics (
\normindex{REMD
})
2646 is a method that can be used to speed up
2647 the sampling of any type of simulation, especially if
2648 conformations are separated by relatively high energy barriers.
2649 It involves simulating multiple replicas of the same system
2650 at different temperatures and randomly exchanging the complete state
2651 of two replicas at regular intervals with the probability:
2653 P(
1 \leftrightarrow 2)=
\min\left(
1,
\exp\left[
2654 \left(
\frac{1}{k_B T_1
} -
\frac{1}{k_B T_2
}\right)(U_1 - U_2)
2657 where $T_1$ and $T_2$ are the reference temperatures and $U_1$ and $U_2$
2658 are the instantaneous potential energies of replicas
1 and
2 respectively.
2659 After exchange the velocities are scaled by $(T_1/T_2)^
{\pm0.5
}$
2660 and a neighbor search is performed the next step.
2661 This combines the fast sampling and frequent barrier-crossing
2662 of the highest temperature with correct Boltzmann sampling at
2663 all the different temperatures~
\cite{Hukushima96a,Sugita99
}.
2664 We only attempt exchanges for neighboring temperatures as the probability
2665 decreases very rapidly with the temperature difference.
2666 One should not attempt exchanges for all possible pairs in one step.
2667 If, for instance, replicas
1 and
2 would exchange, the chance of
2668 exchange for replicas
2 and
3 not only depends on the energies of
2669 replicas
2 and
3, but also on the energy of replica
1.
2670 In
{\gromacs} this is solved by attempting exchange for all ``odd''
2671 pairs on ``odd'' attempts and for all ``even'' pairs on ``even'' attempts.
2672 If we have four replicas:
0,
1,
2 and
3, ordered in temperature
2673 and we attempt exchange every
1000 steps, pairs
0-
1 and
2-
3
2674 will be tried at steps
1000,
3000 etc. and pair
1-
2 at steps
2000,
4000 etc.
2676 How should one choose the temperatures?
2677 The energy difference can be written as:
2679 U_1 - U_2 = N_
{df
} \frac{c
}{2} k_B (T_1 - T_2)
2681 where $N_
{df
}$ is the total number of degrees of freedom of one replica
2682 and $c$ is
1 for harmonic potentials and around
2 for protein/water systems.
2683 If $T_2 = (
1+
\epsilon) T_1$ the probability becomes:
2685 P(
1 \leftrightarrow 2)
2686 =
\exp\left( -
\frac{\epsilon^
2 c\,N_
{df
}}{2 (
1+
\epsilon)
} \right)
2687 \approx \exp\left(-
\epsilon^
2 \frac{c
}{2} N_
{df
} \right)
2689 Thus for a probability of $e^
{-
2}\approx 0.135$
2690 one obtains $
\epsilon \approx 2/
\sqrt{c\,N_
{df
}}$.
2691 With all bonds constrained one has $N_
{df
} \approx 2\, N_
{atoms
}$
2692 and thus for $c$ =
2 one should choose $
\epsilon$ as $
1/
\sqrt{N_
{atoms
}}$.
2693 However there is one problem when using pressure coupling. The density at
2694 higher temperatures will decrease, leading to higher energy~
\cite{Seibert2005a
},
2695 which should be taken into account. The
{\gromacs} website features a
2696 so-called ``REMD calculator,'' that lets you type in the temperature range and
2697 the number of atoms, and based on that proposes a set of temperatures.
2699 An extension to the REMD for the isobaric-isothermal ensemble was
2700 proposed by Okabe
{\em et al.
}~
\cite{Okabe2001a
}. In this work the
2701 exchange probability is modified to:
2703 P(
1 \leftrightarrow 2)=
\min\left(
1,
\exp\left[
2704 \left(
\frac{1}{k_B T_1
} -
\frac{1}{k_B T_2
}\right)(U_1 - U_2) +
2705 \left(
\frac{P_1
}{k_B T_1
} -
\frac{P_2
}{k_B T_2
}\right)
\left(V_1-V_2
\right)
2708 where $P_1$ and $P_2$ are the respective reference pressures and $V_1$ and
2709 $V_2$ are the respective instantaneous volumes in the simulations.
2710 In most cases the differences in volume are so small that the second
2711 term is negligible. It only plays a role when the difference between
2712 $P_1$ and $P_2$ is large or in phase transitions.
2714 Hamiltonian replica exchange is also supported in
{\gromacs}. In
2715 Hamiltonian replica exchange, each replica has a different
2716 Hamiltonian, defined by the free energy pathway specified for the simulation. The
2717 exchange probability to maintain the correct ensemble probabilities is:
2718 \beq P(
1 \leftrightarrow 2)=
\min\left(
1,
\exp\left[
2719 \left(
\frac{1}{k_B T
} -
\frac{1}{k_B T
}\right)((U_1(x_2) - U_1(x_1)) + (U_2(x_1) - U_2(x_2)))
2723 The separate Hamiltonians are defined by the free energy functionality
2724 of
{\gromacs}, with swaps made between the different values of
2725 $
\lambda$ defined in the mdp file.
2727 Hamiltonian and temperature replica exchange can also be performed
2728 simultaneously, using the acceptance criteria:
2730 P(
1 \leftrightarrow 2)=
\min\left(
1,
\exp\left[
2731 \left(
\frac{1}{k_B T
} -
\right)(
\frac{U_1(x_2) - U_1(x_1)
}{k_B T_1
} +
\frac{U_2(x_1) - U_2(x_2)
}{k_B T_2
})
2735 Gibbs sampling replica exchange has also been implemented in
2736 {\gromacs}~
\cite{Chodera2011
}. In Gibbs sampling replica exchange, all
2737 possible pairs are tested for exchange, allowing swaps between
2738 replicas that are not neighbors.
2740 Gibbs sampling replica exchange requires no additional potential
2741 energy calculations. However there is an additional communication
2742 cost in Gibbs sampling replica exchange, as for some permutations,
2743 more than one round of swaps must take place. In some cases, this
2744 extra communication cost might affect the efficiency.
2746 All replica exchange variants are options of the
{\tt mdrun
}
2747 program. It will only work when MPI is installed, due to the inherent
2748 parallelism in the algorithm. For efficiency each replica can run on a
2749 separate rank. See the manual page of
{\tt mdrun
} on how to use these
2752 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2754 \section{Essential Dynamics sampling
\index{essential dynamics
}\index{principal component analysis
}\seeindexquiet{PCA
}{covariance analysis
}}
2755 The results from Essential Dynamics (see
\secref{covanal
})
2756 of a protein can be used to guide MD simulations. The idea is that
2757 from an initial MD simulation (or from other sources) a definition of
2758 the collective fluctuations with largest amplitude is obtained. The
2759 position along one or more of these collective modes can be
2760 constrained in a (second) MD simulation in a number of ways for
2761 several purposes. For example, the position along a certain mode may
2762 be kept fixed to monitor the average force (free-energy gradient) on
2763 that coordinate in that position. Another application is to enhance
2764 sampling efficiency with respect to usual MD
2765 \cite{Degroot96a,Degroot96b
}. In this case, the system is encouraged
2766 to sample its available configuration space more systematically than
2767 in a diffusion-like path that proteins usually take.
2769 Another possibility to enhance sampling is
\normindex{flooding
}.
2770 Here a flooding potential is added to certain
2771 (collective) degrees of freedom to expel the system out
2772 of a region of phase space
\cite{Lange2006a
}.
2774 The procedure for essential dynamics sampling or flooding is as follows.
2775 First, the eigenvectors and eigenvalues need to be determined
2776 using covariance analysis (
{\tt g_covar
})
2777 or normal-mode analysis (
{\tt g_nmeig
}).
2778 Then, this information is fed into
{\tt make_edi
},
2779 which has many options for selecting vectors and setting parameters,
2780 see
{\tt gmx make_edi -h
}.
2781 The generated
{\tt edi
} input file is then passed to
{\tt mdrun
}.
2783 % } % Brace matches ifthenelse test for gmxlite
2785 % \ifthenelse{\equal{\gmxlite}{1}}{}{
2786 \section{\normindex{Expanded Ensemble
}}
2788 In an expanded ensemble simulation~
\cite{Lyubartsev1992
}, both the coordinates and the
2789 thermodynamic ensemble are treated as configuration variables that can
2790 be sampled over. The probability of any given state can be written as:
2792 P(
\vec{x
},k)
\propto \exp\left(-
\beta_k U_k + g_k
\right),
2794 where $
\beta_k =
\frac{1}{k_B T_k
}$ is the $
\beta$ corresponding to the $k$th
2795 thermodynamic state, and $g_k$ is a user-specified weight factor corresponding
2796 to the $k$th state. This space is therefore a
{\em mixed
},
{\em generalized
}, or
{\em
2797 expanded
} ensemble which samples from multiple thermodynamic
2798 ensembles simultaneously. $g_k$ is chosen to give a specific weighting
2799 of each subensemble in the expanded ensemble, and can either be fixed,
2800 or determined by an iterative procedure. The set of $g_k$ is
2801 frequently chosen to give each thermodynamic ensemble equal
2802 probability, in which case $g_k$ is equal to the free energy in
2803 non-dimensional units, but they can be set to arbitrary values as
2804 desired. Several different algorithms can be used to equilibrate
2805 these weights, described in the mdp option listings.
2806 % } % Brace matches ifthenelse test for gmxlite
2808 In
{\gromacs}, this space is sampled by alternating sampling in the $k$
2809 and $
\vec{x
}$ directions. Sampling in the $
\vec{x
}$ direction is done
2810 by standard molecular dynamics sampling; sampling between the
2811 different thermodynamics states is done by Monte Carlo, with several
2812 different Monte Carlo moves supported. The $k$ states can be defined
2813 by different temperatures, or choices of the free energy $
\lambda$
2814 variable, or both. Expanded ensemble simulations thus represent a
2815 serialization of the replica exchange formalism, allowing a single
2816 simulation to explore many thermodynamic states.
2820 \section{Parallelization
\index{parallelization
}}
2821 The CPU time required for a simulation can be reduced by running the simulation
2822 in parallel over more than one core.
2823 Ideally, one would want to have linear scaling: running on $N$ cores
2824 makes the simulation $N$ times faster. In practice this can only be
2825 achieved for a small number of cores. The scaling will depend
2826 a lot on the algorithms used. Also, different algorithms can have different
2827 restrictions on the interaction ranges between atoms.
2829 \section{Domain decomposition
\index{domain decomposition
}}
2830 Since most interactions in molecular simulations are local,
2831 domain decomposition is a natural way to decompose the system.
2832 In domain decomposition, a spatial domain is assigned to each rank,
2833 which will then integrate the equations of motion for the particles
2834 that currently reside in its local domain. With domain decomposition,
2835 there are two choices that have to be made: the division of the unit cell
2836 into domains and the assignment of the forces to domains.
2837 Most molecular simulation packages use the half-shell method for assigning
2838 the forces. But there are two methods that always require less communication:
2839 the eighth shell~
\cite{Liem1991
} and the midpoint~
\cite{Shaw2006
} method.
2840 {\gromacs} currently uses the eighth shell method, but for certain systems
2841 or hardware architectures it might be advantageous to use the midpoint
2842 method. Therefore, we might implement the midpoint method in the future.
2843 Most of the details of the domain decomposition can be found
2844 in the
{\gromacs} 4 paper~
\cite{Hess2008b
}.
2846 \subsection{Coordinate and force communication
}
2847 In the most general case of a triclinic unit cell,
2848 the space in divided with a
1-,
2-, or
3-D grid in parallelepipeds
2849 that we call domain decomposition cells.
2850 Each cell is assigned to a particle-particle rank.
2851 The system is partitioned over the ranks at the beginning
2852 of each MD step in which neighbor searching is performed.
2853 Since the neighbor searching is based on charge groups, charge groups
2854 are also the units for the domain decomposition.
2855 Charge groups are assigned to the cell where their center of geometry resides.
2856 Before the forces can be calculated, the coordinates from some
2857 neighboring cells need to be communicated,
2858 and after the forces are calculated, the forces need to be communicated
2859 in the other direction.
2860 The communication and force assignment is based on zones that
2861 can cover one or multiple cells.
2862 An example of a zone setup is shown in
\figref{ddcells
}.
2865 \centerline{\includegraphics[width=
6cm
]{plots/dd-cells
}}
2867 A non-staggered domain decomposition grid of
3$
\times$
2$
\times$
2 cells.
2868 Coordinates in zones
1 to
7 are communicated to the corner cell
2869 that has its home particles in zone
0.
2870 $r_c$ is the cut-off radius.
2875 The coordinates are communicated by moving data along the ``negative''
2876 direction in $x$, $y$ or $z$ to the next neighbor. This can be done in one
2877 or multiple pulses. In
\figref{ddcells
} two pulses in $x$ are required,
2878 then one in $y$ and then one in $z$. The forces are communicated by
2879 reversing this procedure. See the
{\gromacs} 4 paper~
\cite{Hess2008b
}
2880 for details on determining which non-bonded and bonded forces
2881 should be calculated on which rank.
2883 \subsection{Dynamic load balancing
\swapindexquiet{dynamic
}{load balancing
}}
2884 When different ranks have a different computational load
2885 (load imbalance), all ranks will have to wait for the one
2886 that takes the most time. One would like to avoid such a situation.
2887 Load imbalance can occur due to three reasons:
2889 \item inhomogeneous particle distribution
2890 \item inhomogeneous interaction cost distribution (charged/uncharged,
2891 water/non-water due to
{\gromacs} water innerloops)
2892 \item statistical fluctuation (only with small particle numbers)
2894 So we need a dynamic load balancing algorithm
2895 where the volume of each domain decomposition cell
2896 can be adjusted
{\em independently
}.
2897 To achieve this, the
2- or
3-D domain decomposition grids need to be
2898 staggered.
\figref{ddtric
} shows the most general case in
2-D.
2899 Due to the staggering, one might require two distance checks
2900 for deciding if a charge group needs to be communicated:
2901 a non-bonded distance and a bonded distance check.
2904 \centerline{\includegraphics[width=
7cm
]{plots/dd-tric
}}
2906 The zones to communicate to the rank of zone
0,
2907 see the text for details. $r_c$ and $r_b$ are the non-bonded
2908 and bonded cut-off radii respectively, $d$ is an example
2909 of a distance between following, staggered boundaries of cells.
2914 By default,
{\tt mdrun
} automatically turns on the dynamic load
2915 balancing during a simulation when the total performance loss
2916 due to the force calculation imbalance is
5\% or more.
2917 {\bf Note
} that the reported force load imbalance numbers might be higher,
2918 since the force calculation is only part of work that needs to be done
2919 during an integration step.
2920 The load imbalance is reported in the log file at log output steps
2921 and when the
{\tt -v
} option is used also on screen.
2922 The average load imbalance and the total performance loss
2923 due to load imbalance are reported at the end of the log file.
2925 There is one important parameter for the dynamic load balancing,
2926 which is the minimum allowed scaling. By default, each dimension
2927 of the domain decomposition cell can scale down by at least
2928 a factor of
0.8. For
3-D domain decomposition this allows cells
2929 to change their volume by about a factor of
0.5, which should allow
2930 for compensation of a load imbalance of
100\%.
2931 The minimum allowed scaling can be changed with the
{\tt -dds
}
2932 option of
{\tt mdrun
}.
2934 \subsection{Constraints in parallel
\index{constraints
}}
2935 \label{subsec:plincs
}
2936 Since with domain decomposition parts of molecules can reside
2937 on different ranks, bond constraints can cross cell boundaries.
2938 Therefore a parallel constraint algorithm is required.
2939 {\gromacs} uses the
\normindex{P-LINCS
} algorithm~
\cite{Hess2008a
},
2940 which is the parallel version of the
\normindex{LINCS
} algorithm~
\cite{Hess97
}
2941 % \ifthenelse{\equal{\gmxlite}{1}}
2943 {(see
\ssecref{lincs
}).
}
2944 The P-LINCS procedure is illustrated in
\figref{plincs
}.
2945 When molecules cross the cell boundaries, atoms in such molecules
2946 up to (
{\tt lincs_order +
1}) bonds away are communicated over the cell boundaries.
2947 Then, the normal LINCS algorithm can be applied to the local bonds
2948 plus the communicated ones. After this procedure, the local bonds
2949 are correctly constrained, even though the extra communicated ones are not.
2950 One coordinate communication step is required for the initial LINCS step
2951 and one for each iteration. Forces do not need to be communicated.
2954 \centerline{\includegraphics[width=
6cm
]{plots/par-lincs2
}}
2956 Example of the parallel setup of P-LINCS with one molecule
2957 split over three domain decomposition cells, using a matrix
2958 expansion order of
3.
2959 The top part shows which atom coordinates need to be communicated
2960 to which cells. The bottom parts show the local constraints (solid)
2961 and the non-local constraints (dashed) for each of the three cells.
2966 \subsection{Interaction ranges
}
2967 Domain decomposition takes advantage of the locality of interactions.
2968 This means that there will be limitations on the range of interactions.
2969 By default,
{\tt mdrun
} tries to find the optimal balance between
2970 interaction range and efficiency. But it can happen that a simulation
2971 stops with an error message about missing interactions,
2972 or that a simulation might run slightly faster with shorter
2973 interaction ranges. A list of interaction ranges
2974 and their default values is given in
\tabref{dd_ranges
}.
2978 \begin{tabular
}{|c|c|ll|
}
2980 interaction & range & option & default \\
2982 non-bonded & $r_c$ = max($r_
{\mathrm{list
}}$,$r_
{\mathrm{VdW
}}$,$r_
{\mathrm{Coul
}}$) &
{\tt mdp
} file & \\
2983 two-body bonded & max($r_
{\mathrm{mb
}}$,$r_c$) &
{\tt mdrun -rdd
} & starting conf. +
10\% \\
2984 multi-body bonded & $r_
{\mathrm{mb
}}$ &
{\tt mdrun -rdd
} & starting conf. +
10\% \\
2985 constraints & $r_
{\mathrm{con
}}$ &
{\tt mdrun -rcon
} & est. from bond lengths \\
2986 virtual sites & $r_
{\mathrm{con
}}$ &
{\tt mdrun -rcon
} &
0 \\
2990 \caption{The interaction ranges with domain decomposition.
}
2991 \label{tab:dd_ranges
}
2994 In most cases the defaults of
{\tt mdrun
} should not cause the simulation
2995 to stop with an error message of missing interactions.
2996 The range for the bonded interactions is determined from the distance
2997 between bonded charge-groups in the starting configuration, with
10\% added
2998 for headroom. For the constraints, the value of $r_
{\mathrm{con
}}$ is determined by
2999 taking the maximum distance that (
{\tt lincs_order +
1}) bonds can cover
3000 when they all connect at angles of
120 degrees.
3001 The actual constraint communication is not limited by $r_
{\mathrm{con
}}$,
3002 but by the minimum cell size $L_C$, which has the following lower limit:
3004 L_C
\geq \max(r_
{\mathrm{mb
}},r_
{\mathrm{con
}})
3006 Without dynamic load balancing the system is actually allowed to scale
3007 beyond this limit when pressure scaling is used.
3008 {\bf Note
} that for triclinic boxes, $L_C$ is not simply the box diagonal
3009 component divided by the number of cells in that direction,
3010 rather it is the shortest distance between the triclinic cells borders.
3011 For rhombic dodecahedra this is a factor of $
\sqrt{3/
2}$ shorter
3014 When $r_
{\mathrm{mb
}} > r_c$,
{\tt mdrun
} employs a smart algorithm to reduce
3015 the communication. Simply communicating all charge groups within
3016 $r_
{\mathrm{mb
}}$ would increase the amount of communication enormously.
3017 Therefore only charge-groups that are connected by bonded interactions
3018 to charge groups which are not locally present are communicated.
3019 This leads to little extra communication, but also to a slightly
3020 increased cost for the domain decomposition setup.
3021 In some cases,
{\eg} coarse-grained simulations with a very short cut-off,
3022 one might want to set $r_
{\mathrm{mb
}}$ by hand to reduce this cost.
3024 \subsection{Multiple-Program, Multiple-Data PME parallelization
\index{PME
}}
3025 \label{subsec:mpmd_pme
}
3026 Electrostatics interactions are long-range, therefore special
3027 algorithms are used to avoid summation over many atom pairs.
3028 In
{\gromacs} this is usually
3029 % \ifthenelse{\equal{\gmxlite}{1}}
3031 {PME (
\secref{pme
}).
}
3032 Since with PME all particles interact with each other, global communication
3033 is required. This will usually be the limiting factor for
3034 scaling with domain decomposition.
3035 To reduce the effect of this problem, we have come up with
3036 a Multiple-Program, Multiple-Data approach~
\cite{Hess2008b
}.
3037 Here, some ranks are selected to do only the PME mesh calculation,
3038 while the other ranks, called particle-particle (PP) ranks,
3039 do all the rest of the work.
3040 For rectangular boxes the optimal PP to PME rank ratio is usually
3:
1,
3041 for rhombic dodecahedra usually
2:
1.
3042 When the number of PME ranks is reduced by a factor of
4, the number
3043 of communication calls is reduced by about a factor of
16.
3044 Or put differently, we can now scale to
4 times more ranks.
3045 In addition, for modern
4 or
8 core machines in a network,
3046 the effective network bandwidth for PME is quadrupled,
3047 since only a quarter of the cores will be using the network connection
3048 on each machine during the PME calculations.
3051 \centerline{\includegraphics[width=
12cm
]{plots/mpmd-pme
}}
3053 Example of
8 ranks without (left) and with (right) MPMD.
3054 The PME communication (red arrows) is much higher on the left
3055 than on the right. For MPMD additional PP - PME coordinate
3056 and force communication (blue arrows) is required,
3057 but the total communication complexity is lower.
3058 \label{fig:mpmd_pme
}
3062 {\tt mdrun
} will by default interleave the PP and PME ranks.
3063 If the ranks are not number consecutively inside the machines,
3064 one might want to use
{\tt mdrun -ddorder pp_pme
}.
3065 For machines with a real
3-D torus and proper communication software
3066 that assigns the ranks accordingly one should use
3067 {\tt mdrun -ddorder cartesian
}.
3069 To optimize the performance one should usually set up the cut-offs
3070 and the PME grid such that the PME load is
25 to
33\% of the total
3071 calculation load.
{\tt grompp
} will print an estimate for this load
3072 at the end and also
{\tt mdrun
} calculates the same estimate
3073 to determine the optimal number of PME ranks to use.
3074 For high parallelization it might be worthwhile to optimize
3075 the PME load with the
{\tt mdp
} settings and/or the number
3076 of PME ranks with the
{\tt -npme
} option of
{\tt mdrun
}.
3077 For changing the electrostatics settings it is useful to know
3078 the accuracy of the electrostatics remains nearly constant
3079 when the Coulomb cut-off and the PME grid spacing are scaled
3081 {\bf Note
} that it is usually better to overestimate than to underestimate
3082 the number of PME ranks, since the number of PME ranks is smaller
3083 than the number of PP ranks, which leads to less total waiting time.
3085 The PME domain decomposition can be
1-D or
2-D along the $x$ and/or
3086 $y$ axis.
2-D decomposition is also known as
\normindex{pencil decomposition
} because of
3087 the shape of the domains at high parallelization.
3088 1-D decomposition along the $y$ axis can only be used when
3089 the PP decomposition has only
1 domain along $x$.
2-D PME decomposition
3090 has to have the number of domains along $x$ equal to the number of
3091 the PP decomposition.
{\tt mdrun
} automatically chooses
1-D or
2-D
3092 PME decomposition (when possible with the total given number of ranks),
3093 based on the minimum amount of communication for the coordinate redistribution
3094 in PME plus the communication for the grid overlap and transposes.
3095 To avoid superfluous communication of coordinates and forces
3096 between the PP and PME ranks, the number of DD cells in the $x$
3097 direction should ideally be the same or a multiple of the number
3098 of PME ranks. By default,
{\tt mdrun
} takes care of this issue.
3100 \subsection{Domain decomposition flow chart
}
3101 In
\figref{dd_flow
} a flow chart is shown for domain decomposition
3102 with all possible communication for different algorithms.
3103 For simpler simulations, the same flow chart applies,
3104 without the algorithms and communication for
3105 the algorithms that are not used.
3108 \centerline{\includegraphics[width=
12cm
]{plots/flowchart
}}
3110 Flow chart showing the algorithms and communication (arrows)
3111 for a standard MD simulation with virtual sites, constraints
3112 and separate PME-mesh ranks.
3118 \section{Implicit solvation
\index{implicit solvation
}\index{Generalized Born methods
}}
3120 Implicit solvent models provide an efficient way of representing
3121 the electrostatic effects of solvent molecules, while saving a
3122 large piece of the computations involved in an accurate, aqueous
3123 description of the surrounding water in molecular dynamics simulations.
3124 Implicit solvation models offer several advantages compared with
3125 explicit solvation, including eliminating the need for the equilibration of water
3126 around the solute, and the absence of viscosity, which allows the protein
3127 to more quickly explore conformational space.
3129 Implicit solvent calculations in
{\gromacs} can be done using the
3130 generalized Born-formalism, and the Still~
\cite{Still97
}, HCT~
\cite{Truhlar96
},
3131 and OBC~
\cite{Case04
} models are available for calculating the Born radii.
3133 Here, the free energy $G_
{\mathrm{solv
}}$ of solvation is the sum of three terms,
3134 a solvent-solvent cavity term ($G_
{\mathrm{cav
}}$), a solute-solvent van der
3135 Waals term ($G_
{\mathrm{vdw
}}$), and finally a solvent-solute electrostatics
3136 polarization term ($G_
{\mathrm{pol
}}$).
3138 The sum of $G_
{\mathrm{cav
}}$ and $G_
{\mathrm{vdw
}}$ corresponds to the (non-polar)
3139 free energy of solvation for a molecule from which all charges
3140 have been removed, and is commonly called $G_
{\mathrm{np
}}$,
3141 calculated from the total solvent accessible surface area
3142 multiplied with a surface tension.
3143 The total expression for the solvation free energy then becomes:
3146 G_
{\mathrm{solv
}} = G_
{\mathrm{np
}} + G_
{\mathrm{pol
}}
3150 Under the generalized Born model, $G_
{\mathrm{pol
}}$ is calculated from the generalized Born equation~
\cite{Still97
}:
3153 G_
{\mathrm{pol
}} =
\left(
1-
\frac{1}{\epsilon}\right)
\sum_{i=
1}^n
\sum_{j>i
}^n
\frac {q_i q_j
}{\sqrt{r^
2_
{ij
} + b_i b_j
\exp\left(
\frac{-r^
2_
{ij
}}{4 b_i b_j
}\right)
}}
3154 \label{eqn:gb_still
}
3157 In
{\gromacs}, we have introduced the substitution~
\cite{Larsson10
}:
3160 c_i=
\frac{1}{\sqrt{b_i
}}
3161 \label{eqn:gb_subst
}
3164 which makes it possible to introduce a cheap transformation to a new
3165 variable $x$ when evaluating each interaction, such that:
3168 x=
\frac{r_
{ij
}}{\sqrt{b_i b_j
}} = r_
{ij
} c_i c_j
3169 \label{eqn:gb_subst2
}
3172 In the end, the full re-formulation of~
\ref{eqn:gb_still
} becomes:
3175 G_
{\mathrm{pol
}} =
\left(
1-
\frac{1}{\epsilon}\right)
\sum_{i=
1}^n
\sum_{j>i
}^n
\frac{q_i q_j
}{\sqrt{b_i b_j
}} ~
\xi (x) =
\left(
1-
\frac{1}{\epsilon}\right)
\sum_{i=
1}^n q_i c_i
\sum_{j>i
}^n q_j c_j~
\xi (x)
3176 \label{eqn:gb_final
}
3179 The non-polar part ($G_
{\mathrm{np
}}$) of Equation~
\ref{eqn:gb_solv
} is calculated
3180 directly from the Born radius of each atom using a simple ACE type
3181 approximation by Schaefer
{\em et al.
}~
\cite{Karplus98
}, including a
3182 simple loop over all atoms.
3183 This requires only one extra solvation parameter, independent of atom type,
3184 but differing slightly between the three Born radii models.
3186 % LocalWords: GROningen MAchine BIOSON Groningen GROMACS Berendsen der Spoel
3187 % LocalWords: Drunen Comp Phys Comm ROck NS FFT pbc EM ifthenelse gmxlite ff
3188 % LocalWords: octahedra triclinic Ewald PME PPPM trjconv xy solvated
3189 % LocalWords: boxtypes boxshapes editconf Lennard mdpopt COM XTC TNG kT defunits
3190 % LocalWords: Boltzmann's Mueller nb int mdrun chargegroup simplerc prefactor
3191 % LocalWords: pme waterloops CH NH CO df com virial integrator Verlet vverlet
3192 % LocalWords: integrators ref timepoint timestep timesteps mdp md vv avek NVE
3193 % LocalWords: NVT off's leapfrogv lll LR rmfast SPC fs Nos physicality ps GMX
3194 % LocalWords: Tcoupling nonergodic thermostatting NOSEHOOVER algorithmes ij yx
3195 % LocalWords: Parrinello Rahman rescales atm anisotropically ccc xz zx yy yz
3196 % LocalWords: zy zz se barostat compressibilities MTTK NPT Martyna al isobaric
3197 % LocalWords: Tuckerman vir PV fkT iLt iL Liouville NHC Eq baro mu trj mol bc
3198 % LocalWords: freezegroup Shannon's polarizability Overhauser barostats iLn KE
3199 % LocalWords: negligibly thermostatted Tobias rhombic maxwell et xtc tng TC rlist
3200 % LocalWords: waals LINCS holonomic plincs lincs unc ang SA Langevin SD amu BD
3201 % LocalWords: bfgs Broyden Goldfarb Shanno mkT kJ DFLEXIBLE Nocedal diag nmeig
3202 % LocalWords: diagonalization anaeig nmens covanal ddg feia BT dp dq pV dV dA
3203 % LocalWords: NpT eq stepsize REMD constrainted website Okabe MPI covar edi dd
3204 % LocalWords: progman NMR ddcells innerloops ddtric tric dds rdd conf rcon est
3205 % LocalWords: mb PP MPMD ddorder pp cartesian grompp npme parallelizable edr
3206 % LocalWords: macromolecule nstlist vacuo parallelization dof indices MBAR AVX
3207 % LocalWords: TOL numerics parallelized eigenvectors dG parallelepipeds VdW np
3208 % LocalWords: Coul multi solvation HCT OBC solv cav vdw Schaefer symplectic dt
3209 % LocalWords: pymbar multinode subensemble Monte solute subst groupconcept GPU
3210 % LocalWords: dodecahedron octahedron dodecahedra equilibration usinggroups nm
3211 % LocalWords: topologies rlistlong CUDA GPUs rcoulomb SIMD BlueGene FPUs erfc
3212 % LocalWords: cutoffschemesupport unbuffered bondeds AdResS OpenMP ewald rtol
3213 % LocalWords: verletdrift peptide RMS rescaling ergodicity ergodic discretized
3214 % LocalWords: isothermal compressibility isotropically anisotropic iteratively
3215 % LocalWords: incompressible integrations translational biomolecules NMA PCA
3216 % LocalWords: Bennett's equilibrated Hamiltonians covariance equilibrate
3217 % LocalWords: inhomogeneous conformational online other's th