Merge branch origin/release-5-0
[alexxy/gromacs.git] / docs / manual / forcefield.tex
1 %
2 % This file is part of the GROMACS molecular simulation package.
3 %
4 % Copyright (c) 2013,2014,2015, 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.
8 %
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.
13 %
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.
18 %
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.
23 %
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.
31 %
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.
34
35 \chapter{Interaction function and force fields\index{force field}}
36 \label{ch:ff}
37 To accommodate the potential functions used
38 in some popular force fields (see \ref{sec:ff}), {\gromacs} offers a choice of functions,
39 both for non-bonded interaction and for dihedral interactions. They
40 are described in the appropriate subsections.
41
42 The potential functions can be subdivided into three parts
43 \begin{enumerate}
44 \item   {\em Non-bonded}: Lennard-Jones or Buckingham, and Coulomb or
45 modified Coulomb. The non-bonded interactions are computed on the
46 basis of a neighbor list (a list of non-bonded atoms within a certain
47 radius), in which exclusions are already removed.
48 \item   {\em Bonded}: covalent bond-stretching, angle-bending,
49 improper dihedrals, and proper dihedrals. These are computed on the
50 basis of fixed lists. 
51 \item   {\em Restraints}: position restraints, angle restraints,
52 distance restraints, orientation restraints and dihedral restraints, all
53 based on fixed lists. 
54 \end{enumerate}
55
56 \section{Non-bonded interactions}
57 Non-bonded interactions in {\gromacs} are pair-additive and centro-symmetric:
58 \beq
59 V(\ve{r}_1,\ldots \ve{r}_N) = \sum_{i<j}V_{ij}(\rvij);
60 \eeq
61 \beq
62 \ve{F}_i = -\sum_j \frac{dV_{ij}(r_{ij})}{dr_{ij}} \frac{\rvij}{r_{ij}} = -\ve{F}_j
63 \eeq
64 The non-bonded interactions contain a \normindex{repulsion} term, 
65 a \normindex{dispersion}
66 term, and a Coulomb term. The repulsion and dispersion term are
67 combined in either the Lennard-Jones (or 6-12 interaction), or the
68 Buckingham (or exp-6 potential). In addition, (partially) charged atoms
69 act through the Coulomb term. 
70
71 \subsection{The Lennard-Jones interaction}
72 \label{sec:lj}
73 The \normindex{Lennard-Jones} potential $V_{LJ}$ between two atoms equals:
74 \beq
75 V_{LJ}(\rij) =  \frac{C_{ij}^{(12)}}{\rij^{12}} -
76                         \frac{C_{ij}^{(6)}}{\rij^6}     
77 \eeq
78 See also \figref{lj}
79 The parameters $C^{(12)}_{ij}$ and $C^{(6)}_{ij}$  depend on pairs of
80 {\em atom types}; consequently they are taken from a matrix of
81 LJ-parameters. In the Verlet cut-off scheme, the potential is shifted
82 by a constant such that it is zero at the cut-off distance.
83
84 \begin{figure}
85 \centerline{\includegraphics[width=8cm]{plots/f-lj}}
86 \caption {The Lennard-Jones interaction.}
87 \label{fig:lj}
88 \end{figure}
89  
90 The force derived from this potential is:
91 \beq
92 \ve{F}_i(\rvij) = \left( 12~\frac{C_{ij}^{(12)}}{\rij^{13}} -
93                                  6~\frac{C_{ij}^{(6)}}{\rij^7} \right) \rnorm 
94 \eeq
95
96 The LJ potential may also be written in the following form:
97 \beq
98 V_{LJ}(\rvij) = 4\epsilon_{ij}\left(\left(\frac{\sigma_{ij}} {\rij}\right)^{12}
99                 - \left(\frac{\sigma_{ij}}{\rij}\right)^{6} \right)
100 \label{eqn:sigeps}      
101 \eeq
102
103 In constructing the parameter matrix for the non-bonded LJ-parameters,
104 two types of \normindex{combination rule}s can be used within {\gromacs},
105 only geometric averages (type 1 in the input section of the force-field file):
106 \beq
107 \begin{array}{rcl}
108 C_{ij}^{(6)}    &=& \left({C_{ii}^{(6)} \, C_{jj}^{(6)}}\right)^{1/2}    \\
109 C_{ij}^{(12)}   &=& \left({C_{ii}^{(12)} \, C_{jj}^{(12)}}\right)^{1/2}
110 \label{eqn:comb}
111 \end{array}
112 \eeq
113 or, alternatively the Lorentz-Berthelot rules can be used. An arithmetic average is used to calculate $\sigma_{ij}$, while a geometric average is used to calculate $\epsilon_{ij}$ (type 2):
114 \beq
115 \begin{array}{rcl}
116  \sigma_{ij}   &=& \frac{1}{ 2}(\sigma_{ii} + \sigma_{jj})        \\
117  \epsilon_{ij} &=& \left({\epsilon_{ii} \, \epsilon_{jj}}\right)^{1/2}
118  \label{eqn:lorentzberthelot}
119 \end{array}
120 \eeq
121 finally an geometric average for both parameters can be used (type 3):
122 \beq
123 \begin{array}{rcl}
124  \sigma_{ij}   &=& \left({\sigma_{ii} \, \sigma_{jj}}\right)^{1/2}        \\
125  \epsilon_{ij} &=& \left({\epsilon_{ii} \, \epsilon_{jj}}\right)^{1/2}
126 \end{array}
127 \eeq
128 This last rule is used by the OPLS force field.
129
130
131 %\ifthenelse{\equal{\gmxlite}{1}}{}{
132 \subsection{\normindex{Buckingham potential}}
133 The Buckingham
134 potential has a more flexible and realistic repulsion term
135 than the Lennard-Jones interaction, but is also more expensive to
136 compute. The potential form is:
137 \beq
138 V_{bh}(\rij) = A_{ij} \exp(-B_{ij} \rij) -
139                         \frac{C_{ij}}{\rij^6}
140 \eeq
141 \begin{figure}
142 \centerline{\includegraphics[width=8cm]{plots/f-bham}}
143 \caption {The Buckingham interaction.}
144 \label{fig:bham}
145 \end{figure}
146
147 See also \figref{bham}.  The force derived from this is:
148 \beq
149  \ve{F}_i(\rij) = \left[ A_{ij}B_{ij}\exp(-B_{ij} \rij) -
150                                  6\frac{C_{ij}}{\rij^7} \right] \rnorm
151 \eeq
152
153 %} % Brace matches ifthenelse test for gmxlite
154
155 \subsection{Coulomb interaction}
156 \label{sec:coul}
157 \newcommand{\epsr}{\varepsilon_r}
158 \newcommand{\epsrf}{\varepsilon_{rf}}
159 The \normindex{Coulomb} interaction between two charge particles is given by:
160 \beq
161 V_c(\rij) = f \frac{q_i q_j}{\epsr \rij}
162 \label{eqn:vcoul}
163 \eeq
164 See also \figref{coul}, where $f = \frac{1}{4\pi \varepsilon_0} =
165 138.935\,485$ (see \chref{defunits})
166
167 \begin{figure}
168 \centerline{\includegraphics[width=8cm]{plots/vcrf}}
169 \caption[The Coulomb interaction with and without reaction field.]{The
170 Coulomb interaction (for particles with equal signed charge) with and
171 without reaction field. In the latter case $\epsr$ was 1, $\epsrf$ was 78,
172 and $r_c$ was 0.9 nm.
173 The dot-dashed line is the same as the dashed line, except for a constant.}
174 \label{fig:coul}
175 \end{figure}
176
177 The force derived from this potential is:
178 \beq
179 \ve{F}_i(\rvij) = f \frac{q_i q_j}{\epsr\rij^2}\rnorm
180 \eeq
181
182 A plain Coulomb interaction should only be used without cut-off or when all pairs fall within the cut-off, since there is an abrupt, large change in the force at the cut-off. In case you do want to use a cut-off, the potential can be shifted by a constant to make the potential the integral of the force. With the group cut-off scheme, this shift is only applied to non-excluded pairs. With the Verlet cut-off scheme, the shift is also applied to excluded pairs and self interactions, which makes the potential equivalent to a reaction field with $\epsrf=1$ (see below).
183
184 In {\gromacs} the  relative \swapindex{dielectric}{constant} 
185 \normindex{$\epsr$}
186 may be set in the in the input for {\tt grompp}. 
187
188 %\ifthenelse{\equal{\gmxlite}{1}}{}{
189 \subsection{Coulomb interaction with \normindex{reaction field}}
190 \label{sec:coulrf}
191 The Coulomb interaction can be modified for homogeneous systems by
192 assuming a constant dielectric environment beyond the cut-off $r_c$
193 with a dielectric constant of {$\epsrf$}. The interaction then reads:
194 \beq
195 V_{crf} ~=~
196   f \frac{q_i q_j}{\epsr\rij}\left[1+\frac{\epsrf-\epsr}{2\epsrf+\epsr}
197   \,\frac{\rij^3}{r_c^3}\right]
198   - f\frac{q_i q_j}{\epsr r_c}\,\frac{3\epsrf}{2\epsrf+\epsr}
199 \label{eqn:vcrf}
200 \eeq
201 in which the constant expression on the right makes the potential
202 zero at the cut-off $r_c$. For charged cut-off spheres this corresponds
203 to neutralization with a homogeneous background charge.
204 We can rewrite \eqnref{vcrf} for simplicity as
205 \beq
206 V_{crf} ~=~     f \frac{q_i q_j}{\epsr}\left[\frac{1}{\rij} + k_{rf}~ \rij^2 -c_{rf}\right]
207 \eeq
208 with
209 \bea
210 k_{rf}  &=&     \frac{1}{r_c^3}\,\frac{\epsrf-\epsr}{(2\epsrf+\epsr)}   \label{eqn:krf}\\
211 c_{rf}  &=&     \frac{1}{r_c}+k_{rf}\,r_c^2 ~=~ \frac{1}{r_c}\,\frac{3\epsrf}{(2\epsrf+\epsr)}
212 \label{eqn:crf}
213 \eea
214 For large $\epsrf$ the $k_{rf}$ goes to $r_c^{-3}/2$,
215 while for $\epsrf$ = $\epsr$ the correction vanishes.
216 In \figref{coul}
217 the modified interaction is plotted, and it is clear that the derivative 
218 with respect to $\rij$ (= -force) goes to zero at the cut-off distance.
219 The force derived from this potential reads:
220 \beq
221 \ve{F}_i(\rvij) = f \frac{q_i q_j}{\epsr}\left[\frac{1}{\rij^2} - 2 k_{rf}\rij\right]\rnorm
222 \label{eqn:fcrf}
223 \eeq
224 The reaction-field correction should also be applied to all excluded
225 atoms pairs, including self pairs, in which case the normal Coulomb
226 term in \eqnsref{vcrf}{fcrf} is absent.
227
228 Tironi {\etal} have introduced a generalized reaction field in which
229 the dielectric continuum beyond the cut-off $r_c$ also has an ionic strength
230 $I$~\cite{Tironi95}. In this case we can rewrite the constants $k_{rf}$ and 
231 $c_{rf}$ using the inverse Debye screening length $\kappa$:
232 \bea
233 \kappa^2  &=&     
234    \frac{2 I \,F^2}{\varepsilon_0 \epsrf RT}
235    = \frac{F^2}{\varepsilon_0 \epsrf RT}\sum_{i=1}^{K} c_i z_i^2     \\
236 k_{rf}  &=&     \frac{1}{r_c^3}\,
237     \frac{(\epsrf-\epsr)(1 + \kappa r_c) + \half\epsrf(\kappa r_c)^2}
238          {(2\epsrf + \epsr)(1 + \kappa r_c) + \epsrf(\kappa r_c)^2}
239     \label{eqn:kgrf}\\
240 c_{rf}  &=&     \frac{1}{r_c}\,
241     \frac{3\epsrf(1 + \kappa r_c + \half(\kappa r_c)^2)}
242          {(2\epsrf+\epsr)(1 + \kappa r_c) + \epsrf(\kappa r_c)^2}
243     \label{eqn:cgrf}
244 \eea
245 where $F$ is Faraday's constant, $R$ is the ideal gas constant, $T$
246 the absolute temperature, $c_i$ the molar concentration for species
247 $i$ and $z_i$ the charge number of species $i$ where we have $K$
248 different species. In the limit of zero ionic strength ($\kappa=0$)
249 \eqnsref{kgrf}{cgrf} reduce to the simple forms of \eqnsref{krf}{crf}
250 respectively.
251
252 \subsection{Modified non-bonded interactions}
253 \label{sec:mod_nb_int}
254 In {\gromacs}, the non-bonded potentials can be
255 modified by a shift function, also called a force-switch function,
256 since it switches the force to zero at the cut-off.
257 The purpose of this is to replace the
258 truncated forces by forces that are continuous and have continuous
259 derivatives at the \normindex{cut-off} radius. With such forces the
260 time integration produces smaller errors. But note that for
261 Lennard-Jones interactions these errors are usually smaller than other errors,
262 such as integration errors at the repulsive part of the potential.
263 For Coulomb interactions we advise against using a shifted potential
264 and for use of a reaction field or a proper long-range method such as PME.
265  
266 There is {\em no} fundamental difference between a switch function
267 (which multiplies the potential with a function) and a shift function
268 (which adds a function to the force or potential)~\cite{Spoel2006a}. The switch
269 function is a special case of the shift function, which we apply to
270 the {\em force function} $F(r)$, related to the electrostatic or
271 van der Waals force acting on particle $i$ by particle $j$ as:
272 \beq
273 \ve{F}_i = c \, F(r_{ij}) \frac{\rvij}{r_{ij}}
274 \eeq
275 For pure Coulomb or Lennard-Jones interactions
276 $F(r) = F_\alpha(r) = \alpha \, r^{-(\alpha+1)}$.
277 The switched force $F_s(r)$ can generally be written as:
278 \beq
279 \begin{array}{rcl}
280 \vspace{2mm}
281 F_s(r)~=&~F_\alpha(r)   & r < r_1               \\
282 \vspace{2mm}
283 F_s(r)~=&~F_\alpha(r)+S(r)      & r_1 \le r < r_c       \\
284 F_s(r)~=&~0             & r_c \le r     
285 \end{array}
286 \eeq
287 When $r_1=0$ this is a traditional shift function, otherwise it acts as a 
288 switch function. The corresponding shifted potential function then reads:
289 \beq
290 V_s(r) =  \int^{\infty}_r~F_s(x)\, dx
291 \eeq
292
293 The {\gromacs} force switch function should be smooth at the boundaries, therefore
294 the following boundary conditions are imposed on the switch function:
295 \beq
296 \begin{array}{rcl}
297 S(r_1)          &=&0            \\
298 S'(r_1)         &=&0            \\
299 S(r_c)          &=&-F_\alpha(r_c)       \\
300 S'(r_c)         &=&-F_\alpha'(r_c)
301 \end{array}
302 \eeq
303 A 3$^{rd}$ degree polynomial of the form
304 \beq
305 S(r) = A(r-r_1)^2 + B(r-r_1)^3
306 \eeq
307 fulfills these requirements. The constants A and B are given by the
308 boundary condition at $r_c$: 
309 \beq
310 \begin{array}{rcl}
311 \vspace{2mm}
312 A &~=~& -\alpha \, \displaystyle
313         \frac{(\alpha+4)r_c~-~(\alpha+1)r_1} {r_c^{\alpha+2}~(r_c-r_1)^2} \\
314 B &~=~& \alpha \, \displaystyle
315         \frac{(\alpha+3)r_c~-~(\alpha+1)r_1}{r_c^{\alpha+2}~(r_c-r_1)^3}
316 \end{array}
317 \eeq
318 Thus the total force function is:
319 \beq
320 F_s(r) = \frac{\alpha}{r^{\alpha+1}} + A(r-r_1)^2 + B(r-r_1)^3
321 \eeq
322 and the potential function reads:
323 \beq
324 V_s(r) = \frac{1}{r^\alpha} - \frac{A}{3} (r-r_1)^3 - \frac{B}{4} (r-r_1)^4 - C
325 \eeq
326 where 
327 \beq
328 C =  \frac{1}{r_c^\alpha} - \frac{A}{3} (r_c-r_1)^3 - \frac{B}{4} (r_c-r_1)^4
329 \eeq
330
331 \subsection{Modified short-range interactions with Ewald summation}
332 When Ewald summation\index{Ewald sum} or \seeindex{particle-mesh
333 Ewald}{PME}\index{Ewald, particle-mesh} is used to calculate the
334 long-range interactions, the 
335 short-range Coulomb potential must also be modified. Here the potential
336 is switched to (nearly) zero at the cut-off, instead of the force.
337 In this case the short range potential is given by:
338 \beq
339 V(r) = f \frac{\mbox{erfc}(\beta r_{ij})}{r_{ij}} q_i q_j,
340 \eeq
341 where $\beta$ is a parameter that determines the relative weight 
342 between the direct space sum and the reciprocal space sum and erfc$(x)$ is
343 the complementary error function. For further 
344 details on long-range electrostatics, see \secref{lr_elstat}.
345 %} % Brace matches ifthenelse test for gmxlite
346
347
348 \section{Bonded interactions}
349 Bonded interactions are based on a fixed list of atoms. They are not
350 exclusively pair interactions, but include 3- and 4-body interactions
351 as well. There are {\em bond stretching} (2-body), {\em bond angle}
352 (3-body), and {\em dihedral angle} (4-body) interactions. A special
353 type of dihedral interaction (called {\em improper dihedral}) is used
354 to force atoms to remain in a plane or to prevent transition to a
355 configuration of opposite chirality (a mirror image).
356
357 \subsection{Bond stretching}
358 \label{sec:bondpot}
359 \subsubsection{Harmonic potential}
360 \label{subsec:harmonicbond}
361 The \swapindex{bond}{stretching} between two covalently bonded atoms
362 $i$ and $j$ is represented by a harmonic potential:
363
364 \begin{figure}
365 \centerline{\raisebox{2cm}{\includegraphics[width=5cm]{plots/bstretch}}\includegraphics[width=7cm]{plots/f-bond}}
366 \caption[Bond stretching.]{Principle of bond stretching (left), and the bond
367 stretching potential (right).}
368 \label{fig:bstretch1}
369 \end{figure}
370
371 \beq
372 V_b~(\rij) = \half k^b_{ij}(\rij-b_{ij})^2
373 \eeq
374 See also \figref{bstretch1}, with the force given by:
375 \beq
376 \ve{F}_i(\rvij) = k^b_{ij}(\rij-b_{ij}) \rnorm
377 \eeq
378
379 %\ifthenelse{\equal{\gmxlite}{1}}{}{
380 \subsubsection{Fourth power potential}
381 \label{subsec:G96bond}
382 In the \gromosv{96} force field~\cite{gromos96}, the covalent bond potential
383 is, for reasons of computational efficiency, written as:
384 \beq
385 V_b~(\rij) = \frac{1}{4}k^b_{ij}\left(\rij^2-b_{ij}^2\right)^2
386 \eeq
387 The corresponding force is:
388 \beq
389 \ve{F}_i(\rvij) = k^b_{ij}(\rij^2-b_{ij}^2)~\rvij
390 \eeq
391 The force constants for this form of the potential are related to the usual
392 harmonic force constant $k^{b,\mathrm{harm}}$ (\secref{bondpot}) as
393 \beq
394 2 k^b b_{ij}^2 = k^{b,\mathrm{harm}}
395 \eeq
396 The force constants are mostly derived from the harmonic ones used in 
397 \gromosv{87}~\cite{biomos}. Although this form is computationally more 
398 efficient
399 (because no square root has to be evaluated), it is conceptually more
400 complex. One particular disadvantage is that since the form is not harmonic,
401 the average energy of a single bond is not equal to $\half kT$ as it is for 
402 the normal harmonic potential.
403
404 \subsection{\normindex{Morse potential} bond stretching}
405 \label{subsec:Morsebond}
406 %\author{F.P.X. Everdij}
407 %
408 For some systems that require an anharmonic bond stretching potential,
409 the Morse potential~\cite{Morse29} 
410 between two atoms {\it i} and {\it j} is available
411 in {\gromacs}. This potential differs from the harmonic potential in 
412 that it has an asymmetric potential well and a zero force at infinite
413 distance. The functional form is:
414 \beq
415 \displaystyle V_{morse} (r_{ij}) = D_{ij} [1 - \exp(-\beta_{ij}(r_{ij}-b_{ij}))]^2,
416 \eeq
417 See also \figref{morse}, and the corresponding force is:
418 \beq
419 \begin{array}{rcl}
420 \displaystyle {\bf F}_{morse} ({\bf r}_{ij})&=&2 D_{ij} \beta_{ij} r_{ij} \exp(-\beta_{ij}(r_{ij}-b_{ij})) * \\
421 \displaystyle \: & \: &[1 - \exp(-\beta_{ij}(r_{ij}-b_{ij}))] \frac{\displaystyle {\bf r}_{ij}}{\displaystyle r_{ij}},
422 \end{array}
423 \eeq
424 where \( \displaystyle D_{ij} \) is the depth of the well in kJ/mol,
425 \( \displaystyle \beta_{ij} \) defines the steepness of the well (in
426 nm\(^{-1} \)), and \( \displaystyle b_{ij} \) is the equilibrium
427 distance in nm.  The steepness parameter \( \displaystyle \beta_{ij}
428 \) can be expressed in terms of the reduced mass of the atoms {\it i}
429 and {\it j}, the fundamental vibration frequency \( \displaystyle
430 \omega_{ij} \) and the well depth \( \displaystyle D_{ij} \):
431 \beq
432 \displaystyle \beta_{ij}= \omega_{ij} \sqrt{\frac{\mu_{ij}}{2 D_{ij}}}
433 \eeq
434 and because \( \displaystyle \omega = \sqrt{k/\mu} \), one can rewrite \( \displaystyle \beta_{ij} \) in terms of the harmonic force constant \( \displaystyle k_{ij} \):
435 \beq
436 \displaystyle \beta_{ij}= \sqrt{\frac{k_{ij}}{2 D_{ij}}}
437 \label{eqn:betaij}
438 \eeq
439 For small deviations \( \displaystyle (r_{ij}-b_{ij}) \), one can
440 approximate the \( \displaystyle \exp \)-term to first-order using a
441 Taylor expansion:
442 \beq
443 \displaystyle \exp(-x) \approx 1-x
444 \label{eqn:expminx}
445 \eeq
446 and substituting \eqnref{betaij} and \eqnref{expminx} in the functional form:
447 \beq
448 \begin{array}{rcl}
449 \displaystyle V_{morse} (r_{ij})&=&D_{ij} [1 - \exp(-\beta_{ij}(r_{ij}-b_{ij}))]^2\\
450 \displaystyle \:&=&D_{ij} [1 - (1 -\sqrt{\frac{k_{ij}}{2 D_{ij}}}(r_{ij}-b_{ij}))]^2\\
451 \displaystyle \:&=&\frac{1}{2} k_{ij} (r_{ij}-b_{ij}))^2
452 \end{array}
453 \eeq
454 we recover the harmonic bond stretching potential.
455
456 \begin{figure}
457 \centerline{\includegraphics[width=7cm]{plots/f-morse}}
458 \caption{The Morse potential well, with bond length 0.15 nm.}
459 \label{fig:morse}
460 \end{figure}
461
462 \subsection{Cubic bond stretching potential}
463 \label{subsec:cubicbond}
464 Another anharmonic bond stretching potential that is slightly simpler
465 than the Morse potential adds a cubic term in the distance to the
466 simple harmonic form:
467 \beq
468 V_b~(\rij) = k^b_{ij}(\rij-b_{ij})^2 + k^b_{ij}k^{cub}_{ij}(\rij-b_{ij})^3
469 \eeq
470 A flexible \normindex{water} model (based on
471 the SPC water model~\cite{Berendsen81}) including 
472 a cubic bond stretching potential for the O-H bond
473 was developed by Ferguson~\cite{Ferguson95}. This model was found
474 to yield a reasonable infrared spectrum. The Ferguson water model is
475 available in the {\gromacs} library ({\tt flexwat-ferguson.itp}). 
476 It should be noted that the potential is asymmetric: overstretching leads to
477 infinitely low energies. The \swapindex{integration}{timestep} is therefore
478 limited to 1 fs.
479
480 The force corresponding to this potential is:
481 \beq
482 \ve{F}_i(\rvij) = 2k^b_{ij}(\rij-b_{ij})~\rnorm + 3k^b_{ij}k^{cub}_{ij}(\rij-b_{ij})^2~\rnorm
483 \eeq
484
485 \subsection{FENE bond stretching potential\index{FENE potential}}
486 \label{subsec:FENEbond}
487 In coarse-grained polymer simulations the beads are often connected
488 by a FENE (finitely extensible nonlinear elastic) potential~\cite{Warner72}:
489 \beq
490 V_{\mbox{\small FENE}}(\rij) =
491   -\half k^b_{ij} b^2_{ij} \log\left(1 - \frac{\rij^2}{b^2_{ij}}\right)
492 \eeq
493 The potential looks complicated, but the expression for the force is simpler:
494 \beq
495 F_{\mbox{\small FENE}}(\rvij) =
496   -k^b_{ij} \left(1 - \frac{\rij^2}{b^2_{ij}}\right)^{-1} \rvij
497 \eeq
498 At short distances the potential asymptotically goes to a harmonic
499 potential with force constant $k^b$, while it diverges at distance $b$.
500 %} % Brace matches ifthenelse test for gmxlite
501
502 \subsection{Harmonic angle potential}
503 \label{subsec:harmonicangle}
504 \newcommand{\tijk}{\theta_{ijk}}
505 The bond-\swapindex{angle}{vibration} between a triplet of atoms $i$ - $j$ - $k$
506 is also represented by a harmonic potential on the angle $\tijk$
507
508 \begin{figure}
509 \centerline{\raisebox{1cm}{\includegraphics[width=5cm]{plots/angle}}\includegraphics[width=7cm]{plots/f-angle}}
510 \caption[Angle vibration.]{Principle of angle vibration (left) and the
511 bond angle potential (right).}
512 \label{fig:angle}
513 \end{figure}
514
515 \beq
516 V_a(\tijk) = \half k^{\theta}_{ijk}(\tijk-\tijk^0)^2
517 \eeq
518 As the bond-angle vibration is represented by a harmonic potential, the
519 form is the same as the bond stretching (\figref{bstretch1}).
520
521 The force equations are given by the chain rule:
522 \beq
523 \begin{array}{l}
524 \Fvi    ~=~ -\displaystyle\frac{d V_a(\tijk)}{d \rvi}   \\
525 \Fvk    ~=~ -\displaystyle\frac{d V_a(\tijk)}{d \rvk}   \\
526 \Fvj    ~=~ -\Fvi-\Fvk
527 \end{array}
528 ~ \mbox{ ~ where ~ } ~
529  \tijk = \arccos \frac{(\rvij \cdot \ve{r}_{kj})}{r_{ij}r_{kj}}
530 \eeq
531 The numbering $i,j,k$ is in sequence of covalently bonded atoms. Atom
532 $j$ is in the middle; atoms $i$  and $k$ are at the ends (see \figref{angle}).
533 {\bf Note} that in the input in topology files, angles are given in degrees and
534 force constants in kJ/mol/rad$^2$.
535
536 %\ifthenelse{\equal{\gmxlite}{1}}{}{
537 \subsection{Cosine based angle potential}
538 \label{subsec:G96angle}
539 In the \gromosv{96} force field a simplified function is used to represent angle
540 vibrations:
541 \beq
542 V_a(\tijk) = \half k^{\theta}_{ijk}\left(\cos(\tijk) - \cos(\tijk^0)\right)^2
543 \label{eq:G96angle}
544 \eeq
545 where 
546 \beq
547 \cos(\tijk) = \frac{\rvij\cdot\ve{r}_{kj}}{\rij r_{kj}}
548 \eeq
549 The corresponding force can be derived by partial differentiation with respect
550 to the atomic positions. The force constants in this function are related
551 to the force constants in the harmonic form $k^{\theta,\mathrm{harm}}$
552 (\ssecref{harmonicangle}) by:
553 \beq
554 k^{\theta} \sin^2(\tijk^0) = k^{\theta,\mathrm{harm}}
555 \eeq
556 In the \gromosv{96} manual there is a much more complicated conversion formula
557 which is temperature dependent. The formulas are equivalent at 0 K
558 and the differences at 300 K are on the order of 0.1 to 0.2\%.
559 {\bf Note} that in the input in topology files, angles are given in degrees and
560 force constants in kJ/mol.
561
562 \subsection{Restricted bending potential}
563 \label{subsec:ReB}
564 The restricted bending (ReB) potential~\cite{MonicaGoga2013} prevents the bending angle $\theta$
565 from reaching the $180^{\circ}$ value. In this way, the numerical instabilities
566 due to the calculation of the torsion angle and potential are eliminated when
567 performing coarse-grained molecular dynamics simulations.
568
569 To systematically hinder the bending angles from reaching the $180^{\circ}$ value,
570 the bending potential \ref{eq:G96angle} is divided by a $\sin^2\theta$ factor:
571 %
572 \beq
573 V_{\rm ReB}(\theta_i) = \frac{1}{2} k_{\theta} \frac{(\cos\theta_i - \cos\theta_0)^2}{\sin^2\theta_i}.
574 \label{eq:ReB}
575 \eeq
576 %
577 Figure ~\figref{ReB} shows the comparison between the ReB potential, \ref{eq:ReB},
578 and the standard one \ref{eq:G96angle}.
579 %
580 \begin{figure}
581 \centerline{\includegraphics[width=10cm]{plots/fig-02}}
582 \vspace*{8pt}
583 \caption{Bending angle potentials: cosine harmonic (solid black line), angle harmonic
584 (dashed black line) and restricted bending (red) with the same bending constant
585 $k_{\theta}=85$ kJ mol$^{-1}$ and equilibrium angle $\theta_0=130^{\circ}$.
586 The orange line represents the sum of a cosine harmonic ($k =50$ kJ mol$^{-1}$)
587 with a restricted bending ($k =25$ kJ mol$^{-1}$) potential, both with $\theta_0=130^{\circ}$.}
588 \label{fig:ReB}
589 \end{figure}
590 %
591 The wall of the ReB potential is very repulsive in the region close to $180^{\circ}$ and,
592 as a result, the bending angles are kept within a safe interval, far from instabilities.
593 The power $2$ of $\sin\theta_i$ in the denominator has been chosen to guarantee this behavior
594 and allows an elegant differentiation:
595 %
596 \beq
597 F_{\rm ReB}(\theta_i) = \frac{2k_{\theta}}{\sin^4\theta_i}(\cos\theta_i - \cos\theta_0) (1 - \cos\theta_i\cos\theta_0) \frac{\partial \cos\theta_i}{\partial \vec r_{k}}.
598 \label{eq:diff_ReB}
599 \eeq
600 %
601 Due to its construction, the restricted bending potential cannot be used for equilibrium
602 $\theta_0$ values too close to $0^{\circ}$ or $180^{\circ}$ (from experience, at least $10^{\circ}$
603 difference is recommended). It is very important that, in the starting configuration,
604 all the bending angles have to be in the safe interval to avoid initial instabilities.
605 This bending potential can be used in combination with any form of torsion potential.
606 It will always prevent three consecutive particles from becoming collinear and,
607 as a result, any torsion potential will remain free of singularities.
608 It can be also added to a standard bending potential to affect the angle around $180^{\circ}$,
609 but to keep its original form around the minimum (see the orange curve in \figref{ReB}).
610
611
612 \subsection{Urey-Bradley potential}
613 \label{subsec:Urey-Bradley}
614 The \swapindex{Urey-Bradley bond-angle}{vibration} between a triplet
615 of atoms $i$ - $j$ - $k$ is represented by a harmonic potential on the
616 angle $\tijk$ and a harmonic correction term on the distance between
617 the atoms $i$ and $k$. Although this can be easily written as a simple
618 sum of two terms, it is convenient to have it as a single entry in the
619 topology file and in the output as a separate energy term. It is used mainly
620 in the CHARMm force field~\cite{BBrooks83}. The energy is given by:
621
622 \beq
623 V_a(\tijk) = \half k^{\theta}_{ijk}(\tijk-\tijk^0)^2 + \half k^{UB}_{ijk}(r_{ik}-r_{ik}^0)^2
624 \eeq
625
626 The force equations can be deduced from sections~\ssecref{harmonicbond}
627 and~\ssecref{harmonicangle}.
628
629 \subsection{Bond-Bond cross term}
630 \label{subsec:bondbondcross}
631 The bond-bond cross term for three particles $i, j, k$ forming bonds
632 $i-j$ and $k-j$ is given by~\cite{Lawrence2003b}:
633 \begin{equation}
634 V_{rr'} ~=~ k_{rr'} \left(\left|\ve{r}_{i}-\ve{r}_j\right|-r_{1e}\right) \left(\left|\ve{r}_{k}-\ve{r}_j\right|-r_{2e}\right)
635 \label{crossbb}
636 \end{equation}
637 where $k_{rr'}$ is the force constant, and $r_{1e}$ and $r_{2e}$ are the
638 equilibrium bond lengths of the $i-j$ and $k-j$ bonds respectively. The force
639 associated with this potential on particle $i$ is:
640 \begin{equation}
641 \ve{F}_{i} = -k_{rr'}\left(\left|\ve{r}_{k}-\ve{r}_j\right|-r_{2e}\right)\frac{\ve{r}_i-\ve{r}_j}{\left|\ve{r}_{i}-\ve{r}_j\right|}
642 \end{equation}
643 The force on atom $k$ can be obtained by swapping $i$ and $k$ in the above
644 equation. Finally, the force on atom $j$ follows from the fact that the sum
645 of internal forces should be zero: $\ve{F}_j = -\ve{F}_i-\ve{F}_k$.
646
647 \subsection{Bond-Angle cross term}
648 \label{subsec:bondanglecross}
649 The bond-angle cross term for three particles $i, j, k$ forming bonds
650 $i-j$ and $k-j$ is given by~\cite{Lawrence2003b}:
651 \begin{equation}
652 V_{r\theta} ~=~ k_{r\theta} \left(\left|\ve{r}_{i}-\ve{r}_k\right|-r_{3e} \right) \left(\left|\ve{r}_{i}-\ve{r}_j\right|-r_{1e} + \left|\ve{r}_{k}-\ve{r}_j\right|-r_{2e}\right)
653 \end{equation}
654 where $k_{r\theta}$ is the force constant, $r_{3e}$ is the $i-k$ distance,
655 and the other constants are the same as in Equation~\ref{crossbb}. The force
656 associated with the potential on atom $i$ is:
657 \begin{equation}
658 \ve{F}_{i} ~=~ -k_{r\theta}\left[\left(\left|\ve{r}_{i}-\ve{r}_{k}\right|-r_{3e}\right)\frac{\ve{r}_i-\ve{r}_j}{\left|\ve{r}_{i}-\ve{r}_j\right|} \\
659 + \left(\left|\ve{r}_{i}-\ve{r}_j\right|-r_{1e} + \left|\ve{r}_{k}-\ve{r}_j\right|-r_{2e}\right)\frac{\ve{r}_i-\ve{r}_k}{\left|\ve{r}_{i}-\ve{r}_k\right|}\right]
660 \end{equation}
661
662 \subsection{Quartic angle potential}
663 \label{subsec:quarticangle}
664 For special purposes there is an angle potential
665 that uses a fourth order polynomial:
666 \beq
667 V_q(\tijk) ~=~ \sum_{n=0}^5 C_n (\tijk-\tijk^0)^n
668 \eeq
669 %} % Brace matches ifthenelse test for gmxlite
670
671 %% new commands %%%%%%%%%%%%%%%%%%%%%%
672 \newcommand{\rvkj}{{\bf r}_{kj}}
673 \newcommand{\rkj}{r_{kj}}
674 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
675
676 \subsection{Improper dihedrals\swapindexquiet{improper}{dihedral}}
677 \label{sec:imp}
678 Improper dihedrals are meant to keep \swapindex{planar}{group}s ({\eg} 
679 aromatic rings) planar, or to prevent molecules from flipping over to their
680 \normindex{mirror image}s, see \figref{imp}.
681
682 \begin {figure}
683 \centerline{\includegraphics[width=4cm]{plots/ring-imp}\hspace{1cm}
684 \includegraphics[width=3cm]{plots/subst-im}\hspace{1cm}\includegraphics[width=3cm]{plots/tetra-im}}
685 \caption[Improper dihedral angles.]{Principle of improper
686 dihedral angles. Out of plane bending for rings (left), substituents
687 of rings (middle), out of tetrahedral (right). The improper dihedral
688 angle $\xi$ is defined as the angle between planes (i,j,k) and (j,k,l)
689 in all cases.}
690 \label{fig:imp}
691 \end {figure}
692
693 \subsubsection{Improper dihedrals: harmonic type}
694 \label{subsec:harmonicimproperdihedral}
695 The simplest improper dihedral potential is a harmonic potential; it is plotted in
696 \figref{imps}.
697 \beq
698 V_{id}(\xi_{ijkl}) = \half k_{\xi}(\xi_{ijkl}-\xi_0)^2
699 \eeq
700 Since the potential is harmonic it is discontinuous,
701 but since the discontinuity is chosen at 180$^\circ$ distance from $\xi_0$
702 this will never cause problems.
703 {\bf Note} that in the input in topology files, angles are given in degrees and
704 force constants in kJ/mol/rad$^2$.
705
706 \begin{figure}
707 \centerline{\includegraphics[width=8cm]{plots/f-imps}}
708 \caption{Improper dihedral potential.}
709 \label{fig:imps}
710 \end{figure}
711
712 \subsubsection{Improper dihedrals: periodic type}
713 \label{subsec:periodicimproperdihedral}
714 This potential is identical to the periodic proper dihedral (see below).
715 There is a separate dihedral type for this (type 4) only to be able
716 to distinguish improper from proper dihedrals in the parameter section
717 and the output.
718
719 \subsection{Proper dihedrals\swapindexquiet{proper}{dihedral}}
720 For the normal \normindex{dihedral} interaction there is a choice of
721 either the {\gromos} periodic function or a function based on
722 expansion in powers of $\cos \phi$ (the so-called Ryckaert-Bellemans
723 potential). This choice has consequences for the inclusion of special
724 interactions between the first and the fourth atom of the dihedral
725 quadruple. With the periodic {\gromos} potential a special 1-4
726 LJ-interaction must be included; with the Ryckaert-Bellemans potential
727 {\em for alkanes} the \normindex{1-4 interaction}s must be excluded
728 from the non-bonded list.  {\bf Note:} Ryckaert-Bellemans potentials
729 are also used in {\eg} the OPLS force field in combination with 1-4
730 interactions. You should therefore not modify topologies generated by
731 {\tt \normindex{pdb2gmx}} in this case.
732
733 \subsubsection{Proper dihedrals: periodic type}
734 \label{subsec:properdihedral}
735 Proper dihedral angles are defined according to the IUPAC/IUB
736 convention, where $\phi$ is the angle between the $ijk$ and the $jkl$
737 planes, with {\bf zero} corresponding to the {\em cis} configuration
738 ($i$ and $l$ on the same side). There are two dihedral function types
739 in {\gromacs} topology files. There is the standard type 1 which behaves
740 like any other bonded interactions. For certain force fields, type 9
741 is useful. Type 9 allows multiple potential functions to be applied
742 automatically to a single dihedral in the {\tt [ dihedral ]} section
743 when multiple parameters are defined for the same atomtypes
744 in the {\tt [ dihedraltypes ]} section.
745
746 \begin{figure}
747 \centerline{\raisebox{1cm}{\includegraphics[width=5cm]{plots/dih}}\includegraphics[width=7cm]{plots/f-dih}}
748 \caption[Proper dihedral angle.]{Principle of proper dihedral angle
749 (left, in {\em trans} form) and the dihedral angle potential (right).} 
750 \label{fig:pdihf}
751 \end{figure}
752 \beq
753 V_d(\phi_{ijkl}) = k_{\phi}(1 + \cos(n \phi - \phi_s))
754 \eeq
755
756 %\ifthenelse{\equal{\gmxlite}{1}}{}{
757 \subsubsection{Proper dihedrals: Ryckaert-Bellemans function}
758 \label{subsec:RBdihedral}
759 For alkanes, the following proper dihedral potential is often used
760 (see \figref{rbdih}):
761 \beq
762 V_{rb}(\phi_{ijkl}) = \sum_{n=0}^5 C_n( \cos(\psi ))^n,
763 \eeq 
764 where $\psi = \phi - 180^\circ$.  \\
765 {\bf Note:} A conversion from one convention to another can be achieved by 
766 multiplying every coefficient \( \displaystyle C_n \) 
767 by \( \displaystyle (-1)^n \).
768
769 An example of constants for $C$ is given in \tabref{crb}.
770
771 \begin{table}
772 \centerline{
773 \begin{tabular}{|lr|lr|lr|}
774 \dline
775 $C_0$   & 9.28  & $C_2$   & -13.12  & $C_4$   & 26.24   \\
776 $C_1$   & 12.16 & $C_3$   & -3.06   & $C_5$   & -31.5   \\
777 \dline
778 \end{tabular}
779 }
780 \caption{Constants for Ryckaert-Bellemans potential (kJ mol$^{-1}$).}
781 \label{tab:crb}
782 \end{table}
783
784 \begin{figure}
785 \centerline{\includegraphics[width=8cm]{plots/f-rbs}}
786 \caption{Ryckaert-Bellemans dihedral potential.}
787 \label{fig:rbdih}
788 \end{figure}
789
790 ({\bf Note:} The use of this potential implies exclusion of LJ interactions
791 between the first and the last atom of the dihedral, and $\psi$ is defined
792 according to the ``polymer convention'' ($\psi_{trans}=0$).)
793
794 The RB dihedral function can also be used to include Fourier dihedrals
795 (see below):
796 \beq
797 V_{rb} (\phi_{ijkl}) ~=~ \frac{1}{2} \left[F_1(1+\cos(\phi)) + F_2(
798 1-\cos(2\phi)) + F_3(1+\cos(3\phi)) + F_4(1-\cos(4\phi))\right]
799 \eeq
800 Because of the equalities \( \cos(2\phi) = 2\cos^2(\phi) - 1 \),
801 \( \cos(3\phi) = 4\cos^3(\phi) - 3\cos(\phi) \) and
802 \( \cos(4\phi) = 8\cos^4(\phi) - 8\cos^2(\phi) + 1 \)
803 one can translate the OPLS parameters to 
804 Ryckaert-Bellemans parameters as follows:
805 \beq
806 \displaystyle
807 \begin{array}{rcl}
808 \displaystyle C_0&=&F_2 + \frac{1}{2} (F_1 + F_3)\\
809 \displaystyle C_1&=&\frac{1}{2} (- F_1 + 3 \, F_3)\\
810 \displaystyle C_2&=& -F_2 + 4 \, F_4\\
811 \displaystyle C_3&=&-2 \, F_3\\
812 \displaystyle C_4&=&-4 \, F_4\\
813 \displaystyle C_5&=&0
814 \end{array}
815 \eeq 
816 with OPLS parameters in protein convention and RB parameters in
817 polymer convention (this yields a minus sign for the odd powers of 
818 cos$(\phi)$).\\
819 \noindent{\bf Note:} Mind the conversion from {\bf kcal mol$^{-1}$} for 
820 literature OPLS and RB parameters to {\bf kJ mol$^{-1}$} in {\gromacs}.\\
821 %} % Brace matches ifthenelse test for gmxlite
822
823 \subsubsection{Proper dihedrals: Fourier function}
824 \label{subsec:Fourierdihedral}
825 The OPLS potential function is given as the first three
826 or four~\cite{Jorgensen2005a} cosine terms of a Fourier series.
827 In {\gromacs} the four term function is implemented:
828 \beq
829 V_{F} (\phi_{ijkl}) ~=~ \frac{1}{2} \left[C_1(1+\cos(\phi)) + C_2(
830 1-\cos(2\phi)) + C_3(1+\cos(3\phi)) + C_4(1+\cos(4\phi))\right],
831 \eeq
832 %\ifthenelse{\equal{\gmxlite}{1}}{}{
833 Internally, {\gromacs}
834 uses the Ryckaert-Bellemans code
835 to compute Fourier dihedrals (see above), because this is more efficient.\\
836 \noindent{\bf Note:} Mind the conversion from {\emph kcal mol$^{-1}$} for 
837 literature OPLS parameters to {\bf kJ mol$^{-1}$} in {\gromacs}.\\
838
839 \subsubsection{Proper dihedrals: Restricted torsion potential}
840 \label{subsec:ReT}
841 In a manner very similar to the restricted bending potential (see \ref{subsec:ReB}),
842 a restricted torsion/dihedral potential is introduced:
843 %
844 \beq
845 V_{\rm ReT}(\phi_i) = \frac{1}{2} k_{\phi} \frac{(\cos\phi_i - \cos\phi_0)^2}{\sin^2\phi_i}
846 \label{eq:ReT}
847 \eeq
848 %
849 with the advantages of being a function of $\cos\phi$ (no problems taking the derivative of $\sin\phi$)
850 and of keeping the torsion angle at only one minimum value. In this case, the factor $\sin^2\phi$ does
851 not allow the dihedral angle to move from the [$-180^{\circ}$:0] to [0:$180^{\circ}$] interval, i.e. it cannot have maxima both at $-\phi_0$ and $+\phi_0$ maxima, but only one of them.
852 For this reason, all the dihedral angles of the starting configuration should have their values in the
853 desired angles interval and the the equilibrium $\phi_0$ value should not be too close to the interval limits
854 (as for the restricted bending potential, described in \ref{subsec:ReB}, at least $10^{\circ}$ difference is recommended).
855
856 \subsubsection{Proper dihedrals: Combined bending-torsion potential}
857 \label{subsec:CBT}
858 When the four particles forming the dihedral angle become collinear (this situation will never happen in
859 atomistic simulations, but it can occur in coarse-grained simulations) the calculation of the
860 torsion angle and potential leads to numerical instabilities.
861 One way to avoid this is to use the restricted bending potential (see \ref{subsec:ReB})
862 that prevents the dihedral
863 from reaching the $180^{\circ}$ value.
864
865 Another way is to disregard any effects of the dihedral becoming ill-defined,
866 keeping the dihedral force and potential calculation continuous in entire angle range
867 by coupling the torsion potential (in a cosine form) with the bending potentials of the
868 adjacent bending angles in a unique expression:
869 %
870 \beq
871 V_{\rm CBT}(\theta_{i-1}, \theta_i, \phi_i) = k_{\phi} \sin^3\theta_{i-1} \sin^3\theta_{i} \sum_{n=0}^4 { a_n \cos^n\phi_i}.
872 \label{eq:CBT}
873 \eeq
874 %
875 This combined bending-torsion (CBT) potential has been proposed by~\cite{BulacuGiessen2005}
876 for polymer melt simulations and is extensively described in~\cite{MonicaGoga2013}.
877
878 This potential has two main advantages:
879 \begin{itemize}
880 \item
881 it does not only depend on the dihedral angle $\phi_i$ (between the $i-2$, $i-1$, $i$ and $i+1$ beads)
882 but also on the bending angles $\theta_{i-1}$ and $\theta_i$ defined from three adjacent beads
883 ($i-2$, $i-1$ and $i$, and $i-1$, $i$ and $i+1$, respectively).
884 The two $\sin^3\theta$ pre-factors, tentatively suggested by~\cite{ScottScheragator1966} and theoretically
885 discussed by~\cite{PaulingBond}, cancel the torsion potential and force when either of the two bending angles
886 approaches the value of $180^\circ$.
887 \item
888 its dependence on $\phi_i$ is expressed through a polynomial in $\cos\phi_i$ that avoids the singularities in
889 $\phi=0^\circ$ or $180^\circ$ in calculating the torsional force.
890 \end{itemize}
891
892 These two  properties make the CBT potential well-behaved for MD simulations with weak constraints
893 on the bending angles or even for steered / non-equilibrium MD in which the bending and torsion angles suffer major
894 modifications.
895 When using the CBT potential, the bending potentials for the adjacent $\theta_{i-1}$ and $\theta_i$ may have any form.
896 It is also possible to leave out the two angle bending terms ($\theta_{i-1}$ and $\theta_{i}$) completely.
897 \figref{CBT} illustrates the difference between a torsion potential with and without the $\sin^{3}\theta$ factors
898 (blue and gray curves, respectively).
899 %
900 \begin{figure}
901 \centerline{\includegraphics[width=10cm]{plots/fig-04}}
902 \caption{Blue: surface plot of the combined bending-torsion potential
903 (\ref{eq:CBT} with $k = 10$ kJ mol$^{-1}$, $a_0=2.41$, $a_1=-2.95$, $a_2=0.36$, $a_3=1.33$)
904 when, for simplicity, the bending angles behave the same ($\theta_1=\theta_2=\theta$).
905 Gray: the same torsion potential without the $\sin^{3}\theta$ terms (Ryckaert-Bellemans type).
906 $\phi$ is the dihedral angle.}
907 \label{fig:CBT}
908 \end{figure}
909 %
910 Additionally, the derivative of $V_{CBT}$ with respect to the Cartesian variables is straightforward:
911 %
912 \begin{equation}
913 \frac{\partial V_{\rm CBT}(\theta_{i-1},\theta_i,\phi_i)} {\partial \vec r_{l}} = \frac{\partial V_{\rm CBT}}{\partial \theta_{i-1}} \frac{\partial \theta_{i-1}}{\partial \vec r_{l}} +
914                                                                                   \frac{\partial V_{\rm CBT}}{\partial \theta_{i  }} \frac{\partial \theta_{i  }}{\partial \vec r_{l}} +
915                                                                                   \frac{\partial V_{\rm CBT}}{\partial \phi_{i    }} \frac{\partial \phi_{i    }}{\partial \vec r_{l}}
916 \label{eq:force_cbt}
917 \end{equation}
918 %
919 The CBT is based on a cosine form without multiplicity, so it can only be symmetrical around $0^{\circ}$.
920 To obtain an asymmetrical dihedral angle distribution (e.g. only one maximum in [$-180^{\circ}$:$180^{\circ}$] interval),
921 a standard torsion potential such as harmonic angle  or  periodic cosine potentials should be used instead of a CBT potential.
922 However, these two forms have the inconveniences of the force derivation ($1/\sin\phi$) and of the alignment of beads
923 ($\theta_i$ or $\theta_{i-1} = 0^{\circ}, 180^{\circ}$).
924 Coupling such non-$\cos\phi$ potentials with $\sin^3\theta$ factors does not improve simulation stability since there are
925 cases in which $\theta$ and $\phi$ are simultaneously $180^{\circ}$. The integration at this step would be possible
926 (due to the cancelling of the torsion potential) but the next step would be singular
927 ($\theta$ is not $180^{\circ}$ and $\phi$ is very close to $180^{\circ}$).
928
929 %\ifthenelse{\equal{\gmxlite}{1}}{}{
930 \subsection{Tabulated bonded interaction functions\index{tabulated bonded interaction function}}
931 \label{subsec:tabulatedinteraction}
932 For full flexibility, any functional shape can be used for
933 bonds, angles and dihedrals through user-supplied tabulated functions.
934 The functional shapes are:
935 \bea
936 V_b(r_{ij})      &=& k \, f^b_n(r_{ij}) \\
937 V_a(\tijk)       &=& k \, f^a_n(\tijk) \\
938 V_d(\phi_{ijkl}) &=& k \, f^d_n(\phi_{ijkl})
939 \eea
940 where $k$ is a force constant in units of energy
941 and $f$ is a cubic spline function; for details see \ssecref{cubicspline}.
942 For each interaction, the force constant $k$ and the table number $n$
943 are specified in the topology.
944 There are two different types of bonds, one that generates exclusions (type 8)
945 and one that does not (type 9).
946 For details see \tabref{topfile2}.
947 The table files are supplied to the {\tt mdrun} program.
948 After the table file name an underscore, the letter ``b'' for bonds,
949 ``a'' for angles or ``d'' for dihedrals and the table number are appended.
950 For example, for a bond with $n=0$ (and using the default table file name)
951 the table is read from the file {\tt table_b0.xvg}.  Multiple tables can be
952 supplied simply by using different values of $n$, and are applied to the appropriate
953 bonds, as specified in the topology (\tabref{topfile2}).
954 The format for the table files is three columns with $x$, $f(x)$, $-f'(x)$,
955 where $x$ should be uniformly-spaced. Requirements for entries in the topology
956 are given in~\tabref{topfile2}. 
957 The setup of the tables is as follows:
958 \\{\bf bonds}:
959 $x$ is the distance in nm. For distances beyond the table length,
960 {\tt mdrun} will quit with an error message.
961 \\{\bf angles}:
962 $x$ is the angle in degrees. The table should go from
963 0 up to and including 180 degrees; the derivative is taken in degrees.
964 \\{\bf dihedrals}:
965 $x$ is the dihedral angle in degrees. The table should go from
966 -180 up to and including 180 degrees;
967 the IUPAC/IUB convention is used, {\ie} zero is cis,
968 the derivative is taken in degrees.
969 %} % Brace matches ifthenelse test for gmxlite
970
971 \section{Restraints}
972 Special potentials are used for imposing restraints on the motion of
973 the system, either to avoid disastrous deviations, or to include
974 knowledge from experimental data. In either case they are not really
975 part of the force field and the reliability of the parameters is not
976 important. The potential forms, as implemented in {\gromacs}, are
977 mentioned just for the sake of completeness. Restraints and constraints
978 refer to quite different algorithms in {\gromacs}.
979
980 \subsection{Position restraints\swapindexquiet{position}{restraint}}
981 \label{subsec:positionrestraint}
982 These are used to restrain particles to fixed reference positions
983 $\ve{R}_i$. They can be used during equilibration in order to avoid
984 drastic rearrangements of critical parts ({\eg} to restrain motion
985 in a protein that is subjected to large solvent forces when the
986 solvent is not yet equilibrated). Another application is the
987 restraining of particles in a shell around a region that is simulated
988 in detail, while the shell is only approximated because it lacks
989 proper interaction from missing particles outside the
990 shell. Restraining will then maintain the integrity of the inner
991 part. For spherical shells, it is a wise procedure to make the force
992 constant depend on the radius, increasing from zero at the inner
993 boundary to a large value at the outer boundary. This feature has
994 not, however, been implemented in {\gromacs}.
995 \newcommand{\unitv}[1]{\hat{\bf #1}}
996 \newcommand{\halfje}[1]{\frac{#1}{2}}
997
998 The following form is used: 
999 \beq
1000 V_{pr}(\ve{r}_i) = \halfje{1}k_{pr}|\rvi-\ve{R}_i|^2
1001 \eeq
1002 The potential is plotted in \figref{positionrestraint}.
1003
1004 \begin{figure}
1005 \centerline{\includegraphics[width=8cm]{plots/f-pr}}
1006 \caption{Position restraint potential.}
1007 \label{fig:positionrestraint}
1008 \end{figure}
1009
1010 The potential form can be rewritten without loss of generality as:
1011 \beq
1012 V_{pr}(\ve{r}_i) = \halfje{1} \left[ k_{pr}^x (x_i-X_i)^2 ~\unitv{x} + k_{pr}^y (y_i-Y_i)^2 ~\unitv{y} + k_{pr}^z (z_i-Z_i)^2 ~\unitv{z}\right]
1013 \eeq
1014
1015 Now the forces are:
1016 \beq
1017 \begin{array}{rcl}
1018 F_i^x &=& -k_{pr}^x~(x_i - X_i) \\
1019 F_i^y &=& -k_{pr}^y~(y_i - Y_i) \\
1020 F_i^z &=& -k_{pr}^z~(z_i - Z_i)
1021 \end{array}
1022 \eeq
1023 Using three different force constants the position 
1024 restraints can be turned on or off
1025 in each spatial dimension; this means that atoms can be harmonically
1026 restrained to a plane or a line.
1027 Position restraints are applied to a special fixed list of atoms. Such a
1028 list is usually generated by the {\tt \normindex{pdb2gmx}} program.
1029
1030 \subsection{\swapindex{Flat-bottomed}{position restraint}s}
1031 \label{subsec:fbpositionrestraint}
1032 Flat-bottomed position restraints can be used to restrain particles to 
1033 part of the simulation volume. No force acts on the restrained
1034 particle within the flat-bottomed region of the potential, however a
1035 harmonic force acts to move the particle to the flat-bottomed region
1036 if it is outside it. It is possible to apply normal and
1037 flat-bottomed position restraints on the same particle (however, only
1038 with the same reference position $\ve{R}_i$). The following general potential
1039 is used (Figure~\ref{fig:fbposres}A):
1040 \beq
1041  V_\mathrm{fb}(\ve{r}_i) = \frac{1}{2}k_\mathrm{fb} [d_g(\ve{r}_i;\ve{R}_i) - r_\mathrm{fb}]^2\,H[d_g(\ve{r}_i;\ve{R}_i) - r_\mathrm{fb}],
1042 \eeq
1043 where $\ve{R}_i$ is the reference position, $r_\mathrm{fb}$ is the distance
1044 from the center with a flat potential, $k_\mathrm{fb}$ the force constant, and $H$ is the Heaviside step
1045 function. The distance $d_g(\ve{r}_i;\ve{R}_i)$ from the reference
1046 position depends on the geometry $g$ of the flat-bottomed potential.
1047
1048 \begin{figure}
1049 \centerline{\includegraphics[width=10cm]{plots/fbposres}}
1050 \caption{Flat-bottomed position restraint potential. (A) Not
1051   inverted, (B) inverted.}
1052 \label{fig:fbposres}
1053 \end{figure}
1054
1055 The following geometries for the flat-bottomed potential are supported:\newline
1056 {\bfseries Sphere} ($g =1$): The particle is kept in a sphere of given
1057 radius. The force acts towards the center of the sphere. The following distance calculation is used:
1058 \beq
1059   d_g(\ve{r}_i;\ve{R}_i) = |\ve{r}_i-\ve{R}_i|
1060 \eeq
1061 {\bfseries Cylinder} ($g=6,7,8$): The particle is kept in a cylinder of given radius
1062 parallel to the $x$ ($g=6$), $y$ ($g=7$), or $z$-axis ($g=8$). For backwards compatibility, setting
1063 $g=2$ is mapped to $g=8$ in the code so that old {\tt .tpr} files and topologies work.  
1064 The force from the flat-bottomed potential acts towards the axis of the cylinder. 
1065 The component of the force parallel to the cylinder axis is zero.
1066 For a cylinder aligned along the $z$-axis:
1067 \beq
1068  d_g(\ve{r}_i;\ve{R}_i) = \sqrt{ (x_i-X_i)^2 + (y_i - Y_i)^2 }
1069 \eeq
1070 {\bfseries Layer} ($g=3,4,5$): The particle is kept in a layer defined by the
1071 thickness and the normal of the layer. The layer normal can be parallel to the $x$, $y$, or
1072 $z$-axis. The force acts parallel to the layer normal.\\
1073 \beq
1074  d_g(\ve{r}_i;\ve{R}_i) = |x_i-X_i|, \;\;\;\mbox{or}\;\;\; 
1075  d_g(\ve{r}_i;\ve{R}_i) = |y_i-Y_i|, \;\;\;\mbox{or}\;\;\; 
1076 d_g(\ve{r}_i;\ve{R}_i) = |z_i-Z_i|.
1077 \eeq
1078
1079 It is possible to apply multiple independent flat-bottomed position
1080 restraints of different geometry on one particle. For example, applying
1081 a cylinder and a layer in $z$ keeps a particle within a
1082 disk. Applying three layers in $x$, $y$, and $z$ keeps the particle within a cuboid.
1083
1084 In addition, it is possible to invert the restrained region with the
1085 unrestrained region, leading to a potential that acts to keep the particle {\it outside} of the volume
1086 defined by $\ve{R}_i$, $g$, and $r_\mathrm{fb}$. That feature is
1087 switched on by defining a negative $r_\mathrm{fb}$ in the
1088 topology. The following potential is used (Figure~\ref{fig:fbposres}B):
1089 \beq
1090   V_\mathrm{fb}^{\mathrm{inv}}(\ve{r}_i) = \frac{1}{2}k_\mathrm{fb}
1091   [d_g(\ve{r}_i;\ve{R}_i) - |r_\mathrm{fb}|]^2\,
1092   H[ -(d_g(\ve{r}_i;\ve{R}_i) - |r_\mathrm{fb}|)].
1093 \eeq
1094
1095
1096
1097 %\ifthenelse{\equal{\gmxlite}{1}}{}{
1098 \subsection{Angle restraints\swapindexquiet{angle}{restraint}}
1099 \label{subsec:anglerestraint}
1100 These are used to restrain the angle between two pairs of particles
1101 or between one pair of particles and the $z$-axis.
1102 The functional form is similar to that of a proper dihedral.
1103 For two pairs of atoms: 
1104 \beq
1105 V_{ar}(\ve{r}_i,\ve{r}_j,\ve{r}_k,\ve{r}_l)
1106         = k_{ar}(1 - \cos(n (\theta - \theta_0))
1107         )
1108 ,~~~~\mbox{where}~~
1109 \theta = \arccos\left(\frac{\ve{r}_j -\ve{r}_i}{\|\ve{r}_j -\ve{r}_i\|}
1110  \cdot \frac{\ve{r}_l -\ve{r}_k}{\|\ve{r}_l -\ve{r}_k\|} \right)
1111 \eeq
1112 For one pair of atoms and the $z$-axis: 
1113 \beq
1114 V_{ar}(\ve{r}_i,\ve{r}_j) = k_{ar}(1 - \cos(n (\theta - \theta_0))
1115         )
1116 ,~~~~\mbox{where}~~
1117 \theta = \arccos\left(\frac{\ve{r}_j -\ve{r}_i}{\|\ve{r}_j -\ve{r}_i\|}
1118  \cdot \left( \begin{array}{c} 0 \\ 0 \\ 1 \\ \end{array} \right) \right)
1119 \eeq
1120 A multiplicity ($n$) of 2 is useful when you do not want to distinguish
1121 between parallel and anti-parallel vectors.
1122 The equilibrium angle $\theta$ should be between 0 and 180 degrees
1123 for multiplicity 1 and between 0 and 90 degrees for multiplicity 2.
1124
1125
1126 \subsection{Dihedral restraints\swapindexquiet{dihedral}{restraint}}
1127 \label{subsec:dihedralrestraint}
1128 These are used to restrain the dihedral angle $\phi$ defined by four particles
1129 as in an improper dihedral (sec.~\ref{sec:imp}) but with a slightly
1130 modified potential. Using:
1131 \beq
1132 \phi' = \left(\phi-\phi_0\right) ~{\rm MOD}~ 2\pi
1133 \label{eqn:dphi}
1134 \eeq
1135 where $\phi_0$ is the reference angle, the potential is defined as:
1136 \beq
1137 V_{dihr}(\phi') ~=~ \left\{
1138 \begin{array}{lcllll}
1139 \half k_{dihr}(\phi'-\phi_0-\Delta\phi)^2      
1140                 &\mbox{for}&     \phi' & >   & \Delta\phi       \\[1.5ex]
1141 0               &\mbox{for}&     \phi' & \le & \Delta\phi       \\[1.5ex]
1142 \end{array}\right.
1143 \label{eqn:dihre}
1144 \eeq
1145 where $\Delta\phi$ is a user defined angle and $k_{dihr}$ is the force 
1146 constant.
1147 {\bf Note} that in the input in topology files, angles are given in degrees and
1148 force constants in kJ/mol/rad$^2$.
1149 %} % Brace matches ifthenelse test for gmxlite
1150
1151 \subsection{Distance restraints\swapindexquiet{distance}{restraint}}
1152 \label{subsec:distancerestraint}
1153 Distance restraints 
1154 add a penalty to the potential when the distance between specified
1155 pairs of atoms exceeds a threshold value. They are normally used to
1156 impose experimental restraints from, for instance, experiments in nuclear
1157 magnetic resonance (NMR), on the motion of the system. Thus, MD can be
1158 used for structure refinement using NMR data\index{nmr
1159 refinement}\index{refinement,nmr}.
1160 In {\gromacs} there are three ways to impose restraints on pairs of atoms:
1161 \begin{itemize}
1162 \item Simple harmonic restraints: use {\tt [ bonds ]} type 6
1163 %\ifthenelse{\equal{\gmxlite}{1}}
1164 {.}
1165 {(see \secref{excl}).}
1166 \item\label{subsec:harmonicrestraint}Piecewise linear/harmonic restraints: {\tt [ bonds ]} type 10.
1167 \item Complex NMR distance restraints, optionally with pair, time and/or
1168 ensemble averaging.
1169 \end{itemize}
1170 The last two options will be detailed now.
1171
1172 The potential form for distance restraints is quadratic below a specified
1173 lower bound and between two specified upper bounds, and linear beyond the
1174 largest bound (see \figref{dist}).
1175 \beq
1176 V_{dr}(r_{ij}) ~=~ \left\{
1177 \begin{array}{lcllllll}
1178 \half k_{dr}(r_{ij}-r_0)^2      
1179                 &\mbox{for}&     &     & r_{ij} & < & r_0       \\[1.5ex]
1180 0               &\mbox{for}& r_0 & \le & r_{ij} & < & r_1       \\[1.5ex]
1181 \half k_{dr}(r_{ij}-r_1)^2      
1182                 &\mbox{for}& r_1 & \le & r_{ij} & < & r_2       \\[1.5ex]
1183 \half k_{dr}(r_2-r_1)(2r_{ij}-r_2-r_1)  
1184                 &\mbox{for}& r_2 & \le & r_{ij} &   &
1185 \end{array}\right.
1186 \label{eqn:disre}
1187 \eeq
1188
1189 \begin{figure}
1190 \centerline{\includegraphics[width=8cm]{plots/f-dr}}
1191 \caption{Distance Restraint potential.}
1192 \label{fig:dist}
1193 \end{figure}
1194
1195 The forces are
1196 \beq
1197 \ve{F}_i~=~ \left\{
1198 \begin{array}{lcllllll}
1199 -k_{dr}(r_{ij}-r_0)\frac{\rvij}{r_{ij}} 
1200                 &\mbox{for}&     &     & r_{ij} & < & r_0       \\[1.5ex]
1201 0               &\mbox{for}& r_0 & \le & r_{ij} & < & r_1       \\[1.5ex]
1202 -k_{dr}(r_{ij}-r_1)\frac{\rvij}{r_{ij}} 
1203                 &\mbox{for}& r_1 & \le & r_{ij} & < & r_2       \\[1.5ex]
1204 -k_{dr}(r_2-r_1)\frac{\rvij}{r_{ij}}    
1205                 &\mbox{for}& r_2 & \le & r_{ij} &   &
1206 \end{array} \right.
1207 \eeq
1208
1209 For restraints not derived from NMR data, this functionality
1210 will usually suffice and a section of {\tt [ bonds ]} type 10
1211 can be used to apply individual restraints between pairs of
1212 %\ifthenelse{\equal{\gmxlite}{1}}{atoms.}{
1213 atoms, see \ssecref{topfile}.
1214 %} % Brace matches ifthenelse test for gmxlite 
1215 For applying restraints derived from NMR measurements, more complex
1216 functionality might be required, which is provided through
1217 the {\tt [~distance_restraints~]} section and is described below.
1218
1219 %\ifthenelse{\equal{\gmxlite}{1}}{}{
1220 \subsubsection{Time averaging\swapindexquiet{time-averaged}{distance restraint}}
1221 Distance restraints based on instantaneous distances can potentially reduce
1222 the fluctuations in a molecule significantly. This problem can be overcome by restraining
1223 to a {\em time averaged} distance~\cite{Torda89}.
1224 The forces with time averaging are:
1225 \beq
1226 \ve{F}_i~=~ \left\{
1227 \begin{array}{lcllllll}
1228 -k^a_{dr}(\bar{r}_{ij}-r_0)\frac{\rvij}{r_{ij}}   
1229                 &\mbox{for}&     &     & \bar{r}_{ij} & < & r_0 \\[1.5ex]
1230 0               &\mbox{for}& r_0 & \le & \bar{r}_{ij} & < & r_1 \\[1.5ex]
1231 -k^a_{dr}(\bar{r}_{ij}-r_1)\frac{\rvij}{r_{ij}}   
1232                 &\mbox{for}& r_1 & \le & \bar{r}_{ij} & < & r_2 \\[1.5ex]
1233 -k^a_{dr}(r_2-r_1)\frac{\rvij}{r_{ij}}    
1234                 &\mbox{for}& r_2 & \le & \bar{r}_{ij} &   &
1235 \end{array} \right.
1236 \eeq
1237 where $\bar{r}_{ij}$ is given by an exponential running average with decay time $\tau$:
1238 \beq
1239 \bar{r}_{ij} ~=~ < r_{ij}^{-3} >^{-1/3}
1240 \label{eqn:rav}
1241 \eeq
1242 The force constant $k^a_{dr}$ is switched on slowly to compensate for
1243 the lack of history at the beginning of the simulation:
1244 \beq
1245 k^a_{dr} = k_{dr} \left(1-\exp\left(-\frac{t}{\tau}\right)\right)
1246 \eeq
1247 Because of the time averaging, we can no longer speak of a distance restraint
1248 potential.
1249
1250 This way an atom can satisfy two incompatible distance restraints 
1251 {\em on average} by moving between two positions. 
1252 An example would be an amino acid side-chain that is rotating around
1253 its $\chi$ dihedral angle, thereby coming close to various other groups.
1254 Such a mobile side chain can give rise to multiple NOEs that can not be
1255 fulfilled by a single structure.
1256
1257 The computation of the time
1258 averaged distance in the {\tt mdrun} program is done in the following fashion:
1259 \beq
1260 \begin{array}{rcl}
1261 \overline{r^{-3}}_{ij}(0)       &=& r_{ij}(0)^{-3}      \\
1262 \overline{r^{-3}}_{ij}(t)       &=& \overline{r^{-3}}_{ij}(t-\Delta t)~\exp{\left(-\frac{\Delta t}{\tau}\right)} + r_{ij}(t)^{-3}\left[1-\exp{\left(-\frac{\Delta t}{\tau}\right)}\right]
1263 \label{eqn:ravdisre}
1264 \end{array}
1265 \eeq
1266
1267 When a pair is within the bounds, it can still feel a force
1268 because the time averaged distance can still be beyond a bound.
1269 To prevent the protons from being pulled too close together, a mixed
1270 approach can be used. In this approach, the penalty is zero when the
1271 instantaneous distance is within the bounds, otherwise the violation is
1272 the square root of the product of the instantaneous violation and the 
1273 time averaged violation:
1274 \beq
1275 \ve{F}_i~=~ \left\{
1276 \begin{array}{lclll}
1277 k^a_{dr}\sqrt{(r_{ij}-r_0)(\bar{r}_{ij}-r_0)}\frac{\rvij}{r_{ij}}   
1278     & \mbox{for} & r_{ij} < r_0 & \mbox{and} & \bar{r}_{ij} < r_0 \\[1.5ex]
1279 -k^a _{dr} \,
1280   \mbox{min}\left(\sqrt{(r_{ij}-r_1)(\bar{r}_{ij}-r_1)},r_2-r_1\right)
1281   \frac{\rvij}{r_{ij}}   
1282     & \mbox{for} & r_{ij} > r_1 & \mbox{and} & \bar{r}_{ij} > r_1 \\[1.5ex]
1283 0               &\mbox{otherwise}
1284 \end{array} \right.
1285 \eeq
1286
1287 \subsubsection{Averaging over multiple pairs\swapindexquiet{ensemble-averaged}{distance restraint}} 
1288
1289 Sometimes it is unclear from experimental data which atom pair
1290 gives rise to a single NOE, in other occasions it can be obvious that
1291 more than one pair contributes due to the symmetry of the system, {\eg} a
1292 methyl group with three protons. For such a group, it is not possible 
1293 to distinguish between the protons, therefore they should all be taken into
1294 account when calculating the distance between this methyl group and another
1295 proton (or group of protons).
1296 Due to the physical nature of magnetic resonance, the intensity of the
1297 NOE signal is inversely proportional to the sixth power of the inter-atomic 
1298 distance.
1299 Thus, when combining atom pairs, 
1300 a fixed list of $N$ restraints may be taken together, 
1301 where the apparent ``distance'' is given by:
1302 \beq
1303 r_N(t) = \left [\sum_{n=1}^{N} \bar{r}_{n}(t)^{-6} \right]^{-1/6}
1304 \label{eqn:rsix}
1305 \eeq
1306 where we use $r_{ij}$ or \eqnref{rav} for the $\bar{r}_{n}$.
1307 The $r_N$ of the instantaneous and time-averaged distances
1308 can be combined to do a mixed restraining, as indicated above.
1309 As more pairs of protons contribute to the same NOE signal, the intensity
1310 will increase, and the summed ``distance'' will be shorter than any of
1311 its components due to the reciprocal summation. 
1312
1313 There are two options for distributing the forces over the atom pairs.
1314 In the conservative option, the force is defined as the derivative of the
1315 restraint potential with respect to the coordinates. This results in
1316 a conservative potential when time averaging is not used.
1317 The force distribution over the pairs is proportional to $r^{-6}$.
1318 This means that a close pair feels a much larger force than a distant pair,
1319 which might lead to a molecule that is ``too rigid.''
1320 The other option is an equal force distribution. In this case each pair
1321 feels $1/N$ of the derivative of the restraint potential with respect to 
1322 $r_N$. The advantage of this method is that more conformations might be
1323 sampled, but the non-conservative nature of the forces can lead to
1324 local heating of the protons.
1325
1326 It is also possible to use {\em ensemble averaging} using multiple
1327 (protein)  molecules. In this case the bounds should be lowered as in:
1328 \beq
1329 \begin{array}{rcl}
1330 r_1     &~=~&   r_1 * M^{-1/6}  \\
1331 r_2     &~=~&   r_2 * M^{-1/6}
1332 \end{array}
1333 \eeq
1334 where $M$ is the number of molecules. The {\gromacs} preprocessor {\tt grompp}
1335 can do this automatically when the appropriate option is given.
1336 The resulting ``distance'' is 
1337 then used to calculate the scalar force according to:
1338 \beq
1339 \ve{F}_i~=~\left\{
1340 \begin{array}{rcl}
1341 ~& 0 \hspace{4cm}  & r_{N} < r_1         \\
1342  & k_{dr}(r_{N}-r_1)\frac{\rvij}{r_{ij}} & r_1 \le r_{N} < r_2 \\
1343  & k_{dr}(r_2-r_1)\frac{\rvij}{r_{ij}}    & r_{N} \ge r_2 
1344 \end{array} \right.
1345 \eeq
1346 where $i$ and $j$ denote the atoms of all the 
1347 pairs that contribute to the NOE signal.
1348
1349 \subsubsection{Using distance restraints}
1350
1351 A list of distance restrains based on NOE data can be added to a molecule
1352 definition in your topology file, like in the following example:
1353
1354 \begin{verbatim}
1355 [ distance_restraints ]
1356 ; ai   aj   type   index   type'      low     up1     up2     fac
1357 10     16      1       0       1      0.0     0.3     0.4     1.0
1358 10     28      1       1       1      0.0     0.3     0.4     1.0
1359 10     46      1       1       1      0.0     0.3     0.4     1.0
1360 16     22      1       2       1      0.0     0.3     0.4     2.5
1361 16     34      1       3       1      0.0     0.5     0.6     1.0
1362 \end{verbatim}
1363
1364 In this example a number of features can be found.  In columns {\tt
1365 ai} and {\tt aj} you find the atom numbers of the particles to be
1366 restrained. The {\tt type} column should always be 1.  As explained in
1367 ~\ssecref{distancerestraint}, multiple distances can contribute to a single NOE
1368 signal. In the topology this can be set using the {\tt index}
1369 column. In our example, the restraints 10-28 and 10-46 both have index
1370 1, therefore they are treated simultaneously.  An extra requirement
1371 for treating restraints together is that the restraints must be on
1372 successive lines, without any other intervening restraint.  The {\tt
1373 type'} column will usually be 1, but can be set to 2 to obtain a
1374 distance restraint that will never be time- and ensemble-averaged;
1375 this can be useful for restraining hydrogen bonds.  The columns {\tt
1376 low}, {\tt up1}, and {\tt up2} hold the values of $r_0$, $r_1$, and
1377 $r_2$ from ~\eqnref{disre}.  In some cases it can be useful to have
1378 different force constants for some restraints; this is controlled by
1379 the column {\tt fac}.  The force constant in the parameter file is
1380 multiplied by the value in the column {\tt fac} for each restraint.
1381 %} % Brace matches ifthenelse test for gmxlite
1382
1383 \newcommand{\SSS}{{\mathbf S}}
1384 \newcommand{\DD}{{\mathbf D}}
1385 \newcommand{\RR}{{\mathbf R}}
1386
1387 %\ifthenelse{\equal{\gmxlite}{1}}{}{
1388 \subsection{Orientation restraints\swapindexquiet{orientation}{restraint}}
1389 \label{subsec:orientationrestraint}
1390 This section describes how orientations between vectors,
1391 as measured in certain NMR experiments, can be calculated
1392 and restrained in MD simulations.
1393 The presented refinement methodology and a comparison of results
1394 with and without time and ensemble averaging have been
1395 published~\cite{Hess2003}.
1396 \subsubsection{Theory}
1397 In an NMR experiment, orientations of vectors can be measured when a 
1398 molecule does not tumble completely isotropically in the solvent.
1399 Two examples of such orientation measurements are
1400 residual \normindex{dipolar couplings}
1401 (between two nuclei) or chemical shift anisotropies.
1402 An observable for a vector $\ve{r}_i$ can be written as follows:
1403 \beq
1404 \delta_i = \frac{2}{3} \mbox{tr}(\SSS\DD_i)
1405 \eeq
1406 where $\SSS$ is the dimensionless order tensor of the molecule.
1407 The tensor $\DD_i$ is given by:
1408 \beq
1409 \label{orient_def}
1410 \DD_i = \frac{c_i}{\|\ve{r}_i\|^\alpha} \left(
1411 %\begin{array}{lll}
1412 %3 r_x r_x - \ve{r}\cdot\ve{r} & 3 r_x r_y & 3 r_x r_z \\
1413 %3 r_x r_y                     & 3 r_y r_y - \ve{r}\cdot\ve{r} & 3yz \\
1414 %3 r_x r_z                     & 3 r_y r_z & 3 r_z r_z - \ve{r}\cdot\ve{r}
1415 %\end{array} \right)
1416 \begin{array}{lll}
1417 3 x x - 1 & 3 x y     & 3 x z     \\
1418 3 x y     & 3 y y - 1 & 3 y z     \\
1419 3 x z     & 3 y z     & 3 z z - 1 \\
1420 \end{array} \right)
1421 \eeq
1422 \beq
1423 \mbox{with:} \quad 
1424 x=\frac{r_{i,x}}{\|\ve{r}_i\|}, \quad
1425 y=\frac{r_{i,y}}{\|\ve{r}_i\|}, \quad 
1426 z=\frac{r_{i,z}}{\|\ve{r}_i\|}
1427 \eeq
1428 For a dipolar coupling $\ve{r}_i$ is the vector connecting the two
1429 nuclei, $\alpha=3$ and the constant $c_i$ is given by:
1430 \beq
1431 c_i = \frac{\mu_0}{4\pi} \gamma_1^i \gamma_2^i \frac{\hbar}{4\pi}
1432 \eeq
1433 where $\gamma_1^i$ and $\gamma_2^i$ are the gyromagnetic ratios of the
1434 two nuclei.
1435
1436 The order tensor is symmetric and has trace zero. Using a rotation matrix
1437 ${\mathbf T}$ it can be transformed into the following form:
1438 \beq
1439 {\mathbf T}^T \SSS {\mathbf T} = s \left( \begin{array}{ccc}
1440 -\frac{1}{2}(1-\eta) & 0                    & 0 \\
1441 0                    & -\frac{1}{2}(1+\eta) & 0 \\
1442 0                    & 0                    & 1
1443 \end{array} \right)
1444 \eeq
1445 where $-1 \leq s \leq 1$ and $0 \leq \eta \leq 1$.
1446 $s$ is called the order parameter and $\eta$ the asymmetry of the
1447 order tensor $\SSS$. When the molecule tumbles isotropically in the
1448 solvent, $s$ is zero, and no orientational effects can be observed
1449 because all $\delta_i$ are zero.
1450
1451 %\newpage
1452
1453 \subsubsection{Calculating orientations in a simulation}
1454 For reasons which are explained below, the $\DD$ matrices are calculated
1455 which respect to a reference orientation of the molecule. The orientation
1456 is defined by a rotation matrix $\RR$, which is needed to least-squares fit
1457 the current coordinates of a selected set of atoms onto
1458 a reference conformation. The reference conformation is the starting
1459 conformation of the simulation. In case of ensemble averaging, which will
1460 be treated later, the structure is taken from the first subsystem.
1461 The calculated $\DD_i^c$ matrix is given by:
1462 \begin{equation}
1463 \label{D_rot}
1464 \DD_i^c(t) = \RR(t) \DD_i(t) \RR^T(t)
1465 \end{equation}
1466 The calculated orientation for vector $i$ is given by:
1467 \beq
1468 \delta^c_i(t) = \frac{2}{3} \mbox{tr}(\SSS(t)\DD_i^c(t))
1469 \eeq
1470 The order tensor $\SSS(t)$ is usually unknown.
1471 A reasonable choice for the order tensor is the tensor
1472 which minimizes the (weighted) mean square difference between the calculated
1473 and the observed orientations:
1474 \begin{equation}
1475 \label{S_msd}
1476 MSD(t) = \left(\sum_{i=1}^N w_i\right)^{-1} \sum_{i=1}^N w_i (\delta_i^c (t) -\delta_i^{exp})^2
1477 \end{equation}
1478 To properly combine different types of measurements, the unit of $w_i$ should
1479 be such that all terms are dimensionless. This means the unit of $w_i$
1480 is the unit of $\delta_i$ to the power $-2$.
1481 {\bf Note} that scaling all $w_i$ with a constant factor does not influence
1482 the order tensor.
1483
1484 \subsubsection{Time averaging}
1485 Since the tensors $\DD_i$ fluctuate rapidly in time, much faster than can
1486 be observed in an experiment, they should be averaged over time in the simulation.
1487 However, in a simulation the time and the number of copies of
1488 a molecule are limited. Usually one can not obtain a converged average
1489 of the $\DD_i$ tensors over all orientations of the molecule.
1490 If one assumes that the average orientations of the $\ve{r}_i$ vectors
1491 within the molecule converge much faster than the tumbling time of
1492 the molecule, the tensor can be averaged in an axis system that 
1493 rotates with the molecule, as expressed by equation~(\ref{D_rot}).
1494 The time-averaged tensors are calculated
1495 using an exponentially decaying memory function:
1496 \beq
1497 \DD^a_i(t) = \frac{\displaystyle
1498 \int_{u=t_0}^t \DD^c_i(u) \exp\left(-\frac{t-u}{\tau}\right)\mbox{d} u
1499 }{\displaystyle
1500 \int_{u=t_0}^t \exp\left(-\frac{t-u}{\tau}\right)\mbox{d} u
1501 }
1502 \eeq
1503 Assuming that the order tensor $\SSS$ fluctuates slower than the
1504 $\DD_i$, the time-averaged orientation can be calculated as:
1505 \beq
1506 \delta_i^a(t) = \frac{2}{3} \mbox{tr}(\SSS(t) \DD_i^a(t))
1507 \eeq
1508 where the order tensor $\SSS(t)$ is calculated using expression~(\ref{S_msd})
1509 with $\delta_i^c(t)$ replaced by $\delta_i^a(t)$.
1510
1511 \subsubsection{Restraining}
1512 The simulated structure can be restrained by applying a force proportional
1513 to the difference between the calculated and the experimental orientations.
1514 When no time averaging is applied, a proper potential can be defined as:
1515 \beq
1516 V = \frac{1}{2} k \sum_{i=1}^N w_i (\delta_i^c (t) -\delta_i^{exp})^2
1517 \eeq
1518 where the unit of $k$ is the unit of energy.
1519 Thus the effective force constant for restraint $i$ is $k w_i$.
1520 The forces are given by minus the gradient of $V$.
1521 The force $\ve{F}\!_i$ working on vector $\ve{r}_i$ is:
1522 \begin{eqnarray*}
1523 \ve{F}\!_i(t) 
1524 & = & - \frac{\mbox{d} V}{\mbox{d}\ve{r}_i} \\
1525 & = & -k w_i (\delta_i^c (t) -\delta_i^{exp}) \frac{\mbox{d} \delta_i (t)}{\mbox{d}\ve{r}_i} \\
1526 & = & -k w_i (\delta_i^c (t) -\delta_i^{exp})
1527 \frac{2 c_i}{\|\ve{r}\|^{2+\alpha}} \left(2 \RR^T \SSS \RR \ve{r}_i - \frac{2+\alpha}{\|\ve{r}\|^2} \mbox{tr}(\RR^T \SSS \RR \ve{r}_i \ve{r}_i^T) \ve{r}_i \right)
1528 \end{eqnarray*}
1529
1530 \subsubsection{Ensemble averaging}
1531 Ensemble averaging can be applied by simulating a system of $M$ subsystems
1532 that each contain an identical set of orientation restraints. The systems only
1533 interact via the orientation restraint potential which is defined as:
1534 \beq
1535 V = M \frac{1}{2} k \sum_{i=1}^N w_i 
1536 \langle \delta_i^c (t) -\delta_i^{exp} \rangle^2
1537 \eeq
1538 The force on vector $\ve{r}_{i,m}$ in subsystem $m$ is given by:
1539 \beq
1540 \ve{F}\!_{i,m}(t) = - \frac{\mbox{d} V}{\mbox{d}\ve{r}_{i,m}} =
1541 -k w_i \langle \delta_i^c (t) -\delta_i^{exp} \rangle \frac{\mbox{d} \delta_{i,m}^c (t)}{\mbox{d}\ve{r}_{i,m}} \\
1542 \eeq 
1543
1544 \subsubsection{Time averaging}
1545 When using time averaging it is not possible to define a potential.
1546 We can still define a quantity that gives a rough idea of the energy
1547 stored in the restraints:
1548 \beq
1549 V = M \frac{1}{2} k^a \sum_{i=1}^N w_i 
1550 \langle \delta_i^a (t) -\delta_i^{exp} \rangle^2
1551 \eeq
1552 The force constant $k_a$ is switched on slowly to compensate for the
1553 lack of history at times close to $t_0$. It is exactly proportional
1554 to the amount of average that has been accumulated:
1555 \beq
1556 k^a =
1557  k \, \frac{1}{\tau}\int_{u=t_0}^t \exp\left(-\frac{t-u}{\tau}\right)\mbox{d} u
1558 \eeq
1559 What really matters is the definition of the force. It is chosen to
1560 be proportional to the square root of the product of the time-averaged
1561 and the instantaneous deviation.
1562 Using only the time-averaged deviation induces large oscillations.
1563 The force is given by:
1564 \beq
1565 \ve{F}\!_{i,m}(t) =
1566 %\left\{ \begin{array}{ll}
1567 %0 & \mbox{for} \quad \langle \delta_i^a (t) -\delta_i^{exp} \rangle \langle \delta_i (t) -\delta_i^{exp} \rangle \leq 0 \\
1568 %... & \mbox{for} \quad \langle \delta_i^a (t) -\delta_i^{exp} \rangle \langle \delta_i (t) -\delta_i^{exp} \rangle > 0 
1569 %\end{array}
1570 %\right.
1571 \left\{ \begin{array}{ll}
1572 0 & \quad \mbox{for} \quad a\, b \leq 0 \\
1573 \displaystyle
1574 k^a w_i \frac{a}{|a|} \sqrt{a\, b} \, \frac{\mbox{d} \delta_{i,m}^c (t)}{\mbox{d}\ve{r}_{i,m}}
1575 & \quad \mbox{for} \quad a\, b > 0 
1576 \end{array}
1577 \right.
1578 \eeq
1579 \begin{eqnarray*}
1580 a &=& \langle \delta_i^a (t) -\delta_i^{exp} \rangle \\
1581 b &=& \langle \delta_i^c (t) -\delta_i^{exp} \rangle
1582 \end{eqnarray*}
1583
1584 \subsubsection{Using orientation restraints}
1585 Orientation restraints can be added to a molecule definition in
1586 the topology file in the section {\tt [~orientation_restraints~]}.
1587 Here we give an example section containing five N-H residual dipolar
1588 coupling restraints:
1589
1590 \begin{verbatim}
1591 [ orientation_restraints ]
1592 ; ai   aj  type  exp.  label  alpha    const.     obs.   weight
1593 ;                                Hz      nm^3       Hz    Hz^-2
1594   31   32     1     1      3      3     6.083    -6.73      1.0
1595   43   44     1     1      4      3     6.083    -7.87      1.0
1596   55   56     1     1      5      3     6.083    -7.13      1.0
1597   65   66     1     1      6      3     6.083    -2.57      1.0
1598   73   74     1     1      7      3     6.083    -2.10      1.0
1599 \end{verbatim}
1600
1601 The unit of the observable is Hz, but one can choose any other unit.
1602 In columns {\tt
1603 ai} and {\tt aj} you find the atom numbers of the particles to be
1604 restrained. The {\tt type} column should always be 1.
1605 The {\tt exp.} column denotes the experiment number, starting
1606 at 1. For each experiment a separate order tensor $\SSS$
1607 is optimized. The label should be a unique number larger than zero
1608 for each restraint. The {\tt alpha} column contains the power $\alpha$ 
1609 that is used in equation~(\ref{orient_def}) to calculate the orientation.
1610 The {\tt const.} column contains the constant $c_i$ used in the same
1611 equation. The constant should have the unit of the observable times
1612 nm$^\alpha$. The column {\tt obs.} contains the observable, in any
1613 unit you like. The last column contains the weights $w_i$; the unit
1614 should be the inverse of the square of the unit of the observable.
1615
1616 Some parameters for orientation restraints can be specified in the
1617 {\tt grompp.mdp} file, for a study of the effect of different
1618 force constants and averaging times and ensemble averaging see~\cite{Hess2003}.
1619 %} % Brace matches ifthenelse test for gmxlite
1620
1621 %\ifthenelse{\equal{\gmxlite}{1}}{}{
1622 \section{Polarization}
1623 Polarization can be treated by {\gromacs} by attaching
1624 \normindex{shell} (\normindex{Drude}) particles to atoms and/or
1625 virtual sites. The energy of the shell particle is then minimized at
1626 each time step in order to remain on the Born-Oppenheimer surface.
1627
1628 \subsection{Simple polarization}
1629 This is merely a harmonic potential with equilibrium distance 0.
1630
1631 \subsection{Water polarization}
1632 A special potential for water that allows anisotropic polarization of
1633 a single shell particle~\cite{Maaren2001a}.
1634
1635 \subsection{Thole polarization}
1636 Based on early work by \normindex{Thole}~\cite{Thole81}, Roux and
1637 coworkers have implemented potentials for molecules like
1638 ethanol~\cite{Lamoureux2003a,Lamoureux2003b,Noskov2005a}. Within such
1639 molecules, there are intra-molecular interactions between shell
1640 particles, however these must be screened because full Coulomb would
1641 be too strong. The potential between two shell particles $i$ and $j$ is:
1642 \newcommand{\rbij}{\bar{r}_{ij}}
1643 \beq
1644 V_{thole} ~=~ \frac{q_i q_j}{r_{ij}}\left[1-\left(1+\frac{\rbij}{2}\right){\rm exp}^{-\rbij}\right]
1645 \eeq
1646 {\bf Note} that there is a sign error in Equation~1 of Noskov {\em et al.}~\cite{Noskov2005a}:
1647 \beq
1648 \rbij ~=~ a\frac{r_{ij}}{(\alpha_i \alpha_j)^{1/6}}
1649 \eeq
1650 where $a$ is a magic (dimensionless) constant, usually chosen to be
1651 2.6~\cite{Noskov2005a}; $\alpha_i$ and $\alpha_j$ are the polarizabilities
1652 of the respective shell particles.
1653
1654 %} % Brace matches ifthenelse test for gmxlite
1655
1656 %\ifthenelse{\equal{\gmxlite}{1}}{}{
1657 \section{Free energy interactions}
1658 \label{sec:feia}
1659 \index{free energy interactions}
1660 \newcommand{\LAM}{\lambda}
1661 \newcommand{\LL}{(1-\LAM)}
1662 \newcommand{\dvdl}[1]{\frac{\partial #1}{\partial \LAM}}
1663 This section describes the $\lambda$-dependence of the potentials
1664 used for free energy calculations (see \secref{fecalc}).
1665 All common types of potentials and constraints can be
1666 interpolated smoothly from state A ($\lambda=0$) to state B
1667 ($\lambda=1$) and vice versa.
1668 All bonded interactions are interpolated by linear interpolation
1669 of the interaction parameters. Non-bonded interactions can be
1670 interpolated linearly or via soft-core interactions.
1671
1672 Starting in {\gromacs} 4.6, $\lambda$ is a vector, allowing different
1673 components of the free energy transformation to be carried out at
1674 different rates.  Coulomb, Lennard-Jones, bonded, and restraint terms
1675 can all be controlled independently, as described in the {\tt .mdp}
1676 options.
1677
1678 \subsubsection{Harmonic potentials}
1679 The example given here is for the bond potential, which is harmonic
1680 in {\gromacs}. However,  these equations apply to the angle potential
1681 and the improper dihedral potential as well.
1682 \bea
1683 V_b     &=&\half\left[\LL k_b^A + 
1684                 \LAM k_b^B\right] \left[b - \LL b_0^A - \LAM b_0^B\right]^2  \\
1685 \dvdl{V_b}&=&\half(k_b^B-k_b^A)
1686                 \left[b - \LL b_0^A + \LAM b_0^B\right]^2 + 
1687                 \nonumber\\
1688         & & \phantom{\half}(b_0^A-b_0^B) \left[b - \LL b_0^A -\LAM b_0^B\right]
1689                 \left[\LL k_b^A + \LAM k_b^B \right]
1690 \eea
1691
1692 \subsubsection{\gromosv{96} bonds and angles}
1693 Fourth-power bond stretching and cosine-based angle potentials
1694 are interpolated by linear interpolation of the force constant
1695 and the equilibrium position. Formulas are not given here.
1696
1697 \subsubsection{Proper dihedrals}
1698 For the proper dihedrals, the equations are somewhat more complicated:
1699 \bea
1700 V_d     &=&\left[\LL k_d^A + \LAM k_d^B \right]
1701         \left( 1+ \cos\left[n_{\phi} \phi - 
1702                     \LL \phi_s^A - \LAM \phi_s^B
1703                     \right]\right)\\
1704 \dvdl{V_d}&=&(k_d^B-k_d^A) 
1705          \left( 1+ \cos
1706                  \left[
1707                     n_{\phi} \phi- \LL \phi_s^A - \LAM \phi_s^B
1708                  \right]
1709          \right) +
1710          \nonumber\\
1711         &&(\phi_s^B - \phi_s^A) \left[\LL k_d^A - \LAM k_d^B\right] 
1712         \sin\left[  n_{\phi}\phi - \LL \phi_s^A - \LAM \phi_s^B \right]
1713 \eea
1714 {\bf Note:} that the multiplicity $n_{\phi}$ can not be parameterized
1715 because the function should remain periodic on the interval $[0,2\pi]$.
1716
1717 \subsubsection{Tabulated bonded interactions}
1718 For tabulated bonded interactions only the force constant can interpolated:
1719 \bea
1720       V  &=& (\LL k^A + \LAM k^B) \, f \\
1721 \dvdl{V} &=& (k^B - k^A) \, f
1722 \eea
1723
1724 \subsubsection{Coulomb interaction}
1725 The \normindex{Coulomb} interaction between two particles 
1726 of which the charge varies with $\LAM$ is:
1727 \bea
1728 V_c &=& \frac{f}{\epsrf \rij}\left[\LL q_i^A q_j^A + \LAM\, q_i^B q_j^B\right] \\
1729 \dvdl{V_c}&=& \frac{f}{\epsrf \rij}\left[- q_i^A q_j^A + q_i^B q_j^B\right]
1730 \eea
1731 where $f = \frac{1}{4\pi \varepsilon_0} = 138.935\,485$ (see \chref{defunits}).
1732
1733 \subsubsection{Coulomb interaction with \normindex{reaction field}}
1734 The Coulomb interaction including a reaction field, between two particles 
1735 of which the charge varies with $\LAM$ is:
1736 \bea
1737 V_c     &=& f\left[\frac{1}{\rij} + k_{rf}~ \rij^2 -c_{rf}\right]
1738              \left[\LL q_i^A q_j^A + \LAM\, q_i^B q_j^B\right] \\
1739 \dvdl{V_c}&=& f\left[\frac{1}{\rij} + k_{rf}~ \rij^2 -c_{rf}\right]
1740                \left[- q_i^A q_j^A + q_i^B q_j^B\right]
1741                \label{eq:dVcoulombdlambda}
1742 \eea
1743 {\bf Note} that the constants $k_{rf}$ and $c_{rf}$ are 
1744 defined using the dielectric 
1745 constant $\epsrf$ of the medium (see \secref{coulrf}).
1746
1747 \subsubsection{Lennard-Jones interaction}
1748 For the \normindex{Lennard-Jones} interaction between two particles 
1749 of which the {\em atom type} varies with $\LAM$ we can write:
1750 \bea
1751 V_{LJ}  &=&     \frac{\LL C_{12}^A + \LAM\, C_{12}^B}{\rij^{12}} -
1752                 \frac{\LL C_6^A + \LAM\, C_6^B}{\rij^6}   \\
1753 \dvdl{V_{LJ}}&=&\frac{C_{12}^B - C_{12}^A}{\rij^{12}} -
1754                 \frac{C_6^B - C_6^A}{\rij^6}
1755                 \label{eq:dVljdlambda}
1756 \eea
1757 It should be noted that it is also possible to express a pathway from
1758 state A to state B using $\sigma$ and $\epsilon$ (see \eqnref{sigeps}).
1759 It may seem to make sense physically to vary the force field parameters
1760 $\sigma$ and $\epsilon$ rather 
1761 than the derived parameters $C_{12}$ and $C_{6}$.
1762 However, the difference between the pathways in parameter space
1763 is not large, and the free energy itself
1764 does not depend on the pathway, so we use the simple formulation
1765 presented above.
1766
1767 \subsubsection{Kinetic Energy}
1768 When the mass of a particle changes, there is also a contribution of
1769 the kinetic energy to the free energy (note that we can not write 
1770 the momentum \ve{p} as m\ve{v}, since that would result 
1771 in the sign of $\dvdl{E_k}$ being incorrect~\cite{Gunsteren98a}):
1772
1773 \bea
1774 E_k      &=&     \half\frac{\ve{p}^2}{\LL m^A + \LAM m^B}        \\
1775 \dvdl{E_k}&=&    -\half\frac{\ve{p}^2(m^B-m^A)}{(\LL m^A + \LAM m^B)^2}
1776 \eea
1777 after taking the derivative, we {\em can} insert \ve{p} = m\ve{v}, such that:
1778 \beq
1779 \dvdl{E_k}~=~    -\half\ve{v}^2(m^B-m^A)
1780 \eeq
1781
1782 \subsubsection{Constraints}
1783 \label{subsubsec:constraints}
1784 The constraints are formally part of the Hamiltonian, and therefore
1785 they give a contribution to the free energy. In {\gromacs} this can be
1786 calculated using the \normindex{LINCS} or the \normindex{SHAKE} algorithm.
1787 If we have $k = 1 \ldots K$ constraint equations $g_k$ for LINCS, then
1788 \beq
1789 g_k     =       |\ve{r}_{k}| - d_{k}
1790 \eeq
1791 where $\ve{r}_k$ is the displacement vector between two particles and 
1792 $d_k$ is the constraint distance between the two particles. We can express
1793 the fact that the constraint distance has a $\LAM$ dependency by
1794 \beq
1795 d_k     =       \LL d_{k}^A + \LAM d_k^B
1796 \eeq
1797
1798 Thus the $\LAM$-dependent constraint equation is
1799 \beq
1800 g_k     =       |\ve{r}_{k}| - \left(\LL d_{k}^A + \LAM d_k^B\right).
1801 \eeq
1802
1803 The (zero) contribution $G$ to the Hamiltonian from the constraints
1804 (using Lagrange multipliers $\lambda_k$, which are logically distinct
1805 from the free-energy $\LAM$) is
1806 \bea
1807 G           &=&     \sum^K_k \lambda_k g_k    \\
1808 \dvdl{G}    &=&     \frac{\partial G}{\partial d_k} \dvdl{d_k} \\
1809             &=&     - \sum^K_k \lambda_k \left(d_k^B-d_k^A\right)
1810 \eea
1811
1812 For SHAKE, the constraint equations are
1813 \beq
1814 g_k     =       \ve{r}_{k}^2 - d_{k}^2
1815 \eeq
1816 with $d_k$ as before, so
1817 \bea
1818 \dvdl{G}    &=&     -2 \sum^K_k \lambda_k \left(d_k^B-d_k^A\right)
1819 \eea
1820
1821 \subsection{Soft-core interactions\index{soft-core interactions}}
1822 \begin{figure}
1823 \centerline{\includegraphics[height=6cm]{plots/softcore}}
1824 \caption{Soft-core interactions at $\LAM=0.5$, with $p=2$ and
1825 $C_6^A=C_{12}^A=C_6^B=C_{12}^B=1$.}
1826 \label{fig:softcore}
1827 \end{figure}
1828 In a free-energy calculation where particles grow out of nothing, or 
1829 particles disappear, using the the simple linear interpolation of the 
1830 Lennard-Jones and Coulomb potentials as described in Equations~\ref{eq:dVljdlambda}
1831 and \ref{eq:dVcoulombdlambda} may lead to poor convergence.  When the particles have nearly disappeared, or are close to appearing (at $\LAM$ close to 0 or 1), the interaction energy will be weak enough for particles to get very 
1832 close to each other, leading to large fluctuations in the measured values of 
1833 $\partial V/\partial \LAM$ (which, because of the simple linear 
1834 interpolation, depends on the potentials at both the endpoints of $\LAM$).
1835
1836 To circumvent these problems, the singularities in the potentials need to be removed. This can be done by modifying the regular Lennard-Jones and Coulomb potentials with ``soft-core'' potentials that limit the energies and forces 
1837 involved at $\LAM$ values between 0 and 1, but not \emph{at} $\LAM=0$ 
1838 or 1.
1839
1840 In {\gromacs} the soft-core potentials $V_{sc}$ are shifted versions of the
1841 regular potentials, so that the singularity in the potential and its
1842 derivatives at $r=0$ is never reached:
1843 \bea
1844 V_{sc}(r) &=& \LL V^A(r_A) + \LAM V^B(r_B)
1845     \\
1846 r_A &=& \left(\alpha \sigma_A^6 \LAM^p + r^6 \right)^\frac{1}{6}
1847     \\
1848 r_B &=& \left(\alpha \sigma_B^6 \LL^p + r^6 \right)^\frac{1}{6}
1849 \eea
1850 where $V^A$ and $V^B$ are the normal ``hard core'' Van der Waals or
1851 electrostatic potentials in state A ($\LAM=0$) and state B ($\LAM=1$)
1852 respectively, $\alpha$ is the soft-core parameter (set with {\tt sc_alpha} 
1853 in the {\tt .mdp} file), $p$ is the soft-core $\LAM$ power (set with 
1854 {\tt sc_power}), $\sigma$ is the radius of the interaction, which is 
1855 $(C_{12}/C_6)^{1/6}$ or an input parameter ({\tt sc_sigma}) when $C_6$ 
1856 or $C_{12}$ is zero.
1857
1858 For intermediate $\LAM$, $r_A$ and $r_B$ alter the interactions very little
1859 for $r > \alpha^{1/6} \sigma$ and quickly switch the soft-core
1860 interaction to an almost constant value for smaller $r$ (\figref{softcore}). 
1861 The force is:
1862 \beq
1863 F_{sc}(r) = -\frac{\partial V_{sc}(r)}{\partial r} =
1864  \LL F^A(r_A) \left(\frac{r}{r_A}\right)^5 +
1865 \LAM F^B(r_B) \left(\frac{r}{r_B}\right)^5
1866 \eeq
1867 where $F^A$ and $F^B$ are the ``hard core'' forces.
1868 The contribution to the derivative of the free energy is:
1869 \bea
1870 \dvdl{V_{sc}(r)} & = &
1871  V^B(r_B) -V^A(r_A)  + 
1872         \LL \frac{\partial V^A(r_A)}{\partial r_A}
1873                    \frac{\partial r_A}{\partial \LAM} + 
1874         \LAM\frac{\partial V^B(r_B)}{\partial r_B}
1875                    \frac{\partial r_B}{\partial \LAM}
1876 \nonumber\\
1877 &=&
1878  V^B(r_B) -V^A(r_A)  + \nonumber \\
1879  & &
1880  \frac{p \alpha}{6}
1881        \left[ \LAM F^B(r_B) r^{-5}_B \sigma_B^6 \LL^{p-1} -
1882                \LL F^A(r_A) r^{-5}_A \sigma_A^6 \LAM^{p-1} \right]
1883 \eea
1884
1885 The original GROMOS Lennard-Jones soft-core function~\cite{Beutler94}
1886 uses $p=2$, but $p=1$ gives a smoother $\partial H/\partial\LAM$ curve.
1887 %When the changes between the two states involve both the disappearing
1888 %and appearing of atoms, it is important that the overlapping of atoms
1889 %happens around $\LAM=0.5$. This can usually be achieved with
1890 %$\alpha$$\approx0.7$ for $p=1$ and $\alpha$$\approx1.5$ for $p=2$.
1891 %MRS: this is now eliminated as of 4.6, since changes between atoms are done linearly.
1892
1893 Another issue that should be considered is the soft-core effect of hydrogens
1894 without Lennard-Jones interaction. Their soft-core $\sigma$ is
1895 set with {\tt sc-sigma} in the {\tt .mdp} file. These hydrogens
1896 produce peaks in $\partial H/\partial\LAM$ at $\LAM$ is 0 and/or 1 for $p=1$
1897 and close to 0 and/or 1 with $p=2$. Lowering {\tt\mbox{sc-sigma}} will decrease
1898 this effect, but it will also increase the interactions with hydrogens
1899 relative to the other interactions in the soft-core state.
1900
1901 When soft-core potentials are selected (by setting {\tt sc-alpha} \textgreater
1902 0), and the Coulomb and Lennard-Jones potentials are turned on or off
1903 sequentially, then the Coulombic interaction is turned off linearly,
1904 rather than using soft-core interactions, which should be less
1905 statistically noisy in most cases. This behavior can be overwritten
1906 by using the mdp option {\tt sc-coul} to {\tt yes}. Note that the {\tt sc-coul}
1907 is only taken into account when lambda states are used, not with
1908 {\tt couple-lambda0/couple-lambda1}, and you can still turn off soft-core
1909 interactions by setting {\tt sc-alpha=0}. Additionally, the soft-core
1910 interaction potential is only applied when either the A or B
1911 state has zero interaction potential. If both A and B states have
1912 nonzero interaction potential, default linear scaling described above
1913 is used. When both Coulombic and Lennard-Jones interactions are turned
1914 off simultaneously, a soft-core potential is used, and a hydrogen is
1915 being introduced or deleted, the sigma is set to {\tt sc-sigma-min},
1916 which itself defaults to {\tt sc-sigma-default}.
1917
1918 Recently, a new formulation of the soft-core approach has been derived
1919 that in most cases gives lower and more even statistical variance than
1920 the standard soft-core path described above.~\cite{Pham2011,Pham2012}
1921 Specifically, we have:
1922 \bea
1923 V_{sc}(r) &=& \LL V^A(r_A) + \LAM V^B(r_B)
1924     \\
1925 r_A &=& \left(\alpha \sigma_A^{48} \LAM^p + r^{48} \right)^\frac{1}{48}
1926     \\
1927 r_B &=& \left(\alpha \sigma_B^{48} \LL^p + r^{48} \right)^\frac{1}{48}
1928 \eea
1929 This ``1-1-48'' path is also implemented in {\gromacs}. Note that for this path the soft core $\alpha$
1930 should satisfy $0.001 < \alpha < 0.003$, rather than $\alpha \approx
1931 0.5$.
1932
1933 %} % Brace matches ifthenelse test for gmxlite
1934
1935 %\ifthenelse{\equal{\gmxlite}{1}}{}{
1936 \section{Methods}
1937 \subsection{Exclusions and 1-4 Interactions.}
1938 Atoms within a molecule that are close by in the chain, 
1939 {\ie} atoms that are covalently bonded, or linked by one or two
1940 atoms are called {\em first neighbors, second neighbors} and 
1941 {\em \swapindex{third}{neighbor}s}, respectively (see \figref{chain}).  
1942 Since the interactions of atom {\bf i} with atoms {\bf i+1} and {\bf i+2} 
1943 are mainly quantum mechanical, they can not be modeled by a Lennard-Jones potential.
1944 Instead it is assumed that these interactions are adequately modeled
1945 by a harmonic bond term or constraint ({\bf i, i+1}) and a harmonic angle term
1946 ({\bf i, i+2}). The first and second neighbors (atoms {\bf i+1} and {\bf i+2}) 
1947 are therefore
1948 {\em excluded} from the Lennard-Jones \swapindex{interaction}{list} 
1949 of atom {\bf i};
1950 atoms {\bf i+1} and {\bf i+2} are called {\em \normindex{exclusions}} of atom {\bf i}.
1951
1952 \begin{figure}
1953 \centerline{\includegraphics[width=8cm]{plots/chain}}
1954 \caption{Atoms along an alkane chain.}
1955 \label{fig:chain}
1956 \end{figure}
1957
1958 For third neighbors, the normal Lennard-Jones repulsion is sometimes
1959 still too strong, which means that when applied to a molecule, the
1960 molecule would deform or break due to the internal strain. This is
1961 especially the case for carbon-carbon interactions in a {\em
1962 cis}-conformation ({\eg} {\em cis}-butane).  Therefore, for some of these
1963 interactions, the Lennard-Jones repulsion has been reduced in the
1964 {\gromos} force field, which is implemented by keeping a separate list of
1965 1-4 and normal Lennard-Jones parameters. In other force fields, such
1966 as OPLS~\cite{Jorgensen88}, the standard Lennard-Jones parameters are reduced
1967 by a factor of two, but in that case also the dispersion (r$^{-6}$)
1968 and the Coulomb interaction are scaled.
1969 {\gromacs} can use either of these methods.
1970
1971 \subsection{Charge Groups\index{charge group}}
1972 \label{sec:cg}
1973 In principle, the force calculation in MD is an $O(N^2)$ problem.
1974 Therefore, we apply a \normindex{cut-off} for non-bonded force (NBF)
1975 calculations; only the particles within a certain distance of each
1976 other are interacting. This reduces the cost to $O(N)$ (typically
1977 $100N$ to $200N$) of the NBF. It also introduces an error, which is,
1978 in most cases, acceptable, except when applying the cut-off implies
1979 the creation of charges, in which case you should consider using the
1980 lattice sum methods provided by {\gromacs}.
1981
1982 Consider a water molecule interacting with another atom. If we would apply
1983 a plain cut-off on an atom-atom basis we might include the atom-oxygen
1984 interaction (with a charge of $-0.82$) without the compensating charge
1985 of the protons, and as a result, induce a large dipole moment over the system.
1986 Therefore, we have to keep groups of atoms with total charge
1987 0 together. These groups are called {\em charge groups}. Note that with
1988 a proper treatment of long-range electrostatics (e.g. particle-mesh Ewald
1989 (\secref{pme}), keeping charge groups together is not required.
1990
1991 \subsection{Treatment of Cut-offs in the group scheme\index{cut-off}}
1992 \newcommand{\rs}{$r_{short}$}
1993 \newcommand{\rl}{$r_{long}$}
1994 {\gromacs} is quite flexible in treating cut-offs, which implies
1995 there can be quite a number of parameters to set. These parameters are
1996 set in the input file for {\tt grompp}. There are two sort of parameters
1997 that affect the cut-off interactions; you can select which type
1998 of interaction to use in each case, and which cut-offs should be
1999 used in the neighbor searching.
2000
2001 For both Coulomb and van der Waals interactions there are interaction
2002 type selectors (termed {\tt vdwtype} and {\tt coulombtype}) and two
2003 parameters, for a total of six non-bonded interaction parameters. See
2004 the User Guide for a complete description of these parameters.
2005
2006 The neighbor searching (NS) can be performed using a single-range, or a twin-range 
2007 approach. Since the former is merely a special case of the latter, we will 
2008 discuss the more general twin-range. In this case, NS is described by two
2009 radii: {\tt rlist} and max({\tt rcoulomb},{\tt rvdw}).
2010 Usually one builds the neighbor list every 10 time steps
2011 or every 20 fs (parameter {\tt nstlist}). In the neighbor list, all interaction 
2012 pairs that  fall within {\tt rlist} are stored. Furthermore, the 
2013 interactions between pairs that do not
2014 fall within {\tt rlist} but do fall within max({\tt rcoulomb},{\tt rvdw})
2015 are computed during NS.  The
2016 forces and energy are stored separately and added to short-range forces
2017 at every time step between successive NS. If {\tt rlist} = 
2018 max({\tt rcoulomb},{\tt rvdw}), no forces
2019 are evaluated during neighbor list generation.
2020 The \normindex{virial} is calculated from the sum of the short- and
2021 long-range forces.
2022 This means that the virial can be slightly asymmetrical at non-NS steps.
2023 When mdrun is compiled to use mixed precision, the virial is almost always asymmetrical because the
2024 off-diagonal elements are about as large as each element in the sum.
2025 In most cases this is not really a problem, since the fluctuations in the
2026 virial can be 2 orders of magnitude larger than the average.
2027
2028 Except for the plain cut-off,
2029 all of the interaction functions in \tabref{funcparm}
2030 require that neighbor searching be done with a larger radius than the $r_c$
2031 specified for the functional form, because of the use of charge groups.
2032 The extra radius is typically of the order of 0.25 nm (roughly the 
2033 largest distance between two atoms in a charge group plus the distance a 
2034 charge group can diffuse within neighbor list updates).
2035
2036 %If your charge groups are very large it may be interesting to turn off charge
2037 %groups, by setting the option 
2038 %{\tt bAtomList = yes} in your {\tt grompp.mdp} file.
2039 %In this case only a small extra radius to account for diffusion needs to be 
2040 %added (0.1 nm). Do not however use this together with the plain cut-off
2041 %method, as it will generate large artifacts (\secref{cg}).
2042 %In summary, there are four parameters that describe NS behavior:
2043 %{\tt nstlist} (update frequency in number of time steps),
2044 %{\tt bAtomList} (whether or not charge groups are used to generate neighbor list, the default is to use charge groups, so {\tt bAtomList = no}),
2045 %{\tt rshort} and {\tt rlong} which are the two radii {\rs} and {\rl}
2046 %described above.
2047
2048 \begin{table}[ht]
2049 \centering
2050 \begin{tabular}{|ll|l|}
2051 \dline
2052 \multicolumn{2}{|c|}{Type}              & Parameters            \\
2053 \hline
2054 Coulomb&Plain cut-off   & $r_c$, $\epsr$        \\
2055 &Reaction field         & $r_c$, $\epsrf$       \\
2056 &Shift function         & $r_1$, $r_c$, $\epsr$         \\
2057 &Switch function        & $r_1$, $r_c$, $\epsr$         \\
2058 \hline
2059 VdW&Plain cut-off       & $r_c$         \\
2060 &Shift function         & $r_1$, $r_c$          \\
2061 &Switch function        & $r_1$, $r_c$          \\
2062 \dline
2063 \end{tabular}
2064 \caption[Parameters for the different functional forms of the
2065 non-bonded interactions.]{Parameters for the different functional
2066 forms of the non-bonded interactions.}
2067 \label{tab:funcparm}
2068 \end{table}
2069 %} % Brace matches ifthenelse test for gmxlite
2070
2071
2072 \newcommand{\vvis}{\ve{r}_s}
2073 \newcommand{\Fi}{\ve{F}_i'}
2074 \newcommand{\Fj}{\ve{F}_j'}
2075 \newcommand{\Fk}{\ve{F}_k'}
2076 \newcommand{\Fl}{\ve{F}_l'}
2077 \newcommand{\Fvis}{\ve{F}_{s}}
2078 \newcommand{\rvik}{\ve{r}_{ik}}
2079 \newcommand{\rvis}{\ve{r}_{is}}
2080 \newcommand{\rvjk}{\ve{r}_{jk}}
2081 \newcommand{\rvjl}{\ve{r}_{jl}}
2082
2083 %\ifthenelse{\equal{\gmxlite}{1}}{}{
2084 \section{Virtual interaction sites\index{virtual interaction sites}}
2085 \label{sec:virtual_sites}
2086 Virtual interaction sites (called \seeindex{dummy atoms}{virtual interaction sites} in {\gromacs} versions before 3.3)
2087 can be used in {\gromacs} in a number of ways. 
2088 We write the position of the virtual site $\ve{r}_s$ as a function of
2089 the positions of other particles \ve{r}$_i$: $\ve{r}_s =
2090 f(\ve{r}_1..\ve{r}_n)$. The virtual site, which may carry charge or be
2091 involved in other interactions, can now be used in the force
2092 calculation.  The force acting on the virtual site must be
2093 redistributed over the particles with mass in a consistent way.
2094 A good way to do this can be found in ref.~\cite{Berendsen84b}.
2095 We can write the potential energy as:
2096 \beq
2097 V = V(\vvis,\ve{r}_1,\ldots,\ve{r}_n) = V^*(\ve{r}_1,\ldots,\ve{r}_n)
2098 \eeq
2099 The force on the particle $i$ is then:
2100 \beq
2101 \ve{F}_i = -\frac{\partial V^*}{\partial \ve{r}_i} 
2102          = -\frac{\partial V}{\partial \ve{r}_i} - 
2103             \frac{\partial V}{\partial \vvis} 
2104             \frac{\partial \vvis}{\partial \ve{r}_i}
2105          = \ve{F}_i^{direct} + \Fi
2106 \eeq
2107 The first term is the normal force. 
2108 The second term is the force on particle $i$ due to the virtual site, which
2109 can be written in tensor notation:
2110 \newcommand{\partd}[2]{\displaystyle\frac{\partial #1}{\partial #2_i}}
2111 \beq
2112 \Fi = \left[\begin{array}{ccc}
2113 \partd{x_s}{x} & \partd{y_s}{x} & \partd{z_s}{x}        \\[1ex]
2114 \partd{x_s}{y} & \partd{y_s}{y} & \partd{z_s}{y}        \\[1ex]
2115 \partd{x_s}{z} & \partd{y_s}{z} & \partd{z_s}{z}
2116 \end{array}\right]\Fvis
2117 \label{eqn:fvsite}
2118 \eeq
2119 where $\Fvis$ is the force on the virtual site and $x_s$, $y_s$ and
2120 $z_s$ are the coordinates of the virtual site. In this way, the total
2121 force and the total torque are conserved~\cite{Berendsen84b}.
2122
2123 The computation of the \normindex{virial}
2124 (\eqnref{Xi}) is non-trivial when virtual sites are used. Since the
2125 virial involves a summation over all the atoms (rather than virtual
2126 sites), the forces must be redistributed from the virtual sites to the
2127 atoms (using ~\eqnref{fvsite}) {\em before} computation of the
2128 virial. In some special cases where the forces on the atoms can be
2129 written as a linear combination of the forces on the virtual sites (types 2
2130 and 3 below) there is no difference between computing the virial
2131 before and after the redistribution of forces.  However, in the
2132 general case redistribution should be done first.
2133
2134 \begin{figure}
2135 \centerline{\includegraphics[width=15cm]{plots/dummies}}
2136 \caption[Virtual site construction.]{The six different types of virtual
2137 site construction in \protect{\gromacs}. The constructing atoms are
2138 shown as black circles, the virtual sites in gray.}
2139 \label{fig:vsites}
2140 \end{figure}
2141
2142 There are six ways to construct virtual sites from surrounding atoms in
2143 {\gromacs}, which we classify by the number of constructing
2144 atoms. {\bf Note} that all site types mentioned can be constructed from
2145 types 3fd (normalized, in-plane) and 3out (non-normalized, out of
2146 plane). However, the amount of computation involved increases sharply
2147 along this list, so we strongly recommended using the first adequate
2148 virtual site type that will be sufficient for a certain purpose.
2149 \figref{vsites} depicts 6 of the available virtual site constructions.
2150 The conceptually simplest construction types are linear combinations:
2151 \beq
2152 \vvis = \sum_{i=1}^N w_i \, \ve{r}_i
2153 \eeq
2154 The force is then redistributed using the same weights:
2155 \beq
2156 \Fi = w_i \, \Fvis
2157 \eeq
2158
2159 The types of virtual sites supported in {\gromacs} are given in the list below.
2160 Constructing atoms in virtual sites can be virtual sites themselves, but
2161 only if they are higher in the list, i.e. virtual sites can be
2162 constructed from ``particles'' that are simpler virtual sites.
2163 \begin{itemize}
2164 \item[{\bf\sf 2.}]\label{subsec:vsite2}As a linear combination of two atoms
2165         (\figref{vsites} 2):
2166 \beq
2167         w_i = 1 - a ~,~~ w_j = a
2168 \eeq
2169         In this case the virtual site is on the line through atoms $i$ and
2170         $j$.
2171
2172 \item[{\bf\sf 3.}]\label{subsec:vsite3}As a linear combination of three atoms
2173         (\figref{vsites} 3):
2174 \beq
2175         w_i = 1 - a - b ~,~~ w_j = a ~,~~ w_k = b
2176 \eeq
2177         In this case the virtual site is in the plane of the other three
2178         particles.
2179
2180 \item[{\bf\sf 3fd.}]\label{subsec:vsite3fd}In the plane of three atoms, with a fixed distance
2181         (\figref{vsites} 3fd):
2182 \beq
2183         \vvis ~=~ \ve{r}_i + b \frac{  \rvij + a \rvjk  }
2184                                     {| \rvij + a \rvjk |}      
2185 \eeq
2186         In this case the virtual site is in the plane of the other three
2187         particles at a distance of $|b|$ from $i$.
2188         The force on particles $i$, $j$ and $k$ due to the force on the virtual
2189         site can be computed as:
2190 \beq
2191         \begin{array}{lcr}
2192         \Fi &=& \displaystyle \Fvis - \gamma ( \Fvis - \ve{p} ) \\[1ex]
2193         \Fj &=& \displaystyle (1-a)\gamma (\Fvis - \ve{p})      \\[1ex]
2194         \Fk &=& \displaystyle a \gamma (\Fvis - \ve{p})         \\
2195         \end{array}
2196         ~\mbox{~ where~ }~
2197         \begin{array}{c}
2198 \displaystyle \gamma = \frac{b}{| \rvij + a \rvjk |} \\[2ex]
2199 \displaystyle \ve{p} = \frac{ \rvis \cdot \Fvis }
2200                       { \rvis \cdot \rvis } \rvis
2201         \end{array}
2202 \eeq
2203
2204 \item[{\bf\sf 3fad.}]\label{subsec:vsite3fad}In the plane of three atoms, with a fixed angle and
2205         distance (\figref{vsites} 3fad):
2206 \beq
2207 \label{eqn:vsite2fad-F}
2208          \vvis ~=~ \ve{r}_i +
2209                     d \cos \theta \frac{\rvij}{|\rvij|} +
2210                     d \sin \theta \frac{\ve{r}_\perp}{|\ve{r}_\perp|}
2211         ~\mbox{~ where~ }~
2212         \ve{r}_\perp ~=~ \rvjk - 
2213                         \frac{ \rvij \cdot \rvjk }
2214                              { \rvij \cdot \rvij }
2215                          \rvij
2216 \eeq
2217         In this case the virtual site is in the plane of the other three
2218         particles at a distance of $|d|$ from $i$ at an angle of
2219         $\alpha$ with $\rvij$. Atom $k$ defines the plane and the
2220         direction of the angle. {\bf Note} that in this case $b$ and
2221         $\alpha$ must be specified, instead of $a$ and $b$ (see also
2222         \secref{vsitetop}). The force on particles $i$, $j$ and $k$
2223         due to the force on the virtual site can be computed as (with
2224         $\ve{r}_\perp$ as defined in \eqnref{vsite2fad-F}):
2225 \newcommand{\dfrac}{\displaystyle\frac}
2226 \beq
2227 \begin{array}{c}
2228         \begin{array}{lclllll}
2229         \Fi &=& \Fvis &-& 
2230                 \dfrac{d \cos \theta}{|\rvij|} \ve{F}_1 &+&
2231                 \dfrac{d \sin \theta}{|\ve{r}_\perp|} \left( 
2232                 \dfrac{ \rvij \cdot \rvjk }
2233                      { \rvij \cdot \rvij } \ve{F}_2     +
2234                 \ve{F}_3 \right)                                \\[3ex]
2235         \Fj &=& &&
2236                 \dfrac{d \cos \theta}{|\rvij|} \ve{F}_1 &-&
2237                 \dfrac{d \sin \theta}{|\ve{r}_\perp|} \left(
2238                  \ve{F}_2 + 
2239                  \dfrac{ \rvij \cdot \rvjk }
2240                         { \rvij \cdot \rvij } \ve{F}_2 +
2241                 \ve{F}_3 \right)                                \\[3ex]
2242         \Fk &=& && &&
2243                 \dfrac{d \sin \theta}{|\ve{r}_\perp|} \ve{F}_2  \\[3ex]
2244         \end{array}                                             \\[5ex]
2245         \mbox{where ~}
2246         \ve{F}_1 = \Fvis -
2247                   \dfrac{ \rvij \cdot \Fvis }
2248                         { \rvij \cdot \rvij } \rvij
2249         \mbox{\,, ~}
2250         \ve{F}_2 = \ve{F}_1 -
2251                   \dfrac{ \ve{r}_\perp \cdot \Fvis }
2252                         { \ve{r}_\perp \cdot \ve{r}_\perp } \ve{r}_\perp
2253         \mbox{~and ~}
2254         \ve{F}_3 = \dfrac{ \rvij \cdot \Fvis }
2255                          { \rvij \cdot \rvij } \ve{r}_\perp
2256 \end{array}
2257 \eeq
2258
2259 \item[{\bf\sf 3out.}]\label{subsec:vsite3out}As a non-linear combination of three atoms, out of plane
2260         (\figref{vsites} 3out):
2261 \beq
2262         \vvis ~=~ \ve{r}_i + a \rvij + b \rvik +
2263                 c (\rvij \times \rvik)
2264 \eeq
2265         This enables the construction of virtual sites out of the plane of the
2266         other atoms.
2267         The force on particles $i,j$ and $k$ due to the force on the virtual
2268         site can be computed as:
2269 \beq
2270 \begin{array}{lcl}
2271 \vspace{4mm}
2272 \Fj &=& \left[\begin{array}{ccc}
2273  a              &  -c\,z_{ik}   & c\,y_{ik}     \\[0.5ex]
2274  c\,z_{ik}      &   a           & -c\,x_{ik}    \\[0.5ex]
2275 -c\,y_{ik}      &   c\,x_{ik}   & a
2276 \end{array}\right]\Fvis                                 \\
2277 \vspace{4mm}
2278 \Fk &=& \left[\begin{array}{ccc}
2279  b              &   c\,z_{ij}   & -c\,y_{ij}    \\[0.5ex]
2280 -c\,z_{ij}      &   b           & c\,x_{ij}     \\[0.5ex]
2281  c\,y_{ij}      &  -c\,x_{ij}   & b
2282 \end{array}\right]\Fvis                                 \\
2283 \Fi &=& \Fvis - \Fj - \Fk
2284 \end{array}
2285 \eeq
2286
2287 \item[{\bf\sf 4fdn.}]\label{subsec:vsite4fdn}From four atoms, with a fixed distance, see separate Fig.\ \ref{fig:vsite-4fdn}.
2288 This construction is a bit
2289 complex, in particular since the previous type (4fd) could be unstable which forced us
2290 to introduce a more elaborate construction:
2291
2292 \begin{figure}
2293 \centerline{\includegraphics[width=5cm]{plots/vsite-4fdn}}
2294 \caption {The new 4fdn virtual site construction, which is stable even when all constructing
2295 atoms are in the same plane.}
2296 \label{fig:vsite-4fdn}
2297 \end{figure}
2298          
2299 \begin{eqnarray}
2300 \mathbf{r}_{ja} &=& a\, \mathbf{r}_{ik} - \mathbf{r}_{ij} = a\, (\mathbf{x}_k - \mathbf{x}_i) - (\mathbf{x}_j - \mathbf{x}_i) \nonumber \\
2301 \mathbf{r}_{jb} &=& b\, \mathbf{r}_{il} - \mathbf{r}_{ij} = b\, (\mathbf{x}_l - \mathbf{x}_i) - (\mathbf{x}_j - \mathbf{x}_i) \nonumber \\
2302 \mathbf{r}_m &=& \mathbf{r}_{ja} \times \mathbf{r}_{jb} \nonumber \\
2303 \mathbf{x}_s &=& \mathbf{x}_i + c \frac{\mathbf{r}_m}{|\mathbf{r}_m|}
2304 \label{eq:vsite}
2305 \end{eqnarray}
2306
2307         In this case the virtual site is at a distance of $|c|$ from $i$, while $a$ and $b$ are 
2308         parameters. {\bf Note} that the vectors $\mathbf{r}_{ik}$ and $\mathbf{r}_{ij}$ are not normalized
2309         to save floating-point operations.
2310         The force on particles $i$, $j$, $k$ and $l$ due to the force 
2311         on the virtual site are computed through chain rule derivatives
2312         of the construction expression. This is exact and conserves energy,
2313         but it does lead to relatively lengthy expressions that we do not
2314         include here (over 200 floating-point operations). The interested reader can 
2315         look at the source code in \verb+vsite.c+. Fortunately, this vsite type is normally
2316         only used for chiral centers such as $C_{\alpha}$ atoms in proteins.
2317       
2318 The new 4fdn construct is identified with a `type' value of 2 in the topology. The earlier 4fd
2319 type is still supported internally (`type' value 1), but it should not be used for
2320 new simulations. All current {\gromacs} tools will automatically generate type 4fdn instead.
2321
2322
2323 \item[{\bf\sf N.}]\label{subsec:vsiteN} A linear combination of $N$ atoms with relative
2324 weights $a_i$. The weight for atom $i$ is:
2325 \beq
2326   w_i = a_i \left(\sum_{j=1}^N a_j \right)^{-1}
2327 \eeq
2328 There are three options for setting the weights:
2329 \begin{itemize}
2330 \item[COG] center of geometry: equal weights
2331 \item[COM] center of mass: $a_i$ is the mass of atom $i$;
2332 when in free-energy simulations the mass of the atom is changed,
2333 only the mass of the A-state is used for the weight
2334 \item[COW] center of weights: $a_i$ is defined by the user
2335 \end{itemize}
2336
2337 \end{itemize}
2338 %} % Brace matches ifthenelse test for gmxlite
2339
2340 \newcommand{\dr}{{\rm d}r}
2341 \newcommand{\avcsix}{\left< C_6 \right>}
2342
2343 %\ifthenelse{\equal{\gmxlite}{1}}{}{
2344 \section{Long Range Electrostatics}
2345 \label{sec:lr_elstat}
2346 \subsection{Ewald summation\index{Ewald sum}}
2347 \label{sec:ewald}
2348 The total electrostatic energy of $N$ particles and their periodic
2349 images\index{periodic boundary conditions} is given by
2350 \begin{equation}
2351 V=\frac{f}{2}\sum_{n_x}\sum_{n_y}
2352 \sum_{n_{z}*} \sum_{i}^{N} \sum_{j}^{N}
2353 \frac{q_i q_j}{{\bf r}_{ij,{\bf n}}}.
2354 \label{eqn:totalcoulomb}
2355 \end{equation}
2356 $(n_x,n_y,n_z)={\bf n}$ is the box index vector, and the star indicates that
2357 terms with $i=j$ should be omitted when $(n_x,n_y,n_z)=(0,0,0)$. The
2358 distance ${\bf r}_{ij,{\bf n}}$ is the real distance between the charges and
2359 not the minimum-image. This sum is conditionally convergent, but
2360 very slow.
2361
2362 Ewald summation was first introduced as a method to calculate
2363 long-range interactions of the periodic images in
2364 crystals~\cite{Ewald21}. The idea is to convert the single
2365 slowly-converging sum \eqnref{totalcoulomb} into two
2366 quickly-converging terms and a constant term:
2367 \begin{eqnarray}
2368 V &=& V_{\mathrm{dir}} + V_{\mathrm{rec}} + V_{0} \\[0.5ex]
2369 V_{\mathrm{dir}} &=& \frac{f}{2} \sum_{i,j}^{N}
2370 \sum_{n_x}\sum_{n_y}
2371 \sum_{n_{z}*} q_i q_j \frac{\mbox{erfc}(\beta {r}_{ij,{\bf n}} )}{{r}_{ij,{\bf n}}} \\[0.5ex]
2372 V_{\mathrm{rec}} &=& \frac{f}{2 \pi V} \sum_{i,j}^{N} q_i q_j
2373 \sum_{m_x}\sum_{m_y}
2374 \sum_{m_{z}*} \frac{\exp{\left( -(\pi {\bf m}/\beta)^2 + 2 \pi i
2375       {\bf m} \cdot ({\bf r}_i - {\bf r}_j)\right)}}{{\bf m}^2} \\[0.5ex]
2376 V_{0} &=& -\frac{f \beta}{\sqrt{\pi}}\sum_{i}^{N} q_i^2,
2377 \end{eqnarray}
2378 where $\beta$ is a parameter that determines the relative weight of the
2379 direct and reciprocal sums and ${\bf m}=(m_x,m_y,m_z)$.
2380 In this way we can use a short cut-off (of the order of $1$~nm) in the direct space sum and a
2381 short cut-off in the reciprocal space sum ({\eg} 10 wave vectors in each
2382 direction). Unfortunately, the computational cost of the reciprocal
2383 part of the sum increases as $N^2$
2384 (or $N^{3/2}$ with a slightly better algorithm) and it is therefore not
2385 realistic for use in large systems.
2386
2387 \subsubsection{Using Ewald}
2388 Don't use Ewald unless you are absolutely sure this is what you want -
2389 for almost all cases the PME method below will perform much better.
2390 If you still want to employ classical Ewald summation enter this in
2391 your {\tt .mdp} file, if the side of your box is about $3$~nm:
2392
2393 \begin{verbatim}
2394 coulombtype     = Ewald
2395 rvdw            = 0.9
2396 rlist           = 0.9
2397 rcoulomb        = 0.9
2398 fourierspacing  = 0.6
2399 ewald-rtol      = 1e-5
2400 \end{verbatim}
2401
2402 The ratio of the box dimensions and the {\tt fourierspacing} parameter determines
2403 the highest magnitude of wave vectors $m_x,m_y,m_z$ to use in each
2404 direction. With a 3-nm cubic box this example would use $11$ wave vectors
2405 (from $-5$ to $5$) in each direction.  The {\tt ewald-rtol} parameter
2406 is the relative strength of the electrostatic interaction at the
2407 cut-off. Decreasing this gives you a more accurate direct sum, but a
2408 less accurate reciprocal sum.
2409
2410 \subsection{\normindex{PME}}
2411 \label{sec:pme}
2412 Particle-mesh Ewald is a method proposed by Tom
2413 Darden~\cite{Darden93} to improve the performance of the
2414 reciprocal sum. Instead of directly summing wave vectors, the charges
2415 are assigned to a grid using interpolation. The implementation in
2416 {\gromacs} uses cardinal B-spline interpolation~\cite{Essmann95},
2417 which is referred to as smooth PME (SPME).
2418 The grid is then Fourier transformed with a 3D FFT algorithm and the
2419 reciprocal energy term obtained by a single sum over the grid in
2420 k-space.
2421
2422 The potential at the grid points is calculated by inverse
2423 transformation, and by using the interpolation factors we get the
2424 forces on each atom.
2425
2426 The PME algorithm scales as $N \log(N)$, and is substantially faster
2427 than ordinary Ewald summation on medium to large systems. On very
2428 small systems it might still be better to use Ewald to avoid the
2429 overhead in setting up grids and transforms.
2430 For the parallelization of PME see the section on MPMD PME (\ssecref{mpmd_pme}).
2431
2432 With the Verlet cut-off scheme, the PME direct space potential is
2433 shifted by a constant such that the potential is zero at the
2434 cut-off. This shift is small and since the net system charge is close
2435 to zero, the total shift is very small, unlike in the case of the
2436 Lennard-Jones potential where all shifts add up. We apply the shift
2437 anyhow, such that the potential is the exact integral of the force.
2438
2439 \subsubsection{Using PME}
2440 As an example for using Particle-mesh Ewald summation in {\gromacs}, specify the
2441 following lines in your {\tt .mdp} file:
2442
2443 \begin{verbatim}
2444 coulombtype     = PME
2445 rvdw            = 0.9
2446 rlist           = 0.9
2447 rcoulomb        = 0.9
2448 fourierspacing  = 0.12
2449 pme-order       = 4
2450 ewald-rtol      = 1e-5
2451 \end{verbatim}
2452
2453 In this case the {\tt fourierspacing} parameter determines the maximum
2454 spacing for the FFT grid (i.e. minimum number of grid points),
2455 and {\tt pme-order} controls the
2456 interpolation order. Using fourth-order (cubic) interpolation and this
2457 spacing should give electrostatic energies accurate to about
2458 $5\cdot10^{-3}$. Since the Lennard-Jones energies are not this
2459 accurate it might even be possible to increase this spacing slightly.
2460
2461 Pressure scaling works with PME, but be aware of the fact that
2462 anisotropic scaling can introduce artificial ordering in some systems.
2463
2464 \subsection{\normindex{P3M-AD}}
2465 \label{sec:pppm}
2466 The \seeindex{Particle-Particle Particle-Mesh}{P3M} methods of
2467 Hockney \& Eastwood can also be applied in {\gromacs} for the
2468 treatment of long range electrostatic interactions~\cite{Hockney81}.
2469 Although the P3M method was the first efficient long-range electrostatics
2470 method for molecular simulation, the smooth PME (SPME) method has largely
2471 replaced P3M as the method of choice in atomistic simulations. One performance
2472 disadvantage of the original P3M method was that it required 3 3D-FFT
2473 back transforms to obtain the forces on the particles. But this is not
2474 required for P3M and the forces can be derived through analytical differentiation
2475 of the potential, as done in PME. The resulting method is termed P3M-AD.
2476 The only remaining difference between P3M-AD and PME is the optimization
2477 of the lattice Green influence function for error minimization that P3M uses.
2478 However, in 2012 it has been shown that the SPME influence function can be
2479 modified to obtain P3M~\cite{Ballenegger2012}.
2480 This means that the advantage of error minimization in P3M-AD can be used
2481 at the same computational cost and with the same code as PME,
2482 just by adding a few lines to modify the influence function.
2483 However, at optimal parameter setting the effect of error minimization
2484 in P3M-AD is less than 10\%. P3M-AD does show large accuracy gains with
2485 interlaced (also known as staggered) grids, but that is not supported
2486 in {\gromacs} (yet).
2487
2488 P3M is used in {\gromacs} with exactly the same options as used with PME
2489 by selecting the electrostatics type:
2490 \begin{verbatim}
2491 coulombtype     = P3M-AD
2492 \end{verbatim}
2493
2494 \subsection{Optimizing Fourier transforms and PME calculations}
2495 It is recommended to optimize the parameters for calculation of
2496 electrostatic interaction such as PME grid dimensions and cut-off radii.
2497 This is particularly relevant to do before launching long production runs.
2498
2499 {\gromacs} includes a special tool, {\tt g_tune_pme}, which automates the 
2500 process of selecting the optimal size of the grid and number of PME-only
2501 notes.
2502
2503 %
2504 % Temporarily removed since I am not sure about the state of the testlr
2505 % program...
2506 %
2507 %It is possible to test the accuracy of your settings using the program
2508 %{\tt\normindex{testlr}} in the {\tt src/gmxlib} dir. This program computes
2509 %forces and potentials using PPPM and an Ewald implementation and gives the
2510 %absolute and RMS errors in both:
2511 %\begin{verbatim}
2512 %ERROR ANALYSIS
2513 %Error:         Max Abs         RMS
2514 %Force            1.132       0.251
2515 %Potential        0.113       0.035
2516 %\end{verbatim}
2517 %{\bf Note:} these numbers were generated using a grid spacing of
2518 %0.058 nm and $r_c$ = 1.0 nm.
2519 %
2520 %You can see what the accuracy is without optimizing the
2521 %$\hat{G}(k)$ function, if you pass the {\tt -ghat} option to {\tt
2522 %testlr}. Try it if you think the {\tt mk_ghat} procedure is a waste
2523 %of time.
2524 %} % Brace matches ifthenelse test for gmxlite
2525
2526
2527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2529 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2530
2531 %\ifthenelse{\equal{\gmxlite}{1}}{}{
2532 \section{Long Range Van der Waals interactions}
2533 \subsection{Dispersion correction\index{dispersion correction}}
2534 In this section, we derive long-range corrections due to the use of a
2535 cut-off for Lennard-Jones or Buckingham interactions.
2536 We assume that the cut-off is
2537 so long that the repulsion term can safely be neglected, and therefore
2538 only the dispersion term is taken into account. Due to the nature of
2539 the dispersion interaction (we are truncating a potential proportional
2540 to $-r^{-6}$), energy and pressure corrections are both negative. While
2541 the energy correction is usually small, it may be important for free
2542 energy calculations where differences between two different Hamiltonians
2543 are considered. In contrast, the pressure correction is very large and
2544 can not be neglected under any circumstances where a correct pressure is
2545 required, especially for any NPT simulations. Although it is, in
2546 principle, possible to parameterize a force field such that the pressure
2547 is close to the desired experimental value without correction, such a
2548 method makes the parameterization dependent on the cut-off and is therefore
2549 undesirable.
2550
2551 \subsubsection{Energy}
2552 \label{sec:ecorr}
2553 The long-range contribution of the dispersion interaction to the
2554 virial can be derived analytically, if we assume a homogeneous
2555 system beyond the cut-off distance $r_c$. The dispersion energy
2556 between two particles is written as:
2557 \beq
2558 V(\rij) ~=~- C_6\,\rij^{-6}
2559 \eeq
2560 and the corresponding force is:
2561 \beq
2562 \Fvij ~=~- 6\,C_6\,\rij^{-8}\rvij
2563 \eeq
2564 In a periodic system it is not easy to calculate the full potentials,
2565 so usually a cut-off is applied, which can be abrupt or smooth.
2566 We will call the potential and force with cut-off $V_c$ and $\ve{F}_c$.
2567 The long-range contribution to the dispersion energy
2568 in a system with $N$ particles and particle density $\rho$ = $N/V$ is:
2569 \beq
2570 \label{eqn:enercorr}
2571 V_{lr} ~=~ \half N \rho\int_0^{\infty}   4\pi r^2 g(r) \left( V(r) -V_c(r) \right) {\dr}
2572 \eeq
2573 We will integrate this for the shift function, which is the most general
2574 form of van der Waals interaction available in {\gromacs}.
2575 The shift function has a constant difference $S$ from 0 to $r_1$
2576 and is 0 beyond the cut-off distance $r_c$.
2577 We can integrate \eqnref{enercorr}, assuming that the density in the sphere
2578 within $r_1$ is equal to the global density and
2579 the radial distribution function $g(r)$ is 1 beyond $r_1$:
2580 \bea
2581 \nonumber
2582 V_{lr}  &=& \half N \left(
2583   \rho\int_0^{r_1}  4\pi r^2 g(r) \, C_6 \,S\,{\dr}
2584 + \rho\int_{r_1}^{r_c}  4\pi r^2 \left( V(r) -V_c(r) \right) {\dr}
2585 + \rho\int_{r_c}^{\infty}  4\pi r^2 V(r) \, {\dr}
2586 \right) \\
2587 & = & \half N \left(\left(\frac{4}{3}\pi \rho r_1^{3} - 1\right) C_6 \,S
2588 + \rho\int_{r_1}^{r_c} 4\pi r^2 \left( V(r) -V_c(r) \right) {\dr}
2589 -\frac{4}{3} \pi N \rho\, C_6\,r_c^{-3}
2590 \right)
2591 \eea
2592 where the term $-1$ corrects for the self-interaction.
2593 For a plain cut-off we only need to assume that $g(r)$ is 1 beyond $r_c$
2594 and the correction reduces to~\cite{Allen87}:
2595 \bea
2596 V_{lr} & = & -\frac{2}{3} \pi N \rho\, C_6\,r_c^{-3}
2597 \eea
2598 If we consider, for example, a box of pure water, simulated with a cut-off
2599 of 0.9 nm and a density of 1 g cm$^{-3}$ this correction is
2600 $-0.75$ kJ mol$^{-1}$ per molecule.
2601
2602 For a homogeneous mixture we need to define
2603 an {\em average dispersion constant}:
2604 \beq
2605 \label{eqn:avcsix}
2606 \avcsix = \frac{2}{N(N-1)}\sum_i^N\sum_{j>i}^N C_6(i,j)\\
2607 \eeq
2608 In {\gromacs}, excluded pairs of atoms do not contribute to the average.
2609
2610 In the case of inhomogeneous simulation systems, {\eg} a system with a
2611 lipid interface, the energy correction can be applied if
2612 $\avcsix$ for both components is comparable.
2613
2614 \subsubsection{Virial and pressure}
2615 The scalar virial of the system due to the dispersion interaction between
2616 two particles $i$ and $j$ is given by:
2617 \beq
2618 \Xi~=~-\half \rvij \cdot \Fvij ~=~ 3\,C_6\,\rij^{-6}
2619 \eeq
2620 The pressure is given by:
2621 \beq
2622 P~=~\frac{2}{3\,V}\left(E_{kin} - \Xi\right)
2623 \eeq
2624 The long-range correction to the virial is given by:
2625 \beq
2626 \Xi_{lr} ~=~ \half N \rho \int_0^{\infty} 4\pi r^2 g(r) (\Xi -\Xi_c) \,\dr
2627 \eeq
2628 We can again integrate the long-range contribution to the
2629 virial assuming $g(r)$ is 1 beyond $r_1$:
2630 \bea
2631 \Xi_{lr}&=&     \half N \rho \left(
2632     \int_{r_1}^{r_c}  4 \pi r^2 (\Xi -\Xi_c)  \,\dr
2633   + \int_{r_c}^{\infty} 4 \pi r^2 3\,C_6\,\rij^{-6}\,  \dr
2634 \right) \nonumber\\
2635         &=&     \half N \rho \left(
2636     \int_{r_1}^{r_c} 4 \pi r^2 (\Xi -\Xi_c) \, \dr
2637   + 4 \pi C_6 \, r_c^{-3} \right)
2638 \eea
2639 For a plain cut-off the correction to the pressure is~\cite{Allen87}:
2640 \beq
2641 P_{lr}~=~-\frac{4}{3} \pi C_6\, \rho^2 r_c^{-3}
2642 \eeq
2643 Using the same example of a water box, the correction to the virial is
2644 0.75 kJ mol$^{-1}$ per molecule,
2645 the corresponding correction to the pressure for 
2646 SPC water is approximately $-280$ bar.
2647
2648 For homogeneous mixtures, we can again use the average dispersion constant
2649 $\avcsix$ (\eqnref{avcsix}):
2650 \beq
2651 P_{lr}~=~-\frac{4}{3} \pi \avcsix \rho^2 r_c^{-3}
2652 \label{eqn:pcorr}
2653 \eeq
2654 For inhomogeneous systems, \eqnref{pcorr} can be applied under the same
2655 restriction as holds for the energy (see \secref{ecorr}).
2656
2657 \subsection{Lennard-Jones PME\index{LJ-PME}}
2658
2659 In order to treat systems, using Lennard-Jones potentials, that are
2660 non-homogeneous outside of the cut-off distance, we can instead use
2661 the Particle-mesh Ewald method as discussed for electrostatics above.
2662 In this case the modified Ewald equations become
2663 \begin{eqnarray}
2664 V &=& V_{\mathrm{dir}} + V_{\mathrm{rec}} + V_{0} \\[0.5ex]
2665 V_{\mathrm{dir}} &=& -\frac{1}{2} \sum_{i,j}^{N}
2666 \sum_{n_x}\sum_{n_y}
2667 \sum_{n_{z}*} \frac{C^{ij}_6 g(\beta {r}_{ij,{\bf n}})}{{r_{ij,{\bf n}}}^6}
2668 \label{eqn:ljpmerealspace}\\[0.5ex]
2669 V_{\mathrm{rec}} &=& \frac{{\pi}^{\frac{3}{2}} \beta^{3}}{2V} \sum_{m_x}\sum_{m_y}\sum_{m_{z}*}
2670 f(\pi |{\mathbf m}|/\beta) \times \sum_{i,j}^{N} C^{ij}_6 {\mathrm{exp}}\left[-2\pi i {\bf m}\cdot({\bf r_i}-{\bf r_j})\right] \\[0.5ex]
2671 V_{0} &=& -\frac{\beta^{6}}{12}\sum_{i}^{N} C^{ii}_6
2672 \end{eqnarray}
2673
2674 where ${\bf m}=(m_x,m_y,m_z)$, $\beta$ is the parameter determining the weight between
2675 direct and reciprocal space, and ${C^{ij}_6}$ is the combined dispersion
2676 parameter for particle $i$ and $j$. The star indicates that terms
2677 with $i = j$ should be omitted when $((n_x,n_y,n_z)=(0,0,0))$, and
2678 ${\bf r}_{ij,{\bf n}}$ is the real distance between the particles.
2679 Following the derivation by Essmann~\cite{Essmann95}, the functions $f$ and $g$ introduced above are defined as
2680 \begin{eqnarray}
2681 f(x)&=&1/3\left[(1-2x^2){\mathrm{exp}}(-x^2) + 2{x^3}\sqrt{\pi}\,{\mathrm{erfc}}(x) \right] \\
2682 g(x)&=&{\mathrm{exp}}(-x^2)(1+x^2+\frac{x^4}{2}).
2683 \end{eqnarray}
2684
2685 The above methodology works fine as long as the dispersion parameters can be combined geometrically (\eqnref{comb}) in the same
2686 way as the charges for electrostatics
2687 \begin{equation}
2688 C^{ij}_{6,\mathrm{geom}} = \left(C^{ii}_6 \, C^{jj}_6\right)^{1/2}
2689 \end{equation}
2690 For Lorentz-Berthelot combination rules (\eqnref{lorentzberthelot}), the reciprocal part of this sum has to be calculated
2691 seven times due to the splitting of the dispersion parameter according to
2692 \begin{equation}
2693 C^{ij}_{6,\mathrm{L-B}} = (\sigma_i+\sigma_j)^6=\sum_{n=0}^{6} P_{n}\sigma_{i}^{n}\sigma_{j}^{(6-n)},
2694 \end{equation}
2695 for $P_{n}$ the Pascal triangle coefficients. This introduces a
2696 non-negligible cost to the reciprocal part, requiring seven separate
2697 FFTs, and therefore this has been the limiting factor in previous
2698 attempts to implement LJ-PME. A solution to this problem is to use
2699 geometrical combination rules in order to calculate an approximate
2700 interaction parameter for the reciprocal part of the potential,
2701 yielding a total interaction of
2702 \begin{eqnarray}
2703 V(r<r_c) & = & \underbrace{C^{\mathrm{dir}}_6 g(\beta r) r^{-6}}_{\mathrm{Direct \  space}} + \underbrace{C^\mathrm{recip}_{6,\mathrm{geom}} [1 - g(\beta r)] r^{-6}}_{\mathrm{Reciprocal \  space}} \nonumber \\
2704 &=& C^\mathrm{recip}_{6,\mathrm{geom}}r^{-6} + \left(C^{\mathrm{dir}}_6-C^\mathrm{recip}_{6,\mathrm{geom}}\right)g(\beta r)r^{-6} \\
2705 V(r>r_c) & = & \underbrace{C^\mathrm{recip}_{6,\mathrm{geom}} [1 - g(\beta r)] r^{-6}}_{\mathrm{Reciprocal \  space}}.
2706 \end{eqnarray}
2707 This will preserve a well-defined Hamiltonian and significantly increase
2708 the performance of the simulations. The approximation does introduce
2709 some errors, but since the difference is located in the interactions
2710 calculated in reciprocal space, the effect will be very small compared
2711 to the total interaction energy. In a simulation of a lipid bilayer,
2712 using a cut-off of 1.0 nm, the relative error in total dispersion
2713 energy was below 0.5\%. A more thorough discussion of this can be
2714 found in \cite{Wennberg13}.
2715
2716 In {\gromacs} we now perform the proper calculation of this interaction
2717 by subtracting, from the direct-space interactions, the contribution
2718 made by the approximate potential that is used in the reciprocal part
2719 \begin{equation}
2720 V_\mathrm{dir} = C^{\mathrm{dir}}_6 r^{-6} - C^\mathrm{recip}_6 [1 - g(\beta r)] r^{-6}.
2721 \label{eqn:ljpmedirectspace}
2722 \end{equation}
2723 This potential will reduce to the expression in \eqnref{ljpmerealspace} when $C^{\mathrm{dir}}_6 = C^\mathrm{recip}_6$, 
2724 and the total interaction is given by
2725 \begin{eqnarray}
2726 \nonumber V(r<r_c) &=& \underbrace{C^{\mathrm{dir}}_6 r^{-6} - C^\mathrm{recip}_6 [1 - g(\beta r)] r^{-6}}_{\mathrm{Direct \  space}} + \underbrace{C^\mathrm{recip}_6 [1 - g(\beta r)] r^{-6}}_{\mathrm{Reciprocal \  space}} \\ 
2727 &=&C^{\mathrm{dir}}_6 r^{-6}
2728 \label {eqn:ljpmecorr2} \\
2729 V(r>r_c) &=& C^\mathrm{recip}_6 [1 - g(\beta r)] r^{-6}.
2730 \end{eqnarray}
2731 For the case when $C^{\mathrm{dir}}_6 \neq C^\mathrm{recip}_6$ this
2732 will retain an unmodified LJ force up to the cut-off, and the error
2733 is an order of magnitude smaller than in simulations where the
2734 direct-space interactions do not account for the approximation used in
2735 reciprocal space. When using a VdW interaction modifier of
2736 potential-shift, the constant
2737 \begin{equation}
2738 \left(-C^{\mathrm{dir}}_6 + C^\mathrm{recip}_6 [1 - g(\beta r_c)]\right) r_c^{-6}
2739 \end{equation}
2740 is added to \eqnref{ljpmecorr2} in order to ensure that the potential
2741 is continuous at the cutoff. Note that, in the same way as \eqnref{ljpmedirectspace}, this degenerates into the
2742 expected $-C_6g(\beta r_c)r^{-6}_c$ when $C^{\mathrm{dir}}_6 =
2743 C^\mathrm{recip}_6$. In addition to this, a long-range dispersion
2744 correction can be applied to correct for the approximation using a
2745 combination rule in reciprocal space. This correction assumes, as for
2746 the cut-off LJ potential, a uniform particle distribution.  But since
2747 the error of the combination rule approximation is very small this
2748 long-range correction is not necessary in most cases. Also note that
2749 this homogenous correction does not correct the surface tension, which
2750 is an inhomogeneous property.
2751
2752 \subsubsection{Using LJ-PME}
2753 As an example for using Particle-mesh Ewald summation for Lennard-Jones interactions in {\gromacs}, specify the
2754 following lines in your {\tt .mdp} file:
2755 \begin{verbatim}
2756 vdwtype          = PME
2757 rvdw             = 0.9
2758 vdw-modifier     = Potential-Shift
2759 rlist            = 0.9
2760 rcoulomb         = 0.9
2761 fourierspacing   = 0.12
2762 pme-order        = 4
2763 ewald-rtol-lj    = 0.001
2764 lj-pme-comb-rule = geometric
2765 \end{verbatim}
2766
2767 The same Fourier grid and interpolation order are used if both
2768 LJ-PME and electrostatic PME are active, so the settings for
2769 {\tt fourierspacing} and {\tt pme-order} are common to both.
2770 {\tt ewald-rtol-lj} controls the
2771 splitting between direct and reciprocal space in the same way as
2772 {\tt ewald-rtol}.  In addition to this, the combination rule to be used
2773 in reciprocal space is determined by {\tt lj-pme-comb-rule}. If the
2774 current force field uses Lorentz-Berthelot combination rules, it is
2775 possible to set {\tt lj-pme-comb-rule = geometric} in order to gain a
2776 significant increase in performance for a small loss in accuracy. The
2777 details of this approximation can be found in the section above.
2778
2779 Note that the use of a complete long-range dispersion correction means
2780 that as with Coulomb PME, {\tt rvdw} is now a free parameter in the
2781 method, rather than being necessarily restricted by the force-field
2782 parameterization scheme. Thus it is now possible to optimize the
2783 cutoff, spacing, order and tolerance terms for accuracy and best
2784 performance.
2785
2786 Naturally, the use of LJ-PME rather than LJ cut-off adds computation
2787 and communication done for the reciprocal-space part, so for best
2788 performance in balancing the load of parallel simulations using
2789 PME-only ranks, more such ranks should be used. It may be possible to
2790 improve upon the automatic load-balancing used by {\tt mdrun}.
2791
2792 %} % Brace matches ifthenelse test for gmxlite
2793
2794 \section{Force field\index{force field}}
2795 \label{sec:ff}
2796 A force field is built up from two distinct components:
2797 \begin{itemize}
2798 \item The set of equations (called the {\em
2799     \index{potential function}s}) used to generate the potential
2800   energies and their derivatives, the forces. These are described in
2801   detail in the previous chapter.
2802 \item The parameters used in this set of equations. These are not
2803   given in this manual, but in the data files corresponding to your
2804   {\gromacs} distribution.
2805 \end{itemize}
2806 Within one set of equations various sets of parameters can be
2807 used. Care must be taken that the combination of equations and
2808 parameters form a consistent set. It is in general dangerous to make
2809 {\em ad hoc} changes in a subset of parameters, because the various
2810 contributions to the total force are usually interdependent. This
2811 means in principle that every change should be documented, verified by
2812 comparison to experimental data and published in a peer-reviewed
2813 journal before it can be used.
2814
2815 {\gromacs} {\gmxver} includes several force fields, and additional
2816 ones are available on the website. If you do not know which one to
2817 select we recommend \gromosv{96} for united-atom setups and OPLS-AA/L for
2818 all-atom parameters. That said, we describe the available options in
2819 some detail.
2820
2821 \subsubsection{All-hydrogen force field}
2822 The \gromosv{87}-based all-hydrogen force field is almost identical to the
2823 normal \gromosv{87} force field, since the extra hydrogens have no
2824 Lennard-Jones interaction and zero charge. The only differences are in
2825 the bond angle and improper dihedral angle terms. This force field is
2826 only useful when you need the exact hydrogen positions, for instance
2827 for distance restraints derived from NMR measurements. When citing
2828 this force field please read the previous paragraph.
2829
2830 \subsection{\gromosv{96}\index{GROMOS96 force field}}
2831 {\gromacs} supports the \gromosv{96} force fields~\cite{gromos96}.
2832 All parameters for the 43A1, 43A2 (development, improved alkane
2833 dihedrals), 45A3, 53A5, and 53A6 parameter sets are included.  All standard
2834 building blocks are included and topologies can be built automatically
2835 by {\tt pdb2gmx}.  
2836
2837 The \gromosv{96} force field is a further development of the \gromosv{87} force field.
2838 It has improvements over the \gromosv{87} force field for proteins and small molecules.
2839 {\bf Note} that the sugar parameters present in 53A6 do correspond to those published in 
2840 2004\cite{Oostenbrink2004}, which are different from those present in 45A4, which
2841 is not included in {\gromacs} at this time.  The 45A4 parameter set corresponds to a later
2842 revision of these parameters. 
2843 The \gromosv{96} force field is not, however, recommended for use with long alkanes and
2844 lipids.  The \gromosv{96} force field differs from the \gromosv{87}
2845 force field in a few respects:
2846 \begin{itemize}
2847 \item the force field parameters
2848 \item the parameters for the bonded interactions are not linked to atom types
2849 \item a fourth power bond stretching potential (\ssecref{G96bond})
2850 \item an angle potential based on the cosine of the angle (\ssecref{G96angle})
2851 \end{itemize}
2852 There are two differences in implementation between {\gromacs} and \gromosv{96}
2853 which can lead to slightly different results when simulating the same system
2854 with both packages: 
2855 \begin{itemize}
2856 \item in \gromosv{96} neighbor searching for solvents is performed on the
2857 first atom of the solvent molecule.  This is not implemented in {\gromacs},
2858 but the difference with searching by centers of charge groups is very small
2859 \item the virial in \gromosv{96} is molecule-based. This is not implemented in
2860 {\gromacs}, which uses atomic virials
2861 \end{itemize}
2862 The \gromosv{96} force field was parameterized with a Lennard-Jones cut-off
2863 of 1.4 nm, so be sure to use a Lennard-Jones cut-off ({\tt rvdw}) of at least 1.4.
2864 A larger cut-off is possible because the Lennard-Jones potential and forces
2865 are almost zero beyond 1.4 nm.
2866
2867 \subsubsection{\gromosv{96} files\swapindexquiet{GROMOS96}{files}}
2868 {\gromacs} can read and write \gromosv{96} coordinate and trajectory files.
2869 These files should have the extension {\tt .g96}.
2870 Such a file can be a \gromosv{96} initial/final
2871 configuration file, a coordinate trajectory file, or a combination of both.
2872 The file is fixed format; all floats are written as 15.9, and as such, files can get huge.
2873 {\gromacs} supports the following data blocks in the given order:
2874 \begin{itemize}
2875 \item Header block:
2876 \begin{verbatim}
2877 TITLE (mandatory)
2878 \end{verbatim}
2879
2880 \item Frame blocks:
2881 \begin{verbatim}
2882 TIMESTEP (optional)
2883 POSITION/POSITIONRED (mandatory)
2884 VELOCITY/VELOCITYRED (optional)
2885 BOX (optional)
2886 \end{verbatim}
2887
2888 \end{itemize}
2889 See the \gromosv{96} manual~\cite{gromos96} for a complete description
2890 of the blocks. {\bf Note} that all {\gromacs} programs can read compressed
2891 (.Z) or gzipped (.gz) files.
2892
2893 \subsection{OPLS/AA\index{OPLS/AA force field}}
2894
2895 \subsection{AMBER\index{AMBER force field}}
2896
2897 {\gromacs} provides native support for the following AMBER force fields:
2898
2899 \begin{itemize}
2900 \item AMBER94~\cite{Cornell1995}
2901 \item AMBER96~\cite{Kollman1996}
2902 \item AMBER99~\cite{Wang2000}
2903 \item AMBER99SB~\cite{Hornak2006}
2904 \item AMBER99SB-ILDN~\cite{Lindorff2010}
2905 \item AMBER03~\cite{Duan2003}
2906 \item AMBERGS~\cite{Garcia2002}
2907 \end{itemize}
2908
2909 \subsection{CHARMM\index{CHARMM force field}}
2910 \label{subsec:charmmff}
2911
2912 {\gromacs} supports the CHARMM force field for proteins~\cite{mackerell04, mackerell98}, lipids~\cite{feller00} and nucleic acids~\cite{foloppe00,Mac2000}. The protein parameters (and to some extent the lipid and nucleic acid parameters) were thoroughly tested -- both by comparing potential energies between the port and the standard parameter set in the CHARMM molecular simulation package, as well by how the protein force field behaves together with {\gromacs}-specific techniques such as virtual sites (enabling long time steps) and a fast implicit solvent recently implemented~\cite{Larsson10} -- and the details and results are presented in the paper by Bjelkmar et al.~\cite{Bjelkmar10}. The nucleic acid parameters, as well as the ones for HEME, were converted and tested by Michel Cuendet.
2913
2914 When selecting the CHARMM force field in {\tt \normindex{pdb2gmx}} the default option is to use \normindex{CMAP} (for torsional correction map). To exclude CMAP, use {\tt -nocmap}. The basic form of the CMAP term implemented in {\gromacs} is a function of the $\phi$ and $\psi$ backbone torsion angles. This term is defined in the {\tt .rtp} file by a {\tt [ cmap ]} statement at the end of each residue supporting CMAP. The following five atom names define the two torsional angles. Atoms 1-4 define $\phi$, and atoms 2-5 define $\psi$. The corresponding atom types are then matched to the correct CMAP type in the {\tt cmap.itp} file that contains the correction maps.
2915
2916 A port of the CHARMM36 force field for use with GROMACS is also available at \url{http://mackerell.umaryland.edu/charmm_ff.shtml#gromacs}.
2917
2918 \subsection{Coarse-grained force fields}
2919 \index{force-field, coarse-grained}
2920 \label{sec:cg-forcefields}
2921 Coarse-graining is a systematic way of reducing the number of degrees of freedom representing a system of interest. To achieve this, typically whole groups of atoms are represented by single beads and the coarse-grained force fields describes their effective interactions. Depending on the choice of parameterization, the functional form of such an interaction can be complicated and often tabulated potentials are used.
2922
2923 Coarse-grained models are designed to reproduce certain properties of a reference system. This can be either a full atomistic model or even experimental data. Depending on the properties to reproduce there are different methods to derive such force fields. An incomplete list of methods is given below:
2924 \begin{itemize}
2925 \item Conserving free energies
2926 \begin{itemize}
2927 \item Simplex method
2928 \item MARTINI force field (see next section)
2929 \end{itemize}
2930 \item Conserving distributions (like the radial distribution function), so-called structure-based coarse-graining
2931 \begin{itemize}
2932 \item (iterative) Boltzmann inversion
2933 \item Inverse Monte Carlo
2934 \end{itemize}
2935 \item Conversing forces
2936 \begin{itemize}
2937 \item Force matching
2938 \end{itemize}
2939 \end{itemize}
2940
2941 Note that coarse-grained potentials are state dependent (e.g. temperature, density,...) and should be re-parametrized depending on the system of interest and the simulation conditions. This can for example be done using the \normindex{Versatile Object-oriented Toolkit for Coarse-Graining Applications (VOTCA)}~\cite{ruehle2009}. The package was designed to assists in systematic coarse-graining, provides implementations for most of the algorithms mentioned above and has a well tested interface to {\gromacs}. It is available as open source and further information can be found at \href{http://www.votca.org}{www.votca.org}.
2942
2943 \subsection{MARTINI\index{Martini force field}}
2944
2945 The MARTINI force field is a coarse-grain parameter set that allows for the construction 
2946 of many systems, including proteins and membranes.
2947
2948 \subsection{PLUM\index{PLUM force field}}
2949
2950 The \normindex{PLUM force field}~\cite{bereau12} is an example of a solvent-free
2951 protein-membrane model for which the membrane was derived from structure-based
2952 coarse-graining~\cite{wang_jpcb10}.  A {\gromacs} implementation can be found at
2953 \href{http://code.google.com/p/plumx/}{code.google.com/p/plumx}. 
2954
2955 % LocalWords:  dihedrals centro ij dV dr LJ lj rcl jj Bertelot OPLS bh bham rf
2956 % LocalWords:  coul defunits grompp crf vcrf fcrf Tironi Debye kgrf cgrf krf dx
2957 % LocalWords:  PPPM der Waals erfc lr elstat chirality bstretch bondpot kT kJ
2958 % LocalWords:  anharmonic morse mol betaij expminx SPC timestep fs FENE ijk kj
2959 % LocalWords:  anglepot CHARMm UB ik rr substituents ijkl Ryckaert Bellemans rb
2960 % LocalWords:  alkanes pdb gmx IUPAC IUB jkl cis rbdih crb kcal cubicspline xvg
2961 % LocalWords:  topfile mdrun posres ar dihr lcllll NMR nmr lcllllll NOEs lclll
2962 % LocalWords:  rav preprocessor ccccccccc ai aj fac disre mdp multi topol tpr
2963 % LocalWords:  fc ravdisre nstdisreout dipolar lll ccc orientational MSD const
2964 % LocalWords:  orire fitgrp nstorireout Drude intra Noskov et al fecalc coulrf
2965 % LocalWords:  polarizabilities parameterized sigeps Ek sc softcore GROMOS NBF
2966 % LocalWords:  hydrogens alkane vdwtype coulombtype rlist rcoulomb rvdw
2967 % LocalWords:  nstlist virial funcparm VdW jk jl fvsite fd vsites lcr vsitetop
2968 % LocalWords:  vsite lclllll lcl parameterize parameterization enercorr avcsix
2969 % LocalWords:  pcorr ecorr totalcoulomb dir fourierspacing ewald rtol Darden gz
2970 % LocalWords:  FFT parallelization MPMD mpmd pme fft hoc Gromos gromos oxygens
2971 % LocalWords:  virials POSITIONRED VELOCITYRED gzipped Charmm Larsson Bjelkmar
2972 % LocalWords:  Cuendet CMAP nocmap dihedral Lennard covalent Verlet
2973 % LocalWords:  Berthelot nm flexwat ferguson itp harmonicangle versa
2974 % LocalWords:  harmonicbond atomtypes dihedraltypes equilibrated fdn
2975 % LocalWords:  distancerestraint LINCS Coulombic ja jb il SPME ILDN
2976 % LocalWords:  Hamiltonians atomtype AMBERGS rtp cmap graining VOTCA