Removed restriction of one reference pull group
[alexxy/gromacs.git] / manual / special.tex
1 % This file is part of the GROMACS molecular simulation package.
2 %
3 % Copyright (c) 2013, by the GROMACS development team, led by
4 % David van der Spoel, Berk Hess, Erik Lindahl, and including many
5 % others, as listed in the AUTHORS file in the top-level source
6 % directory and at http://www.gromacs.org.
7 %
8 % GROMACS is free software; you can redistribute it and/or
9 % modify it under the terms of the GNU Lesser General Public License
10 % as published by the Free Software Foundation; either version 2.1
11 % of the License, or (at your option) any later version.
12 %
13 % GROMACS is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 % Lesser General Public License for more details.
17 %
18 % You should have received a copy of the GNU Lesser General Public
19 % License along with GROMACS; if not, see
20 % http://www.gnu.org/licenses, or write to the Free Software Foundation,
21 % Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
22 %
23 % If you want to redistribute modifications to GROMACS, please
24 % consider that scientific software is very special. Version
25 % control is crucial - bugs must be traceable. We will be happy to
26 % consider code for inclusion in the official distribution, but
27 % derived work must not be called official GROMACS. Details are found
28 % in the README & COPYING files - if they are missing, get the
29 % official version at http://www.gromacs.org.
30 %
31 % To help us fund GROMACS development, we humbly ask that you cite
32 % the research papers on the package. Check out http://www.gromacs.org
33
34 \chapter{Special Topics}
35 \label{ch:special}
36
37
38 \section{Free energy implementation}
39 \label{sec:dgimplement}
40 For free energy calculations, there are two things that must be
41 specified; the end states, and the pathway connecting the end states.
42 The end states can be specified in two ways.  The most straightforward
43 is through the specification of end states in the topology file.  Most
44 potential forms support both an $A$ state and a $B$ state. Whenever both
45 states are specified, then the $A$ state corresponds to the initial free
46 energy state, and the $B$ state corresponds to the final state.
47
48 In some cases, the end state can also be defined in some cases without
49 altering the topology, solely through the {\tt .mdp} file, through the use
50 of the {\tt couple-moltype},{\tt couple-lambda0}, {\tt couple-lambda1}, and
51 {\tt couple-intramol} mdp keywords.  Any molecule type selected in
52 {\tt couple-moltype} will automatically have a $B$ state implicitly
53 constructed (and the $A$ state redefined) according to the {\tt couple-lambda}
54 keywords. {\tt couple-lambda0} and {\tt couple-lambda1} define the non-bonded
55 parameters that are present in the $A$ state ({\tt couple-lambda0})
56 and the $B$ state ({\tt couple-lambda1}).  The choices are 'q','vdw', and
57 'vdw-q'; these indicate the Coulombic, van der Waals, or both parameters
58 that are turned on in the respective state.
59
60 Once the end states are defined, then the path between the end states
61 has to be defined. This path is defined solely in the .mdp file.
62 Starting in 4.6, $\lambda$ is a vector of components, with Coulombic,
63 van der Waals, bonded, restraint, and mass components all able to be
64 adjusted independently.  This makes it possible to turn off the
65 Coulombic term linearly, and then the van der Waals using soft core,
66 all in the same simulation.  This is especially useful for replica
67 exchange or expanded ensemble simulations, where it is important to
68 sample all the way from interacting to non-interacting states in the
69 same simulation to improve sampling.
70
71 {\tt fep-lambdas} is the default array of $\lambda$ values ranging
72 from 0 to 1.  All of the other lambda arrays use the values in this
73 array if they are not specified.  The previous behavior, where the
74 pathway is controlled by a single $\lambda$ variable, can be preserved
75 by using only {\tt fep-lambdas} to define the pathway.
76
77 For example, if you wanted to first to change the Coulombic terms,
78 then the van der Waals terms, changing bonded at the same time rate as
79 the van der Wheals, but changing the restraints throughout the first
80 two-thirds of the simulation, then you could use this $\lambda$ vector:
81
82 \begin{verbatim}
83 coul-lambdas           = 0.0 0.2 0.5 1.0 1.0 1.0 1.0 1.0 1.0 1.0
84 vdw-lambdas            = 0.0 0.0 0.0 0.0 0.4 0.5 0.6 0.7 0.8 1.0
85 bonded-lambdas         = 0.0 0.0 0.0 0.0 0.4 0.5 0.6 0.7 0.8 1.0
86 restraint-lambdas      = 0.0 0.0 0.1 0.2 0.3 0.5 0.7 1.0 1.0 1.0
87 \end{verbatim}
88
89 This is also equivalent to:
90
91 \begin{verbatim}
92 fep-lambdas            = 0.0 0.0 0.0 0.0 0.4 0.5 0.6 0.7 0.8 1.0
93 coul-lambdas           = 0.0 0.2 0.5 1.0 1.0 1.0 1.0 1.0 1.0 1.0
94 restraint-lambdas      = 0.0 0.0 0.1 0.2 0.3 0.5 0.7 1.0 1.0 1.0
95 \end{verbatim}
96 The {\tt fep-lambda array}, in this case, is being used as the default to
97 fill in the bonded and van der Waals $\lambda$ arrays.  Usually, it's best to fill
98 in all arrays explicitly, just to make sure things are properly
99 assigned.
100
101 If you want to turn on only restraints going from $A$ to $B$, then it would be:
102 \begin{verbatim}
103 restraint-lambdas      = 0.0 0.1 0.2 0.4 0.6 1.0
104 \end{verbatim}
105 and all of the other components of the $\lambda$ vector would be left in the $A$ state.
106
107 To compute free energies with a vector $\lambda$ using
108 thermodynamic integration, then the TI equation becomes vector equation:
109 \beq
110 \Delta F = \int \langle \nabla H \rangle \cdot d\vec{\lambda}
111 \eeq
112 or for finite differences:
113 \beq
114 \Delta F \approx \int \sum \langle \nabla H \rangle \cdot \Delta\lambda
115 \eeq
116
117 The external {\tt pymbar} script downloaded from https://SimTK.org/home/pymbar can
118 compute this integral automatically from the {\gromacs} dhdl.xvg output.
119
120 \section{Potential of mean force}
121
122 A potential of mean force (PMF) is a potential that is obtained
123 by integrating the mean force from an ensemble of configurations.
124 In {\gromacs}, there are several different methods to calculate the mean force.
125 Each method has its limitations, which are listed below.
126 \begin{itemize}
127 \item{\bf pull code:} between the centers of mass of molecules or groups of molecules.
128 \item{\bf free-energy code with harmonic bonds or constraints:} between single atoms. 
129 \item{\bf free-energy code with position restraints:} changing the conformation of a relatively immobile group of atoms.
130 \item{\bf pull code in limited cases:} between groups of atoms that are
131 part of a larger molecule for which the bonds are constrained with
132 SHAKE or LINCS. If the pull group if relatively large,
133 the pull code can be used.
134 \end{itemize}
135 The pull and free-energy code a described in more detail
136 in the following two sections.
137
138 \subsubsection{Entropic effects}
139 When a distance between two atoms or the centers of mass of two groups
140 is constrained or restrained, there will be a purely entropic contribution
141 to the PMF due to the rotation of the two groups~\cite{RMNeumann1980a}.
142 For a system of two non-interacting masses the potential of mean force is:
143 \beq
144 V_{pmf}(r) = -(n_c - 1) k_B T \log(r)
145 \eeq
146 where $n_c$ is the number of dimensions in which the constraint works
147 (i.e. $n_c=3$ for a normal constraint and $n_c=1$ when only
148 the $z$-direction is constrained).
149 Whether one needs to correct for this contribution depends on what
150 the PMF should represent. When one wants to pull a substrate
151 into a protein, this entropic term indeed contributes to the work to
152 get the substrate into the protein. But when calculating a PMF
153 between two solutes in a solvent, for the purpose of simulating
154 without solvent, the entropic contribution should be removed.
155 {\bf Note} that this term can be significant; when at 300K the distance is halved,
156 the contribution is 3.5 kJ~mol$^{-1}$.
157
158 \section{Non-equilibrium pulling}
159 When the distance between two groups is changed continuously,
160 work is applied to the system, which means that the system is no longer
161 in equilibrium. Although in the limit of very slow pulling
162 the system is again in equilibrium, for many systems this limit
163 is not reachable within reasonable computational time.
164 However, one can use the Jarzynski relation~\cite{Jarzynski1997a}
165 to obtain the equilibrium free-energy difference $\Delta G$
166 between two distances from many non-equilibrium simulations:
167 \begin{equation}
168    \Delta G_{AB} = -k_BT \log \left\langle e^{-\beta W_{AB}} \right\rangle_A
169    \label{eq:Jarz}
170 \end{equation}
171 where $W_{AB}$ is the work performed to force the system along one path
172 from state A to B, the angular bracket denotes averaging over
173 a canonical ensemble of the initial state A and $\beta=1/k_B T$.
174
175
176 \section{The pull code}
177 \index{center-of-mass pulling}
178 \label{sec:pull}
179 The pull code applies forces or constraints between the centers
180 of mass of one or more pairs of groups of atoms.
181 Each pull reaction coordinate is called a ``coordinate'' and it operates
182 on two pull groups. A pull group can be part of one or more pull
183 coordinates. Furthermore, a coordinate can also operate on a single group
184 and an absolute reference position in space.
185 The distance between a pair of groups can be determined
186 in 1, 2 or 3 dimensions, or can be along a user-defined vector.
187 The reference distance can be constant or can change linearly with time.
188 Normally all atoms are weighted by their mass, but an additional
189 weighting factor can also be used.
190 \begin{figure}
191 \centerline{\includegraphics[width=6cm,angle=270]{plots/pull}}
192 \caption{Schematic picture of pulling a lipid out of a lipid bilayer
193 with umbrella pulling. $V_{rup}$ is the velocity at which the spring is
194 retracted, $Z_{link}$ is the atom to which the spring is attached and
195 $Z_{spring}$ is the location of the spring.}
196 \label{fi:pull} 
197 \end{figure}
198
199 Three different types of calculation are supported,
200 and in all cases the reference distance can be constant
201 or linearly changing with time.
202 \begin{enumerate}
203 \item{\textbf{Umbrella pulling}\swapindexquiet{umbrella}{pulling}}
204 A harmonic potential is applied between
205 the centers of mass of two groups.
206 Thus, the force is proportional to the displacement.
207 \item{\textbf{Constraint pulling\swapindexquiet{constraint}{pulling}}}
208 The distance between the centers of mass of two groups is constrained.
209 The constraint force can be written to a file.
210 This method uses the SHAKE algorithm but only needs 1 iteration to be
211 exact if only two groups are constrained. 
212 \item{\textbf{Constant force pulling}}
213 A constant force is applied between the centers of mass of two groups.
214 Thus, the potential is linear.
215 In this case there is no reference distance of pull rate.
216 \end{enumerate}
217
218 \subsubsection{Definition of the center of mass}
219
220 In {\gromacs}, there are three ways to define the center of mass of a group.
221 The standard way is a ``plain'' center of mass, possibly with additional
222 weighting factors. With periodic boundary conditions it is no longer
223 possible to uniquely define the center of mass of a group of atoms.
224 Therefore, a reference atom is used. For determining the center of mass,
225 for all other atoms in the group, the closest periodic image to the reference
226 atom is used. This uniquely defines the center of mass.
227 By default, the middle (determined by the order in the topology) atom
228 is used as a reference atom, but the user can also select any other atom
229 if it would be closer to center of the group.
230
231 For a layered system, for instance a lipid bilayer, it may be of interest
232 to calculate the PMF of a lipid as function of its distance
233 from the whole bilayer. The whole bilayer can be taken as reference
234 group in that case, but it might also be of interest to define the
235 reaction coordinate for the PMF more locally. The {\tt .mdp} option
236 {\tt pull_geometry = cylinder} does not
237 use all the atoms of the reference group, but instead dynamically only those
238 within a cylinder with radius {\tt r_1} around the pull vector going
239 through the pull group. This only
240 works for distances defined in one dimension, and the cylinder is
241 oriented with its long axis along this one dimension. A second cylinder
242 can be defined with {\tt r_0}, with a linear switch function that weighs
243 the contribution of atoms between {\tt r_0} and {\tt r_1} with
244 distance. This smooths the effects of atoms moving in and out of the
245 cylinder (which causes jumps in the pull forces).
246
247 \begin{figure}
248 \centerline{\includegraphics[width=6cm]{plots/pullref}}
249 \caption{Comparison of a plain center of mass reference group versus a cylinder
250 reference group applied to interface systems. C is the reference group.
251 The circles represent the center of mass of two groups plus the reference group,
252 $d_c$ is the reference distance.}
253 \label{fi:pullref} 
254 \end{figure}   
255
256 For a group of molecules in a periodic system, a plain reference group
257 might not be well-defined. An example is a water slab that is connected
258 periodically in $x$ and $y$, but has two liquid-vapor interfaces along $z$.
259 In such a setup, water molecules can evaporate from the liquid and they
260 will move through the vapor, through the periodic boundary, to the other
261 interface. Such a system is inherently periodic and there is no proper way
262 of defining a ``plain'' center of mass along $z$. A proper solution is to using
263 a cosine shaped weighting profile for all atoms in the reference group.
264 The profile is a cosine with a single period in the unit cell. Its phase
265 is optimized to give the maximum sum of weights, including mass weighting.
266 This provides a unique and continuous reference position that is nearly
267 identical to the plain center of mass position in case all atoms are all
268 within a half of the unit-cell length. See ref \cite{Engin2010a} for details.
269
270 When relative weights $w_i$ are used during the calculations, either
271 by supplying weights in the input or due to cylinder geometry
272 or due to cosine weighting,
273 the weights need to be scaled to conserve momentum:
274 \beq
275 w'_i = w_i
276 \left. \sum_{j=1}^N w_j \, m_j \right/ \sum_{j=1}^N w_j^2 \, m_j
277 \eeq
278 where $m_j$ is the mass of atom $j$ of the group.
279 The mass of the group, required for calculating the constraint force, is:
280 \beq
281 M = \sum_{i=1}^N w'_i \, m_i
282 \eeq
283 The definition of the weighted center of mass is:
284 \beq
285 \ve{r}_{com} = \left. \sum_{i=1}^N w'_i \, m_i \, \ve{r}_i \right/ M
286 \eeq
287 From the centers of mass the AFM, constraint, or umbrella force $\ve{F}_{\!com}$
288 on each group can be calculated.
289 The force on the center of mass of a group is redistributed to the atoms
290 as follows:
291 \beq
292 \ve{F}_{\!i} = \frac{w'_i \, m_i}{M} \, \ve{F}_{\!com}
293 \eeq
294
295 \subsubsection{Limitations}
296 There is one theoretical limitation:
297 strictly speaking, constraint forces can only be calculated between
298 groups that are not connected by constraints to the rest of the system.
299 If a group contains part of a molecule of which the bond lengths
300 are constrained, the pull constraint and LINCS or SHAKE bond constraint
301 algorithms should be iterated simultaneously. This is not done in {\gromacs}.
302 This means that for simulations with {\tt constraints = all-bonds}
303 in the {\tt .mdp} file pulling is, strictly speaking,
304 limited to whole molecules or groups of molecules.
305 In some cases this limitation can be avoided by using the free energy code,
306 see \secref{fepmf}.
307 In practice, the errors caused by not iterating the two constraint
308 algorithms can be negligible when the pull group consists of a large
309 amount of atoms and/or the pull force is small.
310 In such cases, the constraint correction displacement of the pull group
311 is small compared to the bond lengths.
312
313
314
315 \section{\normindex{Enforced Rotation}}
316 \index{rotational pulling|see{enforced rotation}}
317 \index{pulling, rotational|see{enforced rotation}}
318 \label{sec:rotation}
319
320 \mathchardef\mhyphen="2D
321 \newcommand{\rotiso     }{^\mathrm{iso}}
322 \newcommand{\rotisopf   }{^\mathrm{iso\mhyphen pf}}
323 \newcommand{\rotpm      }{^\mathrm{pm}}
324 \newcommand{\rotpmpf    }{^\mathrm{pm\mhyphen pf}}
325 \newcommand{\rotrm      }{^\mathrm{rm}}
326 \newcommand{\rotrmpf    }{^\mathrm{rm\mhyphen pf}}
327 \newcommand{\rotrmtwo   }{^\mathrm{rm2}}
328 \newcommand{\rotrmtwopf }{^\mathrm{rm2\mhyphen pf}}
329 \newcommand{\rotflex    }{^\mathrm{flex}}
330 \newcommand{\rotflext   }{^\mathrm{flex\mhyphen t}}
331 \newcommand{\rotflextwo }{^\mathrm{flex2}}
332 \newcommand{\rotflextwot}{^\mathrm{flex2\mhyphen t}}
333
334 This module can be used to enforce the rotation of a group of atoms, as {\eg}
335 a protein subunit. There are a variety of rotation potentials, among them
336 complex ones that allow flexible adaptations of both the rotated subunit as
337 well as the local rotation axis during the simulation. An example application 
338 can be found in ref. \cite{Kutzner2011}.
339
340 \begin{figure}
341 \centerline{\includegraphics[width=13cm]{plots/rotation.pdf}}
342 \caption[Fixed and flexible axis rotation]{Comparison of fixed and flexible axis
343 rotation. 
344 {\sf A:} Rotating the sketched shape inside the white tubular cavity can create
345 artifacts when a fixed rotation axis (dashed) is used. More realistically, the
346 shape would revolve like a flexible pipe-cleaner (dotted) inside the bearing (gray). 
347 {\sf B:} Fixed rotation around an axis \ve{v} with a pivot point
348 specified by the vector \ve{u}. 
349 {\sf C:} Subdividing the rotating fragment into slabs with separate rotation
350 axes ($\uparrow$) and pivot points ($\bullet$) for each slab allows for
351 flexibility. The distance between two slabs with indices $n$ and $n+1$ is $\Delta x$.}
352 \label{fig:rotation}
353 \end{figure}
354
355 \begin{figure}
356 \centerline{\includegraphics[width=13cm]{plots/equipotential.pdf}}
357 \caption{Selection of different rotation potentials and definition of notation.
358 All four potentials $V$ (color coded) are shown for a single atom at position
359 $\ve{x}_j(t)$.
360 {\sf A:} Isotropic potential $V\rotiso$,
361 {\sf B:} radial motion potential $V\rotrm$ and flexible potential
362 $V\rotflex$,
363 {\sf C--D:} radial motion\,2 potential $V\rotrmtwo$ and
364 flexible\,2 potential $V\rotflextwo$ for $\epsilon' = 0$\,nm$^2$ {\sf (C)}
365 and $\epsilon' = 0.01$\,nm$^2$ {\sf (D)}. The rotation axis is perpendicular to
366 the plane and marked by $\otimes$. The light gray contours indicate Boltzmann factors
367 $e^{-V/(k_B T)}$ in the $\ve{x}_j$-plane for $T=300$\,K and
368 $k=200$\,kJ/(mol$\cdot$nm$^2$). The green arrow shows the direction of the
369 force $\ve{F}_{\!j}$ acting on atom $j$; the blue dashed line indicates the
370 motion of the reference position.}
371 \label{fig:equipotential}
372 \end{figure}
373
374 \subsection{Fixed Axis Rotation}
375 \subsubsection{Stationary Axis with an Isotropic Potential}
376 In the fixed axis approach (see \figref{rotation}B), torque on a group of $N$
377 atoms with positions $\ve{x}_i$ (denoted ``rotation group'') is applied by
378 rotating a reference set of atomic positions -- usually their initial positions
379 $\ve{y}_i^0$ -- at a constant angular velocity $\omega$ around an axis
380 defined by a direction vector $\hat{\ve{v}}$ and a pivot point \ve{u}.
381 To that aim, each atom with position $\ve{x}_i$ is attracted by a
382 ``virtual spring'' potential to its moving reference position
383 $\ve{y}_i = \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{u})$,
384 where $\mathbf{\Omega}(t)$ is a matrix that describes the rotation around the
385 axis. In the simplest case, the ``springs'' are described by a harmonic
386 potential,
387 \beq
388 V\rotiso = \frac{k}{2} \sum_{i=1}^{N} w_i \left[ \mathbf{\Omega}(t)
389 (\ve{y}_i^0 - \ve{u}) - (\ve{x}_i - \ve{u})  \right]^2 ,
390 \label{eqn:potiso}
391 \eeq
392 with optional mass-weighted prefactors $w_i = N \, m_i/M$ with total mass
393 $M = \sum_{i=1}^N m_i$.
394 The rotation matrix $\mathbf{\Omega}(t)$ is 
395 \newcommand{\omcost}{\,\xi\,}   % abbreviation
396 \begin{displaymath}
397 \mathbf{\Omega}(t) =  
398 \left(   
399 \begin{array}{ccc}
400 \cos\omega t + v_x^2\omcost       & v_x v_y\omcost - v_z\sin\omega t  & v_x v_z\omcost + v_y\sin\omega t\\
401 v_x v_y\omcost + v_z\sin\omega t  & \cos\omega t + v_y^2\omcost       & v_y v_z\omcost - v_x\sin\omega t\\
402 v_x v_z\omcost - v_y\sin\omega t  & v_y v_z\omcost + v_x\sin\omega t  & \cos\omega t + v_z^2\omcost     \\
403 \end{array}
404 \right) ,
405 \end{displaymath}
406 where $v_x$, $v_y$, and $v_z$ are the components of the normalized rotation vector
407 $\hat{\ve{v}}$, and $\omcost := 1-\cos(\omega t)$. As illustrated in
408 \figref{equipotential}A for a single atom $j$, the
409 rotation matrix $\mathbf{\Omega}(t)$ operates on the initial reference positions
410 $\ve{y}_j^0 = \ve{x}_j(t_0)$ of atom $j$ at $t=t_0$. At a later
411 time $t$, the reference position has rotated away from its initial place
412 (along the blue dashed line), resulting in the force
413 \beq
414 \ve{F}_{\!j}\rotiso 
415 = -\nabla_{\!j} \, V\rotiso 
416 = k \, w_j \left[
417 \mathbf{\Omega}(t) (\ve{y}_j^0 - \ve{u}) - (\ve{x}_j - \ve{u} ) \right] ,
418 \label{eqn:force_fixed}
419 \eeq
420 which is directed towards the reference position.
421
422
423 \subsubsection{Pivot-Free Isotropic Potential}
424 Instead of a fixed pivot vector \ve{u} this potential uses the center of
425 mass $\ve{x}_c$ of the rotation group as pivot for the rotation axis,
426 \beq
427 \ve{x}_c   = \frac{1}{M} \sum_{i=1}^N m_i \ve{x}_i 
428 \label{eqn:com}
429 \mbox{\hspace{4ex}and\hspace{4ex}}
430 \ve{y}_c^0 = \frac{1}{M} \sum_{i=1}^N m_i \ve{y}_i^0 \ ,
431 \eeq
432 which yields the ``pivot-free'' isotropic potential
433 \beq
434 V\rotisopf = \frac{k}{2} \sum_{i=1}^{N} w_i \left[ \mathbf{\Omega}(t)
435 (\ve{y}_i^0 - \ve{y}_c^0) - (\ve{x}_i - \ve{x}_c) \right]^2 ,
436 \label{eqn:potisopf}
437 \eeq
438 with forces
439 \beq
440 \mathbf{F}_{\!j}\rotisopf = k \, w_j 
441 \left[ 
442 \mathbf{\Omega}(t) ( \ve{y}_j^0 - \ve{y}_c^0) 
443                  - ( \ve{x}_j   - \ve{x}_c )
444 \right] .
445 \label{eqn:force_isopf}
446 \eeq
447 Without mass-weighting, the pivot $\ve{x}_c$ is the geometrical center of
448 the group. 
449 \label{sec:fixed}
450
451 \subsubsection{Parallel Motion Potential Variant}
452 The forces generated by the isotropic potentials
453 (\eqnsref{potiso}{potisopf}) also contain components parallel
454 to the rotation axis and thereby restrain motions along the axis of either the
455 whole rotation group (in case of $V\rotiso$) or within
456 the rotation group (in case of $V\rotisopf$). For cases where
457 unrestrained motion along the axis is preferred, we have implemented a 
458 ``parallel motion'' variant by eliminating all components parallel to the
459 rotation axis for the potential. This is achieved by projecting the distance
460 vectors between reference and actual positions
461 \beq
462 \ve{r}_i = \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{u}) - (\ve{x}_i - \ve{u})
463 \eeq
464 onto the plane perpendicular to the rotation vector,
465 \beq
466 \label{eqn:project}
467 \ve{r}_i^\perp :=  \ve{r}_i - (\ve{r}_i \cdot \hat{\ve{v}})\hat{\ve{v}} \ ,
468 \eeq
469 yielding
470 \bea
471 \nonumber
472 V\rotpm &=& \frac{k}{2} \sum_{i=1}^{N} w_i ( \ve{r}_i^\perp )^2 \\
473         &=& \frac{k}{2} \sum_{i=1}^{N} w_i
474  \left\lbrace
475  \mathbf{\Omega}(t)
476    (\ve{y}_i^0 - \ve{u}) - (\ve{x}_i - \ve{u})  \right. \nonumber \\
477 && \left. - \left\lbrace
478 \left[ \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{u}) - (\ve{x}_i - \ve{u}) \right] \cdot\hat{\ve{v}}
479   \right\rbrace\hat{\ve{v}} \right\rbrace^2 ,
480 \label{eqn:potpm}
481 \eea
482 and similarly
483 \beq
484 \ve{F}_{\!j}\rotpm = k \, w_j \, \ve{r}_j^\perp .
485 \label{eqn:force_pm}
486 \eeq
487
488 \subsubsection{Pivot-Free Parallel Motion Potential}
489 Replacing in \eqnref{potpm} the fixed pivot \ve{u} by the center 
490 of mass $\ve{x_c}$ yields the pivot-free variant of the parallel motion
491 potential. With
492 \beq
493 \ve{s}_i = \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{y}_c^0) - (\ve{x}_i - \ve{x}_c)
494 \eeq
495 the respective potential and forces are
496 \bea
497 V\rotpmpf &=& \frac{k}{2} \sum_{i=1}^{N} w_i ( \ve{s}_i^\perp )^2 \ , \\
498 \label{eqn:potpmpf}
499 \ve{F}_{\!j}\rotpmpf &=& k \, w_j \, \ve{s}_j^\perp .
500 \label{eqn:force_pmpf}
501 \eea
502
503 \subsubsection{Radial Motion Potential}
504 In the above variants, the minimum of the rotation potential is either a single
505 point at the reference position $\ve{y}_i$ (for the isotropic potentials) or a
506 single line through $\ve{y}_i$ parallel to the rotation axis (for the
507 parallel motion potentials). As a result, radial forces restrict radial motions
508 of the atoms. The two subsequent types of rotation potentials, $V\rotrm$
509 and $V\rotrmtwo$, drastically reduce or even eliminate this effect. The first
510 variant, $V\rotrm$ (\figref{equipotential}B), eliminates all force
511 components parallel to the vector connecting the reference atom and the
512 rotation axis,
513 \beq
514 V\rotrm = \frac{k}{2} \sum_{i=1}^{N} w_i \left[
515 \ve{p}_i
516 \cdot(\ve{x}_i - \ve{u}) \right]^2 ,
517 \label{eqn:potrm}
518 \eeq
519 with
520 \beq
521 \ve{p}_i := 
522 \frac{\hat{\ve{v}}\times \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{u})} {\| \hat{\ve{v}}\times \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{u})\|} \ .
523 \eeq
524 This variant depends only on the distance $\ve{p}_i \cdot (\ve{x}_i -
525 \ve{u})$ of atom $i$ from the plane spanned by $\hat{\ve{v}}$ and
526 $\mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{u})$. The resulting force is
527 \beq
528 \mathbf{F}_{\!j}\rotrm =
529  -k \, w_j \left[ \ve{p}_j\cdot(\ve{x}_j - \ve{u}) \right] \,\ve{p}_j \,  .
530 \label{eqn:potrm_force}
531 \eeq
532
533 \subsubsection{Pivot-Free Radial Motion Potential}
534 Proceeding similar to the pivot-free isotropic potential yields a pivot-free
535 version of the above potential. With
536 \beq
537 \ve{q}_i := 
538 \frac{\hat{\ve{v}}\times \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{y}_c^0)} {\| \hat{\ve{v}}\times \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{y}_c^0)\|} \, ,
539 \eeq
540 the potential and force for the pivot-free variant of the radial motion potential read
541 \bea
542 V\rotrmpf & = & \frac{k}{2} \sum_{i=1}^{N} w_i \left[
543 \ve{q}_i
544 \cdot(\ve{x}_i - \ve{x}_c)
545 \right]^2 \, , \\
546 \label{eqn:potrmpf}
547 \mathbf{F}_{\!j}\rotrmpf & = &
548  -k \, w_j \left[ \ve{q}_j\cdot(\ve{x}_j - \ve{x}_c) \right] \,\ve{q}_j 
549  + k   \frac{m_j}{M} \sum_{i=1}^{N} w_i \left[
550  \ve{q}_i\cdot(\ve{x}_i - \ve{x}_c) \right]\,\ve{q}_i \, .
551 \label{eqn:potrmpf_force}
552 \eea
553
554 \subsubsection{Radial Motion 2 Alternative Potential}
555 As seen in \figref{equipotential}B, the force resulting from
556 $V\rotrm$ still contains a small, second-order radial component. In most
557 cases, this perturbation is tolerable; if not, the following
558 alternative, $V\rotrmtwo$, fully eliminates the radial contribution to the
559 force, as depicted in \figref{equipotential}C,
560 \beq
561 V\rotrmtwo = 
562 \frac{k}{2} \sum_{i=1}^{N} w_i\, 
563 \frac{\left[ (\hat{\ve{v}} \times ( \ve{x}_i - \ve{u} ))
564 \cdot \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{u}) \right]^2}
565 {\| \hat{\ve{v}} \times (\ve{x}_i - \ve{u}) \|^2 +
566 \epsilon'} \, ,
567 \label{eqn:potrm2}
568 \eeq
569 where a small parameter $\epsilon'$ has been introduced to avoid singularities.
570 For $\epsilon'=0$\,nm$^2$, the equipotential planes are spanned by $\ve{x}_i -
571 \ve{u}$ and $\hat{\ve{v}}$, yielding a force 
572 perpendicular to $\ve{x}_i - \ve{u}$, thus not contracting or
573 expanding structural parts that moved away from or toward the rotation axis.
574
575 Choosing a small positive  $\epsilon'$ ({\eg},
576 $\epsilon'=0.01$\,nm$^2$, \figref{equipotential}D) in the denominator of
577 \eqnref{potrm2} yields a well-defined potential and continuous forces also 
578 close to the rotation axis, which is not the case for $\epsilon'=0$\,nm$^2$ 
579 (\figref{equipotential}C). With
580 \bea
581 \ve{r}_i & := & \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{u})\\
582 \ve{s}_i & := & \frac{\hat{\ve{v}} \times (\ve{x}_i -
583 \ve{u} ) }{ \| \hat{\ve{v}} \times (\ve{x}_i - \ve{u})
584 \| } \equiv \; \Psi_{i} \;\; {\hat{\ve{v}} \times
585 (\ve{x}_i-\ve{u} ) }\\
586 \Psi_i^{*}   & := & \frac{1}{ \| \hat{\ve{v}} \times
587 (\ve{x}_i-\ve{u}) \|^2 + \epsilon'}
588 \eea
589 the force on atom $j$ reads
590 \beq
591 \ve{F}_{\!j}\rotrmtwo  = 
592 - k\; 
593 \left\lbrace w_j\;
594 (\ve{s}_j\cdot\ve{r}_{\!j})\;
595 \left[ \frac{\Psi_{\!j}^*   }{\Psi_{\!j}  }  \ve{r}_{\!j} 
596      - \frac{\Psi_{\!j}^{*2}}{\Psi_{\!j}^3}
597      (\ve{s}_j\cdot\ve{r}_{\!j})\ve{s}_j \right]
598 \right\rbrace \times \hat{\ve{v}} .
599 \label{eqn:potrm2_force}
600 \eeq
601
602 \subsubsection{Pivot-Free Radial Motion 2 Potential}
603 The pivot-free variant of the above potential is
604 \beq
605 V\rotrmtwopf = 
606 \frac{k}{2} \sum_{i=1}^{N} w_i\, 
607 \frac{\left[ (\hat{\ve{v}} \times ( \ve{x}_i - \ve{x}_c ))
608 \cdot \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c) \right]^2}
609 {\| \hat{\ve{v}} \times (\ve{x}_i - \ve{x}_c) \|^2 +
610 \epsilon'} \, .
611 \label{eqn:potrm2pf}
612 \eeq
613 With
614 \bea
615 \ve{r}_i & := & \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c)\\
616 \ve{s}_i & := & \frac{\hat{\ve{v}} \times (\ve{x}_i -
617 \ve{x}_c ) }{ \| \hat{\ve{v}} \times (\ve{x}_i - \ve{x}_c)
618 \| } \equiv \; \Psi_{i} \;\; {\hat{\ve{v}} \times
619 (\ve{x}_i-\ve{x}_c ) }\\ \Psi_i^{*}   & := & \frac{1}{ \| \hat{\ve{v}} \times
620 (\ve{x}_i-\ve{x}_c) \|^2 + \epsilon'}
621 \eea
622 the force on atom $j$ reads
623 \bea
624 \nonumber
625 \ve{F}_{\!j}\rotrmtwopf & = &
626 - k\; 
627 \left\lbrace w_j\;
628 (\ve{s}_j\cdot\ve{r}_{\!j})\;
629 \left[ \frac{\Psi_{\!j}^*   }{\Psi_{\!j}  } \ve{r}_{\!j} 
630      - \frac{\Psi_{\!j}^{*2}}{\Psi_{\!j}^3}
631      (\ve{s}_j\cdot\ve{r}_{\!j})\ve{s}_j \right]
632 \right\rbrace \times \hat{\ve{v}}\\
633      & &
634 + k\;\frac{m_j}{M} \left\lbrace \sum_{i=1}^{N}
635 w_i\;(\ve{s}_i\cdot\ve{r}_i) \; 
636 \left[ \frac{\Psi_i^*   }{\Psi_i  }  \ve{r}_i
637      - \frac{\Psi_i^{*2}}{\Psi_i^3} (\ve{s}_i\cdot\ve{r}_i )\;
638      \ve{s}_i \right] \right\rbrace \times \hat{\ve{v}} \, .
639 \label{eqn:potrm2pf_force}
640 \eea
641
642 \subsection{Flexible Axis Rotation}
643 As sketched in \figref{rotation}A--B, the rigid body behavior of
644 the fixed axis rotation scheme is a drawback for many applications. In
645 particular, deformations of the rotation group are suppressed when the
646 equilibrium atom positions directly depend on the reference positions. 
647 To avoid this limitation, \eqnsref{potrmpf}{potrm2pf}
648 will now be generalized towards a ``flexible axis'' as sketched in
649 \figref{rotation}C. This will be achieved by subdividing the
650 rotation group into a set of equidistant slabs perpendicular to
651 the rotation vector, and by applying a separate rotation potential to each
652 of these slabs. \figref{rotation}C shows the midplanes of the slabs 
653 as dotted straight lines and the centers as thick black dots.
654
655 To avoid discontinuities in the potential and in the forces, we define
656 ``soft slabs'' by weighing the contributions of each
657 slab $n$ to the total potential function $V\rotflex$ by a Gaussian
658 function
659 \beq
660 \label{eqn:gaussian}
661 g_n(\ve{x}_i) = \Gamma \ \mbox{exp} \left(
662 -\frac{\beta_n^2(\ve{x}_i)}{2\sigma^2}  \right) ,
663 \eeq
664 centered at the midplane of the $n$th slab. Here $\sigma$ is the width
665 of the Gaussian function, $\Delta x$ the distance between adjacent slabs, and
666 \beq
667 \beta_n(\ve{x}_i) := \ve{x}_i \cdot \hat{\ve{v}} - n \, \Delta x \, .
668 \eeq
669 %
670 \begin{figure}
671 \centerline{\includegraphics[width=6.5cm]{plots/gaussians.pdf}}
672 \caption{Gaussian functions $g_n$ centered at $n \, \Delta x$ for a slab
673 distance $\Delta x = 1.5$ nm and $n \geq -2$. Gaussian function $g_0$ is
674 highlighted in bold; the dashed line depicts the sum of the shown Gaussian
675 functions.}
676 \label{fig:gaussians}
677 \end{figure}
678 %
679 A most convenient choice is $\sigma = 0.7 \Delta x$ and
680 \begin{displaymath}
681 1/\Gamma = \sum_{n \in Z}
682 \mbox{exp}
683 \left(-\frac{(n - \frac{1}{4})^2}{2\cdot 0.7^2}\right)
684 \approx 1.75464 \, ,
685 \end{displaymath}
686 which yields a nearly constant sum, essentially independent of $\ve{x}_i$
687 (dashed line in \figref{gaussians}), {\ie},
688 \beq
689 \sum_{n \in Z} g_n(\ve{x}_i) =  1 + \epsilon(\ve{x}_i) \, ,
690 \label{eqn:normal}
691 \eeq
692 with $ | \epsilon(\ve{x}_i) | < 1.3\cdot 10^{-4}$. This choice also
693 implies that the individual contributions to the force from the slabs add up to
694 unity such that no further normalization is required.
695
696 To each slab center $\ve{x}_c^n$, all atoms contribute by their
697 Gaussian-weighted (optionally also mass-weighted) position vectors 
698 $g_n(\ve{x}_i) \, \ve{x}_i$. The
699 instantaneous slab centers $\ve{x}_c^n$ are calculated from the
700 current positions $\ve{x}_i$,
701 \beq
702 \label{eqn:defx0} 
703 \ve{x}_c^n =
704 \frac{\sum_{i=1}^N g_n(\ve{x}_i) \, m_i \, \ve{x}_i}
705      {\sum_{i=1}^N g_n(\ve{x}_i) \, m_i} \, ,\\
706 \eeq
707 while the reference centers $\ve{y}_c^n$ are calculated from the reference 
708 positions $\ve{y}_i^0$,
709 \beq
710 \label{eqn:defy0}
711 \ve{y}_c^n =
712 \frac{\sum_{i=1}^N g_n(\ve{y}_i^0) \, m_i \, \ve{y}_i^0}
713      {\sum_{i=1}^N g_n(\ve{y}_i^0) \, m_i} \, .
714 \eeq
715 Due to the rapid decay of $g_n$, each slab
716 will essentially involve contributions from atoms located within $\approx
717 3\Delta x$ from the slab center only.
718
719 \subsubsection{Flexible Axis Potential}
720 We consider two flexible axis variants. For the first variant,
721 the slab segmentation procedure with Gaussian weighting is applied to the radial 
722 motion potential (\eqnref{potrmpf}\,/\,\figref{equipotential}B),
723 yielding as the contribution of slab $n$
724 \begin{displaymath}
725 V^n = 
726 \frac{k}{2} \sum_{i=1}^{N} w_i \, g_n(\ve{x}_i) 
727 \left[
728 \ve{q}_i^n
729 \cdot
730  (\ve{x}_i - \ve{x}_c^n) 
731 \right]^2  ,
732 \label{eqn:flexpot}
733 \end{displaymath}
734 and a total potential function
735 \beq 
736 V\rotflex = \sum_n V^n \, .
737 \label{eqn:potflex}
738 \eeq
739 Note that the global center of mass $\ve{x}_c$ used in
740 \eqnref{potrmpf} is now replaced by $\ve{x}_c^n$, the center of mass of
741 the slab. With
742 \bea
743 \ve{q}_i^n & := & \frac{\hat{\ve{v}} \times
744 \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c^n) }{ \| \hat{\ve{v}}
745 \times \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c^n) \| } \\
746 b_i^n         & := & \ve{q}_i^n \cdot (\ve{x}_i - \ve{x}_c^n) \, ,
747 \eea
748 the resulting force on atom $j$ reads
749 \bea
750 \nonumber\hspace{-15mm}
751 \ve{F}_{\!j}\rotflex &=&
752 - \, k \, w_j \sum_n g_n(\ve{x}_j) \, b_j^n \left\lbrace  \ve{q}_j^n -
753 b_j^n \frac{\beta_n(\ve{x}_j)}{2\sigma^2} \hat{\ve{v}} \right\rbrace \\ & &
754 + \, k \, m_j \sum_n \frac{g_n(\ve{x}_j)}{\sum_h g_n(\ve{x}_h)}
755 \sum_{i=1}^{N} w_i \, g_n(\ve{x}_i) \, b_i^n \left\lbrace 
756 \ve{q}_i^n -\frac{\beta_n(\ve{x}_j)}{\sigma^2}
757 \left[ \ve{q}_i^n \cdot (\ve{x}_j - \ve{x}_c^n )\right]
758 \hat{\ve{v}} \right\rbrace .
759 \label{eqn:potflex_force}
760 \eea
761 %
762 Note that for $V\rotflex$, as defined, the slabs are fixed in space and so
763 are the reference centers $\ve{y}_c^n$. If during the simulation the
764 rotation group moves too far in $\ve{v}$ direction, it may enter a
765 region where -- due to the lack of nearby reference positions -- no reference
766 slab centers are defined, rendering the potential evaluation impossible. 
767 We therefore have included a slightly modified version of this potential that
768 avoids this problem by attaching the midplane of slab $n=0$ to the center of mass 
769 of the rotation group, yielding slabs that move with the rotation group. 
770 This is achieved by subtracting the center of mass $\ve{x}_c$ of the
771 group from the positions, 
772 \beq
773 \tilde{\ve{x}}_i = \ve{x}_i - \ve{x}_c \, , \mbox{\ \ \ and \ \ } 
774 \tilde{\ve{y}}_i^0 = \ve{y}_i^0 - \ve{y}_c^0 \, ,
775 \label{eqn:trafo} 
776 \eeq
777 such that
778 \bea
779 V\rotflext 
780   & = & \frac{k}{2} \sum_n \sum_{i=1}^{N} w_i \, g_n(\tilde{\ve{x}}_i)
781   \left[ \frac{\hat{\ve{v}} \times \mathbf{\Omega}(t)(\tilde{\ve{y}}_i^0
782   - \tilde{\ve{y}}_c^n) }{ \| \hat{\ve{v}} \times
783 \mathbf{\Omega}(t)(\tilde{\ve{y}}_i^0 -
784 \tilde{\ve{y}}_c^n) \| }
785 \cdot
786  (\tilde{\ve{x}}_i - \tilde{\ve{x}}_c^n) 
787 \right]^2 .
788 \label{eqn:potflext}
789 \eea
790 To simplify the force derivation, and for efficiency reasons, we here assume
791 $\ve{x}_c$ to be constant, and thus $\partial \ve{x}_c / \partial x =
792 \partial \ve{x}_c / \partial y = \partial \ve{x}_c / \partial z = 0$. The
793 resulting force error is small (of order $O(1/N)$ or $O(m_j/M)$ if
794 mass-weighting is applied) and can therefore be tolerated. With this assumption,
795 the forces $\ve{F}\rotflext$ have the same form as
796 \eqnref{potflex_force}.
797
798 \subsubsection{Flexible Axis 2 Alternative Potential}
799 In this second variant, slab segmentation is applied to $V\rotrmtwo$
800 (\eqnref{potrm2pf}), resulting in a flexible axis potential without radial
801 force contributions (\figref{equipotential}C),
802 \beq
803 V\rotflextwo = 
804 \frac{k}{2} \sum_{i=1}^{N} \sum_n w_i\,g_n(\ve{x}_i) 
805 \frac{\left[ (\hat{\ve{v}} \times ( \ve{x}_i - \ve{x}_c^n ))
806 \cdot \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c^n) \right]^2}
807 {\| \hat{\ve{v}} \times (\ve{x}_i - \ve{x}_c^n) \|^2 +
808 \epsilon'} \, .
809 \label{eqn:potflex2}
810 \eeq
811 With
812 \bea
813 \ve{r}_i^n & := & \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c^n)\\
814 \ve{s}_i^n & := & \frac{\hat{\ve{v}} \times (\ve{x}_i -
815 \ve{x}_c^n ) }{ \| \hat{\ve{v}} \times (\ve{x}_i - \ve{x}_c^n)
816 \| } \equiv \; \psi_{i} \;\; {\hat{\ve{v}} \times (\ve{x}_i-\ve{x}_c^n ) }\\
817 \psi_i^{*}     & := & \frac{1}{ \| \hat{\ve{v}} \times (\ve{x}_i-\ve{x}_c^n) \|^2 + \epsilon'}\\ 
818 W_j^n          & := & \frac{g_n(\ve{x}_j)\,m_j}{\sum_h g_n(\ve{x}_h)\,m_h}\\
819 \ve{S}^n   & := & 
820 \sum_{i=1}^{N} w_i\;g_n(\ve{x}_i)
821 \; (\ve{s}_i^n\cdot\ve{r}_i^n)
822 \left[ \frac{\psi_i^*   }{\psi_i  }  \ve{r}_i^n
823      - \frac{\psi_i^{*2}}{\psi_i^3} (\ve{s}_i^n\cdot\ve{r}_i^n )\;
824      \ve{s}_i^n \right] \label{eqn:Sn}
825 \eea
826 the force on atom $j$ reads
827 \bea
828 \nonumber
829 \ve{F}_{\!j}\rotflextwo & = &
830 - k\; 
831 \left\lbrace \sum_n w_j\;g_n(\ve{x}_j)\;
832 (\ve{s}_j^n\cdot\ve{r}_{\!j}^n)\;
833 \left[ \frac{\psi_j^*   }{\psi_j  }  \ve{r}_{\!j}^n 
834      - \frac{\psi_j^{*2}}{\psi_j^3} (\ve{s}_j^n\cdot\ve{r}_{\!j}^n)\;
835      \ve{s}_{\!j}^n \right] \right\rbrace \times \hat{\ve{v}} \\
836 \nonumber
837 & &
838 + k \left\lbrace \sum_n W_{\!j}^n \, \ve{S}^n \right\rbrace \times
839 \hat{\ve{v}}
840 - k \left\lbrace \sum_n W_{\!j}^n \; \frac{\beta_n(\ve{x}_j)}{\sigma^2} \frac{1}{\psi_j}\;\; 
841 \ve{s}_j^n \cdot 
842 \ve{S}^n \right\rbrace \hat{\ve{v}}\\ 
843 & & 
844 + \frac{k}{2} \left\lbrace \sum_n w_j\;g_n(\ve{x}_j)
845 \frac{\beta_n(\ve{x}_j)}{\sigma^2} 
846 \frac{\psi_j^*}{\psi_j^2}( \ve{s}_j^n \cdot \ve{r}_{\!j}^n )^2 \right\rbrace
847 \hat{\ve{v}} .
848 \label{eqn:potflex2_force}
849 \eea
850
851 Applying transformation (\ref{eqn:trafo}) yields a ``translation-tolerant''
852 version of the flexible\,2 potential, $V\rotflextwot$. Again,
853 assuming that $\partial \ve{x}_c / \partial x$,  $\partial \ve{x}_c /
854 \partial y$, $\partial \ve{x}_c / \partial z$ are small, the
855 resulting equations for $V\rotflextwot$ and $\ve{F}\rotflextwot$ are
856 similar to those of $V\rotflextwo$ and $\ve{F}\rotflextwo$.
857
858 \subsection{Usage}
859 To apply enforced rotation, the particles $i$ that are to
860 be subjected to one of the rotation potentials are defined via index groups
861 {\tt rot\_group0}, {\tt rot\_group1}, etc., in the {\tt .mdp} input file. 
862 The reference positions $\ve{y}_i^0$ are
863 read from a special {\tt .trr} file provided to {\tt grompp}. If no such file is found,
864 $\ve{x}_i(t=0)$ are used as reference positions and written to {\tt .trr} such
865 that they can be used for subsequent setups. All parameters of the potentials
866 such as $k$, $\epsilon'$, etc. (\tabref{vars}) are provided as {\tt .mdp}
867 parameters; {\tt rot\_type} selects the type of the potential. 
868 The option {\tt rot\_massw} allows to choose whether or not to use
869 mass-weighted averaging. 
870 For the flexible potentials, a cutoff value $g_n^\mathrm{min}$ 
871 (typically  $g_n^\mathrm{min}=0.001$) makes shure that only
872 significant contributions to $V$ and \ve{F} are evaluated, {\ie} terms with 
873 $g_n(\ve{x}) < g_n^\mathrm{min}$ are omitted.
874 \tabref{quantities} summarizes observables that are written
875 to additional output files and which are described below.
876
877
878 \begin{table}[tbp]
879 \caption{Parameters used by the various rotation potentials.
880 {\sf x}'s indicate which parameter is actually used for a given potential.}
881 %\small
882
883 \newcommand{\kunit}{$\frac{\mathrm{kJ}}{\mathrm{mol} \cdot \mathrm{nm}^2}$}
884 \newcommand{\smtt}[1]{{\hspace{-0.5ex}\small #1\hspace{-0.5ex}}}
885 \label{tab:vars}
886 \begin{center}
887 \begin{tabular}{l>{$}l<{$}rccccccc}
888 \hline
889 parameter           &               &                      & $k$      & $\hat{\ve{v}}$ & $\ve{u}$     & $\omega$    & $\epsilon'$ & $\Delta x$        & $g_n^\mathrm{min}$ \\
890 \multicolumn{3}{l}{{\tt .mdp} input variable name}         & \smtt{k} & \smtt{vec}     & \smtt{pivot} & \smtt{rate} & \smtt{eps}  & \smtt{slab\_dist} & \smtt{min\_gauss}  \\
891 unit                &               &                      & \kunit   & -              & nm           & $^\circ$/ps & nm$^2$      & nm                & \,-\,              \\[1mm]
892 \hline \multicolumn{2}{l}{fixed axis potentials:} & eqn.\\
893 isotropic           & V\rotiso      & (\ref{eqn:potiso})   & {\sf x}  & {\sf x}        & {\sf x}      & {\sf x}     & -           & -                 &  -                 \\
894 --- pivot-free      & V\rotisopf    & (\ref{eqn:potisopf}) & {\sf x}  & {\sf x}        & -            & {\sf x}     & -           & -                 &  -                 \\
895 parallel motion     & V\rotpm       & (\ref{eqn:potpm})    & {\sf x}  & {\sf x}        & {\sf x}      & {\sf x}     & -           & -                 &  -                 \\
896 --- pivot-free      & V\rotpmpf     & (\ref{eqn:potpmpf})  & {\sf x}  & {\sf x}        & -            & {\sf x}     & -           & -                 &  -                 \\
897 radial motion       & V\rotrm       & (\ref{eqn:potrm})    & {\sf x}  & {\sf x}        & {\sf x}      & {\sf x}     & -           & -                 &  -                 \\
898 --- pivot-free      & V\rotrmpf     & (\ref{eqn:potrmpf})  & {\sf x}  & {\sf x}        & -            & {\sf x}     & -           & -                 &  -                 \\
899 radial motion\,2    & V\rotrmtwo    & (\ref{eqn:potrm2})   & {\sf x}  & {\sf x}        & {\sf x}      & {\sf x}     & {\sf x}     & -                 &  -                 \\
900 --- pivot-free      & V\rotrmtwopf  & (\ref{eqn:potrm2pf}) & {\sf x}  & {\sf x}        & -            & {\sf x}     & {\sf x}     & -                 &  -                 \\ \hline
901 \multicolumn{2}{l}{flexible axis potentials:}  & eqn.\\
902 flexible            & V\rotflex     & (\ref{eqn:potflex})  & {\sf x}  & {\sf x}        & -            & {\sf x}     & -           & {\sf x}           &  {\sf x}           \\
903 --- transl. tol.    & V\rotflext    & (\ref{eqn:potflext}) & {\sf x}  & {\sf x}        & -            & {\sf x}     & -           & {\sf x}           &  {\sf x}           \\
904 flexible\,2         & V\rotflextwo  & (\ref{eqn:potflex2}) & {\sf x}  & {\sf x}        & -            & {\sf x}     & {\sf x}     & {\sf x}           &  {\sf x}           \\
905 --- transl. tol.    & V\rotflextwot &  -                   & {\sf x}  & {\sf x}        & -            & {\sf x}     & {\sf x}     & {\sf x}           &  {\sf x}           \\
906 \hline
907 \end{tabular}
908 \end{center}
909 \end{table}
910
911 \begin{table}
912 \caption{Quantities recorded in output files during enforced rotation simulations.
913 All slab-wise data is written every {\tt nstsout} steps, other rotation data every {\tt nstrout} steps.}
914 \label{tab:quantities}
915 \begin{center}
916 \begin{tabular}{llllcc}
917 \hline
918 quantity                                             & unit    & equation                          & output file     & fixed   & flexible\\ \hline
919 $V(t)$                                               & kJ/mol  & see \ref{tab:vars}                & {\tt rotation}  & {\sf x} & {\sf x} \\
920 $\theta_\mathrm{ref}(t)$                             & degrees & $\theta_\mathrm{ref}(t)=\omega t$ & {\tt rotation}  & {\sf x} & {\sf x} \\
921 $\theta_\mathrm{av}(t)$                              & degrees & (\ref{eqn:avangle})               & {\tt rotation}  & {\sf x} & -       \\
922 $\theta_\mathrm{fit}(t)$, $\theta_\mathrm{fit}(t,n)$ & degrees & (\ref{eqn:rmsdfit})               & {\tt rotangles} & -       & {\sf x} \\
923 $\ve{y}_0(n)$, $\ve{x}_0(t,n)$                       & nm      & (\ref{eqn:defx0}, \ref{eqn:defy0})& {\tt rotslabs}  & -       & {\sf x} \\
924 $\tau(t)$                                            & kJ/mol  & (\ref{eqn:torque})                & {\tt rotation}  & {\sf x} & -       \\
925 $\tau(t,n)$                                          & kJ/mol  & (\ref{eqn:torque})                & {\tt rottorque} & -       & {\sf x} \\ \hline
926 \end{tabular}
927 \end{center}
928 \end{table}
929
930
931 \subsubsection*{Angle of Rotation Groups: Fixed Axis}
932 For fixed axis rotation, the average angle $\theta_\mathrm{av}(t)$ of the 
933 group relative to the reference group is determined via the distance-weighted
934 angular deviation of all rotation group atoms from their reference positions,
935 \beq
936 \theta_\mathrm{av} = \left. \sum_{i=1}^{N} r_i \ \theta_i \right/ \sum_{i=1}^N r_i \ .
937 \label{eqn:avangle}
938 \eeq
939 Here, $r_i$ is the distance of the reference position to the rotation axis, and
940 the difference angles $\theta_i$ are determined from the atomic positions, 
941 projected onto a plane perpendicular to the rotation axis through pivot point
942 $\ve{u}$ (see \eqnref{project} for the definition of $\perp$),
943 \beq
944 \cos \theta_i = 
945 \frac{(\ve{y}_i-\ve{u})^\perp \cdot (\ve{x}_i-\ve{u})^\perp}
946      { \| (\ve{y}_i-\ve{u})^\perp \cdot (\ve{x}_i-\ve{u})^\perp
947      \| } \ .
948 \eeq
949 %
950 The sign of $\theta_\mathrm{av}$ is chosen such that
951 $\theta_\mathrm{av} > 0$ if the actual structure rotates ahead of the reference.
952
953 \subsubsection*{Angle of Rotation Groups: Flexible Axis}
954 For flexible axis rotation, two outputs are provided, the angle of the
955 entire rotation group, and separate angles for the segments in the slabs.
956 The angle of the entire rotation group is determined by an RMSD fit 
957 of $\ve{x}_i$
958 to the reference positions $\ve{y}_i^0$ at $t=0$, yielding $\theta_\mathrm{fit}$
959 as the angle by which the reference has to be rotated around $\hat{\ve{v}}$ 
960 for the optimal fit,
961 \beq
962 \mathrm{RMSD} \big( \ve{x}_i,\ \mathbf{\Omega}(\theta_\mathrm{fit})
963 \ve{y}_i^0 \big) \stackrel{!}{=} \mathrm{min} \, .
964 \label{eqn:rmsdfit}
965 \eeq
966 To determine the local angle for each slab $n$, both reference and actual
967 positions are weighted with the Gaussian function of slab $n$, and 
968 $\theta_\mathrm{fit}(t,n)$ is calculated as in \eqnref{rmsdfit}) from the
969 Gaussian-weighted positions.
970
971 For all angles, the {\tt .mdp} input option {\tt rot\_fit\_method} controls
972 whether a normal RMSD fit is performed or whether for the fit each
973 position $\ve{x}_i$ is put at the same distance to the rotation axis as its
974 reference counterpart $\ve{y}_i^0$. In the latter case, the RMSD
975 measures only angular differences, not radial ones.
976
977
978 \subsubsection*{Angle Determination by Searching the Energy Minimum}
979 Alternatively, for {\tt rot\_fit\_method = potential}, the angle of the rotation 
980 group is determined as the angle for which the rotation potential energy is minimal.
981 Therefore, the used rotation potential is additionally evaluated for a set of angles
982 around the current reference angle. In this case, the {\tt rotangles.log} output file
983 contains the values of the rotation potential at the chosen set of angles, while 
984 {\tt rotation.xvg} lists the angle with minimal potential energy.
985
986
987 \subsubsection*{Torque}
988 \label{torque}
989 The torque $\ve{\tau}(t)$ exerted by the rotation potential is calculated for fixed
990 axis rotation via
991 \beq
992 \ve{\tau}(t) = \sum_{i=1}^{N} \ve{r}_i(t) \times \ve{f}_{\!i}^\perp(t) ,
993 \label{eqn:torque}
994 \eeq
995 where $\ve{r}_i(t)$ is the distance vector from the rotation axis to
996 $\ve{x}_i(t)$ and $\ve{f}_{\!i}^\perp(t)$ is the force component
997 perpendicular to $\ve{r}_i(t)$ and $\hat{\ve{v}}$. For flexible axis
998 rotation, torques $\ve{\tau}_{\!n}$ are calculated for each slab using the
999 local rotation axis of the slab and the Gaussian-weighted positions.
1000
1001
1002
1003 \section{Calculating a PMF using the free-energy code}
1004 \label{sec:fepmf}
1005 \index{potentials of mean force}
1006 \index{free energy calculations}
1007 The free-energy coupling-parameter approach (see~\secref{fecalc})
1008 provides several ways to calculate potentials of mean force.
1009 A potential of mean force between two atoms can be calculated
1010 by connecting them with a harmonic potential or a constraint.
1011 For this purpose there are special potentials that avoid the generation of
1012 extra exclusions, see~\secref{excl}.
1013 When the position of the minimum or the constraint length is 1 nm more
1014 in state B than in state A, the restraint or constraint force is given
1015 by $\partial H/\partial \lambda$.
1016 The distance between the atoms can be changed as a function of $\lambda$
1017 and time by setting {\tt delta-lambda} in the {\tt .mdp} file.
1018 The results should be identical (although not numerically
1019 due to the different implementations) to the results of the pull code
1020 with umbrella sampling and constraint pulling.
1021 Unlike the pull code, the free energy code can also handle atoms that
1022 are connected by constraints.
1023
1024 Potentials of mean force can also be calculated using position restraints.
1025 With position restraints, atoms can be linked to a position in space
1026 with a harmonic potential (see \ssecref{positionrestraint}).
1027 These positions can be made a function of the coupling parameter $\lambda$.
1028 The positions for the A and the B states are supplied to {\tt grompp} with
1029 the {\tt -r} and {\tt -rb} options, respectively.
1030 One could use this approach to do \normindex{targeted MD};
1031 note that we do not encourage the use of targeted MD for proteins.
1032 A protein can be forced from one conformation to another by using
1033 these conformations as position restraint coordinates for state A and B.
1034 One can then slowly change $\lambda$ from 0 to 1.
1035 The main drawback of this approach is that the conformational freedom
1036 of the protein is severely limited by the position restraints,
1037 independent of the change from state A to B.
1038 Also, the protein is forced from state A to B in an almost straight line,
1039 whereas the real pathway might be very different.
1040 An example of a more fruitful application is a solid system or a liquid
1041 confined between walls where one wants to measure the force required
1042 to change the separation between the boundaries or walls.
1043 Because the boundaries (or walls) already need to be fixed,
1044 the position restraints do not limit the system in its sampling.
1045
1046 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1049 \newcommand{\amine}{\sf -NH$_2$}
1050 \newcommand{\amines}{\sf -NH-}
1051 \newcommand{\aminep}{\sf -NH$_3^+$}
1052 \section{Removing fastest \swapindex{degrees of}{freedom}}
1053 \label{sec:rmfast}
1054 The maximum time step in MD simulations is limited by the smallest
1055 oscillation period that can be found in the simulated
1056 system. Bond-stretching vibrations are in their quantum-mechanical
1057 ground state and are therefore better represented by a constraint 
1058 instead of a harmonic potential.
1059
1060 For the remaining degrees of freedom, the shortest oscillation period
1061 (as measured from a simulation) is 13~fs for bond-angle vibrations
1062 involving hydrogen atoms. Taking as a guideline that with a Verlet
1063 (leap-frog) integration scheme a minimum of 5 numerical integration
1064 steps should be performed per period of a harmonic oscillation in
1065 order to integrate it with reasonable accuracy, the maximum time step
1066 will be about 3~fs. Disregarding these very fast oscillations of
1067 period 13~fs, the next shortest periods are around 20~fs, which will
1068 allow a maximum time step of about 4~fs.
1069
1070 Removing the bond-angle degrees of freedom from hydrogen atoms can
1071 best be done by defining them as \normindex{virtual interaction sites}
1072 instead of normal atoms. Whereas a normal atom is connected to the molecule
1073 with bonds, angles and dihedrals, a virtual site's position is calculated
1074 from the position of three nearby heavy atoms in a predefined manner
1075 (see also \secref{virtual_sites}). For the hydrogens in water and in
1076 hydroxyl, sulfhydryl, or amine groups, no degrees of freedom can be
1077 removed, because rotational freedom should be preserved. The only
1078 other option available to slow down these motions is to increase the
1079 mass of the hydrogen atoms at the expense of the mass of the connected
1080 heavy atom. This will increase the moment of inertia of the water
1081 molecules and the hydroxyl, sulfhydryl, or amine groups, without
1082 affecting the equilibrium properties of the system and without
1083 affecting the dynamical properties too much. These constructions will
1084 shortly be described in \secref{vsitehydro} and have previously
1085 been described in full detail~\cite{feenstra99}.
1086
1087 Using both virtual sites and \swapindex{modified}{mass}es, the next
1088 bottleneck is likely to be formed by the improper dihedrals (which are
1089 used to preserve planarity or chirality of molecular groups) and the
1090 peptide dihedrals. The peptide dihedral cannot be changed without
1091 affecting the physical behavior of the protein. The improper dihedrals
1092 that preserve planarity mostly deal with aromatic residues. Bonds,
1093 angles, and dihedrals in these residues can also be replaced with
1094 somewhat elaborate virtual site constructions.
1095
1096 All modifications described in this section can be performed using the
1097 {\gromacs} topology building tool {\tt \normindex{pdb2gmx}}. Separate
1098 options exist to increase hydrogen masses, virtualize all hydrogen atoms,
1099 or also virtualize all aromatic residues. {\bf Note} that when all hydrogen
1100 atoms are virtualized, those inside the aromatic residues will be
1101 virtualized as well, {\ie} hydrogens in the aromatic residues are treated
1102 differently depending on the treatment of the aromatic residues.
1103
1104 Parameters for the virtual site constructions for the hydrogen atoms are
1105 inferred from the force field parameters ({\em vis}. bond lengths and
1106 angles) directly by {\tt \normindex{grompp}} while processing the
1107 topology file.  The constructions for the aromatic residues are based
1108 on the bond lengths and angles for the geometry as described in the
1109 force fields, but these parameters are hard-coded into {\tt
1110 \normindex{pdb2gmx}} due to the complex nature of the construction
1111 needed for a whole aromatic group.
1112
1113 \subsection{Hydrogen bond-angle vibrations}
1114 \label{sec:vsitehydro}
1115 \subsubsection{Construction of virtual sites} %%%%%%%%%%%%%%%%%%%%%%%%%
1116 \begin{figure}
1117 \centerline{\includegraphics[width=11cm]{plots/dumtypes}}
1118 \caption[Virtual site constructions for hydrogen atoms.]{The different
1119 types of virtual site constructions used for hydrogen atoms. The atoms
1120 used in the construction of the virtual site(s) are depicted as black
1121 circles, virtual sites as gray ones. Hydrogens are smaller than heavy
1122 atoms. {\sf A}: fixed bond angle, note that here the hydrogen is not a
1123 virtual site; {\sf B}: in the plane of three atoms, with fixed distance;
1124 {\sf C}: in the plane of three atoms, with fixed angle and distance;
1125 {\sf D}: construction for amine groups ({\amine} or {\aminep}), see
1126 text for details.}
1127 \label{fig:vsitehydro}
1128 \end{figure}
1129
1130 The goal of defining hydrogen atoms as virtual sites is to remove all
1131 high-frequency degrees of freedom from them. In some cases, not all
1132 degrees of freedom of a hydrogen atom should be removed, {\eg} in the
1133 case of hydroxyl or amine groups the rotational freedom of the
1134 hydrogen atom(s) should be preserved. Care should be taken that no
1135 unwanted correlations are introduced by the construction of virtual
1136 sites, {\eg} bond-angle vibration between the constructing atoms could
1137 translate into hydrogen bond-length vibration. Additionally, since
1138 virtual sites are by definition massless, in order to preserve total
1139 system mass, the mass of each hydrogen atom that is treated as virtual
1140 site should be added to the bonded heavy atom.
1141
1142 Taking into account these considerations, the hydrogen atoms in a
1143 protein naturally fall into several categories, each requiring a
1144 different approach (see also \figref{vsitehydro}).
1145
1146 \begin{itemize}
1147
1148 \item{\em hydroxyl ({\sf -OH}) or sulfhydryl ({\sf -SH})
1149 hydrogen:\/} The only internal degree of freedom in a hydroxyl group
1150 that can be constrained is the bending of the {\sf C-O-H} angle. This
1151 angle is fixed by defining an additional bond of appropriate length,
1152 see \figref{vsitehydro}A. Doing so removes the high-frequency angle bending,
1153 but leaves the dihedral rotational freedom. The same goes for a
1154 sulfhydryl group. {\bf Note} that in these cases the hydrogen is not treated
1155 as a virtual site.
1156
1157 \item{\em single amine or amide ({\amines}) and aromatic hydrogens
1158 ({\sf -CH-}):\/} The position of these hydrogens cannot be constructed
1159 from a linear combination of bond vectors, because of the flexibility
1160 of the angle between the heavy atoms. Instead, the hydrogen atom is
1161 positioned at a fixed distance from the bonded heavy atom on a line
1162 going through the bonded heavy atom and a point on the line through
1163 both second bonded atoms, see \figref{vsitehydro}B.
1164
1165 \item{\em planar amine ({\amine}) hydrogens:\/} The method used for
1166 the single amide hydrogen is not well suited for planar amine groups,
1167 because no suitable two heavy atoms can be found to define the
1168 direction of the hydrogen atoms. Instead, the hydrogen is constructed
1169 at a fixed distance from the nitrogen atom, with a fixed angle to the
1170 carbon atom, in the plane defined by one of the other heavy atoms, see
1171 \figref{vsitehydro}C.
1172
1173 \item{\em amine group (umbrella {\amine} or {\aminep}) hydrogens:\/}
1174 Amine hydrogens with rotational freedom cannot be constructed as virtual
1175 sites from the heavy atoms they are connected to, since this would
1176 result in loss of the rotational freedom of the amine group. To
1177 preserve the rotational freedom while removing the hydrogen bond-angle
1178 degrees of freedom, two ``dummy masses'' are constructed with the same
1179 total mass, moment of inertia (for rotation around the {\sf C-N} bond)
1180 and center of mass as the amine group. These dummy masses have no
1181 interaction with any other atom, except for the fact that they are
1182 connected to the carbon and to each other, resulting in a rigid
1183 triangle. From these three particles, the positions of the nitrogen and
1184 hydrogen atoms are constructed as linear combinations of the two
1185 carbon-mass vectors and their outer product, resulting in an amine
1186 group with rotational freedom intact, but without other internal
1187 degrees of freedom. See \figref{vsitehydro}D.
1188
1189 \end{itemize}
1190
1191 \begin{figure}
1192 \centerline{\includegraphics[width=15cm]{plots/dumaro}}
1193 \caption[Virtual site constructions for aromatic residues.]{The
1194 different types of virtual site constructions used for aromatic
1195 residues. The atoms used in the construction of the virtual site(s) are
1196 depicted as black circles, virtual sites as gray ones. Hydrogens are
1197 smaller than heavy atoms. {\sf A}: phenylalanine; {\sf B}: tyrosine
1198 (note that the hydroxyl hydrogen is {\em not} a virtual site); {\sf C}:
1199 tryptophan; {\sf D}: histidine.}
1200 \label{fig:vistearo}
1201 \end{figure}
1202
1203 \subsection{Out-of-plane vibrations in aromatic groups}
1204 \label{sec:vsitearo}
1205 The planar arrangements in the side chains of the aromatic residues
1206 lends itself perfectly to a virtual-site construction, giving a
1207 perfectly planar group without the inherently unstable constraints
1208 that are necessary to keep normal atoms in a plane. The basic approach
1209 is to define three atoms or dummy masses with constraints between them
1210 to fix the geometry and create the rest of the atoms as simple virtual
1211 sites type (see \secref{virtual_sites}) from these three. Each of
1212 the aromatic residues require a different approach:
1213
1214 \begin{itemize}
1215
1216 \item{\em Phenylalanine:\/} {\sf C}$_\gamma$, {\sf C}$_{{\epsilon}1}$,
1217 and {\sf C}$_{{\epsilon}2}$ are kept as normal atoms, but with each a
1218 mass of one third the total mass of the phenyl group. See
1219 \figref{vsitehydro}A.
1220
1221 \item{\em Tyrosine:\/} The ring is treated identically to the
1222 phenylalanine ring. Additionally, constraints are defined between {\sf
1223 C}$_{{\epsilon}1}$, {\sf C}$_{{\epsilon}2}$, and {\sf O}$_{\eta}$.
1224 The original improper dihedral angles will keep both triangles (one
1225 for the ring and one with {\sf O}$_{\eta}$) in a plane, but due to the
1226 larger moments of inertia this construction will be much more
1227 stable. The bond-angle in the hydroxyl group will be constrained by a
1228 constraint between {\sf C}$_\gamma$ and {\sf H}$_{\eta}$. {\bf Note} that
1229 the hydrogen is not treated as a virtual site. See
1230 \figref{vsitehydro}B.
1231
1232 \item{\em Tryptophan:\/} {\sf C}$_\beta$ is kept as a normal atom
1233 and two dummy masses are created at the center of mass of each of the
1234 rings, each with a mass equal to the total mass of the respective ring
1235 ({\sf C}$_{{\delta}2}$ and {\sf C}$_{{\epsilon}2}$ are each
1236 counted half for each ring). This keeps the overall center of mass and
1237 the moment of inertia almost (but not quite) equal to what it was. See
1238 \figref{vsitehydro}C.
1239
1240 \item{\em Histidine:\/} {\sf C}$_\gamma$, {\sf C}$_{{\epsilon}1}$
1241 and {\sf N}$_{{\epsilon}2}$ are kept as normal atoms, but with masses
1242 redistributed such that the center of mass of the ring is
1243 preserved. See \figref{vsitehydro}D.
1244
1245 \end{itemize}
1246
1247 \section{Viscosity calculation\index{viscosity}}
1248
1249 The shear viscosity is a property of liquids that can be determined easily  
1250 by experiment. It is useful for parameterizing a force field
1251 because it is a kinetic property, while most other properties
1252 which are used for parameterization are thermodynamic.
1253 The viscosity is also an important property, since it influences
1254 the rates of conformational changes of molecules solvated in the liquid.
1255
1256 The viscosity can be calculated from an equilibrium simulation using
1257 an Einstein relation:
1258 \beq
1259 \eta = \frac{1}{2}\frac{V}{k_B T} \lim_{t \rightarrow \infty}
1260 \frac{\mbox{d}}{\mbox{d} t} \left\langle 
1261 \left( \int_{t_0}^{{t_0}+t} P_{xz}(t') \mbox{d} t' \right)^2
1262 \right\rangle_{t_0}
1263 \eeq
1264 This can be done with {\tt g_energy}.
1265 This method converges very slowly~\cite{Hess2002a}, and as such
1266 a nanosecond simulation might not
1267 be long enough for an accurate determination of the viscosity.
1268 The result is very dependent on the treatment of the electrostatics.
1269 Using a (short) cut-off results in large noise on the off-diagonal
1270 pressure elements, which can increase the calculated viscosity by an order
1271 of magnitude.
1272
1273 {\gromacs} also has a non-equilibrium method for determining
1274 the viscosity~\cite{Hess2002a}.
1275 This makes use of the fact that energy, which is fed into system by
1276 external forces, is dissipated through viscous friction. The generated heat
1277 is removed by coupling to a heat bath. For a Newtonian liquid adding a 
1278 small force will result in a velocity gradient according to the following
1279 equation:
1280 \beq
1281 a_x(z) + \frac{\eta}{\rho} \frac{\partial^2 v_x(z)}{\partial z^2} = 0
1282 \eeq
1283 Here we have applied an acceleration $a_x(z)$ in the $x$-direction, which
1284 is a function of the $z$-coordinate.
1285 In {\gromacs} the acceleration profile is:
1286 \beq
1287 a_x(z) = A \cos\left(\frac{2\pi z}{l_z}\right)
1288 \eeq
1289 where $l_z$ is the height of the box. The generated velocity profile is:
1290 \beq
1291 v_x(z) = V \cos\left(\frac{2\pi z}{l_z}\right)
1292 \eeq
1293 \beq
1294 V = A \frac{\rho}{\eta}\left(\frac{l_z}{2\pi}\right)^2
1295 \eeq
1296 The viscosity can be calculated from $A$ and $V$:
1297 \beq
1298 \label{visc}
1299 \eta = \frac{A}{V}\rho \left(\frac{l_z}{2\pi}\right)^2
1300 \eeq
1301
1302 In the simulation $V$ is defined as:
1303 \beq
1304 V = \frac{\displaystyle \sum_{i=1}^N m_i v_{i,x} 2 \cos\left(\frac{2\pi z}{l_z}\right)}
1305          {\displaystyle \sum_{i=1}^N m_i}
1306 \eeq
1307 The generated velocity profile is not coupled to the heat bath. Moreover,
1308 the velocity profile is excluded from the kinetic energy.
1309 One would like $V$ to be as large as possible to get good statistics.
1310 However, the shear rate should not be so high that the system gets too far
1311 from equilibrium. The maximum shear rate occurs where the cosine is zero,
1312 the rate being:
1313 \beq
1314 \mbox{sh}_{\max} =  \max_z \left| \frac{\partial v_x(z)}{\partial z} \right|
1315 = A \frac{\rho}{\eta} \frac{l_z}{2\pi}
1316 \eeq
1317 For a simulation with: $\eta=10^{-3}$ [kg\,m$^{-1}$\,s$^{-1}$],
1318 $\rho=10^3$\,[kg\,m$^{-3}$] and $l_z=2\pi$\,[nm],
1319 $\mbox{sh}_{\max}=1$\,[ps\,nm$^{-1}$] $A$.
1320 This shear rate should be smaller than one over the longest
1321 correlation time in the system. For most liquids, this will be the rotation
1322 correlation time, which is around 10 ps. In this case, $A$ should
1323 be smaller than 0.1\,[nm\,ps$^{-2}$].
1324 When the shear rate is too high, the observed viscosity will be too low.
1325 Because $V$ is proportional to the square of the box height,
1326 the optimal box is elongated in the $z$-direction.
1327 In general, a simulation length of 100 ps is enough to obtain an
1328 accurate value for the viscosity.
1329
1330 The heat generated by the viscous friction is removed by coupling to a heat
1331 bath. Because this coupling is not instantaneous the real temperature of the
1332 liquid will be slightly lower than the observed temperature.
1333 Berendsen derived this temperature shift~\cite{Berendsen91}, which can
1334 be written in terms of the shear rate as:
1335 \beq
1336 T_s = \frac{\eta\,\tau}{2 \rho\,C_v} \mbox{sh}_{\max}^2
1337 \eeq
1338 where $\tau$ is the coupling time for the Berendsen thermostat and
1339 $C_v$ is the heat capacity. Using the values of the example above,
1340 $\tau=10^{-13}$ [s] and $C_v=2 \cdot 10^3$\,[J kg$^{-1}$\,K$^{-1}$], we
1341 get: $T_s=25$\,[K\,ps$^{-2}$]\,sh$_{\max}^2$. When we want the shear
1342 rate to be smaller than $1/10$\,[ps$^{-1}$], $T_s$ is smaller than
1343 0.25\,[K], which is negligible.
1344
1345 {\bf Note} that the system has to build up the velocity profile when starting
1346 from an equilibrium state. This build-up time is of the order of the
1347 correlation time of the liquid.
1348
1349 Two quantities are written to the energy file, along with their averages
1350 and fluctuations: $V$ and $1/\eta$, as obtained from (\ref{visc}).
1351
1352 \section{Tabulated interaction functions\index{tabulated interaction functions}}
1353 \subsection{Cubic splines for potentials}
1354 \label{subsec:cubicspline}
1355 In some of the inner loops of {\gromacs}, look-up tables are used 
1356 for computation of potential and forces. 
1357 The tables are interpolated using a cubic
1358 spline algorithm. 
1359 There are separate tables for electrostatic, dispersion, and repulsion
1360 interactions,
1361 but for the sake of caching performance these have been combined
1362 into a single array. 
1363 The cubic spline interpolation for $x_i \leq x < x_{i+1}$ looks like this:
1364 \beq
1365 V_s(x) = A_0 + A_1 \,\epsilon + A_2 \,\epsilon^2 + A_3 \,\epsilon^3
1366 \label{eqn:spline}
1367 \eeq
1368 where the table spacing $h$ and fraction $\epsilon$ are given by:
1369 \bea
1370 h       &=&     x_{i+1} - x_i   \\
1371 \epsilon&=&     (x - x_i)/h
1372 \eea
1373 so that $0 \le \epsilon < 1$.
1374 From this, we can calculate the derivative in order to determine the forces:
1375 \beq
1376 -V_s'(x) ~=~ 
1377 -\frac{{\rm d}V_s(x)}{{\rm d}\epsilon}\frac{{\rm d}\epsilon}{{\rm d}x} ~=~
1378 -(A_1 + 2 A_2 \,\epsilon + 3 A_3 \,\epsilon^2)/h
1379 \eeq
1380 The four coefficients are determined from the four conditions
1381 that $V_s$ and $-V_s'$ at both ends of each interval should match
1382 the exact potential $V$ and force $-V'$.
1383 This results in the following errors for each interval:
1384 \bea
1385 |V_s  - V  |_{max} &=& V'''' \frac{h^4}{384} + O(h^5) \\
1386 |V_s' - V' |_{max} &=& V'''' \frac{h^3}{72\sqrt{3}} + O(h^4) \\
1387 |V_s''- V''|_{max} &=& V'''' \frac{h^2}{12}  + O(h^3)
1388 \eea
1389 V and V' are continuous, while V'' is the first discontinuous
1390 derivative.
1391 The number of points per nanometer is 500 and 2000
1392 for single- and double-precision versions of {\gromacs}, respectively.
1393 This means that the errors in the potential and force will usually
1394 be smaller than the single precision accuracy.
1395
1396 {\gromacs} stores $A_0$, $A_1$, $A_2$ and $A_3$.
1397 The force routines get a table with these four parameters and
1398 a scaling factor $s$ that is equal to the number of points per nm.
1399 ({\bf Note} that $h$ is $s^{-1}$).
1400 The algorithm goes a little something like this:
1401 \begin{enumerate}
1402 \item   Calculate distance vector (\ve{r}$_{ij}$) and distance r$_{ij}$
1403 \item   Multiply r$_{ij}$ by $s$ and truncate to an integer value $n_0$
1404         to get a table index
1405 \item   Calculate fractional component ($\epsilon$ = $s$r$_{ij} - n_0$) 
1406         and $\epsilon^2$ 
1407 \item   Do the interpolation to calculate the potential $V$ and the scalar force $f$
1408 \item   Calculate the vector force \ve{F} by multiplying $f$ with \ve{r}$_{ij}$
1409 \end{enumerate}
1410
1411 {\bf Note} that table look-up is significantly {\em
1412 slower} than computation of the most simple Lennard-Jones and Coulomb
1413 interaction. However, it is much faster than the shifted Coulomb
1414 function used in conjunction with the PPPM method. Finally, it is much
1415 easier to modify a table for the potential (and get a graphical
1416 representation of it) than to modify the inner loops of the MD
1417 program.
1418
1419 \subsection{User-specified potential functions}
1420 \label{subsec:userpot}
1421 You can also use your own \index{potential function}s 
1422 without editing the {\gromacs} code. 
1423 The potential function should be according to the following equation
1424 \beq
1425 V(r_{ij}) ~=~ \frac{q_i q_j}{4 \pi\epsilon_0} f(r_{ij}) + C_6 \,g(r_{ij}) + C_{12} \,h(r_{ij})
1426 \eeq
1427 where $f$, $g$, and $h$ are user defined functions. {\bf Note} that if $g(r)$ represents a
1428 normal dispersion interaction, $g(r)$ should be $<$ 0. C$_6$, C$_{12}$
1429 and the charges are read from the topology. Also note that combination
1430 rules are only supported for Lennard-Jones and Buckingham, and that
1431 your tables should match the parameters in the binary topology.
1432
1433 When you add the following lines in your {\tt .mdp} file:
1434
1435 {\small
1436 \begin{verbatim}
1437 rlist           = 1.0
1438 coulombtype     = User
1439 rcoulomb        = 1.0
1440 vdwtype         = User
1441 rvdw            = 1.0
1442 \end{verbatim}}
1443
1444 {\tt mdrun} will read a single non-bonded table file,
1445 or multiple when {\tt energygrp-table} is set (see below).
1446 The name of the file(s) can be set with the {\tt mdrun} option {\tt -table}.
1447 The table file should contain seven columns of table look-up data in the
1448 order: $x$, $f(x)$, $-f'(x)$, $g(x)$, $-g'(x)$, $h(x)$, $-h'(x)$.
1449 The $x$ should run from 0 to $r_c+1$ (the value of {\tt table_extension} can be
1450 changed in the {\tt .mdp} file).
1451 You can choose the spacing you like; for the standard tables {\gromacs}
1452 uses a spacing of 0.002 and 0.0005 nm when you run in single
1453 and double precision, respectively.  In this
1454 context, $r_c$ denotes the maximum of the two cut-offs {\tt rvdw} and
1455 {\tt rcoulomb} (see above). These variables need not be the same (and
1456 need not be 1.0 either).  Some functions used for potentials contain a
1457 singularity at $x = 0$, but since atoms are normally not closer to each
1458 other than 0.1 nm, the function value at $x = 0$ is not important.
1459 Finally, it is also
1460 possible to combine a standard Coulomb with a modified LJ potential
1461 (or vice versa). One then specifies {\eg} {\tt coulombtype = Cut-off} or
1462 {\tt coulombtype = PME}, combined with {\tt vdwtype = User}.  The table file must
1463 always contain the 7 columns however, and meaningful data (i.e. not
1464 zeroes) must be entered in all columns.  A number of pre-built table
1465 files can be found in the {\tt GMXLIB} directory for 6-8, 6-9, 6-10, 6-11, and 6-12
1466 Lennard-Jones potentials combined with a normal Coulomb.
1467
1468 If you want to have different functional forms between different
1469 groups of atoms, this can be set through energy groups.
1470 Different tables can be used for non-bonded interactions between
1471 different energy groups pairs through the {\tt .mdp} option {\tt energygrp-table}
1472 (see \secref{mdpopt}).
1473 Atoms that should interact with a different potential should
1474 be put into different energy groups.
1475 Between group pairs which are not listed in {\tt energygrp-table},
1476 the normal user tables will be used. This makes it easy to use
1477 a different functional form between a few types of atoms.
1478
1479 \section{Mixed Quantum-Classical simulation techniques}
1480
1481 In a molecular mechanics (MM) force field, the influence of electrons
1482 is expressed by empirical parameters that are assigned on the basis of
1483 experimental data, or on the basis of results from high-level quantum
1484 chemistry calculations. These are valid for the ground state of a
1485 given covalent structure, and the MM approximation is usually
1486 sufficiently accurate for ground-state processes in which the overall
1487 connectivity between the atoms in the system remains
1488 unchanged. However, for processes in which the connectivity does
1489 change, such as chemical reactions, or processes that involve multiple
1490 electronic states, such as photochemical conversions, electrons can no
1491 longer be ignored, and a quantum mechanical description is required
1492 for at least those parts of the system in which the reaction takes
1493 place.
1494
1495 One approach to the simulation of chemical reactions in solution, or
1496 in enzymes, is to use a combination of quantum mechanics (QM) and
1497 molecular mechanics (MM). The reacting parts of the system are treated
1498 quantum mechanically, with the remainder being modeled using the
1499 force field. The current version of {\gromacs} provides interfaces to
1500 several popular Quantum Chemistry packages (MOPAC~\cite{mopac},
1501 GAMESS-UK~\cite{gamess-uk}, Gaussian~\cite{g03} and CPMD~\cite{Car85a}).
1502
1503 {\gromacs} interactions between the two subsystems are
1504 either handled as described by Field {\em et al.}~\cite{Field90a} or
1505 within the ONIOM approach by Morokuma and coworkers~\cite{Maseras96a,
1506 Svensson96a}.
1507
1508 \subsection{Overview}
1509
1510 Two approaches for describing the interactions between the QM and MM
1511 subsystems are supported in this version:
1512
1513 \begin{enumerate}
1514 \item{\textbf{Electronic Embedding}} The electrostatic interactions
1515 between the electrons of the QM region and the MM atoms and between
1516 the QM nuclei and the MM atoms are included in the Hamiltonian for
1517 the QM subsystem: \beq H^{QM/MM} =
1518 H^{QM}_e-\sum_i^n\sum_J^M\frac{e^2Q_J}{4\pi\epsilon_0r_{iJ}}+\sum_A^N\sum_J^M\frac{e^2Z_AQ_J}{e\pi\epsilon_0R_{AJ}},
1519 \eeq where $n$ and $N$ are the number of electrons and nuclei in the
1520 QM region, respectively, and $M$ is the number of charged MM
1521 atoms. The first term on the right hand side is the original
1522 electronic Hamiltonian of an isolated QM system. The first of the
1523 double sums is the total electrostatic interaction between the QM
1524 electrons and the MM atoms. The total electrostatic interaction of the
1525 QM nuclei with the MM atoms is given by the second double sum. Bonded
1526 interactions between QM and MM atoms are described at the MM level by
1527 the appropriate force field terms. Chemical bonds that connect the two
1528 subsystems are capped by a hydrogen atom to complete the valence of
1529 the QM region. The force on this atom, which is present in the QM
1530 region only, is distributed over the two atoms of the bond. The cap
1531 atom is usually referred to as a link atom.
1532
1533 \item{\textbf{ONIOM}} In the ONIOM approach, the energy and gradients
1534 are first evaluated for the isolated QM subsystem at the desired level
1535 of {\it{ab initio}} theory. Subsequently, the energy and gradients of
1536 the total system, including the QM region, are computed using the
1537 molecular mechanics force field and added to the energy and gradients
1538 calculated for the isolated QM subsystem. Finally, in order to correct
1539 for counting the interactions inside the QM region twice, a molecular
1540 mechanics calculation is performed on the isolated QM subsystem and
1541 the energy and gradients are subtracted. This leads to the following
1542 expression for the total QM/MM energy (and gradients likewise): \beq
1543 E_{tot} = E_{I}^{QM}
1544 +E_{I+II}^{MM}-E_{I}^{MM}, \eeq where the
1545 subscripts I and II refer to the QM and MM subsystems,
1546 respectively. The superscripts indicate at what level of theory the
1547 energies are computed. The ONIOM scheme has the
1548 advantage that it is not restricted to a two-layer QM/MM description,
1549 but can easily handle more than two layers, with each layer described
1550 at a different level of theory.
1551 \end{enumerate}
1552
1553 \subsection{Usage}
1554
1555 To make use of the QM/MM functionality in {\gromacs}, one needs to:
1556
1557 \begin{enumerate}
1558 \item introduce link atoms at the QM/MM boundary, if needed;
1559 \item specify which atoms are to be treated at a QM level;
1560 \item specify the QM level, basis set, type of QM/MM interface and so on. 
1561 \end{enumerate}
1562
1563 \subsubsection{Adding link atoms}
1564
1565 At the bond that connects the QM and MM subsystems, a link atoms is
1566 introduced.  In {\gromacs} the link atom has special atomtype, called
1567 LA. This atomtype is treated as a hydrogen atom in the QM calculation,
1568 and as a virtual site in the force field calculation. The link atoms, if
1569 any, are part of the system, but have no interaction with any other
1570 atom, except that the QM force working on it is distributed over the
1571 two atoms of the bond. In the topology, the link atom (LA), therefore,
1572 is defined as a virtual site atom:
1573
1574 {\small
1575 \begin{verbatim}
1576 [ virtual_sites2 ]
1577 LA QMatom MMatom 1 0.65
1578 \end{verbatim}}
1579
1580 See~\secref{vsitetop} for more details on how virtual sites are
1581 treated. The link atom is replaced at every step of the simulation.
1582
1583 In addition, the bond itself is replaced by a constraint:
1584
1585 {\small
1586 \begin{verbatim}
1587 [ constraints ]
1588 QMatom MMatom 2 0.153
1589 \end{verbatim}}
1590
1591 {\bf Note} that, because in our system the QM/MM bond is a carbon-carbon
1592 bond (0.153 nm), we use a constraint length of 0.153 nm, and dummy
1593 position of 0.65. The latter is the ratio between the ideal C-H
1594 bond length and the ideal C-C bond length. With this ratio, the link
1595 atom is always 0.1 nm away from the {\tt QMatom}, consistent with the
1596 carbon-hydrogen bond length. If the QM and MM subsystems are connected
1597 by a different kind of bond, a different constraint and a different
1598 dummy position, appropriate for that bond type, are required.
1599
1600 \subsubsection{Specifying the QM atoms}
1601
1602 Atoms that should be treated at a QM level of theory, including the
1603 link atoms, are added to the index file. In addition, the chemical
1604 bonds between the atoms in the QM region are to be defined as
1605 connect bonds (bond type 5) in the topology file:
1606
1607 {\small
1608 \begin{verbatim}
1609 [ bonds ]
1610 QMatom1 QMatom2 5
1611 QMatom2 QMatom3 5
1612 \end{verbatim}}
1613
1614 \subsubsection{Specifying the QM/MM simulation parameters}
1615
1616 In the {\tt .mdp} file, the following parameters control a QM/MM simulation.
1617
1618 \begin{description}
1619
1620 \item[\tt QMMM = no]\mbox{}\\ If this is set to {\tt yes}, a QM/MM
1621 simulation is requested. Several groups of atoms can be described at
1622 different QM levels separately. These are specified in the QMMM-grps
1623 field separated by spaces. The level of {\it{ab initio}} theory at which the
1624 groups are described is specified by {\tt QMmethod} and {\tt QMbasis}
1625 Fields. Describing the groups at different levels of theory is only
1626 possible with the ONIOM QM/MM scheme, specified by {\tt QMMMscheme}.
1627
1628 \item[\tt QMMM-grps =]\mbox{}\\groups to be described at the QM level
1629
1630 \item[\tt QMMMscheme = normal]\mbox{}\\Options are {\tt normal} and
1631 {\tt ONIOM}. This selects the QM/MM interface. {\tt normal} implies
1632 that the QM subsystem is electronically embedded in the MM
1633 subsystem. There can only be one {\tt QMMM-grps} that is modeled at
1634 the {\tt QMmethod} and {\tt QMbasis} level of {\it{ ab initio}}
1635 theory. The rest of the system is described at the MM level. The QM
1636 and MM subsystems interact as follows: MM point charges are included
1637 in the QM one-electron Hamiltonian and all Lennard-Jones interactions
1638 are described at the MM level. If {\tt ONIOM} is selected, the
1639 interaction between the subsystem is described using the ONIOM method
1640 by Morokuma and co-workers. There can be more than one QMMM-grps each
1641 modeled at a different level of QM theory (QMmethod and QMbasis).
1642
1643 \item[\tt QMmethod = ]\mbox{}\\Method used to compute the energy
1644 and gradients on the QM atoms. Available methods are AM1, PM3, RHF,
1645 UHF, DFT, B3LYP, MP2, CASSCF, MMVB and CPMD. For CASSCF, the number of
1646 electrons and orbitals included in the active space is specified by
1647 {\tt CASelectrons} and {\tt CASorbitals}. For CPMD, the plane-wave
1648 cut-off is specified by the {\tt planewavecutoff} keyword.
1649
1650 \item[\tt QMbasis = ]\mbox{}\\Gaussian basis set used to expand the
1651 electronic wave-function. Only Gaussian basis sets are currently
1652 available, i.e. STO-3G, 3-21G, 3-21G*, 3-21+G*, 6-21G, 6-31G, 6-31G*,
1653 6-31+G*, and 6-311G. For CPMD, which uses plane wave expansion rather
1654 than atom-centered basis functions, the {\tt planewavecutoff} keyword
1655 controls the plane wave expansion.
1656
1657 \item[\tt QMcharge = ]\mbox{}\\The total charge in {\it{e}} of the {\tt
1658 QMMM-grps}. In case there are more than one {\tt QMMM-grps}, the total
1659 charge of each ONIOM layer needs to be specified separately.
1660
1661 \item[\tt QMmult = ]\mbox{}\\The multiplicity of the {\tt
1662 QMMM-grps}. In case there are more than one {\tt QMMM-grps}, the
1663 multiplicity of each ONIOM layer needs to be specified separately.
1664
1665 \item[\tt CASorbitals = ]\mbox{}\\The number of orbitals to be
1666 included in the active space when doing a CASSCF computation.
1667
1668 \item[\tt CASelectrons = ]\mbox{}\\The number of electrons to be
1669 included in the active space when doing a CASSCF computation.
1670
1671 \item[\tt SH = no]\mbox{}\\If this is set to yes, a QM/MM MD
1672 simulation on the excited state-potential energy surface and enforce a
1673 diabatic hop to the ground-state when the system hits the conical
1674 intersection hyperline in the course the simulation. This option only
1675 works in combination with the CASSCF method.
1676
1677 \end{description}
1678
1679 \subsection{Output}
1680
1681 The energies and gradients computed in the QM calculation are added to
1682 those computed by {\gromacs}. In the {\tt .edr} file there is a section
1683 for the total QM energy.
1684
1685 \subsection{Future developments}
1686
1687 Several features are currently under development to increase the
1688 accuracy of the QM/MM interface. One useful feature is the use of
1689 delocalized MM charges in the QM computations. The most important
1690 benefit of using such smeared-out charges is that the Coulombic
1691 potential has a finite value at interatomic distances. In the point
1692 charge representation, the partially-charged MM atoms close to the QM
1693 region tend to ``over-polarize'' the QM system, which leads to artifacts
1694 in the calculation.
1695
1696 What is needed as well is a transition state optimizer.
1697
1698 \section{\normindex{Adaptive Resolution Scheme}}
1699 \newcommand{\adress}{AdResS}
1700 The adaptive resolution scheme~\cite{Praprotnik2005,Praprotnik2008} (\seeindex{\adress}{Adaptive Resolution Scheme}) couples two systems with different resolutions by a force interpolation scheme.
1701 In contrast to the mixed Quantum-Classical simulation techniques of the previous section, the number of high resolution particles is not fixed, but can vary over the simulation time.
1702
1703 Below we discuss {\adress} for a double resolution (atomistic and coarse grained) representation of the same system. See \figref{adress} for illustration.
1704 The details of implementation described in this section were published in~\cite{Junghans2010,Fritsch2012}.
1705
1706 \begin{figure}
1707 \begin{center}
1708 \includegraphics[width=0.5\textwidth]{plots/adress}
1709 \caption{A schematic illustration of the {\adress} method for water.} 
1710 \label{fig:adress}
1711 \end{center}
1712 \end{figure}
1713 Every molecule needs a well-defined mapping point (usually the center of mass)
1714 but any other linear combination of particle coordinates is also sufficient. 
1715 In the topology the mapping point is defined by a virtual site. The forces in the coarse-grained region are functions of the mapping point positions only.
1716 In this implementation molecules are modeled by charge groups or sets of charge groups, which actually allows one to have multiple mapping points per molecule. This can be useful for bigger molecules like polymers. In that case one has to also extend the AdResS description to bonded interactions~\cite{Praprotnik2011}, which will be implemented into \gromacs in one of the future versions.
1717
1718 The force between two molecules is given by~\cite{Praprotnik2005}
1719 \footnote{Note that the equation obeys Newton's third law, which is not the case for other interpolation schemes~\cite{DelleSite2007}.}:
1720 \begin{equation}
1721 \vec{F}_{\alpha\beta}=w_\alpha w_\beta \vec{F}^\mathrm{ex,mol}_{\alpha\beta} + \left[1-w_\alpha w_\beta\right] \vec{F}^\mathrm{cg,mol}_{\alpha\beta}~,
1722 \label{eqn:interpolation}
1723 \end{equation}
1724 where $\alpha$ and $\beta$ label the two molecules and $w_\alpha$, $w_\beta$ are the adaptive weights of the two molecules.
1725
1726 The first part, which represents the explicit interaction of the molecules, can be written as:
1727 \begin{equation}
1728 \vec{F}^\mathrm{ex,mol}_{\alpha\beta}=\sum_{i\in\alpha}\sum_{j\in\beta} \vec{F}^\mathrm{ex}_{ij}~,
1729 \end{equation}
1730 where $\vec{F}^\mathrm{ex}_{ij}$ is the force between the $i$th atom  in  $\alpha$th molecule and the $j$th atom in the $\beta$th molecule, which is given by an explicit force field.
1731 The second part of \eqnref{interpolation} comes from the coarse-grained interaction of the molecules.
1732 In \gromacs a slightly extended case is implemented:
1733 \begin{equation}
1734   \vec{F}_{\alpha\beta}=\sum_{i\in\alpha}\sum_{j\in\beta} w_i w_j \vec{F}^\mathrm{ex}_{ij} + \left[1-w_\alpha w_\beta\right] \vec{F}^\mathrm{cg,mol}_{\alpha\beta}~,
1735 \label{eqn:interpolation2}
1736 \end{equation}
1737 where $w_i$ and $w_j$ are atom-wise weights, which are determined by the {\tt adress-site} option. For {\tt adress-site} being the center of mass, atom $i$ has the weight of the center of mass of its \emph{charge group}.
1738 The weight $w_\alpha$ of molecule $\alpha$ is determined by the position of coarse-grained particle, which is constructed as a virtual site from the atomistic particles as specified in the topology.
1739 This extension allows one to perform all kind of AdResS variations, but the common case can be recovered by using a center of mass virtual site in the topology, {\tt adress-site=COM} and putting all atoms (except the virtual site representing the coarse-grained interaction) of a molecule into one charge group.
1740 For big molecules, it is sometimes useful to use an atom-based weight, which can be either be achieved by setting {\tt adress-site=atomperatom} or putting every atom into a separate charge group (the center of mass of a charge group with one atom is the atom itself).
1741
1742 The coarse-grained force field $\vec{F}^\mathrm{cg}$ is usually derived from the atomistic system by structure-based coarse-graining (see \secref{cg-forcefields}). To specify which atoms belong to a coarse-grained representation, energy groups are used.
1743 Each coarse-grained interaction has to be associated with a specific energy group, which is why the virtual sites representing the coarse-grained interactions also have to be in different charge groups. The energy groups which are treated as coarse-grained interactions are then listed in {\tt adress_cg_grp_names}.
1744 The most important element of this interpolation (see \eqnref{interpolation} and \eqnref{interpolation2}) is the adaptive weighting function (for illustration see \figref{adress}):
1745 \begin{equation}
1746 w(x)=
1747 \left\{\begin{array}{c@{\;:\;}l}
1748 1&\mathrm{atomistic/explicit\;region}\\
1749 0<w<1&\mathrm{hybrid\;region}\\
1750 0&\mathrm{coarse-grained\;region}
1751 \end{array}\right.~,
1752 \label{equ:weighting}
1753 \end{equation}
1754 which has a value between 0 and 1.
1755 This definition of $w$ gives a purely explicit force in the explicit region and a purely coarse-grained force in the coarse-grained region,
1756 so essentially \eqnref{interpolation} only the hybrid region has mixed interactions which would not appear in a standard simulation.
1757 In {\gromacs}, a $\cos^2$-like function is implemented as a weighting function:
1758 \begin{equation}
1759 w(x)=
1760 \left\{\begin{array}{c@{\;:\;}r@{x}l}
1761 0&&>d_\mathrm{ex}+d_\mathrm{hy}\\
1762 \cos^2\left(\frac{\pi}{2d_\mathrm{hy}}(x-d_\mathrm{ex})\right)&d_\mathrm{ex}+d_\mathrm{hy}>&>d_\mathrm{ex}\\
1763 1&d_\mathrm{ex}>&
1764 \end{array}\right.~,
1765 \label{equ:wf}
1766 \end{equation}
1767 where $d_\mathrm{ex}$ and $d_\mathrm{hy}$ are the sizes of the explicit and the hybrid region, respectively.
1768 Depending on the physical interest of the research, other functions could be implemented as long as the following boundary conditions are fulfilled:
1769 The function is 1) continuous, 2) monotonic and 3) has zero derivatives at the boundaries.
1770 Spherical and one-dimensional splitting  of the simulation box has been implemented ({\tt adress-type} option)
1771 and depending on this, the distance $x$ to the center of the explicit region is calculated as follows:
1772 \begin{equation}
1773 x=
1774 \left\{
1775 \begin{array}{c@{\;:\;}l}
1776   |(\vec{R}_\alpha-\vec{R}_\mathrm{ct})\cdot\hat{e}|&\mathrm{splitting\;in\;}\hat{e}\mathrm{\;direction}\\
1777 |\vec{R}_\alpha-\vec{R}_\mathrm{ct}|&\mathrm{spherical\;splitting}
1778 \end{array}
1779 \right.~,
1780 \end{equation}
1781 where $\vec{R}_\mathrm{ct}$ is the center of the explicit zone (defined by {\tt adress-reference-coords} option). $\vec{R}_\alpha$ is the mapping point of the $\alpha$th molecule. For the center of mass mapping, it is given by:
1782 \begin{equation}
1783 R_\alpha=\frac{\sum_{i\in\alpha}m_i r_i}{\sum_{i\in\alpha}m_i}
1784 \label{equ:com-def}
1785 \end{equation}
1786 Note that the value of the weighting function depends exclusively on the mapping of the molecule.
1787
1788 The interpolation of forces (see \eqnref{interpolation2}) can produce inhomogeneities in the density and affect the structure of the system in the hybrid region.
1789
1790 One way of reducing the density inhomogeneities is by the application of the so-called thermodynamic force (TF)~\cite{Poblete2010}.
1791 Such a force consists of a space-dependent external field applied in the hybrid region on the coarse-grained site of each molecule. It can be specified for each of the species of the system.
1792 The TF compensates the pressure profile~\cite{Fritsch2012b} that emerges under a homogeneous density profile. Therefore, it can correct the local density inhomogeneities in the hybrid region and it also allows the coupling of atomistic and coarse-grained representations which by construction have different pressures at the target density.
1793 The field can be determined by an iterative procedure, which is described in detail in the \href{http://code.google.com/p/votca/downloads/list?&q=manual}{manual} of the \normindex{VOTCA package}~\cite{ruehle2009}. Setting the {\tt adress-interface-correction} to {\tt thermoforce} enables the TF correction and\newline{\tt adress-tf-grp-names} defines the energy groups to act on.
1794
1795 \subsection{Example: Adaptive resolution simulation of water}\label{subsec:adressexample}
1796 In this section the set up of  an adaptive resolution simulation coupling atomistic SPC ~\cite{Berendsen81} water to its coarse-grained representation will be explained (as used in \cite{Fritsch2012b}).
1797 The following steps are required to setup the simulation:
1798 \begin{itemize}
1799 \item Perform a reference all-atom simulation
1800 \item Create a coarse-grained representation and save it as tabulated interaction function 
1801 \item Create a hybrid topology for the SPC water
1802 \item Modify the atomistic coordinate file to include the coarse grained representation
1803 \item Define the geometry of the adaptive simulation in the grompp input file
1804 \item Create an index file
1805 \end{itemize}
1806 The coarse-grained representation of the interaction is stored as tabulated interaction function see \ssecref{userpot}. The convention is to use the $C^{(12)}$  columns with the  $C^{(12)}$- coefficient set to 1. All other columns should be zero. The VOTCA manual has detailed instructions and a tutorial for SPC water on how to coarse-grain the interaction using various techniques.
1807 Here we named the coarse grained interaction CG, so the corresponding tabulated file is {\tt table_CG_CG.xvg}. To create the topology one can start from the atomistic topology file (e.g. share/gromacs/top/oplsaa.ff/spc.itp), we are assuming rigid water here. In the VOTCA tutorial the file is named {\tt hybrid_spc.itp}.
1808 The only difference to the atomistic topology is the addition of a coarse-grained virtual site:
1809 {\small
1810 \begin{verbatim}
1811 [ moleculetype ]
1812 ; molname       nrexcl
1813 SOL             2
1814
1815 [ atoms ]
1816 ;   nr   type  resnr residue  atom   cgnr     charge       mass
1817      1  opls_116   1    SOL     OW      1      -0.82
1818      2  opls_117   1    SOL    HW1      1       0.41
1819      3  opls_117   1    SOL    HW2      1       0.41
1820      4     CG      1    SOL     CG      2       0
1821
1822
1823 [ settles ]
1824 ; OW    funct   doh     dhh
1825 1       1       0.1     0.16330
1826
1827 [ exclusions ]
1828 1       2       3
1829 2       1       3
1830 3       1       2
1831
1832 [ virtual_sites3 ]
1833 ; Site from funct a d
1834 4 1 2 3 1 0.05595E+00 0.05595E+00
1835 \end{verbatim}}
1836 The virtual site type 3 with the specified coefficients places the virtual site in the center of mass of the molecule (for larger molecules virtual_sitesn has to be used).
1837 We now need to include our modified water model in the topology file and define the type {\tt CG}. In {\tt topol.top}:
1838 {\small
1839 \begin{verbatim}
1840 #include "ffoplsaa.itp"
1841
1842 [ atomtypes ]
1843 ;name  mass        charge    ptype   sigma     epsilon
1844  CG    0.00000     0.0000    V       1    0.25
1845
1846 #include "hybrid_spc.itp"
1847
1848 [ system ]
1849 Adaptive water
1850 [ molecules ]
1851 SOL    8507
1852 \end{verbatim}}
1853 The $\sigma$ and $\epsilon$ values correspond to $C_6=1$ and $C_{12}=1$ and thus the table file should contain the coarse-grained interaction in either the $C_6$ or $C_{12}$ column. In the example the OPLS force field is used where $\sigma$ and $\epsilon$ are specified.
1854 Note that for force fields which define atomtypes directly in terms of $C_6$ and $C_{12}$ ( like {\tt gmx.ff} ) one can simply set $C_6=0$ and $C_{12}=1$. See section \ssecref{userpot} for more details on tabulated interactions. Since now the water molecule has a virtual site the coordinate file also needs to include that.
1855 {\small
1856 \begin{verbatim}
1857 adaptive water coordinates
1858 34028
1859     1SOL     OW    1   0.283   0.886   0.647
1860     1SOL    HW1    2   0.359   0.884   0.711
1861     1SOL    HW2    3   0.308   0.938   0.566
1862     1SOL     CG    4   0.289   0.889   0.646
1863     1SOL     OW    5   1.848   0.918   0.082
1864     1SOL    HW1    6   1.760   0.930   0.129
1865     1SOL    HW2    7   1.921   0.912   0.150
1866     1SOL     CG    8   1.847   0.918   0.088
1867     (...)
1868 \end{verbatim}}
1869 This file can be created manually or using the VOTCA tool {\tt csg_map } with the {\tt --hybrid} option.\\
1870 In the grompp input file the AdResS feature needs to be enabled and the geometry defined.
1871 {\small
1872 \begin{verbatim}
1873 (...)
1874 ; AdResS relevant options
1875 energygrps               = CG
1876 energygrp_table          = CG CG
1877
1878 ; Method for doing Van der Waals
1879 vdw-type                 = user
1880
1881 adress                  = yes
1882 adress_type             = xsplit
1883 adress_ex_width         = 1.5
1884 adress_hy_width         = 1.5
1885 adress_interface_correction = off
1886 adress_reference_coords = 8 0 0
1887 adress_cg_grp_names = CG
1888 \end{verbatim}}
1889
1890 Here we are defining an energy group {\tt CG} which consists of the coarse-grained virtual site.
1891 As discussed above, the coarse-grained interaction is usually tabulated. This requires the {\tt vdw-type} parameter to be set to {\tt user}. In the case where multi-component systems are coarse-grained, an energy group has to be defined for each component. Note that all the energy groups defining coarse-grained representations have to be listed again in {\tt adress_cg_grp_names} to distinguish them from regular energy groups.\\
1892 The index file has to be updated to have a group CG which includes all the coarse-grained virtual sites. This can be done easily using the {\tt make_ndx} tool of gromacs.
1893
1894 \section{Using VMD plug-ins for trajectory file I/O}
1895 \index{VMD plug-ins}\index{trajectory file}{\gromacs} tools are able
1896 to use the plug-ins found in an existing installation of
1897 \href{http://www.ks.uiuc.edu/Research/vmd}{VMD} in order to read and
1898 write trajectory files in formats that are not native to
1899 {\gromacs}. You will be able to supply an AMBER DCD-format trajectory
1900 filename directly to {\gromacs} tools, for example.
1901
1902 This requires a VMD installation not older than version 1.8, that your
1903 system provides the dlopen function so that programs can determine at
1904 run time what plug-ins exist, and that you build shared libraries when
1905 building {\gromacs}. CMake will find the vmd executable in your path, and
1906 from it, or the environment variable {\tt VMDDIR} at configuration or
1907 run time, locate the plug-ins. Alternatively, the {\tt VMD_PLUGIN_PATH}
1908 can be used at run time to specify a path where these plug-ins can be
1909 found. Note that these plug-ins are in a binary format, and that format
1910 must match the architecture of the machine attempting to use them.
1911
1912
1913 % LocalWords:  PMF pmf kJ mol Jarzynski BT bilayer rup mdp AFM fepmf fecalc rb
1914 % LocalWords:  posre grompp fs Verlet dihedrals hydrogens hydroxyl sulfhydryl
1915 % LocalWords:  vsitehydro planarity chirality pdb gmx virtualize virtualized xz
1916 % LocalWords:  vis massless tryptophan histidine phenyl parameterizing ij PPPM
1917 % LocalWords:  parameterization Berendsen rlist coulombtype rcoulomb vdwtype LJ
1918 % LocalWords:  rvdw energygrp mdrun pre GMXLIB mdpopt MOPAC GAMESS CPMD ONIOM
1919 % LocalWords:  Morokuma iJ AQ AJ initio atomtype QMatom MMatom QMMM grps et al
1920 % LocalWords:  QMmethod QMbasis QMMMscheme RHF DFT LYP CASSCF MMVB CASelectrons
1921 % LocalWords:  CASorbitals planewavecutoff STO QMcharge QMmult diabatic edr
1922 % LocalWords:  hyperline delocalized Coulombic indices nm ccc th ps
1923 % LocalWords:  GTX CPUs GHz md sd bd vv avek tcoupl andersen tc OPLSAA GROMOS
1924 % LocalWords:  OBC obc CCMA tol pbc xyz barostat pcoupl acc gpu PLUGIN Cmake GX
1925 % LocalWords:  MSVC gcc installpath cmake DGMX DCMAKE functionalities GPGPU GTS
1926 % LocalWords:  OpenCL DeviceID gromacs gpus html GeForce Quadro FX Plex CX GF
1927 % LocalWords:  VMD DCD GROningen MAchine BIOSON Groningen der Spoel Drunen Comp
1928 % LocalWords:  Phys Comm moltype intramol vdw Waals fep multivector pf
1929 % LocalWords:  pymbar dhdl xvg LINCS Entropic entropic solutes ref com iso pm
1930 % LocalWords:  rm prefactors equipotential potiso potisopf potpm trr
1931 % LocalWords:  potrm potrmpf midplanes midplane gaussians potflex vars massw av
1932 % LocalWords:  shure observables rccccccc vec eps dist min eqn transl nstsout
1933 % LocalWords:  nstrout rotangles rotslabs rottorque RMSD rmsdfit excl NH amine
1934 % LocalWords:  positionrestraint es SH phenylalanine solvated sh nanometer QM
1935 % LocalWords:  Lennard Buckingham UK Svensson ab vsitetop co UHF MP interatomic
1936 % LocalWords:  AdResS adress cg grp coords TF VOTCA thermoforce tf SPC userpot
1937 % LocalWords:  itp sitesn atomtypes ff csg ndx Tesla CHARMM AA gauss
1938 % LocalWords:  CMAP nocmap fators Monte performant lib LD DIR llllcc
1939 % LocalWords:  CMake homepage DEV overclocking GT dlopen vmd VMDDIR
1940 % LocalWords:  versa PME atomperatom graining forcefields hy spc OPLS
1941 % LocalWords:  topol multi