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