Fixed typo and adds corrects units in the friction tensor equation.
[gromacs.git] / docs / manual / special.tex
blob82697ad67abca63e22f9ec999a85a71155dda0ee
2 % This file is part of the GROMACS molecular simulation package.
4 % Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
5 % Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 % and including many others, as listed in the AUTHORS file in the
7 % top-level source directory and at http://www.gromacs.org.
9 % GROMACS is free software; you can redistribute it and/or
10 % modify it under the terms of the GNU Lesser General Public License
11 % as published by the Free Software Foundation; either version 2.1
12 % of the License, or (at your option) any later version.
14 % GROMACS is distributed in the hope that it will be useful,
15 % but WITHOUT ANY WARRANTY; without even the implied warranty of
16 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 % Lesser General Public License for more details.
19 % You should have received a copy of the GNU Lesser General Public
20 % License along with GROMACS; if not, see
21 % http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 % Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 % If you want to redistribute modifications to GROMACS, please
25 % consider that scientific software is very special. Version
26 % control is crucial - bugs must be traceable. We will be happy to
27 % consider code for inclusion in the official distribution, but
28 % derived work must not be called official GROMACS. Details are found
29 % in the README & COPYING files - if they are missing, get the
30 % official version at http://www.gromacs.org.
32 % To help us fund GROMACS development, we humbly ask that you cite
33 % the research papers on the package. Check out http://www.gromacs.org.
35 \chapter{Special Topics}
36 \label{ch:special}
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.
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.
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.
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.
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 Waals, but changing the restraints throughout the first
80 two-thirds of the simulation, then you could use this $\lambda$ vector:
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}
89 This is also equivalent to:
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.
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.
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
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.
120 \section{Potential of mean force}
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 AWH code:} currently acts on coordinates provided by the pull code.
129 \item{\bf free-energy code with harmonic bonds or constraints:} between single atoms.
130 \item{\bf free-energy code with position restraints:} changing the conformation of a relatively immobile group of atoms.
131 \item{\bf pull code in limited cases:} between groups of atoms that are
132 part of a larger molecule for which the bonds are constrained with
133 SHAKE or LINCS. If the pull group if relatively large,
134 the pull code can be used.
135 \end{itemize}
137 The pull and free-energy code a described in more detail
138 in the following two sections.
140 \subsubsection{Entropic effects}
141 When a distance between two atoms or the centers of mass of two groups
142 is constrained or restrained, there will be a purely entropic contribution
143 to the PMF due to the rotation of the two groups~\cite{RMNeumann1980a}.
144 For a system of two non-interacting masses the potential of mean force is:
145 \beq
146 V_{pmf}(r) = -(n_c - 1) k_B T \log(r)
147 \eeq
148 where $n_c$ is the number of dimensions in which the constraint works
149 (i.e. $n_c=3$ for a normal constraint and $n_c=1$ when only
150 the $z$-direction is constrained).
151 Whether one needs to correct for this contribution depends on what
152 the PMF should represent. When one wants to pull a substrate
153 into a protein, this entropic term indeed contributes to the work to
154 get the substrate into the protein. But when calculating a PMF
155 between two solutes in a solvent, for the purpose of simulating
156 without solvent, the entropic contribution should be removed.
157 {\bf Note} that this term can be significant; when at 300K the distance is halved,
158 the contribution is 3.5 kJ~mol$^{-1}$.
160 \section{Non-equilibrium pulling}
161 When the distance between two groups is changed continuously,
162 work is applied to the system, which means that the system is no longer
163 in equilibrium. Although in the limit of very slow pulling
164 the system is again in equilibrium, for many systems this limit
165 is not reachable within reasonable computational time.
166 However, one can use the Jarzynski relation~\cite{Jarzynski1997a}
167 to obtain the equilibrium free-energy difference $\Delta G$
168 between two distances from many non-equilibrium simulations:
169 \begin{equation}
170 \Delta G_{AB} = -k_BT \log \left\langle e^{-\beta W_{AB}} \right\rangle_A
171 \label{eq:Jarz}
172 \end{equation}
173 where $W_{AB}$ is the work performed to force the system along one path
174 from state A to B, the angular bracket denotes averaging over
175 a canonical ensemble of the initial state A and $\beta=1/k_B T$.
178 \section{The pull code}
179 \index{center-of-mass pulling}
180 \label{sec:pull}
181 The pull code applies forces or constraints between the centers
182 of mass of one or more pairs of groups of atoms.
183 Each pull reaction coordinate is called a ``coordinate'' and it operates
184 on usually two, but sometimes more, pull groups. A pull group can be part of one or more pull
185 coordinates. Furthermore, a coordinate can also operate on a single group
186 and an absolute reference position in space.
187 The distance between a pair of groups can be determined
188 in 1, 2 or 3 dimensions, or can be along a user-defined vector.
189 The reference distance can be constant or can change linearly with time.
190 Normally all atoms are weighted by their mass, but an additional
191 weighting factor can also be used.
192 \begin{figure}
193 \centerline{\includegraphics[width=6cm,angle=270]{plots/pull}}
194 \caption{Schematic picture of pulling a lipid out of a lipid bilayer
195 with umbrella pulling. $V_{rup}$ is the velocity at which the spring is
196 retracted, $Z_{link}$ is the atom to which the spring is attached and
197 $Z_{spring}$ is the location of the spring.}
198 \label{fig:pull}
199 \end{figure}
201 Several different pull types, i.e. ways to apply the pull force, are supported,
202 and in all cases the reference distance can be constant
203 or linearly changing with time.
204 \begin{enumerate}
205 \item{\textbf{Umbrella pulling}\swapindexquiet{umbrella}{pulling}}
206 A harmonic potential is applied between
207 the centers of mass of two groups.
208 Thus, the force is proportional to the displacement.
209 \item{\textbf{Constraint pulling\swapindexquiet{constraint}{pulling}}}
210 The distance between the centers of mass of two groups is constrained.
211 The constraint force can be written to a file.
212 This method uses the SHAKE algorithm but only needs 1 iteration to be
213 exact if only two groups are constrained.
214 \item{\textbf{Constant force pulling}}
215 A constant force is applied between the centers of mass of two groups.
216 Thus, the potential is linear.
217 In this case there is no reference distance of pull rate.
218 \item{\textbf{Flat bottom pulling}}
219 Like umbrella pulling, but the potential and force are zero for
220 coordinate values below ({\tt pull-coord?-type = flat-bottom}) or above
221 ({\tt pull-coord?-type = flat-bottom-high}) a reference value.
222 This is useful for restraining e.g. the distance
223 between two molecules to a certain region.
224 \end{enumerate}
225 In addition, there are different types of reaction coordinates, so-called pull geometries.
226 These are set with the {\tt .mdp} option {\tt pull-coord?-geometry}.
228 \subsubsection{Definition of the center of mass}
230 In {\gromacs}, there are three ways to define the center of mass of a group.
231 The standard way is a ``plain'' center of mass, possibly with additional
232 weighting factors. With periodic boundary conditions it is no longer
233 possible to uniquely define the center of mass of a group of atoms.
234 Therefore, a reference atom is used. For determining the center of mass,
235 for all other atoms in the group, the closest periodic image to the reference
236 atom is used. This uniquely defines the center of mass.
237 By default, the middle (determined by the order in the topology) atom
238 is used as a reference atom, but the user can also select any other atom
239 if it would be closer to center of the group.
241 For a layered system, for instance a lipid bilayer, it may be of interest
242 to calculate the PMF of a lipid as function of its distance
243 from the whole bilayer. The whole bilayer can be taken as reference
244 group in that case, but it might also be of interest to define the
245 reaction coordinate for the PMF more locally. The {\tt .mdp} option
246 {\tt pull-coord?-geometry = cylinder} does not
247 use all the atoms of the reference group, but instead dynamically only those
248 within a cylinder with radius {\tt pull-cylinder-r} around the pull vector going
249 through the pull group. This only
250 works for distances defined in one dimension, and the cylinder is
251 oriented with its long axis along this one dimension. To avoid jumps in
252 the pull force, contributions of atoms are weighted as a function of distance
253 (in addition to the mass weighting):
254 \bea
255 w(r < r_\mathrm{cyl}) & = &
256 1-2 \left(\frac{r}{r_\mathrm{cyl}}\right)^2 + \left(\frac{r}{r_\mathrm{cyl}}\right)^4 \\
257 w(r \geq r_\mathrm{cyl}) & = & 0
258 \eea
259 Note that the radial dependence on the weight causes a radial force on
260 both cylinder group and the other pull group. This is an undesirable,
261 but unavoidable effect. To minimize this effect, the cylinder radius should
262 be chosen sufficiently large. The effective mass is 0.47 times that of
263 a cylinder with uniform weights and equal to the mass of uniform cylinder
264 of 0.79 times the radius.
266 \begin{figure}
267 \centerline{\includegraphics[width=6cm]{plots/pullref}}
268 \caption{Comparison of a plain center of mass reference group versus a cylinder
269 reference group applied to interface systems. C is the reference group.
270 The circles represent the center of mass of two groups plus the reference group,
271 $d_c$ is the reference distance.}
272 \label{fig:pullref}
273 \end{figure}
275 For a group of molecules in a periodic system, a plain reference group
276 might not be well-defined. An example is a water slab that is connected
277 periodically in $x$ and $y$, but has two liquid-vapor interfaces along $z$.
278 In such a setup, water molecules can evaporate from the liquid and they
279 will move through the vapor, through the periodic boundary, to the other
280 interface. Such a system is inherently periodic and there is no proper way
281 of defining a ``plain'' center of mass along $z$. A proper solution is to using
282 a cosine shaped weighting profile for all atoms in the reference group.
283 The profile is a cosine with a single period in the unit cell. Its phase
284 is optimized to give the maximum sum of weights, including mass weighting.
285 This provides a unique and continuous reference position that is nearly
286 identical to the plain center of mass position in case all atoms are all
287 within a half of the unit-cell length. See ref \cite{Engin2010a} for details.
289 When relative weights $w_i$ are used during the calculations, either
290 by supplying weights in the input or due to cylinder geometry
291 or due to cosine weighting,
292 the weights need to be scaled to conserve momentum:
293 \beq
294 w'_i = w_i
295 \left. \sum_{j=1}^N w_j \, m_j \right/ \sum_{j=1}^N w_j^2 \, m_j
296 \eeq
297 where $m_j$ is the mass of atom $j$ of the group.
298 The mass of the group, required for calculating the constraint force, is:
299 \beq
300 M = \sum_{i=1}^N w'_i \, m_i
301 \eeq
302 The definition of the weighted center of mass is:
303 \beq
304 \ve{r}_{com} = \left. \sum_{i=1}^N w'_i \, m_i \, \ve{r}_i \right/ M
305 \eeq
306 From the centers of mass the AFM, constraint, or umbrella force $\ve{F}_{\!com}$
307 on each group can be calculated.
308 The force on the center of mass of a group is redistributed to the atoms
309 as follows:
310 \beq
311 \ve{F}_{\!i} = \frac{w'_i \, m_i}{M} \, \ve{F}_{\!com}
312 \eeq
314 \subsubsection{Definition of the pull direction}
316 The most common setup is to pull along the direction of the vector containing
317 the two pull groups, this is selected with
318 {\tt pull-coord?-geometry = distance}. You might want to pull along a certain
319 vector instead, which is selected with {\tt pull-coord?-geometry = direction}.
320 But this can cause unwanted torque forces in the system, unless you pull against a reference group with (nearly) fixed orientation, e.g. a membrane protein embedded in a membrane along x/y while pulling along z. If your reference group does not have a fixed orientation, you should probably use
321 {\tt pull-coord?-geometry = direction-relative}, see \figref{pulldirrel}.
322 Since the potential now depends on the coordinates of two additional groups defining the orientation, the torque forces will work on these two groups.
324 \begin{figure}
325 \centerline{\includegraphics[width=5cm]{plots/pulldirrel}}
326 \caption{The pull setup for geometry {\tt direction-relative}. The ``normal'' pull groups are 1 and 2. Groups 3 and 4 define the pull direction and thus the direction of the normal pull forces (red). This leads to reaction forces (blue) on groups 3 and 4, which are perpendicular to the pull direction. Their magnitude is given by the ``normal'' pull force times the ratio of $d_p$ and the distance between groups 3 and 4.}
327 \label{fig:pulldirrel}
328 \end{figure}
330 \subsubsection{Definition of the angle and dihedral pull geometries}
331 Four pull groups are required for {\tt pull-coord?-geometry = angle}. In the same way as for geometries with two groups, each consecutive pair of groups
332 $i$ and $i+1$ define a vector connecting the COMs of groups $i$ and $i+1$. The angle is defined as the angle between the two resulting vectors.
333 E.g., the {\tt .mdp} option {\tt pull-coord?-groups = 1 2 2 4} defines the angle between the vector from the COM of group 1 to the COM of group 2
334 and the vector from the COM of group 2 to the COM of group 4.
335 The angle takes values in the closed interval [0, 180] deg.
336 For {\tt pull-coord?-geometry = angle-axis} the angle is defined with respect to a reference axis given by {\tt pull-coord?-vec} and only two groups need to be given.
337 The dihedral geometry requires six pull groups. These pair up in the same way as described above and so define three vectors. The dihedral angle is defined as the angle between the two
338 planes spanned by the two first and the two last vectors. Equivalently, the dihedral angle can be seen as the angle between the first and the third
339 vector when these vectors are projected onto a plane normal to the second vector (the axis vector).
340 As an example, consider a dihedral angle involving four groups: 1, 5, 8 and 9. Here, the {\tt .mdp} option
341 {\tt pull-coord?-groups = 8 1 1 5 5 9} specifies the three vectors that define the dihedral angle:
342 the first vector is the COM distance vector from group 8 to 1, the second vector is the COM distance vector from group 1 to 5, and the third vector is the COM distance vector from group 5 to 9.
343 The dihedral angle takes values in the interval (-180, 180] deg and has periodic boundaries.
345 \subsubsection{Limitations}
346 There is one theoretical limitation:
347 strictly speaking, constraint forces can only be calculated between
348 groups that are not connected by constraints to the rest of the system.
349 If a group contains part of a molecule of which the bond lengths
350 are constrained, the pull constraint and LINCS or SHAKE bond constraint
351 algorithms should be iterated simultaneously. This is not done in {\gromacs}.
352 This means that for simulations with {\tt constraints = all-bonds}
353 in the {\tt .mdp} file pulling is, strictly speaking,
354 limited to whole molecules or groups of molecules.
355 In some cases this limitation can be avoided by using the free energy code,
356 see \secref{fepmf}.
357 In practice, the errors caused by not iterating the two constraint
358 algorithms can be negligible when the pull group consists of a large
359 amount of atoms and/or the pull force is small.
360 In such cases, the constraint correction displacement of the pull group
361 is small compared to the bond lengths.
364 \section{Adaptive biasing with AWH}
365 \index{AWH}
366 \index{adaptive biasing|see{AWH}}
367 \label{sec:awh}
368 The accelerated weight histogram method (AWH)~\cite{lindahl2014accelerated}
369 calculates the PMF along a reaction coordinate by adding an adaptively determined biasing potential.
370 AWH flattens free energy barriers along the reaction coordinate by applying a history-dependent potential to the system
371 that ``fills up'' free energy minima.
372 This is similar in spirit to other adaptive biasing potential methods,
373 e.g. the Wang-Landau~\cite{wang2001efficient}, local elevation~\cite{huber1994local} and metadynamics~\cite{laio2002escaping} methods.
374 The initial sampling stage of AWH makes the method robust against the choice of input parameters.
375 Furthermore, the target distribution along the reaction coordinate may be chosen freely.
377 \subsection{Basics of the method}
378 Rather than biasing the reaction coordinate $\xi(x)$ directly, AWH acts on a \emph{reference coordinate} $\lambda$.
379 The reaction coordinate $\xi(x)$ is coupled to $\lambda$ with a harmonic potential
380 \begin{equation}
381 Q(\xi,\lambda) = \frac{1}{2} \beta k (\xi - \lambda)^2,
382 \end{equation}
383 so that for large force constants $k$, $\xi \approx \lambda$.
384 Note the use of dimensionless energies for compatibility with previously published work.
385 Units of energy are obtained by multiplication with $k_BT=1/\beta$.
386 In the simulation, $\lambda$ samples the user-defined sampling interval $I$.
387 For a multidimensional reaction coordinate $\xi$, the sampling interval is the Cartesian product
388 $I=\Pi_\mu I_\mu$ (a rectangular domain).
389 The connection between atom coordinates and $\lambda$ is established through the extended ensemble~\cite{Lyubartsev1992},
390 \begin{equation}\label{eq:awh:pxlambda}
391 P(x,\lambda) = \frac{1}{\mathcal{Z}}e^{g(\lambda) - Q(\xi(x),\lambda) - V(x)},
392 \end{equation}
393 where $g(\lambda)$ is a bias function (a free variable) and $V(x)$ is the unbiased potential energy of the system.
394 The distribution along $\lambda$ can be
395 tuned to be any predefined \emph{target distribution} $\rho(\lambda)$ (often chosen to be flat)
396 by choosing $g(\lambda)$ wisely.
397 This is evident from
398 \begin{equation}\label{eq:awh:plambda}
399 P(\lambda) = \int P(x,\lambda) dx =
400 \frac{1}{\mathcal{Z}}e^{g(\lambda)} \int e^{- Q(\xi(x),\lambda) - V(x)} dx
401 \equiv \frac{1}{\mathcal{Z}}e^{g(\lambda) - F(\lambda)},
402 \end{equation}
403 where $F(\lambda)$ is the free energy
404 \begin{equation}\label{eq:awh:flambda}
405 F(\lambda) = -\ln \int e^{- Q(\xi(x),\lambda) - V(x)} dx.
406 \end{equation}
407 Being the convolution of the PMF with the Gaussian defined by the harmonic potential,
408 $F(\lambda)$ is a smoothened version of the PMF.
409 Eq.~\ref{eq:awh:plambda} shows that in order to obtain $P(\lambda)=\rho(\lambda)$,
410 $F(\lambda)$ needs to be determined accurately.
411 Thus, AWH adaptively calculates $F(\lambda)$ and simultaneously converges $P(\lambda)$ toward $\rho(\lambda)$.
413 \subsubsection{The free energy update}
414 AWH is initialized with an estimate of the free energy $F_0(\lambda)$.
415 At regular time intervals this estimate is updated using data collected in between the updates.
416 At update $n$, the applied bias $g_n(\lambda)$ is a function of the current free energy estimate $F_n(\lambda)$
417 and target distribution $\rho_n(\lambda)$,
418 \begin{equation}\label{eq:awh:grhofrelation}
419 g_n(\lambda) = \ln \rho_n(\lambda) +F_n(\lambda),
420 \end{equation}
421 which is consistent with Eq.~\ref{eq:awh:plambda}.
422 Note that also the target distribution may be updated during the simulation (see examples in section~\ref{sec:awh:targets}).
423 Substituting this choice of $g=g_n$ back into Eq.~\ref{eq:awh:plambda} yields the simple free energy update
424 \begin{equation}\label{eq:awh:dfnaive}
425 \Delta F_n(\lambda)
426 = F(\lambda) - F_n(\lambda)
427 = -\ln\frac{P_n(\lambda)}{\rho_n(\lambda)},
428 \end{equation}
429 which would yield a better estimate $F_{n+1} = F_n + \Delta F_n$, assuming $P_n(\lambda)$ can be measured accurately.
430 AWH estimates $P_n(\lambda)$ by regularly calculating the conditional distribution
431 \begin{equation}\label{eq:awh:omega}
432 \omega_n(\lambda|x) \equiv P_n(\lambda|x) = \frac{e^{g_n(\lambda) - Q(\xi(x), \lambda)}}{\sum_{\lambda'} e^{g_n(\lambda') - Q(\xi(x),\lambda')}}.
433 \end{equation}
434 Accumulating these probability weights yields
435 $\sum_t \omega(\lambda|x(t)) \sim P_n(\lambda)$,
436 where $\int P_n(\lambda|x) P_n(x) dx = P_n(\lambda)$ has been used.
437 The $\omega_n(\lambda|x)$ weights are thus the samples of the AWH method.
438 With the limited amount of sampling one has in practice, update scheme \ref{eq:awh:dfnaive} yields very noisy results.
439 AWH instead applies a free energy update that has the same form but which can be applied repeatedly with limited and localized sampling,
440 \begin{equation}
441 \Delta F_n = -\ln \frac{W_n(\lambda) + \sum_t \omega_n(\lambda|x(t))}{W_n(\lambda) + \sum_t\rho_n(\lambda)) }.
442 \end{equation}
443 Here $W_n(\lambda)$ is the \emph{reference weight histogram} representing prior sampling.
444 The update for $W(\lambda)$, disregarding the initial stage (see section~\ref{sec:awh:initial-stage}),
446 \begin{equation}\label{eq:awh:w-update}
447 W_{n+1}(\lambda) = W_n(\lambda) + \sum_t\rho_n(\lambda).
448 \end{equation}
449 Thus, the weight histogram equals the targeted, ``ideal'' history of samples.
450 There are two important things to note about the free energy update.
451 First, sampling is driven away from oversampled, currently local regions.
452 For such $\lambda$ values,
453 $\omega_n(\lambda) > \rho_n(\lambda)$ and
454 $\Delta F_n(\lambda) < 0$,
455 which by Eq.~\ref{eq:awh:grhofrelation} implies
456 $\Delta g_n(\lambda) < 0$
457 (assuming $\Delta \rho_n \equiv 0$).
458 Thus, the probability to sample $\lambda$ decreases after the update (see Eq.~\ref{eq:awh:plambda}).
459 Secondly, the normalization of the histogram $N_n=\sum_\lambda W_n(\lambda)$, determines the update size $|\Delta F(\lambda)|$.
460 For instance, for a single sample $\omega(\lambda|x)$, the shape of the update is approximately a Gaussian function
461 of width $\sigma=1/\sqrt{\beta k}$ and height $\propto 1/N_n$~\cite{lindahl2014accelerated},
462 \begin{equation}\label{eq:awh:dfsize}
463 |\Delta F_n(\lambda)| \propto \frac{1}{N_n} e^{-\frac{1}{2} \beta k (\xi(x) - \lambda)^2}.
464 \end{equation}
465 Therefore, as samples accumulate in $W(\lambda)$ and $N_n$ grows, the updates get smaller, allowing for the free energy to converge.
467 Note that quantity of interest to the user is not $F(\lambda)$ but the PMF $\Phi(\xi)$.
468 $\Phi(\xi)$ is extracted by reweighting samples $\xi(t)$ on the fly~\cite{lindahl2014accelerated}
469 (see also section~\ref{sec:awh:reweight})
470 and will converge at the same rate as $F(\lambda)$, see Fig.~\ref{fig:awh:bias-evolution}.
471 The PMF will be written to output (see section~\ref{sec:awh:usage}).
473 \subsubsection{Applying the bias to the system}
474 The bias potential can be applied to the system in two ways.
475 Either by applying a harmonic potential centered at $\lambda(t)$,
476 which is sampled using (rejection-free) Monte-Carlo sampling from the conditional distribution
477 $\omega_n(\lambda|x(t)) = P_n(\lambda|x(t))$,
478 see Eq.~\ref{eq:awh:omega}.
479 This is also called Gibbs sampling or independence sampling.
480 Alternatively, and by default in the code, the following \emph{convolved bias potential} can be applied,
481 \begin{equation}\label{eq:awh:biaspotential}
482 U_n(\xi) = -\ln \int e^{ g_n(\lambda) -Q(\xi,\lambda)} d \lambda.
483 \end{equation}
484 These two approaches are equivalent in the sense that they give rise to the same biased probabilities $P_n(x)$ (cf.\ \ref{eq:awh:pxlambda})
485 while the dynamics are clearly different in the two cases.
486 This choice does not affect the internals of the AWH algorithm, only what force and potential AWH returns to the MD engine.
488 \begin{figure}
489 \centerline{
490 \includegraphics[width=6cm]{plots/awh-traj} % traj
491 \includegraphics[width=6cm]{plots/awh-invN} % 1/N
493 \centerline{
494 \includegraphics[width=6cm]{plots/awh-sampleweights} % weights
495 \includegraphics[width=6cm]{plots/awh-pmfs} % pmfs
497 \caption{AWH evolution in time for a Brownian particle in a double-well potential.
498 The reaction coordinate $\xi(t)$ traverses the sampling interval multiple times in the initial stage before exiting and entering the final stage (top left).
499 In the final stage, the dynamics of $\xi$ becomes increasingly diffusive.
500 The times of covering are shown as $\times$-markers of different colors.
501 At these times the free energy update size $\sim 1/N$, where $N$ is the size of the weight histogram,
502 is decreased by scaling $N$ by a factor of $\gamma=3$ (top right).
503 In the final stage, $N$ grows at the sampling rate and thus $1/N\sim1/t$.
504 The exit from the final stage is determined on the fly by ensuring that the effective sample weight $s$ of data collected in the final stage
505 exceeds that of initial stage data (bottom left; note that $\ln s(t)$ is plotted).
506 An estimate of the PMF is also extracted from the simulation (bottom right), which after exiting the initial stage should estimate global free energy differences fairly accurately.
508 \label{fig:awh:bias-evolution}
509 \end{figure}
511 \subsection{The initial stage}\label{sec:awh:initial-stage}
512 Initially, when the bias potential is far from optimal,
513 samples will be highly correlated.
514 In such cases,
515 letting $W(\lambda)$ accumulate samples as prescribed by Eq.~\ref{eq:awh:w-update},
516 entails a too rapid decay of the free energy update size.
517 This motivates splitting the simulation into an \emph{initial stage}
518 where the weight histogram grows according to a more restrictive and robust protocol,
519 and a \emph{final stage} where the the weight histogram grows linearly at the sampling rate (Eq.~\ref{eq:awh:w-update}).
520 The AWH initial stage takes inspiration from the well-known Wang-Landau algorithm~\cite{wang2001efficient},
521 although there are differences in the details.
523 In the initial stage the update size is kept constant (by keeping $N_n$ constant) until a transition across the sampling interval has been detected,
524 a ``covering''. For the definition of a covering, see Eq.~\ref{eq:awh:covering} below.
525 After a covering has occurred, $N_n$ is scaled up by a constant ``growth factor'' $\gamma$, chosen heuristically as $\gamma=3$.
526 Thus, in the initial stage
527 $N_n$ is set dynamically as
528 $N_{n} = \gamma^{m} N_0$,
529 where $m$ is the number of coverings.
530 Since the update size scales as $1/N$ ( Eq.~\ref{eq:awh:dfsize})
531 this leads to a close to exponential decay of the update size in the initial stage,
532 see Fig.~\ref{fig:awh:bias-evolution}.
534 The update size %
535 directly determines the rate of change of $F_n(\lambda)$ and hence,
536 from Eq.~\ref{eq:awh:grhofrelation},
537 also the rate of change of the bias funcion $g_n(\lambda)$
538 Thus initially, when $N_n$ is kept small and updates large,
539 the system will be driven along the reaction coordinate by the constantly fluctuating bias.
540 If $N_0$ is set small enough,
541 the first transition will typically be fast because of the large update size
542 and will quickly give a first rough estimate of the free energy.
543 The second transition, using $N_1=\gamma N_0$ refines this estimate further.
544 Thus, rather than very carefully filling free energy minima using a small initial update size,
545 the sampling interval is sweeped back-and-forth multiple times,
546 using a wide range of update sizes,
547 see Fig.~\ref{fig:awh:bias-evolution}.
548 This way, the initial stage also makes AWH robust against the choice of $N_0$.
550 \subsubsection{The covering criterion}
551 In the general case of a multidimensional reaction coordinate $\lambda=(\lambda_\mu)$,
552 the sampling interval $I$ is considered covered when all dimensions have been covered.
553 A dimension $d$ is covered if all points $\lambda_\mu$ in the one-dimensional sampling interval
554 $I_\mu$ have been ``visited''.
555 Finally, a point $\lambda_\mu \in I_\mu$ has been visited if there is at least one point $\lambda^*\in I$
556 with $\lambda^*_\mu = \lambda_\mu$
557 that since the last covering has
558 accumulated probability weight corresponding to the peak of a
559 multidimensional Gaussian distribution
560 \begin{equation}\label{eq:awh:covering}
561 \Delta W(\lambda^*)
562 \ge w_{\mathrm{peak}}
563 \equiv \prod_\mu \frac{\Delta \lambda_\mu}{\sqrt{2\pi}\sigma_k}.
564 \end{equation}
565 Here, $\Delta \lambda_\mu$ is the point spacing of the discretized $I_\mu$ %of the $\lambda$ grid
566 and $\sigma_k=1/\sqrt{\beta k_\mu}$ (where $k_\mu$ is the force constant)
567 is the Gaussian width.
569 \subsubsection{Exit from the initial stage}
570 For longer times, when major free energy barriers have largely been flattened by the converging bias potential,
571 the histogram $W(\lambda)$ should grow at the actual sampling rate and the initial stage needs to be exited~\cite{belardinelli2007fast}.
572 There are multiple reasonable (heuristic) ways of determining when this transition should take place.
573 One option is to postulate that the number of samples in the weight histogram $N_n$ should never exceed the actual number of collected samples,
574 and exit the initial stage when this condition breaks~\cite{lindahl2014accelerated}.
575 In the initial stage, $N$ grows close to exponentially while the collected number of samples grows linearly, so an exit will surely occur eventually.
576 Here we instead apply an exit criterion based on the observation that ``artifically'' keeping $N$ constant while
577 continuing to collect samples
578 corresponds to scaling down the relative weight of old samples relative to new ones.
579 Similarly, the subsequent scaling up of $N$ by a factor $\gamma$ corresponds to scaling up the weight of old data.
580 Briefly, the exit criterion is devised such that the weight of a sample collected \emph{after} the initial stage is always larger or equal to
581 the weight of a sample collected \emph{during} the initial stage, see Fig.~\ref{fig:awh:bias-evolution}. This is consistent with scaling down early, noisy data.
583 The initial stage exit criterion will now be described in detail.
584 We start out at the beginning of a covering stage,
585 so that $N$ has just been scaled by $\gamma$ and is now kept constant.
586 Thus, the first sample of this stage has the weight $s= 1/\gamma$ relative to the last sample
587 of the previous covering stage.
588 We assume that $\Delta N$ samples are collected and added to $W$ for each update .
589 To keep $N$ constant, $W$ needs to be scaled down by a factor $N/(N + \Delta N)$ after every update.
590 Equivalently, this means that new data is scaled up relative to old data by the inverse factor.
591 Thus, after $\Delta n$ updates a new sample has the relative weight $s=(1/\gamma) [(N_n + \Delta N)/N_n]^{\Delta n}$.
592 Now assume covering occurs at this time.
593 To continue to the next covering stage,
594 $N$ should be scaled by $\gamma$, which corresponds to again multiplying $s$ by $1/\gamma$.
595 If at this point $s \ge \gamma$, then after rescaling $s \ge 1$;
596 i.e. overall the relative weight of a new sample relative to an old sample is still growing fast.
597 If on the contrary $s < \gamma$, and this defines the exit from the initial stage,
598 then the initial stage is over and from now $N$ simply grows at the sampling rate (see Eq.~\ref{eq:awh:w-update}).
599 To really ensure that $s\ge 1$ holds before exiting, so that samples after the exit have at least the sample weight of older samples,
600 the last covering stage is extended by a sufficient number of updates.
602 \subsection{Choice of target distribution}\label{sec:awh:targets}
603 The target distribution $\rho(\lambda)$ is traditionally chosen to be uniform
604 \begin{equation}
605 \rho_{\mathrm{const}}(\lambda) = \mathrm{const.}
606 \end{equation}
607 This choice exactly flattens $F(\lambda)$ in user-defined sampling interval $I$.
608 Generally, $\rho(\lambda)=0, \lambda\notin I$.
609 In certain cases other choices may be preferable.
610 For instance, in the multidimensional case the rectangular sampling interval is likely to
611 contain regions of very high free energy, e.g. where atoms are clashing.
612 To exclude such regions, $\rho(\lambda)$ can specified by the following function of the free energy
613 \begin{equation}\label{eq:awh:rhocut}
614 \rho_{\mathrm{cut}}(\lambda) \propto \frac{1}{1+ e^{F(\lambda) - F_{\mathrm{cut}}}}, %, \lambda \in I
615 \end{equation}
616 where $F_{\mathrm{cut}}$ is a free energy cutoff (relative to $\min_\lambda F(\lambda)$).
617 Thus, regions of the sampling interval where
618 $F(\lambda) > F_{\mathrm{cut}}$ will be exponentially suppressed (in a smooth fashion).
619 Alternatively, very high free energy regions could be avoided while still flattening more moderate free energy barriers
620 by targeting a Boltzmann distribution corresponding to scaling $\beta=1/k_BT$ by a factor $0<s_\beta<1$,
621 \begin{equation}\label{eq:awh:rhoboltz}
622 \rho_{\mathrm{Boltz}}(\lambda) \propto e^{-s_\beta F(\lambda)}, %, \lambda \in I
623 \end{equation}
624 The parameter $s_\beta$ determines to what degree the free energy landscape is flattened;
625 the lower $s_\beta$, the flatter.
626 Note that both $\rho_{\mathrm{cut}}(\lambda)$ and $\rho_{\mathrm{Boltz}}(\lambda)$
627 depend on $F(\lambda)$, which needs to be substituted by the current best estimate $F_n(\lambda)$.
628 Thus, the target distribution is also updated (consistently with Eq.~\ref{eq:awh:grhofrelation}).
630 There is in fact an alternative approach to obtaining $\rho_{\mathrm{Boltz}}(\lambda)$ as the limiting target distribution in AWH,
631 which is particular in the way the weight histogram $W(\lambda)$ and the target distribution $\rho$ are updated and coupled to each other.
632 This yields an evolution of the bias potential which is very similar to that of well-tempered metadynamics~\cite{barducci2008well},
633 see~\cite{lindahl2014accelerated} for details.
634 Because of the popularity and success of well-tempered metadynamics, this is a special case worth considering.
635 In this case $\rho$ is a function of the reference weight histogram
636 \begin{equation}
637 \rho_{\mathrm{Boltz,loc}}(\lambda) \propto W(\lambda), % \lambda \in I
638 \end{equation}
639 and the update of the weight histogram is modified (cf. Eq.~\ref{eq:awh:w-update})
640 \begin{equation}
641 W_{n+1}(\lambda) = W_{n}(\lambda) + s_{\beta}\sum_t \omega(\lambda|x(t)).
642 \end{equation}
643 Thus, here the weight histogram equals the real history of samples, but scaled by $s_\beta$.
644 This target distribution is called \emph{local} Boltzmann since $W$ is only modified locally, where sampling has taken place.
645 We see that when $s_\beta \approx 0$ the histogram essentially does not grow
646 and the size of the free energy update will stay at a constant value
647 (as in the original formulation of metadynamics).
648 Thus, the free energy estimate will not converge, but continue to fluctuate around the correct value.
649 This illustrates the inherent coupling
650 between the convergence and choice of target distribution for this special choice of target.
651 Furthermore note that when using $\rho=\rho_{\mathrm{Boltz,loc}}$ there is no initial stage (section~\ref{sec:awh:initial-stage}).
652 The rescaling of the weight histogram applied in the initial stage is a global operation,
653 which is incompatible $\rho_{\mathrm{Boltz,loc}}$ only depending locally on the sampling history.
655 Lastly, the target distribution can be modulated by arbitrary probability weights
656 \begin{equation}
657 \rho(\lambda) = \rho_0(\lambda) w_{\mathrm{user}}(\lambda).
658 \end{equation}
659 where $w_{\mathrm{user}}(\lambda)$ is provided by user data and in principle $\rho_0(\lambda)$ can
660 be any of the target distributions mentioned above.
662 \subsection{Multiple independent or sharing biases}
663 Multiple independent bias potentials may be applied within one simulation.
664 This only makes sense if the biased coordinates $\xi^{(1)}$, $\xi^{(2)}$, $\ldots$ evolve essentially independently from one another.
665 A typical example of this would be when applying an independent bias to each monomer of a protein.
666 Furthermore, multiple AWH simulations can be launched in parallel, each with a (set of) indepedendent biases.
668 If the defined sampling interval is large relative to the diffusion time of the reaction coordinate,
669 traversing the sampling interval multiple times as is required by the initial stage (section~\ref{sec:awh:initial-stage})
670 may take an infeasible mount of simulation time.
671 In these cases it could be advantageous to parallelize the work and have a group of multiple ``walkers'' $\xi^{(i)}(t)$ share a single bias potential.
672 This can be achieved by collecting samples from all $\xi^{(i)}$ of the same sharing group into a single histogram and update a common free energy estimate.
673 Samples can be shared between walkers within the simulation and/or between multiple simulations.
674 However, currently only sharing between simulations is supported in the code while all biases within a simulation are independent.
676 Note that when attempting to shorten the simulation time by using bias-sharing walkers,
677 care must be taken to ensure the simulations are still long enough
678 to properly explore and equilibrate all regions of the sampling interval.
679 To begin, the walkers in a group
680 should be decorrelated and distributed approximately according to the target distribution before starting to refine the free energy.
681 This can be achieved e.g. by ``equilibrating'' the shared weight histogram before letting it grow;
682 for instance, $W(\lambda)/N\approx \rho(\lambda)$ with some tolerance.
684 Furthermore, the ``covering'' or transition criterion of the initial stage should to be generalized to detect when the sampling interval has been collectively traversed.
685 One alternative is to just use the same criterion as for a single walker (but now with more samples), see Eq.~\ref{eq:awh:covering}.
686 However, in contrast to the single walker case this does not ensure that any real transitions across the sampling interval has taken place;
687 in principle all walkers could be sampling only very locally and still cover the whole interval.
688 Just as with a standard umbrella sampling procedure, the free energy may appear to be converged while in reality simulations sampling closeby $\lambda$ values
689 are sampling disconnected regions of phase space.
690 A stricter criterion, which helps avoid such issues, is to require that before a simulation marks a point $\lambda_\mu$ along dimension $\mu$ as visited,
691 and shares this with the other walkers,
692 also all points within a certain diameter $D_{\mathrm{cover}}$ should have been visited (i.e.fulfill Eq.~\ref{eq:awh:covering}).
693 Increasing $D_{\mathrm{cover}}$
694 increases robustness, but may slow down convergence.
695 For the maximum value of $D_{\mathrm{cover}}$, equal to the length of the sampling interval,
696 the sampling interval is considered covered when at least one walker has independently traversed the sampling interval.
698 \subsection{Reweighting and combining biased data}\label{sec:awh:reweight}
699 Often one may want to, post-simulation, calculate the unbiased PMF $\Phi(u)$ of another variable $u(x)$.
700 $\Phi(u)$ can be estimated using $\xi$-biased data
701 by reweighting (``unbiasing'') the trajectory
702 using the bias potential $U_{n(t)}$, see Eq.~\ref{eq:awh:biaspotential}.
703 Essentially, one bins the biased data along $u$ and
704 removes the effect of $U_{n(t)}$ by dividing the weight of samples $u(t)$ by $e^{-U_{n(t)}(\xi(t))}$,
705 \begin{equation}\label{eq:awh:unbias}
706 \hat{\Phi}(u) = -\ln
707 \sum_t 1_u(u(t))e^{U_{n(t)}(\xi(t)} \mathcal{Z}_{n(t)}.
708 \end{equation}
709 Here the indicator function $1_u$ denotes the binning procedure: $1_u(u') = 1$ if $u'$ falls into the bin labeled by $u$ and $0$ otherwise.
710 The normalization factor $\mathcal{Z}_n = \int e^{-\Phi(\xi) - U_{n}(\xi)}d \xi$ is the partition function of the extended ensemble.
711 As can be seen $\mathcal{Z}_n$ depends on $\Phi(\xi)$, the PMF of the (biased) reaction coordinate $\xi$
712 (which is calculated and written to file by the AWH simulation).
713 It is advisable to use only final stage data in the reweighting procedure due to the rapid change of the bias potential during the initial stage.
714 If one would include initial stage data,
715 one should %when applying Eq.~\ref{eq:awh:unbias},
716 use the sample weights that are inferred by the repeated rescaling of the histogram in the initial stage,
717 for the sake of consistency.
718 Initial stage samples would then in any case be heavily scaled down relative to final stage samples.
719 Note that Eq.~\ref{eq:awh:unbias} can also be used to combine data from multiple simulations (by adding another sum also over the trajectory set).
720 Furthermore, when multiple independent AWH biases have generated a set of PMF estimates $\{\hat{\Phi}^{(i)}(\xi)\}$,
721 a combined best estimate $\hat{\Phi}(\xi)$ can be obtained by applying self-consistent exponential averaging.
722 More details on this procedure and a derivation of Eq.~\ref{eq:awh:unbias} (using slightly different notation) can be found in \cite{lindahl2017sequence}.
724 \subsection{The friction metric}\label{sec:awh:friction}
725 During the AWH simulation, the following time-integrated force correlation function is calculated,
726 \newcommand{\av}[1]{\left<{#1}\right>}
727 \begin{equation} \label{eq:awh:metric}
728 \eta_{\mu\nu}(\lambda) =
729 \beta
730 \int_0^\infty
731 \frac{
732 \av{\delta \mathcal{F}_{\mu}(x(t),\lambda)
733 \delta \mathcal{F}_\nu(x(0),\lambda)
734 \omega(\lambda|x(t)) \omega(\lambda|x(0))}}
735 {\av{\omega^2(\lambda|x)}}
737 \end{equation}
738 Here $\mathcal F_\mu(x,\lambda) = k_\mu (\xi_\mu(x) - \lambda_\mu)$
739 is the force along dimension $\mu$ from an harmonic potential centered at $\lambda$
740 and $\delta \mathcal F_\mu(x,\lambda) = \mathcal F_\mu(x,\lambda) - \av{\mathcal F_\mu(x,\lambda)}$
741 is the deviation of the force.
742 The factors $\omega(\lambda|x(t))$, see Eq.~\ref{eq:awh:omega}, reweight the samples.
743 $\eta_{\mu\nu}(\lambda)$ is a friction tensor~\cite{sivak2012thermodynamic}.
744 Its matrix elements are inversely proportional to local diffusion coefficients.
745 A measure of sampling (in)efficiency at each $\lambda$ is given by
746 \begin{equation}\label{eq:awh:sqrt-metric}
747 \eta^{\frac{1}{2}}(\lambda) = \sqrt{\det\eta_{\mu\nu}(\lambda)}.
748 \end{equation}
749 A large value of $\eta^{\frac{1}{2}}(\lambda)$ indicates slow dynamics and long correlation times,
750 which may require more sampling.
752 \subsection{Usage}\label{sec:awh:usage}
754 AWH stores data in the energy file ({\tt .edr}) with a frequency set by the user.
755 The data -- the PMF, the convolved bias, distributions of the $\lambda$ and $\xi$ coordinates, etc. --
756 can be extracted after the simulation using the {\tt gmx awh} tool.
757 Furthermore, the trajectory of the reaction coordinate $\xi(t)$ is printed to the pull output file ${\tt pullx.xvg}$.
758 The log file ({\tt .log}) also contains information;
759 check for messages starting with ``awh'', they will tell you about covering and potential sampling issues.
761 \subsubsection{Setting the initial update size}
762 The initial value of the weight histogram size $N$ sets the initial update size (and the rate of change of the bias).
763 When $N$ is kept constant, like in the initial stage,
764 the average variance of the free energy scales as $\varepsilon^2 \sim 1/(ND)$ \cite{lindahl2014accelerated},
765 for a simple model system with constant diffusion $D$ along the reaction coordinate.
766 This provides a ballpark estimate used by AWH to initialize $N$ in terms of more meaningful quantities
767 \begin{equation}\label{eq:awh:n0}
768 \frac{1}{N_0} = \frac{1}{N_0(\varepsilon_0, D)} \sim D\varepsilon_0^2.
769 \end{equation}
770 Essentially, this tells us that a slower system (small $D$) requires more samples (larger $N^0$)
771 to attain the same level of accuracy ($\varepsilon_0$) at a given sampling rate.
772 Conversely, for a system of given diffusion, how to choose the initial biasing rate depends on how good the initial
773 accuracy is.
774 Both the initial error $\varepsilon_0$ and the diffusion $D$ only need to be roughly estimated or guessed. In the typical case, one would only tweak the $D$ parameter,
775 and use a default value for $\varepsilon_0$.
776 For good convergence, $D$ should be chosen as large as possible (while maintaining a stable system)
777 giving large initial bias updates and fast initial transitions.
778 Choosing $D$ too small can lead to slow initial convergence.
779 It may be a good idea to run a short trial simulation and after the first covering check the maximum free energy difference of the PMF estimate.
780 If this is much larger than the expected magnitude of the free energy barriers that should be crossed,
781 then the system is probably being pulled too hard and $D$ should be decreased.
782 $\varepsilon_0$ on the other hand, would only be tweaked when starting an AWH simulation using a fairly accurate guess of the PMF as input.
784 \subsubsection{Tips for efficient sampling}
785 The force constant $k$ should be larger than the curvature of the PMF landscape.
786 If this is not the case, the distributions of the reaction coordinate $\xi$ and the reference coordinate $\lambda$,
787 will differ significantly and warnings will be printed in the log file.
788 One can choose $k$ as large as the time step supports.
789 This will neccessarily increase the number of points of the discretized sampling interval $I$.
790 In general however, it should not affect the performance of the simulation noticeably because the AWH update is implemented such that
791 only sampled points are accessed at free energy update time.
793 As with any method, the choice of reaction coordinate(s) is critical.
794 If a single reaction coordinate does not suffice, identifying a second reaction coordinate and sampling the two-dimensional landscape may help.
795 In this case, using a target distribution with a free energy cutoff (see Eq.~\ref{eq:awh:rhocut})
796 might be required to avoid sampling uninteresting regions of very high free energy.
797 Obtaining accurate free energies for reaction coordinates of much higher dimensionality than 3 or possibly 4 is generally not feasible.
799 Monitoring the transition rate of $\xi(t)$, across the sampling interval is also advisable.
800 For reliable statistics (e.g. when reweighting the trajectory as described in section~\ref{sec:awh:reweight}),
801 one would generally want to observe at least a few transitions after having exited the initial stage.
802 Furthermore, if the dynamics of the reaction coordinate suddenly changes, this may be a sign of e.g.\ a reaction coordinate problem.
804 Difficult regions of sampling may also be detected by calculating the friction tensor $\eta_{\mu\nu}(\lambda)$ in the sampling interval,
805 see section~\ref{sec:awh:friction}.
806 $\eta_{\mu\nu}(\lambda)$ as well as the sampling efficiency measure
807 $\eta^{\frac{1}{2}}(\lambda)$ (Eq.~\ref{eq:awh:sqrt-metric}) are written to the energy file
808 and can be extracted with {\tt gmx awh}.
809 A high peak in $\eta^{\frac{1}{2}}(\lambda)$ indicates that this region requires longer time to sample properly.
811 \section{\normindex{Enforced Rotation}}
812 \index{rotational pulling|see{enforced rotation}}
813 \index{pulling, rotational|see{enforced rotation}}
814 \label{sec:rotation}
816 \mathchardef\mhyphen="2D
817 \newcommand{\rotiso }{^\mathrm{iso}}
818 \newcommand{\rotisopf }{^\mathrm{iso\mhyphen pf}}
819 \newcommand{\rotpm }{^\mathrm{pm}}
820 \newcommand{\rotpmpf }{^\mathrm{pm\mhyphen pf}}
821 \newcommand{\rotrm }{^\mathrm{rm}}
822 \newcommand{\rotrmpf }{^\mathrm{rm\mhyphen pf}}
823 \newcommand{\rotrmtwo }{^\mathrm{rm2}}
824 \newcommand{\rotrmtwopf }{^\mathrm{rm2\mhyphen pf}}
825 \newcommand{\rotflex }{^\mathrm{flex}}
826 \newcommand{\rotflext }{^\mathrm{flex\mhyphen t}}
827 \newcommand{\rotflextwo }{^\mathrm{flex2}}
828 \newcommand{\rotflextwot}{^\mathrm{flex2\mhyphen t}}
830 This module can be used to enforce the rotation of a group of atoms, as {\eg}
831 a protein subunit. There are a variety of rotation potentials, among them
832 complex ones that allow flexible adaptations of both the rotated subunit as
833 well as the local rotation axis during the simulation. An example application
834 can be found in ref. \cite{Kutzner2011}.
836 \begin{figure}
837 \centerline{\includegraphics[width=13cm]{plots/rotation.pdf}}
838 \caption[Fixed and flexible axis rotation]{Comparison of fixed and flexible axis
839 rotation.
840 {\sf A:} Rotating the sketched shape inside the white tubular cavity can create
841 artifacts when a fixed rotation axis (dashed) is used. More realistically, the
842 shape would revolve like a flexible pipe-cleaner (dotted) inside the bearing (gray).
843 {\sf B:} Fixed rotation around an axis \ve{v} with a pivot point
844 specified by the vector \ve{u}.
845 {\sf C:} Subdividing the rotating fragment into slabs with separate rotation
846 axes ($\uparrow$) and pivot points ($\bullet$) for each slab allows for
847 flexibility. The distance between two slabs with indices $n$ and $n+1$ is $\Delta x$.}
848 \label{fig:rotation}
849 \end{figure}
851 \begin{figure}
852 \centerline{\includegraphics[width=13cm]{plots/equipotential.pdf}}
853 \caption{Selection of different rotation potentials and definition of notation.
854 All four potentials $V$ (color coded) are shown for a single atom at position
855 $\ve{x}_j(t)$.
856 {\sf A:} Isotropic potential $V\rotiso$,
857 {\sf B:} radial motion potential $V\rotrm$ and flexible potential
858 $V\rotflex$,
859 {\sf C--D:} radial motion\,2 potential $V\rotrmtwo$ and
860 flexible\,2 potential $V\rotflextwo$ for $\epsilon' = 0$\,nm$^2$ {\sf (C)}
861 and $\epsilon' = 0.01$\,nm$^2$ {\sf (D)}. The rotation axis is perpendicular to
862 the plane and marked by $\otimes$. The light gray contours indicate Boltzmann factors
863 $e^{-V/(k_B T)}$ in the $\ve{x}_j$-plane for $T=300$\,K and
864 $k=200$\,kJ/(mol$\cdot$nm$^2$). The green arrow shows the direction of the
865 force $\ve{F}_{\!j}$ acting on atom $j$; the blue dashed line indicates the
866 motion of the reference position.}
867 \label{fig:equipotential}
868 \end{figure}
870 \subsection{Fixed Axis Rotation}
871 \subsubsection{Stationary Axis with an Isotropic Potential}
872 In the fixed axis approach (see \figref{rotation}B), torque on a group of $N$
873 atoms with positions $\ve{x}_i$ (denoted ``rotation group'') is applied by
874 rotating a reference set of atomic positions -- usually their initial positions
875 $\ve{y}_i^0$ -- at a constant angular velocity $\omega$ around an axis
876 defined by a direction vector $\hat{\ve{v}}$ and a pivot point \ve{u}.
877 To that aim, each atom with position $\ve{x}_i$ is attracted by a
878 ``virtual spring'' potential to its moving reference position
879 $\ve{y}_i = \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{u})$,
880 where $\mathbf{\Omega}(t)$ is a matrix that describes the rotation around the
881 axis. In the simplest case, the ``springs'' are described by a harmonic
882 potential,
883 \beq
884 V\rotiso = \frac{k}{2} \sum_{i=1}^{N} w_i \left[ \mathbf{\Omega}(t)
885 (\ve{y}_i^0 - \ve{u}) - (\ve{x}_i - \ve{u}) \right]^2 ,
886 \label{eqn:potiso}
887 \eeq
888 with optional mass-weighted prefactors $w_i = N \, m_i/M$ with total mass
889 $M = \sum_{i=1}^N m_i$.
890 The rotation matrix $\mathbf{\Omega}(t)$ is
891 \newcommand{\omcost}{\,\xi\,} % abbreviation
892 \begin{displaymath}
893 \mathbf{\Omega}(t) =
894 \left(
895 \begin{array}{ccc}
896 \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\\
897 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\\
898 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 \\
899 \end{array}
900 \right) ,
901 \end{displaymath}
902 where $v_x$, $v_y$, and $v_z$ are the components of the normalized rotation vector
903 $\hat{\ve{v}}$, and $\omcost := 1-\cos(\omega t)$. As illustrated in
904 \figref{equipotential}A for a single atom $j$, the
905 rotation matrix $\mathbf{\Omega}(t)$ operates on the initial reference positions
906 $\ve{y}_j^0 = \ve{x}_j(t_0)$ of atom $j$ at $t=t_0$. At a later
907 time $t$, the reference position has rotated away from its initial place
908 (along the blue dashed line), resulting in the force
909 \beq
910 \ve{F}_{\!j}\rotiso
911 = -\nabla_{\!j} \, V\rotiso
912 = k \, w_j \left[
913 \mathbf{\Omega}(t) (\ve{y}_j^0 - \ve{u}) - (\ve{x}_j - \ve{u} ) \right] ,
914 \label{eqn:force_fixed}
915 \eeq
916 which is directed towards the reference position.
919 \subsubsection{Pivot-Free Isotropic Potential}
920 Instead of a fixed pivot vector \ve{u} this potential uses the center of
921 mass $\ve{x}_c$ of the rotation group as pivot for the rotation axis,
922 \beq
923 \ve{x}_c = \frac{1}{M} \sum_{i=1}^N m_i \ve{x}_i
924 \label{eqn:com}
925 \mbox{\hspace{4ex}and\hspace{4ex}}
926 \ve{y}_c^0 = \frac{1}{M} \sum_{i=1}^N m_i \ve{y}_i^0 \ ,
927 \eeq
928 which yields the ``pivot-free'' isotropic potential
929 \beq
930 V\rotisopf = \frac{k}{2} \sum_{i=1}^{N} w_i \left[ \mathbf{\Omega}(t)
931 (\ve{y}_i^0 - \ve{y}_c^0) - (\ve{x}_i - \ve{x}_c) \right]^2 ,
932 \label{eqn:potisopf}
933 \eeq
934 with forces
935 \beq
936 \mathbf{F}_{\!j}\rotisopf = k \, w_j
937 \left[
938 \mathbf{\Omega}(t) ( \ve{y}_j^0 - \ve{y}_c^0)
939 - ( \ve{x}_j - \ve{x}_c )
940 \right] .
941 \label{eqn:force_isopf}
942 \eeq
943 Without mass-weighting, the pivot $\ve{x}_c$ is the geometrical center of
944 the group.
945 \label{sec:fixed}
947 \subsubsection{Parallel Motion Potential Variant}
948 The forces generated by the isotropic potentials
949 (\eqnsref{potiso}{potisopf}) also contain components parallel
950 to the rotation axis and thereby restrain motions along the axis of either the
951 whole rotation group (in case of $V\rotiso$) or within
952 the rotation group (in case of $V\rotisopf$). For cases where
953 unrestrained motion along the axis is preferred, we have implemented a
954 ``parallel motion'' variant by eliminating all components parallel to the
955 rotation axis for the potential. This is achieved by projecting the distance
956 vectors between reference and actual positions
957 \beq
958 \ve{r}_i = \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{u}) - (\ve{x}_i - \ve{u})
959 \eeq
960 onto the plane perpendicular to the rotation vector,
961 \beq
962 \label{eqn:project}
963 \ve{r}_i^\perp := \ve{r}_i - (\ve{r}_i \cdot \hat{\ve{v}})\hat{\ve{v}} \ ,
964 \eeq
965 yielding
966 \bea
967 \nonumber
968 V\rotpm &=& \frac{k}{2} \sum_{i=1}^{N} w_i ( \ve{r}_i^\perp )^2 \\
969 &=& \frac{k}{2} \sum_{i=1}^{N} w_i
970 \left\lbrace
971 \mathbf{\Omega}(t)
972 (\ve{y}_i^0 - \ve{u}) - (\ve{x}_i - \ve{u}) \right. \nonumber \\
973 && \left. - \left\lbrace
974 \left[ \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{u}) - (\ve{x}_i - \ve{u}) \right] \cdot\hat{\ve{v}}
975 \right\rbrace\hat{\ve{v}} \right\rbrace^2 ,
976 \label{eqn:potpm}
977 \eea
978 and similarly
979 \beq
980 \ve{F}_{\!j}\rotpm = k \, w_j \, \ve{r}_j^\perp .
981 \label{eqn:force_pm}
982 \eeq
984 \subsubsection{Pivot-Free Parallel Motion Potential}
985 Replacing in \eqnref{potpm} the fixed pivot \ve{u} by the center
986 of mass $\ve{x_c}$ yields the pivot-free variant of the parallel motion
987 potential. With
988 \beq
989 \ve{s}_i = \mathbf{\Omega}(t) (\ve{y}_i^0 - \ve{y}_c^0) - (\ve{x}_i - \ve{x}_c)
990 \eeq
991 the respective potential and forces are
992 \bea
993 V\rotpmpf &=& \frac{k}{2} \sum_{i=1}^{N} w_i ( \ve{s}_i^\perp )^2 \ , \\
994 \label{eqn:potpmpf}
995 \ve{F}_{\!j}\rotpmpf &=& k \, w_j \, \ve{s}_j^\perp .
996 \label{eqn:force_pmpf}
997 \eea
999 \subsubsection{Radial Motion Potential}
1000 In the above variants, the minimum of the rotation potential is either a single
1001 point at the reference position $\ve{y}_i$ (for the isotropic potentials) or a
1002 single line through $\ve{y}_i$ parallel to the rotation axis (for the
1003 parallel motion potentials). As a result, radial forces restrict radial motions
1004 of the atoms. The two subsequent types of rotation potentials, $V\rotrm$
1005 and $V\rotrmtwo$, drastically reduce or even eliminate this effect. The first
1006 variant, $V\rotrm$ (\figref{equipotential}B), eliminates all force
1007 components parallel to the vector connecting the reference atom and the
1008 rotation axis,
1009 \beq
1010 V\rotrm = \frac{k}{2} \sum_{i=1}^{N} w_i \left[
1011 \ve{p}_i
1012 \cdot(\ve{x}_i - \ve{u}) \right]^2 ,
1013 \label{eqn:potrm}
1014 \eeq
1015 with
1016 \beq
1017 \ve{p}_i :=
1018 \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})\|} \ .
1019 \eeq
1020 This variant depends only on the distance $\ve{p}_i \cdot (\ve{x}_i -
1021 \ve{u})$ of atom $i$ from the plane spanned by $\hat{\ve{v}}$ and
1022 $\mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{u})$. The resulting force is
1023 \beq
1024 \mathbf{F}_{\!j}\rotrm =
1025 -k \, w_j \left[ \ve{p}_j\cdot(\ve{x}_j - \ve{u}) \right] \,\ve{p}_j \, .
1026 \label{eqn:potrm_force}
1027 \eeq
1029 \subsubsection{Pivot-Free Radial Motion Potential}
1030 Proceeding similar to the pivot-free isotropic potential yields a pivot-free
1031 version of the above potential. With
1032 \beq
1033 \ve{q}_i :=
1034 \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)\|} \, ,
1035 \eeq
1036 the potential and force for the pivot-free variant of the radial motion potential read
1037 \bea
1038 V\rotrmpf & = & \frac{k}{2} \sum_{i=1}^{N} w_i \left[
1039 \ve{q}_i
1040 \cdot(\ve{x}_i - \ve{x}_c)
1041 \right]^2 \, , \\
1042 \label{eqn:potrmpf}
1043 \mathbf{F}_{\!j}\rotrmpf & = &
1044 -k \, w_j \left[ \ve{q}_j\cdot(\ve{x}_j - \ve{x}_c) \right] \,\ve{q}_j
1045 + k \frac{m_j}{M} \sum_{i=1}^{N} w_i \left[
1046 \ve{q}_i\cdot(\ve{x}_i - \ve{x}_c) \right]\,\ve{q}_i \, .
1047 \label{eqn:potrmpf_force}
1048 \eea
1050 \subsubsection{Radial Motion 2 Alternative Potential}
1051 As seen in \figref{equipotential}B, the force resulting from
1052 $V\rotrm$ still contains a small, second-order radial component. In most
1053 cases, this perturbation is tolerable; if not, the following
1054 alternative, $V\rotrmtwo$, fully eliminates the radial contribution to the
1055 force, as depicted in \figref{equipotential}C,
1056 \beq
1057 V\rotrmtwo =
1058 \frac{k}{2} \sum_{i=1}^{N} w_i\,
1059 \frac{\left[ (\hat{\ve{v}} \times ( \ve{x}_i - \ve{u} ))
1060 \cdot \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{u}) \right]^2}
1061 {\| \hat{\ve{v}} \times (\ve{x}_i - \ve{u}) \|^2 +
1062 \epsilon'} \, ,
1063 \label{eqn:potrm2}
1064 \eeq
1065 where a small parameter $\epsilon'$ has been introduced to avoid singularities.
1066 For $\epsilon'=0$\,nm$^2$, the equipotential planes are spanned by $\ve{x}_i -
1067 \ve{u}$ and $\hat{\ve{v}}$, yielding a force
1068 perpendicular to $\ve{x}_i - \ve{u}$, thus not contracting or
1069 expanding structural parts that moved away from or toward the rotation axis.
1071 Choosing a small positive $\epsilon'$ ({\eg},
1072 $\epsilon'=0.01$\,nm$^2$, \figref{equipotential}D) in the denominator of
1073 \eqnref{potrm2} yields a well-defined potential and continuous forces also
1074 close to the rotation axis, which is not the case for $\epsilon'=0$\,nm$^2$
1075 (\figref{equipotential}C). With
1076 \bea
1077 \ve{r}_i & := & \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{u})\\
1078 \ve{s}_i & := & \frac{\hat{\ve{v}} \times (\ve{x}_i -
1079 \ve{u} ) }{ \| \hat{\ve{v}} \times (\ve{x}_i - \ve{u})
1080 \| } \equiv \; \Psi_{i} \;\; {\hat{\ve{v}} \times
1081 (\ve{x}_i-\ve{u} ) }\\
1082 \Psi_i^{*} & := & \frac{1}{ \| \hat{\ve{v}} \times
1083 (\ve{x}_i-\ve{u}) \|^2 + \epsilon'}
1084 \eea
1085 the force on atom $j$ reads
1086 \beq
1087 \ve{F}_{\!j}\rotrmtwo =
1088 - k\;
1089 \left\lbrace w_j\;
1090 (\ve{s}_j\cdot\ve{r}_{\!j})\;
1091 \left[ \frac{\Psi_{\!j}^* }{\Psi_{\!j} } \ve{r}_{\!j}
1092 - \frac{\Psi_{\!j}^{*2}}{\Psi_{\!j}^3}
1093 (\ve{s}_j\cdot\ve{r}_{\!j})\ve{s}_j \right]
1094 \right\rbrace \times \hat{\ve{v}} .
1095 \label{eqn:potrm2_force}
1096 \eeq
1098 \subsubsection{Pivot-Free Radial Motion 2 Potential}
1099 The pivot-free variant of the above potential is
1100 \beq
1101 V\rotrmtwopf =
1102 \frac{k}{2} \sum_{i=1}^{N} w_i\,
1103 \frac{\left[ (\hat{\ve{v}} \times ( \ve{x}_i - \ve{x}_c ))
1104 \cdot \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c) \right]^2}
1105 {\| \hat{\ve{v}} \times (\ve{x}_i - \ve{x}_c) \|^2 +
1106 \epsilon'} \, .
1107 \label{eqn:potrm2pf}
1108 \eeq
1109 With
1110 \bea
1111 \ve{r}_i & := & \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c)\\
1112 \ve{s}_i & := & \frac{\hat{\ve{v}} \times (\ve{x}_i -
1113 \ve{x}_c ) }{ \| \hat{\ve{v}} \times (\ve{x}_i - \ve{x}_c)
1114 \| } \equiv \; \Psi_{i} \;\; {\hat{\ve{v}} \times
1115 (\ve{x}_i-\ve{x}_c ) }\\ \Psi_i^{*} & := & \frac{1}{ \| \hat{\ve{v}} \times
1116 (\ve{x}_i-\ve{x}_c) \|^2 + \epsilon'}
1117 \eea
1118 the force on atom $j$ reads
1119 \bea
1120 \nonumber
1121 \ve{F}_{\!j}\rotrmtwopf & = &
1122 - k\;
1123 \left\lbrace w_j\;
1124 (\ve{s}_j\cdot\ve{r}_{\!j})\;
1125 \left[ \frac{\Psi_{\!j}^* }{\Psi_{\!j} } \ve{r}_{\!j}
1126 - \frac{\Psi_{\!j}^{*2}}{\Psi_{\!j}^3}
1127 (\ve{s}_j\cdot\ve{r}_{\!j})\ve{s}_j \right]
1128 \right\rbrace \times \hat{\ve{v}}\\
1130 + k\;\frac{m_j}{M} \left\lbrace \sum_{i=1}^{N}
1131 w_i\;(\ve{s}_i\cdot\ve{r}_i) \;
1132 \left[ \frac{\Psi_i^* }{\Psi_i } \ve{r}_i
1133 - \frac{\Psi_i^{*2}}{\Psi_i^3} (\ve{s}_i\cdot\ve{r}_i )\;
1134 \ve{s}_i \right] \right\rbrace \times \hat{\ve{v}} \, .
1135 \label{eqn:potrm2pf_force}
1136 \eea
1138 \subsection{Flexible Axis Rotation}
1139 As sketched in \figref{rotation}A--B, the rigid body behavior of
1140 the fixed axis rotation scheme is a drawback for many applications. In
1141 particular, deformations of the rotation group are suppressed when the
1142 equilibrium atom positions directly depend on the reference positions.
1143 To avoid this limitation, \eqnsref{potrmpf}{potrm2pf}
1144 will now be generalized towards a ``flexible axis'' as sketched in
1145 \figref{rotation}C. This will be achieved by subdividing the
1146 rotation group into a set of equidistant slabs perpendicular to
1147 the rotation vector, and by applying a separate rotation potential to each
1148 of these slabs. \figref{rotation}C shows the midplanes of the slabs
1149 as dotted straight lines and the centers as thick black dots.
1151 To avoid discontinuities in the potential and in the forces, we define
1152 ``soft slabs'' by weighing the contributions of each
1153 slab $n$ to the total potential function $V\rotflex$ by a Gaussian
1154 function
1155 \beq
1156 \label{eqn:gaussian}
1157 g_n(\ve{x}_i) = \Gamma \ \mbox{exp} \left(
1158 -\frac{\beta_n^2(\ve{x}_i)}{2\sigma^2} \right) ,
1159 \eeq
1160 centered at the midplane of the $n$th slab. Here $\sigma$ is the width
1161 of the Gaussian function, $\Delta x$ the distance between adjacent slabs, and
1162 \beq
1163 \beta_n(\ve{x}_i) := \ve{x}_i \cdot \hat{\ve{v}} - n \, \Delta x \, .
1164 \eeq
1166 \begin{figure}
1167 \centerline{\includegraphics[width=6.5cm]{plots/gaussians.pdf}}
1168 \caption{Gaussian functions $g_n$ centered at $n \, \Delta x$ for a slab
1169 distance $\Delta x = 1.5$ nm and $n \geq -2$. Gaussian function $g_0$ is
1170 highlighted in bold; the dashed line depicts the sum of the shown Gaussian
1171 functions.}
1172 \label{fig:gaussians}
1173 \end{figure}
1175 A most convenient choice is $\sigma = 0.7 \Delta x$ and
1176 \begin{displaymath}
1177 1/\Gamma = \sum_{n \in Z}
1178 \mbox{exp}
1179 \left(-\frac{(n - \frac{1}{4})^2}{2\cdot 0.7^2}\right)
1180 \approx 1.75464 \, ,
1181 \end{displaymath}
1182 which yields a nearly constant sum, essentially independent of $\ve{x}_i$
1183 (dashed line in \figref{gaussians}), {\ie},
1184 \beq
1185 \sum_{n \in Z} g_n(\ve{x}_i) = 1 + \epsilon(\ve{x}_i) \, ,
1186 \label{eqn:normal}
1187 \eeq
1188 with $ | \epsilon(\ve{x}_i) | < 1.3\cdot 10^{-4}$. This choice also
1189 implies that the individual contributions to the force from the slabs add up to
1190 unity such that no further normalization is required.
1192 To each slab center $\ve{x}_c^n$, all atoms contribute by their
1193 Gaussian-weighted (optionally also mass-weighted) position vectors
1194 $g_n(\ve{x}_i) \, \ve{x}_i$. The
1195 instantaneous slab centers $\ve{x}_c^n$ are calculated from the
1196 current positions $\ve{x}_i$,
1197 \beq
1198 \label{eqn:defx0}
1199 \ve{x}_c^n =
1200 \frac{\sum_{i=1}^N g_n(\ve{x}_i) \, m_i \, \ve{x}_i}
1201 {\sum_{i=1}^N g_n(\ve{x}_i) \, m_i} \, ,\\
1202 \eeq
1203 while the reference centers $\ve{y}_c^n$ are calculated from the reference
1204 positions $\ve{y}_i^0$,
1205 \beq
1206 \label{eqn:defy0}
1207 \ve{y}_c^n =
1208 \frac{\sum_{i=1}^N g_n(\ve{y}_i^0) \, m_i \, \ve{y}_i^0}
1209 {\sum_{i=1}^N g_n(\ve{y}_i^0) \, m_i} \, .
1210 \eeq
1211 Due to the rapid decay of $g_n$, each slab
1212 will essentially involve contributions from atoms located within $\approx
1213 3\Delta x$ from the slab center only.
1215 \subsubsection{Flexible Axis Potential}
1216 We consider two flexible axis variants. For the first variant,
1217 the slab segmentation procedure with Gaussian weighting is applied to the radial
1218 motion potential (\eqnref{potrmpf}\,/\,\figref{equipotential}B),
1219 yielding as the contribution of slab $n$
1220 \begin{displaymath}
1221 V^n =
1222 \frac{k}{2} \sum_{i=1}^{N} w_i \, g_n(\ve{x}_i)
1223 \left[
1224 \ve{q}_i^n
1225 \cdot
1226 (\ve{x}_i - \ve{x}_c^n)
1227 \right]^2 ,
1228 \label{eqn:flexpot}
1229 \end{displaymath}
1230 and a total potential function
1231 \beq
1232 V\rotflex = \sum_n V^n \, .
1233 \label{eqn:potflex}
1234 \eeq
1235 Note that the global center of mass $\ve{x}_c$ used in
1236 \eqnref{potrmpf} is now replaced by $\ve{x}_c^n$, the center of mass of
1237 the slab. With
1238 \bea
1239 \ve{q}_i^n & := & \frac{\hat{\ve{v}} \times
1240 \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c^n) }{ \| \hat{\ve{v}}
1241 \times \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c^n) \| } \\
1242 b_i^n & := & \ve{q}_i^n \cdot (\ve{x}_i - \ve{x}_c^n) \, ,
1243 \eea
1244 the resulting force on atom $j$ reads
1245 \bea
1246 \nonumber\hspace{-15mm}
1247 \ve{F}_{\!j}\rotflex &=&
1248 - \, k \, w_j \sum_n g_n(\ve{x}_j) \, b_j^n \left\lbrace \ve{q}_j^n -
1249 b_j^n \frac{\beta_n(\ve{x}_j)}{2\sigma^2} \hat{\ve{v}} \right\rbrace \\ & &
1250 + \, k \, m_j \sum_n \frac{g_n(\ve{x}_j)}{\sum_h g_n(\ve{x}_h)}
1251 \sum_{i=1}^{N} w_i \, g_n(\ve{x}_i) \, b_i^n \left\lbrace
1252 \ve{q}_i^n -\frac{\beta_n(\ve{x}_j)}{\sigma^2}
1253 \left[ \ve{q}_i^n \cdot (\ve{x}_j - \ve{x}_c^n )\right]
1254 \hat{\ve{v}} \right\rbrace .
1255 \label{eqn:potflex_force}
1256 \eea
1258 Note that for $V\rotflex$, as defined, the slabs are fixed in space and so
1259 are the reference centers $\ve{y}_c^n$. If during the simulation the
1260 rotation group moves too far in $\ve{v}$ direction, it may enter a
1261 region where -- due to the lack of nearby reference positions -- no reference
1262 slab centers are defined, rendering the potential evaluation impossible.
1263 We therefore have included a slightly modified version of this potential that
1264 avoids this problem by attaching the midplane of slab $n=0$ to the center of mass
1265 of the rotation group, yielding slabs that move with the rotation group.
1266 This is achieved by subtracting the center of mass $\ve{x}_c$ of the
1267 group from the positions,
1268 \beq
1269 \tilde{\ve{x}}_i = \ve{x}_i - \ve{x}_c \, , \mbox{\ \ \ and \ \ }
1270 \tilde{\ve{y}}_i^0 = \ve{y}_i^0 - \ve{y}_c^0 \, ,
1271 \label{eqn:trafo}
1272 \eeq
1273 such that
1274 \bea
1275 V\rotflext
1276 & = & \frac{k}{2} \sum_n \sum_{i=1}^{N} w_i \, g_n(\tilde{\ve{x}}_i)
1277 \left[ \frac{\hat{\ve{v}} \times \mathbf{\Omega}(t)(\tilde{\ve{y}}_i^0
1278 - \tilde{\ve{y}}_c^n) }{ \| \hat{\ve{v}} \times
1279 \mathbf{\Omega}(t)(\tilde{\ve{y}}_i^0 -
1280 \tilde{\ve{y}}_c^n) \| }
1281 \cdot
1282 (\tilde{\ve{x}}_i - \tilde{\ve{x}}_c^n)
1283 \right]^2 .
1284 \label{eqn:potflext}
1285 \eea
1286 To simplify the force derivation, and for efficiency reasons, we here assume
1287 $\ve{x}_c$ to be constant, and thus $\partial \ve{x}_c / \partial x =
1288 \partial \ve{x}_c / \partial y = \partial \ve{x}_c / \partial z = 0$. The
1289 resulting force error is small (of order $O(1/N)$ or $O(m_j/M)$ if
1290 mass-weighting is applied) and can therefore be tolerated. With this assumption,
1291 the forces $\ve{F}\rotflext$ have the same form as
1292 \eqnref{potflex_force}.
1294 \subsubsection{Flexible Axis 2 Alternative Potential}
1295 In this second variant, slab segmentation is applied to $V\rotrmtwo$
1296 (\eqnref{potrm2pf}), resulting in a flexible axis potential without radial
1297 force contributions (\figref{equipotential}C),
1298 \beq
1299 V\rotflextwo =
1300 \frac{k}{2} \sum_{i=1}^{N} \sum_n w_i\,g_n(\ve{x}_i)
1301 \frac{\left[ (\hat{\ve{v}} \times ( \ve{x}_i - \ve{x}_c^n ))
1302 \cdot \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c^n) \right]^2}
1303 {\| \hat{\ve{v}} \times (\ve{x}_i - \ve{x}_c^n) \|^2 +
1304 \epsilon'} \, .
1305 \label{eqn:potflex2}
1306 \eeq
1307 With
1308 \bea
1309 \ve{r}_i^n & := & \mathbf{\Omega}(t)(\ve{y}_i^0 - \ve{y}_c^n)\\
1310 \ve{s}_i^n & := & \frac{\hat{\ve{v}} \times (\ve{x}_i -
1311 \ve{x}_c^n ) }{ \| \hat{\ve{v}} \times (\ve{x}_i - \ve{x}_c^n)
1312 \| } \equiv \; \psi_{i} \;\; {\hat{\ve{v}} \times (\ve{x}_i-\ve{x}_c^n ) }\\
1313 \psi_i^{*} & := & \frac{1}{ \| \hat{\ve{v}} \times (\ve{x}_i-\ve{x}_c^n) \|^2 + \epsilon'}\\
1314 W_j^n & := & \frac{g_n(\ve{x}_j)\,m_j}{\sum_h g_n(\ve{x}_h)\,m_h}\\
1315 \ve{S}^n & := &
1316 \sum_{i=1}^{N} w_i\;g_n(\ve{x}_i)
1317 \; (\ve{s}_i^n\cdot\ve{r}_i^n)
1318 \left[ \frac{\psi_i^* }{\psi_i } \ve{r}_i^n
1319 - \frac{\psi_i^{*2}}{\psi_i^3} (\ve{s}_i^n\cdot\ve{r}_i^n )\;
1320 \ve{s}_i^n \right] \label{eqn:Sn}
1321 \eea
1322 the force on atom $j$ reads
1323 \bea
1324 \nonumber
1325 \ve{F}_{\!j}\rotflextwo & = &
1326 - k\;
1327 \left\lbrace \sum_n w_j\;g_n(\ve{x}_j)\;
1328 (\ve{s}_j^n\cdot\ve{r}_{\!j}^n)\;
1329 \left[ \frac{\psi_j^* }{\psi_j } \ve{r}_{\!j}^n
1330 - \frac{\psi_j^{*2}}{\psi_j^3} (\ve{s}_j^n\cdot\ve{r}_{\!j}^n)\;
1331 \ve{s}_{\!j}^n \right] \right\rbrace \times \hat{\ve{v}} \\
1332 \nonumber
1334 + k \left\lbrace \sum_n W_{\!j}^n \, \ve{S}^n \right\rbrace \times
1335 \hat{\ve{v}}
1336 - k \left\lbrace \sum_n W_{\!j}^n \; \frac{\beta_n(\ve{x}_j)}{\sigma^2} \frac{1}{\psi_j}\;\;
1337 \ve{s}_j^n \cdot
1338 \ve{S}^n \right\rbrace \hat{\ve{v}}\\
1339 & &
1340 + \frac{k}{2} \left\lbrace \sum_n w_j\;g_n(\ve{x}_j)
1341 \frac{\beta_n(\ve{x}_j)}{\sigma^2}
1342 \frac{\psi_j^*}{\psi_j^2}( \ve{s}_j^n \cdot \ve{r}_{\!j}^n )^2 \right\rbrace
1343 \hat{\ve{v}} .
1344 \label{eqn:potflex2_force}
1345 \eea
1347 Applying transformation (\ref{eqn:trafo}) yields a ``translation-tolerant''
1348 version of the flexible\,2 potential, $V\rotflextwot$. Again,
1349 assuming that $\partial \ve{x}_c / \partial x$, $\partial \ve{x}_c /
1350 \partial y$, $\partial \ve{x}_c / \partial z$ are small, the
1351 resulting equations for $V\rotflextwot$ and $\ve{F}\rotflextwot$ are
1352 similar to those of $V\rotflextwo$ and $\ve{F}\rotflextwo$.
1354 \subsection{Usage}
1355 To apply enforced rotation, the particles $i$ that are to
1356 be subjected to one of the rotation potentials are defined via index groups
1357 {\tt rot-group0}, {\tt rot-group1}, etc., in the {\tt .mdp} input file.
1358 The reference positions $\ve{y}_i^0$ are
1359 read from a special {\tt .trr} file provided to {\tt grompp}. If no such file is found,
1360 $\ve{x}_i(t=0)$ are used as reference positions and written to {\tt .trr} such
1361 that they can be used for subsequent setups. All parameters of the potentials
1362 such as $k$, $\epsilon'$, etc. (\tabref{vars}) are provided as {\tt .mdp}
1363 parameters; {\tt rot-type} selects the type of the potential.
1364 The option {\tt rot-massw} allows to choose whether or not to use
1365 mass-weighted averaging.
1366 For the flexible potentials, a cutoff value $g_n^\mathrm{min}$
1367 (typically $g_n^\mathrm{min}=0.001$) makes shure that only
1368 significant contributions to $V$ and \ve{F} are evaluated, {\ie} terms with
1369 $g_n(\ve{x}) < g_n^\mathrm{min}$ are omitted.
1370 \tabref{quantities} summarizes observables that are written
1371 to additional output files and which are described below.
1374 \begin{table}[tbp]
1375 \caption{Parameters used by the various rotation potentials.
1376 {\sf x}'s indicate which parameter is actually used for a given potential.}
1377 %\small
1379 \newcommand{\kunit}{$\frac{\mathrm{kJ}}{\mathrm{mol} \cdot \mathrm{nm}^2}$}
1380 \newcommand{\smtt}[1]{{\hspace{-0.5ex}\small #1\hspace{-0.5ex}}}
1381 \label{tab:vars}
1382 \begin{center}
1383 \begin{tabular}{l>{$}l<{$}rccccccc}
1384 \hline
1385 parameter & & & $k$ & $\hat{\ve{v}}$ & $\ve{u}$ & $\omega$ & $\epsilon'$ & $\Delta x$ & $g_n^\mathrm{min}$ \\
1386 \multicolumn{3}{l}{{\tt .mdp} input variable name} & \smtt{k} & \smtt{vec} & \smtt{pivot} & \smtt{rate} & \smtt{eps} & \smtt{slab-dist} & \smtt{min-gauss} \\
1387 unit & & & \kunit & - & nm & $^\circ$/ps & nm$^2$ & nm & \,-\, \\[1mm]
1388 \hline \multicolumn{2}{l}{fixed axis potentials:} & eqn.\\
1389 isotropic & V\rotiso & (\ref{eqn:potiso}) & {\sf x} & {\sf x} & {\sf x} & {\sf x} & - & - & - \\
1390 --- pivot-free & V\rotisopf & (\ref{eqn:potisopf}) & {\sf x} & {\sf x} & - & {\sf x} & - & - & - \\
1391 parallel motion & V\rotpm & (\ref{eqn:potpm}) & {\sf x} & {\sf x} & {\sf x} & {\sf x} & - & - & - \\
1392 --- pivot-free & V\rotpmpf & (\ref{eqn:potpmpf}) & {\sf x} & {\sf x} & - & {\sf x} & - & - & - \\
1393 radial motion & V\rotrm & (\ref{eqn:potrm}) & {\sf x} & {\sf x} & {\sf x} & {\sf x} & - & - & - \\
1394 --- pivot-free & V\rotrmpf & (\ref{eqn:potrmpf}) & {\sf x} & {\sf x} & - & {\sf x} & - & - & - \\
1395 radial motion\,2 & V\rotrmtwo & (\ref{eqn:potrm2}) & {\sf x} & {\sf x} & {\sf x} & {\sf x} & {\sf x} & - & - \\
1396 --- pivot-free & V\rotrmtwopf & (\ref{eqn:potrm2pf}) & {\sf x} & {\sf x} & - & {\sf x} & {\sf x} & - & - \\ \hline
1397 \multicolumn{2}{l}{flexible axis potentials:} & eqn.\\
1398 flexible & V\rotflex & (\ref{eqn:potflex}) & {\sf x} & {\sf x} & - & {\sf x} & - & {\sf x} & {\sf x} \\
1399 --- transl. tol. & V\rotflext & (\ref{eqn:potflext}) & {\sf x} & {\sf x} & - & {\sf x} & - & {\sf x} & {\sf x} \\
1400 flexible\,2 & V\rotflextwo & (\ref{eqn:potflex2}) & {\sf x} & {\sf x} & - & {\sf x} & {\sf x} & {\sf x} & {\sf x} \\
1401 --- transl. tol. & V\rotflextwot & - & {\sf x} & {\sf x} & - & {\sf x} & {\sf x} & {\sf x} & {\sf x} \\
1402 \hline
1403 \end{tabular}
1404 \end{center}
1405 \end{table}
1407 \begin{table}
1408 \caption{Quantities recorded in output files during enforced rotation simulations.
1409 All slab-wise data is written every {\tt nstsout} steps, other rotation data every {\tt nstrout} steps.}
1410 \label{tab:quantities}
1411 \begin{center}
1412 \begin{tabular}{llllcc}
1413 \hline
1414 quantity & unit & equation & output file & fixed & flexible\\ \hline
1415 $V(t)$ & kJ/mol & see \ref{tab:vars} & {\tt rotation} & {\sf x} & {\sf x} \\
1416 $\theta_\mathrm{ref}(t)$ & degrees & $\theta_\mathrm{ref}(t)=\omega t$ & {\tt rotation} & {\sf x} & {\sf x} \\
1417 $\theta_\mathrm{av}(t)$ & degrees & (\ref{eqn:avangle}) & {\tt rotation} & {\sf x} & - \\
1418 $\theta_\mathrm{fit}(t)$, $\theta_\mathrm{fit}(t,n)$ & degrees & (\ref{eqn:rmsdfit}) & {\tt rotangles} & - & {\sf x} \\
1419 $\ve{y}_0(n)$, $\ve{x}_0(t,n)$ & nm & (\ref{eqn:defx0}, \ref{eqn:defy0})& {\tt rotslabs} & - & {\sf x} \\
1420 $\tau(t)$ & kJ/mol & (\ref{eqn:torque}) & {\tt rotation} & {\sf x} & - \\
1421 $\tau(t,n)$ & kJ/mol & (\ref{eqn:torque}) & {\tt rottorque} & - & {\sf x} \\ \hline
1422 \end{tabular}
1423 \end{center}
1424 \end{table}
1427 \subsubsection*{Angle of Rotation Groups: Fixed Axis}
1428 For fixed axis rotation, the average angle $\theta_\mathrm{av}(t)$ of the
1429 group relative to the reference group is determined via the distance-weighted
1430 angular deviation of all rotation group atoms from their reference positions,
1431 \beq
1432 \theta_\mathrm{av} = \left. \sum_{i=1}^{N} r_i \ \theta_i \right/ \sum_{i=1}^N r_i \ .
1433 \label{eqn:avangle}
1434 \eeq
1435 Here, $r_i$ is the distance of the reference position to the rotation axis, and
1436 the difference angles $\theta_i$ are determined from the atomic positions,
1437 projected onto a plane perpendicular to the rotation axis through pivot point
1438 $\ve{u}$ (see \eqnref{project} for the definition of $\perp$),
1439 \beq
1440 \cos \theta_i =
1441 \frac{(\ve{y}_i-\ve{u})^\perp \cdot (\ve{x}_i-\ve{u})^\perp}
1442 { \| (\ve{y}_i-\ve{u})^\perp \cdot (\ve{x}_i-\ve{u})^\perp
1443 \| } \ .
1444 \eeq
1446 The sign of $\theta_\mathrm{av}$ is chosen such that
1447 $\theta_\mathrm{av} > 0$ if the actual structure rotates ahead of the reference.
1449 \subsubsection*{Angle of Rotation Groups: Flexible Axis}
1450 For flexible axis rotation, two outputs are provided, the angle of the
1451 entire rotation group, and separate angles for the segments in the slabs.
1452 The angle of the entire rotation group is determined by an RMSD fit
1453 of $\ve{x}_i$
1454 to the reference positions $\ve{y}_i^0$ at $t=0$, yielding $\theta_\mathrm{fit}$
1455 as the angle by which the reference has to be rotated around $\hat{\ve{v}}$
1456 for the optimal fit,
1457 \beq
1458 \mathrm{RMSD} \big( \ve{x}_i,\ \mathbf{\Omega}(\theta_\mathrm{fit})
1459 \ve{y}_i^0 \big) \stackrel{!}{=} \mathrm{min} \, .
1460 \label{eqn:rmsdfit}
1461 \eeq
1462 To determine the local angle for each slab $n$, both reference and actual
1463 positions are weighted with the Gaussian function of slab $n$, and
1464 $\theta_\mathrm{fit}(t,n)$ is calculated as in \eqnref{rmsdfit}) from the
1465 Gaussian-weighted positions.
1467 For all angles, the {\tt .mdp} input option {\tt rot-fit-method} controls
1468 whether a normal RMSD fit is performed or whether for the fit each
1469 position $\ve{x}_i$ is put at the same distance to the rotation axis as its
1470 reference counterpart $\ve{y}_i^0$. In the latter case, the RMSD
1471 measures only angular differences, not radial ones.
1474 \subsubsection*{Angle Determination by Searching the Energy Minimum}
1475 Alternatively, for {\tt rot-fit-method = potential}, the angle of the rotation
1476 group is determined as the angle for which the rotation potential energy is minimal.
1477 Therefore, the used rotation potential is additionally evaluated for a set of angles
1478 around the current reference angle. In this case, the {\tt rotangles.log} output file
1479 contains the values of the rotation potential at the chosen set of angles, while
1480 {\tt rotation.xvg} lists the angle with minimal potential energy.
1483 \subsubsection*{Torque}
1484 \label{torque}
1485 The torque $\ve{\tau}(t)$ exerted by the rotation potential is calculated for fixed
1486 axis rotation via
1487 \beq
1488 \ve{\tau}(t) = \sum_{i=1}^{N} \ve{r}_i(t) \times \ve{f}_{\!i}^\perp(t) ,
1489 \label{eqn:torque}
1490 \eeq
1491 where $\ve{r}_i(t)$ is the distance vector from the rotation axis to
1492 $\ve{x}_i(t)$ and $\ve{f}_{\!i}^\perp(t)$ is the force component
1493 perpendicular to $\ve{r}_i(t)$ and $\hat{\ve{v}}$. For flexible axis
1494 rotation, torques $\ve{\tau}_{\!n}$ are calculated for each slab using the
1495 local rotation axis of the slab and the Gaussian-weighted positions.
1498 \section{\normindex{Electric fields}}
1499 A pulsed and oscillating electric field can be applied according to:
1500 \begin{equation}
1501 E(t) = E_0 \exp\left[-\frac{(t-t_0)^2}{2\sigma^2}\right]\cos\left[\omega (t-t_0)\right]
1502 \label{eq_efield}
1503 \end{equation}
1504 where $E_0$ is the field strength, the angular frequency \mbox{$\omega = 2\pi c/\lambda$}, $t_0$ is
1505 the time at of the peak in the field strength and $\sigma$ is the with
1506 of the pulse. Special cases occur when $\sigma$ = 0 (non-pulsed field)
1507 and for $\omega$ is 0 (static field).
1509 This simulated \normindex{laser}-pulse was applied to
1510 simulations of melting ice~\cite{Caleman2008a}. A pulsed electric field may
1511 look ike Fig.~\ref{fig:field}. In the supporting
1512 information of that paper the impact of an applied electric field on a
1513 system under periodic boundary conditions is analyzed. It is described
1514 that the effective electric field under PBC is larger than the applied
1515 field, by a factor depending on the size of the box and the dielectric
1516 properties of molecules in the box. For a system with static dielectric
1517 properties this factor can be corrected for. But for a system where
1518 the dielectric varies over time, for example a membrane protein with
1519 a pore that opens and closes during the simulatippn, this way of applying
1520 an electric field is not useful. In such cases one can use the computational
1521 electrophysiology protocol described in the next section (\secref{compel}).
1522 \begin{figure}[ht]
1523 \centerline{\includegraphics[width=8cm]{plots/field}}
1524 \caption {A simulated laser pulse in GROMACS.}
1525 \label{fig:field}
1526 \end{figure}
1528 Electric fields are applied when the following options are specified
1529 in the {\tt grompp.mdp} file. You specify, in order, $E_0$, $\omega$,
1530 $t_0$ and $\sigma$:
1531 \begin{verbatim}
1532 electric-field-x = 0.04 0 0 0
1533 \end{verbatim}
1534 yields a static field with $E_0$ = 0.04 V/nm in the X-direction. In contrast,
1535 \begin{verbatim}
1536 electric-field-x = 2.0 150 5 0
1537 \end{verbatim}
1538 yields an oscillating electric field with $E_0$ = 2 V/nm, $\omega$ = 150/ps and
1539 $t_0$ = 5 ps. Finally
1540 \begin{verbatim}
1541 electric-field-x = 2.0 150 5 1
1542 \end{verbatim}
1543 yields an pulsed-oscillating electric field with $E_0$ = 2 V/nm, $\omega$ = 150/ps and
1544 $t_0$ = 5 ps and $\sigma$ = 1 ps. Read more in ref.~\cite{Caleman2008a}.
1545 Note that the input file format is changed from the undocumented older
1546 version. A figure like Fig.~\ref{fig:field} may be produced by passing
1547 the {\tt -field} option to {\tt gmx mdrun}.
1550 \section{\normindex{Computational Electrophysiology}}
1551 \label{sec:compel}
1553 The Computational Electrophysiology (CompEL) protocol \cite{Kutzner2011b} allows the simulation of
1554 ion flux through membrane channels, driven by transmembrane potentials or ion
1555 concentration gradients. Just as in real cells, CompEL establishes transmembrane
1556 potentials by sustaining a small imbalance of charges $\Delta q$ across the membrane,
1557 which gives rise to a potential difference $\Delta U$ according to the membrane capacitance:
1558 \beq
1559 \Delta U = \Delta q / C_{membrane}
1560 \eeq
1561 The transmembrane electric field and concentration gradients are controlled by
1562 {\tt .mdp} options, which allow the user to set reference counts for the ions on either side
1563 of the membrane. If a difference between the actual and the reference numbers persists
1564 over a certain time span, specified by the user, a number of ion/water pairs are
1565 exchanged between the compartments until the reference numbers are restored.
1566 Alongside the calculation of channel conductance and ion selectivity, CompEL simulations also
1567 enable determination of the channel reversal potential, an important
1568 characteristic obtained in electrophysiology experiments.
1570 In a CompEL setup, the simulation system is divided into two compartments {\bf A} and {\bf B}
1571 with independent ion concentrations. This is best achieved by using double bilayer systems with
1572 a copy (or copies) of the channel/pore of interest in each bilayer (\figref{compelsetup} A, B).
1573 If the channel axes point in the same direction, channel flux is observed
1574 simultaneously at positive and negative potentials in this way, which is for instance
1575 important for studying channel rectification.
1577 \begin{figure}
1578 \centerline{\includegraphics[width=13.5cm]{plots/compelsetup.pdf}}
1579 \caption{Typical double-membrane setup for CompEL simulations (A, B).
1580 Ion\,/\,water molecule exchanges will be performed as needed
1581 between the two light blue volumes around the dotted black lines (A).
1582 Plot (C) shows the potential difference $\Delta U$ resulting
1583 from the selected charge imbalance $\Delta q_{ref}$ between the compartments.}
1584 \label{fig:compelsetup}
1585 \end{figure}
1587 The potential difference $\Delta U$ across the membrane is easily calculated with the
1588 {\tt gmx potential} utility. By this, the potential drop along $z$ or the
1589 pore axis is exactly known in each time interval of the simulation (\figref{compelsetup} C).
1590 Type and number of ions $n_i$ of charge $q_i$, traversing the channel in the simulation,
1591 are written to the {\tt swapions.xvg} output file, from which the average channel
1592 conductance $G$ in each interval $\Delta t$ is determined by:
1593 \beq
1594 G = \frac{\sum_{i} n_{i}q_{i}}{\Delta t \, \Delta U} \, .
1595 \eeq
1596 The ion selectivity is calculated as the number flux ratio of different species.
1597 Best results are obtained by averaging these values over several overlapping time intervals.
1599 The calculation of reversal potentials is best achieved using a small set of simulations in which a given
1600 transmembrane concentration gradient is complemented with small ion imbalances of varying magnitude. For
1601 example, if one compartment contains 1\,M salt and the other 0.1\,M, and given charge neutrality otherwise,
1602 a set of simulations with $\Delta q = 0\,e$, $\Delta q = 2\,e$, $\Delta q = 4\,e$ could
1603 be used. Fitting a straight line through the current-voltage relationship of all obtained
1604 $I$-$U$ pairs near zero current will then yield $U_{rev}$.
1606 \subsection{Usage}
1607 The following {\tt .mdp} options control the CompEL protocol:
1608 {\small
1609 \begin{verbatim}
1610 swapcoords = Z ; Swap positions: no, X, Y, Z
1611 swap-frequency = 100 ; Swap attempt frequency
1612 \end{verbatim}}
1613 Choose {\tt Z} if your membrane is in the $xy$-plane (\figref{compelsetup}).
1614 Ions will be exchanged between compartments depending on their $z$-positions alone.
1615 {\tt swap-frequency} determines how often a swap attempt will be made.
1616 This step requires that the positions of the split groups, the ions, and possibly the solvent molecules are
1617 communicated between the parallel processes, so if chosen too small it can decrease the simulation
1618 performance. The {\tt Position swapping} entry in the cycle and time accounting
1619 table at the end of the {\tt md.log} file summarizes the amount of runtime spent
1620 in the swap module.
1621 {\small
1622 \begin{verbatim}
1623 split-group0 = channel0 ; Defines compartment boundary
1624 split-group1 = channel1 ; Defines other compartment boundary
1625 massw-split0 = no ; use mass-weighted center?
1626 massw-split1 = no
1627 \end{verbatim}}
1628 {\tt split-group0} and {\tt split-group1} are two index groups that define the boundaries
1629 between the two compartments, which are usually the centers of the channels.
1630 If {\tt massw-split0} or {\tt massw-split1} are set to {\tt yes}, the center of mass
1631 of each index group is used as boundary, here in $z$-direction. Otherwise, the
1632 geometrical centers will be used ($\times$ in \figref{compelsetup} A). If, such as here, a membrane
1633 channel is selected as split group, the center of the channel will define the dividing
1634 plane between the compartments (dashed horizontal lines). All index groups
1635 must be defined in the index file.
1637 If, to restore the requested ion counts, an ion from one compartment has to be exchanged
1638 with a water molecule from the other compartment, then those molecules are swapped
1639 which have the largest distance to the compartment-defining boundaries
1640 (dashed horizontal lines). Depending on the ion concentration,
1641 this effectively results in exchanges of molecules between the light blue volumes.
1642 If a channel is very asymmetric in $z$-direction and would extend into one of the
1643 swap volumes, one can offset the swap exchange plane with the {\tt bulk-offset}
1644 parameter. A value of 0.0 means no offset $b$, values $-1.0 < b < 0$ move the
1645 swap exchange plane closer to the lower, values $0 < b < 1.0$ closer to the upper
1646 membrane. \figref{compelsetup} A (left) depicts that for the {\bf A} compartment.
1648 {\small
1649 \begin{verbatim}
1650 solvent-group = SOL ; Group containing the solvent molecules
1651 iontypes = 3 ; Number of different ion types to control
1652 iontype0-name = NA ; Group name of the ion type
1653 iontype0-in-A = 51 ; Reference count of ions of type 0 in A
1654 iontype0-in-B = 35 ; Reference count of ions of type 0 in B
1655 iontype1-name = K
1656 iontype1-in-A = 10
1657 iontype1-in-B = 38
1658 iontype2-name = CL
1659 iontype2-in-A = -1
1660 iontype2-in-B = -1
1661 \end{verbatim}}
1662 The group name of solvent molecules acting as exchange partners for the ions
1663 has to be set with {\tt solvent-group}. The number of different ionic species under
1664 control of the CompEL protocol is given by the {\tt iontypes} parameter,
1665 while {\tt iontype0-name} gives the name of the index group containing the
1666 atoms of this ionic species. The reference number of ions of this type
1667 can be set with the {\tt iontype0-in-A} and {\tt iontype0-in-B} options
1668 for compartments {\bf A} and {\bf B}, respectively. Obviously,
1669 the sum of {\tt iontype0-in-A} and {\tt iontype0-in-B} needs to equal the number
1670 of ions in the group defined by {\tt iontype0-name}.
1671 A reference number of {\tt -1} means: use the number of ions as found at the beginning
1672 of the simulation as the reference value.
1674 {\small
1675 \begin{verbatim}
1676 coupl-steps = 10 ; Average over these many swap steps
1677 threshold = 1 ; Do not swap if < threshold
1678 \end{verbatim}}
1679 If {\tt coupl-steps} is set to 1, then the momentary ion distribution determines
1680 whether ions are exchanged. {\tt coupl-steps} \textgreater\ 1 will use the time-average
1681 of ion distributions over the selected number of attempt steps instead. This can be useful, for example,
1682 when ions diffuse near compartment boundaries, which would lead to numerous unproductive
1683 ion exchanges. A {\tt threshold} of 1 means that a swap is performed if the average ion
1684 count in a compartment differs by at least 1 from the requested values. Higher thresholds
1685 will lead to toleration of larger differences. Ions are exchanged until the requested
1686 number $\pm$ the threshold is reached.
1688 {\small
1689 \begin{verbatim}
1690 cyl0-r = 5.0 ; Split cylinder 0 radius (nm)
1691 cyl0-up = 0.75 ; Split cylinder 0 upper extension (nm)
1692 cyl0-down = 0.75 ; Split cylinder 0 lower extension (nm)
1693 cyl1-r = 5.0 ; same for other channel
1694 cyl1-up = 0.75
1695 cyl1-down = 0.75
1696 \end{verbatim}}
1697 The cylinder options are used to define virtual geometric cylinders around the
1698 channel's pore to track how many ions of which type have passed each channel.
1699 Ions will be counted as having traveled through a channel
1700 according to the definition of the channel's cylinder radius, upper and lower extension,
1701 relative to the location of the respective split group. This will not affect the actual
1702 flux or exchange, but will provide you with the ion permeation numbers across
1703 each of the channels. Note that an ion can only be counted as passing through a particular
1704 channel if it is detected \emph{within} the defined split cylinder in a swap step.
1705 If {\tt swap-frequency} is chosen too high, a particular ion may be detected in compartment {\bf A}
1706 in one swap step, and in compartment {\bf B} in the following swap step, so it will be unclear
1707 through which of the channels it has passed.
1709 A double-layered system for CompEL simulations can be easily prepared by
1710 duplicating an existing membrane/channel MD system in the direction of the membrane
1711 normal (typically $z$) with {\tt gmx editconf -translate 0 0 <l_z>}, where {\tt l_z}
1712 is the box length in that direction. If you have already defined index groups for
1713 the channel for the single-layered system, {\tt gmx make_ndx -n index.ndx -twin} will
1714 provide you with the groups for the double-layered system.
1716 To suppress large fluctuations of the membranes along the swap direction,
1717 it may be useful to apply a harmonic potential (acting only in the swap dimension)
1718 between each of the two channel and/or bilayer centers using umbrella pulling
1719 (see section~\ref{sec:pull}).
1721 \subsection*{Multimeric channels}
1722 If a split group consists of more than one molecule, the correct PBC image of all molecules
1723 with respect to each other has to be chosen such that the channel center can be correctly
1724 determined. \gromacs\ assumes that the starting structure in the {\tt .tpr}
1725 file has the correct PBC representation. Set the following environment variable
1726 to check whether that is the case:
1727 \begin{itemize}
1728 \item {\tt GMX_COMPELDUMP}: output the starting structure after it has been made whole to
1729 {\tt .pdb} file.
1730 \end{itemize}
1733 \section{Calculating a PMF using the free-energy code}
1734 \label{sec:fepmf}
1735 \index{potentials of mean force}
1736 \index{free energy calculations}
1737 The free-energy coupling-parameter approach (see~\secref{fecalc})
1738 provides several ways to calculate potentials of mean force.
1739 A potential of mean force between two atoms can be calculated
1740 by connecting them with a harmonic potential or a constraint.
1741 For this purpose there are special potentials that avoid the generation of
1742 extra exclusions, see~\secref{excl}.
1743 When the position of the minimum or the constraint length is 1 nm more
1744 in state B than in state A, the restraint or constraint force is given
1745 by $\partial H/\partial \lambda$.
1746 The distance between the atoms can be changed as a function of $\lambda$
1747 and time by setting {\tt delta-lambda} in the {\tt .mdp} file.
1748 The results should be identical (although not numerically
1749 due to the different implementations) to the results of the pull code
1750 with umbrella sampling and constraint pulling.
1751 Unlike the pull code, the free energy code can also handle atoms that
1752 are connected by constraints.
1754 Potentials of mean force can also be calculated using position restraints.
1755 With position restraints, atoms can be linked to a position in space
1756 with a harmonic potential (see \ssecref{positionrestraint}).
1757 These positions can be made a function of the coupling parameter $\lambda$.
1758 The positions for the A and the B states are supplied to {\tt grompp} with
1759 the {\tt -r} and {\tt -rb} options, respectively.
1760 One could use this approach to do \normindex{targeted MD};
1761 note that we do not encourage the use of targeted MD for proteins.
1762 A protein can be forced from one conformation to another by using
1763 these conformations as position restraint coordinates for state A and B.
1764 One can then slowly change $\lambda$ from 0 to 1.
1765 The main drawback of this approach is that the conformational freedom
1766 of the protein is severely limited by the position restraints,
1767 independent of the change from state A to B.
1768 Also, the protein is forced from state A to B in an almost straight line,
1769 whereas the real pathway might be very different.
1770 An example of a more fruitful application is a solid system or a liquid
1771 confined between walls where one wants to measure the force required
1772 to change the separation between the boundaries or walls.
1773 Because the boundaries (or walls) already need to be fixed,
1774 the position restraints do not limit the system in its sampling.
1776 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1779 \newcommand{\amine}{\sf -NH$_2$}
1780 \newcommand{\amines}{\sf -NH-}
1781 \newcommand{\aminep}{\sf -NH$_3^+$}
1782 \section{Removing fastest \swapindex{degrees of}{freedom}}
1783 \label{sec:rmfast}
1784 The maximum time step in MD simulations is limited by the smallest
1785 oscillation period that can be found in the simulated
1786 system. Bond-stretching vibrations are in their quantum-mechanical
1787 ground state and are therefore better represented by a constraint
1788 instead of a harmonic potential.
1790 For the remaining degrees of freedom, the shortest oscillation period
1791 (as measured from a simulation) is 13~fs for bond-angle vibrations
1792 involving hydrogen atoms. Taking as a guideline that with a Verlet
1793 (leap-frog) integration scheme a minimum of 5 numerical integration
1794 steps should be performed per period of a harmonic oscillation in
1795 order to integrate it with reasonable accuracy, the maximum time step
1796 will be about 3~fs. Disregarding these very fast oscillations of
1797 period 13~fs, the next shortest periods are around 20~fs, which will
1798 allow a maximum time step of about 4~fs.
1800 Removing the bond-angle degrees of freedom from hydrogen atoms can
1801 best be done by defining them as \normindex{virtual interaction sites}
1802 instead of normal atoms. Whereas a normal atom is connected to the molecule
1803 with bonds, angles and dihedrals, a virtual site's position is calculated
1804 from the position of three nearby heavy atoms in a predefined manner
1805 (see also \secref{virtual_sites}). For the hydrogens in water and in
1806 hydroxyl, sulfhydryl, or amine groups, no degrees of freedom can be
1807 removed, because rotational freedom should be preserved. The only
1808 other option available to slow down these motions is to increase the
1809 mass of the hydrogen atoms at the expense of the mass of the connected
1810 heavy atom. This will increase the moment of inertia of the water
1811 molecules and the hydroxyl, sulfhydryl, or amine groups, without
1812 affecting the equilibrium properties of the system and without
1813 affecting the dynamical properties too much. These constructions will
1814 shortly be described in \secref{vsitehydro} and have previously
1815 been described in full detail~\cite{feenstra99}.
1817 Using both virtual sites and \swapindex{modified}{mass}es, the next
1818 bottleneck is likely to be formed by the improper dihedrals (which are
1819 used to preserve planarity or chirality of molecular groups) and the
1820 peptide dihedrals. The peptide dihedral cannot be changed without
1821 affecting the physical behavior of the protein. The improper dihedrals
1822 that preserve planarity mostly deal with aromatic residues. Bonds,
1823 angles, and dihedrals in these residues can also be replaced with
1824 somewhat elaborate virtual site constructions.
1826 All modifications described in this section can be performed using the
1827 {\gromacs} topology building tool {\tt \normindex{pdb2gmx}}. Separate
1828 options exist to increase hydrogen masses, virtualize all hydrogen atoms,
1829 or also virtualize all aromatic residues. {\bf Note} that when all hydrogen
1830 atoms are virtualized, those inside the aromatic residues will be
1831 virtualized as well, {\ie} hydrogens in the aromatic residues are treated
1832 differently depending on the treatment of the aromatic residues.
1834 Parameters for the virtual site constructions for the hydrogen atoms are
1835 inferred from the force-field parameters ({\em vis}. bond lengths and
1836 angles) directly by {\tt \normindex{grompp}} while processing the
1837 topology file. The constructions for the aromatic residues are based
1838 on the bond lengths and angles for the geometry as described in the
1839 force fields, but these parameters are hard-coded into {\tt
1840 \normindex{pdb2gmx}} due to the complex nature of the construction
1841 needed for a whole aromatic group.
1843 \subsection{Hydrogen bond-angle vibrations}
1844 \label{sec:vsitehydro}
1845 \subsubsection{Construction of virtual sites} %%%%%%%%%%%%%%%%%%%%%%%%%
1846 \begin{figure}
1847 \centerline{\includegraphics[width=11cm]{plots/dumtypes}}
1848 \caption[Virtual site constructions for hydrogen atoms.]{The different
1849 types of virtual site constructions used for hydrogen atoms. The atoms
1850 used in the construction of the virtual site(s) are depicted as black
1851 circles, virtual sites as gray ones. Hydrogens are smaller than heavy
1852 atoms. {\sf A}: fixed bond angle, note that here the hydrogen is not a
1853 virtual site; {\sf B}: in the plane of three atoms, with fixed distance;
1854 {\sf C}: in the plane of three atoms, with fixed angle and distance;
1855 {\sf D}: construction for amine groups ({\amine} or {\aminep}), see
1856 text for details.}
1857 \label{fig:vsitehydro}
1858 \end{figure}
1860 The goal of defining hydrogen atoms as virtual sites is to remove all
1861 high-frequency degrees of freedom from them. In some cases, not all
1862 degrees of freedom of a hydrogen atom should be removed, {\eg} in the
1863 case of hydroxyl or amine groups the rotational freedom of the
1864 hydrogen atom(s) should be preserved. Care should be taken that no
1865 unwanted correlations are introduced by the construction of virtual
1866 sites, {\eg} bond-angle vibration between the constructing atoms could
1867 translate into hydrogen bond-length vibration. Additionally, since
1868 virtual sites are by definition massless, in order to preserve total
1869 system mass, the mass of each hydrogen atom that is treated as virtual
1870 site should be added to the bonded heavy atom.
1872 Taking into account these considerations, the hydrogen atoms in a
1873 protein naturally fall into several categories, each requiring a
1874 different approach (see also \figref{vsitehydro}).
1876 \begin{itemize}
1878 \item{\em hydroxyl ({\sf -OH}) or sulfhydryl ({\sf -SH})
1879 hydrogen:\/} The only internal degree of freedom in a hydroxyl group
1880 that can be constrained is the bending of the {\sf C-O-H} angle. This
1881 angle is fixed by defining an additional bond of appropriate length,
1882 see \figref{vsitehydro}A. Doing so removes the high-frequency angle bending,
1883 but leaves the dihedral rotational freedom. The same goes for a
1884 sulfhydryl group. {\bf Note} that in these cases the hydrogen is not treated
1885 as a virtual site.
1887 \item{\em single amine or amide ({\amines}) and aromatic hydrogens
1888 ({\sf -CH-}):\/} The position of these hydrogens cannot be constructed
1889 from a linear combination of bond vectors, because of the flexibility
1890 of the angle between the heavy atoms. Instead, the hydrogen atom is
1891 positioned at a fixed distance from the bonded heavy atom on a line
1892 going through the bonded heavy atom and a point on the line through
1893 both second bonded atoms, see \figref{vsitehydro}B.
1895 \item{\em planar amine ({\amine}) hydrogens:\/} The method used for
1896 the single amide hydrogen is not well suited for planar amine groups,
1897 because no suitable two heavy atoms can be found to define the
1898 direction of the hydrogen atoms. Instead, the hydrogen is constructed
1899 at a fixed distance from the nitrogen atom, with a fixed angle to the
1900 carbon atom, in the plane defined by one of the other heavy atoms, see
1901 \figref{vsitehydro}C.
1903 \item{\em amine group (umbrella {\amine} or {\aminep}) hydrogens:\/}
1904 Amine hydrogens with rotational freedom cannot be constructed as virtual
1905 sites from the heavy atoms they are connected to, since this would
1906 result in loss of the rotational freedom of the amine group. To
1907 preserve the rotational freedom while removing the hydrogen bond-angle
1908 degrees of freedom, two ``dummy masses'' are constructed with the same
1909 total mass, moment of inertia (for rotation around the {\sf C-N} bond)
1910 and center of mass as the amine group. These dummy masses have no
1911 interaction with any other atom, except for the fact that they are
1912 connected to the carbon and to each other, resulting in a rigid
1913 triangle. From these three particles, the positions of the nitrogen and
1914 hydrogen atoms are constructed as linear combinations of the two
1915 carbon-mass vectors and their outer product, resulting in an amine
1916 group with rotational freedom intact, but without other internal
1917 degrees of freedom. See \figref{vsitehydro}D.
1919 \end{itemize}
1921 \begin{figure}
1922 \centerline{\includegraphics[width=15cm]{plots/dumaro}}
1923 \caption[Virtual site constructions for aromatic residues.]{The
1924 different types of virtual site constructions used for aromatic
1925 residues. The atoms used in the construction of the virtual site(s) are
1926 depicted as black circles, virtual sites as gray ones. Hydrogens are
1927 smaller than heavy atoms. {\sf A}: phenylalanine; {\sf B}: tyrosine
1928 (note that the hydroxyl hydrogen is {\em not} a virtual site); {\sf C}:
1929 tryptophan; {\sf D}: histidine.}
1930 \label{fig:vistearo}
1931 \end{figure}
1933 \subsection{Out-of-plane vibrations in aromatic groups}
1934 \label{sec:vsitearo}
1935 The planar arrangements in the side chains of the aromatic residues
1936 lends itself perfectly to a virtual-site construction, giving a
1937 perfectly planar group without the inherently unstable constraints
1938 that are necessary to keep normal atoms in a plane. The basic approach
1939 is to define three atoms or dummy masses with constraints between them
1940 to fix the geometry and create the rest of the atoms as simple virtual
1941 sites type (see \secref{virtual_sites}) from these three. Each of
1942 the aromatic residues require a different approach:
1944 \begin{itemize}
1946 \item{\em Phenylalanine:\/} {\sf C}$_\gamma$, {\sf C}$_{{\epsilon}1}$,
1947 and {\sf C}$_{{\epsilon}2}$ are kept as normal atoms, but with each a
1948 mass of one third the total mass of the phenyl group. See
1949 \figref{vsitehydro}A.
1951 \item{\em Tyrosine:\/} The ring is treated identically to the
1952 phenylalanine ring. Additionally, constraints are defined between {\sf
1953 C}$_{{\epsilon}1}$, {\sf C}$_{{\epsilon}2}$, and {\sf O}$_{\eta}$.
1954 The original improper dihedral angles will keep both triangles (one
1955 for the ring and one with {\sf O}$_{\eta}$) in a plane, but due to the
1956 larger moments of inertia this construction will be much more
1957 stable. The bond-angle in the hydroxyl group will be constrained by a
1958 constraint between {\sf C}$_\gamma$ and {\sf H}$_{\eta}$. {\bf Note} that
1959 the hydrogen is not treated as a virtual site. See
1960 \figref{vsitehydro}B.
1962 \item{\em Tryptophan:\/} {\sf C}$_\beta$ is kept as a normal atom
1963 and two dummy masses are created at the center of mass of each of the
1964 rings, each with a mass equal to the total mass of the respective ring
1965 ({\sf C}$_{{\delta}2}$ and {\sf C}$_{{\epsilon}2}$ are each
1966 counted half for each ring). This keeps the overall center of mass and
1967 the moment of inertia almost (but not quite) equal to what it was. See
1968 \figref{vsitehydro}C.
1970 \item{\em Histidine:\/} {\sf C}$_\gamma$, {\sf C}$_{{\epsilon}1}$
1971 and {\sf N}$_{{\epsilon}2}$ are kept as normal atoms, but with masses
1972 redistributed such that the center of mass of the ring is
1973 preserved. See \figref{vsitehydro}D.
1975 \end{itemize}
1977 \section{Viscosity calculation\index{viscosity}}
1979 The shear viscosity is a property of liquids that can be determined easily
1980 by experiment. It is useful for parameterizing a force field
1981 because it is a kinetic property, while most other properties
1982 which are used for parameterization are thermodynamic.
1983 The viscosity is also an important property, since it influences
1984 the rates of conformational changes of molecules solvated in the liquid.
1986 The viscosity can be calculated from an equilibrium simulation using
1987 an Einstein relation:
1988 \beq
1989 \eta = \frac{1}{2}\frac{V}{k_B T} \lim_{t \rightarrow \infty}
1990 \frac{\mbox{d}}{\mbox{d} t} \left\langle
1991 \left( \int_{t_0}^{{t_0}+t} P_{xz}(t') \mbox{d} t' \right)^2
1992 \right\rangle_{t_0}
1993 \eeq
1994 This can be done with {\tt gmx energy}.
1995 This method converges very slowly~\cite{Hess2002a}, and as such
1996 a nanosecond simulation might not
1997 be long enough for an accurate determination of the viscosity.
1998 The result is very dependent on the treatment of the electrostatics.
1999 Using a (short) cut-off results in large noise on the off-diagonal
2000 pressure elements, which can increase the calculated viscosity by an order
2001 of magnitude.
2003 {\gromacs} also has a non-equilibrium method for determining
2004 the viscosity~\cite{Hess2002a}.
2005 This makes use of the fact that energy, which is fed into system by
2006 external forces, is dissipated through viscous friction. The generated heat
2007 is removed by coupling to a heat bath. For a Newtonian liquid adding a
2008 small force will result in a velocity gradient according to the following
2009 equation:
2010 \beq
2011 a_x(z) + \frac{\eta}{\rho} \frac{\partial^2 v_x(z)}{\partial z^2} = 0
2012 \eeq
2013 Here we have applied an acceleration $a_x(z)$ in the $x$-direction, which
2014 is a function of the $z$-coordinate.
2015 In {\gromacs} the acceleration profile is:
2016 \beq
2017 a_x(z) = A \cos\left(\frac{2\pi z}{l_z}\right)
2018 \eeq
2019 where $l_z$ is the height of the box. The generated velocity profile is:
2020 \beq
2021 v_x(z) = V \cos\left(\frac{2\pi z}{l_z}\right)
2022 \eeq
2023 \beq
2024 V = A \frac{\rho}{\eta}\left(\frac{l_z}{2\pi}\right)^2
2025 \eeq
2026 The viscosity can be calculated from $A$ and $V$:
2027 \beq
2028 \label{visc}
2029 \eta = \frac{A}{V}\rho \left(\frac{l_z}{2\pi}\right)^2
2030 \eeq
2032 In the simulation $V$ is defined as:
2033 \beq
2034 V = \frac{\displaystyle \sum_{i=1}^N m_i v_{i,x} 2 \cos\left(\frac{2\pi z}{l_z}\right)}
2035 {\displaystyle \sum_{i=1}^N m_i}
2036 \eeq
2037 The generated velocity profile is not coupled to the heat bath. Moreover,
2038 the velocity profile is excluded from the kinetic energy.
2039 One would like $V$ to be as large as possible to get good statistics.
2040 However, the shear rate should not be so high that the system gets too far
2041 from equilibrium. The maximum shear rate occurs where the cosine is zero,
2042 the rate being:
2043 \beq
2044 \mbox{sh}_{\max} = \max_z \left| \frac{\partial v_x(z)}{\partial z} \right|
2045 = A \frac{\rho}{\eta} \frac{l_z}{2\pi}
2046 \eeq
2047 For a simulation with: $\eta=10^{-3}$ [kg\,m$^{-1}$\,s$^{-1}$],
2048 $\rho=10^3$\,[kg\,m$^{-3}$] and $l_z=2\pi$\,[nm],
2049 $\mbox{sh}_{\max}=1$\,[ps\,nm$^{-1}$] $A$.
2050 This shear rate should be smaller than one over the longest
2051 correlation time in the system. For most liquids, this will be the rotation
2052 correlation time, which is around 10 ps. In this case, $A$ should
2053 be smaller than 0.1\,[nm\,ps$^{-2}$].
2054 When the shear rate is too high, the observed viscosity will be too low.
2055 Because $V$ is proportional to the square of the box height,
2056 the optimal box is elongated in the $z$-direction.
2057 In general, a simulation length of 100 ps is enough to obtain an
2058 accurate value for the viscosity.
2060 The heat generated by the viscous friction is removed by coupling to a heat
2061 bath. Because this coupling is not instantaneous the real temperature of the
2062 liquid will be slightly lower than the observed temperature.
2063 Berendsen derived this temperature shift~\cite{Berendsen91}, which can
2064 be written in terms of the shear rate as:
2065 \beq
2066 T_s = \frac{\eta\,\tau}{2 \rho\,C_v} \mbox{sh}_{\max}^2
2067 \eeq
2068 where $\tau$ is the coupling time for the Berendsen thermostat and
2069 $C_v$ is the heat capacity. Using the values of the example above,
2070 $\tau=10^{-13}$ [s] and $C_v=2 \cdot 10^3$\,[J kg$^{-1}$\,K$^{-1}$], we
2071 get: $T_s=25$\,[K\,ps$^{-2}$]\,sh$_{\max}^2$. When we want the shear
2072 rate to be smaller than $1/10$\,[ps$^{-1}$], $T_s$ is smaller than
2073 0.25\,[K], which is negligible.
2075 {\bf Note} that the system has to build up the velocity profile when starting
2076 from an equilibrium state. This build-up time is of the order of the
2077 correlation time of the liquid.
2079 Two quantities are written to the energy file, along with their averages
2080 and fluctuations: $V$ and $1/\eta$, as obtained from (\ref{visc}).
2082 \section{Tabulated interaction functions\index{tabulated interaction functions}}
2083 \subsection{Cubic splines for potentials}
2084 \label{subsec:cubicspline}
2085 In some of the inner loops of {\gromacs}, look-up tables are used
2086 for computation of potential and forces.
2087 The tables are interpolated using a cubic
2088 spline algorithm.
2089 There are separate tables for electrostatic, dispersion, and repulsion
2090 interactions,
2091 but for the sake of caching performance these have been combined
2092 into a single array.
2093 The cubic spline interpolation for $x_i \leq x < x_{i+1}$ looks like this:
2094 \beq
2095 V_s(x) = A_0 + A_1 \,\epsilon + A_2 \,\epsilon^2 + A_3 \,\epsilon^3
2096 \label{eqn:spline}
2097 \eeq
2098 where the table spacing $h$ and fraction $\epsilon$ are given by:
2099 \bea
2100 h &=& x_{i+1} - x_i \\
2101 \epsilon&=& (x - x_i)/h
2102 \eea
2103 so that $0 \le \epsilon < 1$.
2104 From this, we can calculate the derivative in order to determine the forces:
2105 \beq
2106 -V_s'(x) ~=~
2107 -\frac{{\rm d}V_s(x)}{{\rm d}\epsilon}\frac{{\rm d}\epsilon}{{\rm d}x} ~=~
2108 -(A_1 + 2 A_2 \,\epsilon + 3 A_3 \,\epsilon^2)/h
2109 \eeq
2110 The four coefficients are determined from the four conditions
2111 that $V_s$ and $-V_s'$ at both ends of each interval should match
2112 the exact potential $V$ and force $-V'$.
2113 This results in the following errors for each interval:
2114 \bea
2115 |V_s - V |_{max} &=& V'''' \frac{h^4}{384} + O(h^5) \\
2116 |V_s' - V' |_{max} &=& V'''' \frac{h^3}{72\sqrt{3}} + O(h^4) \\
2117 |V_s''- V''|_{max} &=& V'''' \frac{h^2}{12} + O(h^3)
2118 \eea
2119 V and V' are continuous, while V'' is the first discontinuous
2120 derivative.
2121 The number of points per nanometer is 500 and 2000
2122 for mixed- and double-precision versions of {\gromacs}, respectively.
2123 This means that the errors in the potential and force will usually
2124 be smaller than the mixed precision accuracy.
2126 {\gromacs} stores $A_0$, $A_1$, $A_2$ and $A_3$.
2127 The force routines get a table with these four parameters and
2128 a scaling factor $s$ that is equal to the number of points per nm.
2129 ({\bf Note} that $h$ is $s^{-1}$).
2130 The algorithm goes a little something like this:
2131 \begin{enumerate}
2132 \item Calculate distance vector (\ve{r}$_{ij}$) and distance r$_{ij}$
2133 \item Multiply r$_{ij}$ by $s$ and truncate to an integer value $n_0$
2134 to get a table index
2135 \item Calculate fractional component ($\epsilon$ = $s$r$_{ij} - n_0$)
2136 and $\epsilon^2$
2137 \item Do the interpolation to calculate the potential $V$ and the scalar force $f$
2138 \item Calculate the vector force \ve{F} by multiplying $f$ with \ve{r}$_{ij}$
2139 \end{enumerate}
2141 {\bf Note} that table look-up is significantly {\em
2142 slower} than computation of the most simple Lennard-Jones and Coulomb
2143 interaction. However, it is much faster than the shifted Coulomb
2144 function used in conjunction with the PPPM method. Finally, it is much
2145 easier to modify a table for the potential (and get a graphical
2146 representation of it) than to modify the inner loops of the MD
2147 program.
2149 \subsection{User-specified potential functions}
2150 \label{subsec:userpot}
2151 You can also use your own potential functions\index{potential function} without
2152 editing the {\gromacs} code. The potential function should be according to the
2153 following equation
2154 \beq
2155 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})
2156 \eeq
2157 where $f$, $g$, and $h$ are user defined functions. {\bf Note} that if $g(r)$ represents a
2158 normal dispersion interaction, $g(r)$ should be $<$ 0. C$_6$, C$_{12}$
2159 and the charges are read from the topology. Also note that combination
2160 rules are only supported for Lennard-Jones and Buckingham, and that
2161 your tables should match the parameters in the binary topology.
2163 When you add the following lines in your {\tt .mdp} file:
2165 {\small
2166 \begin{verbatim}
2167 rlist = 1.0
2168 coulombtype = User
2169 rcoulomb = 1.0
2170 vdwtype = User
2171 rvdw = 1.0
2172 \end{verbatim}}
2174 {\tt mdrun} will read a single non-bonded table file,
2175 or multiple when {\tt energygrp-table} is set (see below).
2176 The name of the file(s) can be set with the {\tt mdrun} option {\tt -table}.
2177 The table file should contain seven columns of table look-up data in the
2178 order: $x$, $f(x)$, $-f'(x)$, $g(x)$, $-g'(x)$, $h(x)$, $-h'(x)$.
2179 The $x$ should run from 0 to $r_c+1$ (the value of {\tt table_extension} can be
2180 changed in the {\tt .mdp} file).
2181 You can choose the spacing you like; for the standard tables {\gromacs}
2182 uses a spacing of 0.002 and 0.0005 nm when you run in mixed
2183 and double precision, respectively. In this
2184 context, $r_c$ denotes the maximum of the two cut-offs {\tt rvdw} and
2185 {\tt rcoulomb} (see above). These variables need not be the same (and
2186 need not be 1.0 either). Some functions used for potentials contain a
2187 singularity at $x = 0$, but since atoms are normally not closer to each
2188 other than 0.1 nm, the function value at $x = 0$ is not important.
2189 Finally, it is also
2190 possible to combine a standard Coulomb with a modified LJ potential
2191 (or vice versa). One then specifies {\eg} {\tt coulombtype = Cut-off} or
2192 {\tt coulombtype = PME}, combined with {\tt vdwtype = User}. The table file must
2193 always contain the 7 columns however, and meaningful data (i.e. not
2194 zeroes) must be entered in all columns. A number of pre-built table
2195 files can be found in the {\tt GMXLIB} directory for 6-8, 6-9, 6-10, 6-11, and 6-12
2196 Lennard-Jones potentials combined with a normal Coulomb.
2198 If you want to have different functional forms between different
2199 groups of atoms, this can be set through energy groups.
2200 Different tables can be used for non-bonded interactions between
2201 different energy groups pairs through the {\tt .mdp} option {\tt energygrp-table}
2202 (see details in the User Guide).
2203 Atoms that should interact with a different potential should
2204 be put into different energy groups.
2205 Between group pairs which are not listed in {\tt energygrp-table},
2206 the normal user tables will be used. This makes it easy to use
2207 a different functional form between a few types of atoms.
2209 \section{Mixed Quantum-Classical simulation techniques}
2211 In a molecular mechanics (MM) force field, the influence of electrons
2212 is expressed by empirical parameters that are assigned on the basis of
2213 experimental data, or on the basis of results from high-level quantum
2214 chemistry calculations. These are valid for the ground state of a
2215 given covalent structure, and the MM approximation is usually
2216 sufficiently accurate for ground-state processes in which the overall
2217 connectivity between the atoms in the system remains
2218 unchanged. However, for processes in which the connectivity does
2219 change, such as chemical reactions, or processes that involve multiple
2220 electronic states, such as photochemical conversions, electrons can no
2221 longer be ignored, and a quantum mechanical description is required
2222 for at least those parts of the system in which the reaction takes
2223 place.
2225 One approach to the simulation of chemical reactions in solution, or
2226 in enzymes, is to use a combination of quantum mechanics (QM) and
2227 molecular mechanics (MM). The reacting parts of the system are treated
2228 quantum mechanically, with the remainder being modeled using the
2229 force field. The current version of {\gromacs} provides interfaces to
2230 several popular Quantum Chemistry packages (MOPAC~\cite{mopac},
2231 GAMESS-UK~\cite{gamess-uk}, Gaussian~\cite{g03} and CPMD~\cite{Car85a}).
2233 {\gromacs} interactions between the two subsystems are
2234 either handled as described by Field {\em et al.}~\cite{Field90a} or
2235 within the ONIOM approach by Morokuma and coworkers~\cite{Maseras96a,
2236 Svensson96a}.
2238 \subsection{Overview}
2240 Two approaches for describing the interactions between the QM and MM
2241 subsystems are supported in this version:
2243 \begin{enumerate}
2244 \item{\textbf{Electronic Embedding}} The electrostatic interactions
2245 between the electrons of the QM region and the MM atoms and between
2246 the QM nuclei and the MM atoms are included in the Hamiltonian for
2247 the QM subsystem: \beq H^{QM/MM} =
2248 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}},
2249 \eeq where $n$ and $N$ are the number of electrons and nuclei in the
2250 QM region, respectively, and $M$ is the number of charged MM
2251 atoms. The first term on the right hand side is the original
2252 electronic Hamiltonian of an isolated QM system. The first of the
2253 double sums is the total electrostatic interaction between the QM
2254 electrons and the MM atoms. The total electrostatic interaction of the
2255 QM nuclei with the MM atoms is given by the second double sum. Bonded
2256 interactions between QM and MM atoms are described at the MM level by
2257 the appropriate force-field terms. Chemical bonds that connect the two
2258 subsystems are capped by a hydrogen atom to complete the valence of
2259 the QM region. The force on this atom, which is present in the QM
2260 region only, is distributed over the two atoms of the bond. The cap
2261 atom is usually referred to as a link atom.
2263 \item{\textbf{ONIOM}} In the ONIOM approach, the energy and gradients
2264 are first evaluated for the isolated QM subsystem at the desired level
2265 of {\it{ab initio}} theory. Subsequently, the energy and gradients of
2266 the total system, including the QM region, are computed using the
2267 molecular mechanics force field and added to the energy and gradients
2268 calculated for the isolated QM subsystem. Finally, in order to correct
2269 for counting the interactions inside the QM region twice, a molecular
2270 mechanics calculation is performed on the isolated QM subsystem and
2271 the energy and gradients are subtracted. This leads to the following
2272 expression for the total QM/MM energy (and gradients likewise): \beq
2273 E_{tot} = E_{I}^{QM}
2274 +E_{I+II}^{MM}-E_{I}^{MM}, \eeq where the
2275 subscripts I and II refer to the QM and MM subsystems,
2276 respectively. The superscripts indicate at what level of theory the
2277 energies are computed. The ONIOM scheme has the
2278 advantage that it is not restricted to a two-layer QM/MM description,
2279 but can easily handle more than two layers, with each layer described
2280 at a different level of theory.
2281 \end{enumerate}
2283 \subsection{Usage}
2285 To make use of the QM/MM functionality in {\gromacs}, one needs to:
2287 \begin{enumerate}
2288 \item introduce link atoms at the QM/MM boundary, if needed;
2289 \item specify which atoms are to be treated at a QM level;
2290 \item specify the QM level, basis set, type of QM/MM interface and so on.
2291 \end{enumerate}
2293 \subsubsection{Adding link atoms}
2295 At the bond that connects the QM and MM subsystems, a link atoms is
2296 introduced. In {\gromacs} the link atom has special atomtype, called
2297 LA. This atomtype is treated as a hydrogen atom in the QM calculation,
2298 and as a virtual site in the force-field calculation. The link atoms, if
2299 any, are part of the system, but have no interaction with any other
2300 atom, except that the QM force working on it is distributed over the
2301 two atoms of the bond. In the topology, the link atom (LA), therefore,
2302 is defined as a virtual site atom:
2304 {\small
2305 \begin{verbatim}
2306 [ virtual_sites2 ]
2307 LA QMatom MMatom 1 0.65
2308 \end{verbatim}}
2310 See~\secref{vsitetop} for more details on how virtual sites are
2311 treated. The link atom is replaced at every step of the simulation.
2313 In addition, the bond itself is replaced by a constraint:
2315 {\small
2316 \begin{verbatim}
2317 [ constraints ]
2318 QMatom MMatom 2 0.153
2319 \end{verbatim}}
2321 {\bf Note} that, because in our system the QM/MM bond is a carbon-carbon
2322 bond (0.153 nm), we use a constraint length of 0.153 nm, and dummy
2323 position of 0.65. The latter is the ratio between the ideal C-H
2324 bond length and the ideal C-C bond length. With this ratio, the link
2325 atom is always 0.1 nm away from the {\tt QMatom}, consistent with the
2326 carbon-hydrogen bond length. If the QM and MM subsystems are connected
2327 by a different kind of bond, a different constraint and a different
2328 dummy position, appropriate for that bond type, are required.
2330 \subsubsection{Specifying the QM atoms}
2332 Atoms that should be treated at a QM level of theory, including the
2333 link atoms, are added to the index file. In addition, the chemical
2334 bonds between the atoms in the QM region are to be defined as
2335 connect bonds (bond type 5) in the topology file:
2337 {\small
2338 \begin{verbatim}
2339 [ bonds ]
2340 QMatom1 QMatom2 5
2341 QMatom2 QMatom3 5
2342 \end{verbatim}}
2344 \subsubsection{Specifying the QM/MM simulation parameters}
2346 In the {\tt .mdp} file, the following parameters control a QM/MM simulation.
2348 \begin{description}
2350 \item[\tt QMMM = no]\mbox{}\\ If this is set to {\tt yes}, a QM/MM
2351 simulation is requested. Several groups of atoms can be described at
2352 different QM levels separately. These are specified in the QMMM-grps
2353 field separated by spaces. The level of {\it{ab initio}} theory at which the
2354 groups are described is specified by {\tt QMmethod} and {\tt QMbasis}
2355 Fields. Describing the groups at different levels of theory is only
2356 possible with the ONIOM QM/MM scheme, specified by {\tt QMMMscheme}.
2358 \item[\tt QMMM-grps =]\mbox{}\\groups to be described at the QM level
2360 \item[\tt QMMMscheme = normal]\mbox{}\\Options are {\tt normal} and
2361 {\tt ONIOM}. This selects the QM/MM interface. {\tt normal} implies
2362 that the QM subsystem is electronically embedded in the MM
2363 subsystem. There can only be one {\tt QMMM-grps} that is modeled at
2364 the {\tt QMmethod} and {\tt QMbasis} level of {\it{ ab initio}}
2365 theory. The rest of the system is described at the MM level. The QM
2366 and MM subsystems interact as follows: MM point charges are included
2367 in the QM one-electron Hamiltonian and all Lennard-Jones interactions
2368 are described at the MM level. If {\tt ONIOM} is selected, the
2369 interaction between the subsystem is described using the ONIOM method
2370 by Morokuma and co-workers. There can be more than one QMMM-grps each
2371 modeled at a different level of QM theory (QMmethod and QMbasis).
2373 \item[\tt QMmethod = ]\mbox{}\\Method used to compute the energy
2374 and gradients on the QM atoms. Available methods are AM1, PM3, RHF,
2375 UHF, DFT, B3LYP, MP2, CASSCF, MMVB and CPMD. For CASSCF, the number of
2376 electrons and orbitals included in the active space is specified by
2377 {\tt CASelectrons} and {\tt CASorbitals}. For CPMD, the plane-wave
2378 cut-off is specified by the {\tt planewavecutoff} keyword.
2380 \item[\tt QMbasis = ]\mbox{}\\Gaussian basis set used to expand the
2381 electronic wave-function. Only Gaussian basis sets are currently
2382 available, i.e. STO-3G, 3-21G, 3-21G*, 3-21+G*, 6-21G, 6-31G, 6-31G*,
2383 6-31+G*, and 6-311G. For CPMD, which uses plane wave expansion rather
2384 than atom-centered basis functions, the {\tt planewavecutoff} keyword
2385 controls the plane wave expansion.
2387 \item[\tt QMcharge = ]\mbox{}\\The total charge in {\it{e}} of the {\tt
2388 QMMM-grps}. In case there are more than one {\tt QMMM-grps}, the total
2389 charge of each ONIOM layer needs to be specified separately.
2391 \item[\tt QMmult = ]\mbox{}\\The multiplicity of the {\tt
2392 QMMM-grps}. In case there are more than one {\tt QMMM-grps}, the
2393 multiplicity of each ONIOM layer needs to be specified separately.
2395 \item[\tt CASorbitals = ]\mbox{}\\The number of orbitals to be
2396 included in the active space when doing a CASSCF computation.
2398 \item[\tt CASelectrons = ]\mbox{}\\The number of electrons to be
2399 included in the active space when doing a CASSCF computation.
2401 \item[\tt SH = no]\mbox{}\\If this is set to yes, a QM/MM MD
2402 simulation on the excited state-potential energy surface and enforce a
2403 diabatic hop to the ground-state when the system hits the conical
2404 intersection hyperline in the course the simulation. This option only
2405 works in combination with the CASSCF method.
2407 \end{description}
2409 \subsection{Output}
2411 The energies and gradients computed in the QM calculation are added to
2412 those computed by {\gromacs}. In the {\tt .edr} file there is a section
2413 for the total QM energy.
2415 \subsection{Future developments}
2417 Several features are currently under development to increase the
2418 accuracy of the QM/MM interface. One useful feature is the use of
2419 delocalized MM charges in the QM computations. The most important
2420 benefit of using such smeared-out charges is that the Coulombic
2421 potential has a finite value at interatomic distances. In the point
2422 charge representation, the partially-charged MM atoms close to the QM
2423 region tend to ``over-polarize'' the QM system, which leads to artifacts
2424 in the calculation.
2426 What is needed as well is a transition state optimizer.
2428 \section{Using VMD plug-ins for trajectory file I/O}
2429 \index{VMD plug-ins}\index{trajectory file}{\gromacs} tools are able
2430 to use the plug-ins found in an existing installation of
2431 \href{http://www.ks.uiuc.edu/Research/vmd}{VMD} in order to read and
2432 write trajectory files in formats that are not native to
2433 {\gromacs}. You will be able to supply an AMBER DCD-format trajectory
2434 filename directly to {\gromacs} tools, for example.
2436 This requires a VMD installation not older than version 1.8, that your
2437 system provides the dlopen function so that programs can determine at
2438 run time what plug-ins exist, and that you build shared libraries when
2439 building {\gromacs}. CMake will find the vmd executable in your path, and
2440 from it, or the environment variable {\tt VMDDIR} at configuration or
2441 run time, locate the plug-ins. Alternatively, the {\tt VMD_PLUGIN_PATH}
2442 can be used at run time to specify a path where these plug-ins can be
2443 found. Note that these plug-ins are in a binary format, and that format
2444 must match the architecture of the machine attempting to use them.
2447 \section{\normindex{Interactive Molecular Dynamics}}
2448 {\gromacs} supports the interactive molecular dynamics (IMD) protocol as implemented
2449 by \href{http://www.ks.uiuc.edu/Research/vmd}{VMD} to control a running simulation
2450 in NAMD. IMD allows to monitor a running {\gromacs} simulation from a VMD client.
2451 In addition, the user can interact with the simulation by pulling on atoms, residues
2452 or fragments with a mouse or a force-feedback device. Additional information about
2453 the {\gromacs} implementation and an exemplary {\gromacs} IMD system can be found
2454 \href{http://www.mpibpc.mpg.de/grubmueller/interactivemd}{on this homepage}.
2456 \subsection{Simulation input preparation}
2457 The {\gromacs} implementation allows transmission and interaction with a part of the
2458 running simulation only, e.g.\ in cases where no water molecules should be transmitted
2459 or pulled. The group is specified via the {\tt .mdp} option {\tt IMD-group}. When
2460 {\tt IMD-group} is empty, the IMD protocol is disabled and cannot be enabled via the
2461 switches in {\tt mdrun}. To interact with the entire system, {\tt IMD-group} can
2462 be set to {\tt System}. When using {\tt grompp}, a {\tt .gro} file
2463 to be used as VMD input is written out ({\tt -imd} switch of {\tt grompp}).
2465 \subsection{Starting the simulation}
2466 Communication between VMD and {\gromacs} is achieved via TCP sockets and thus enables
2467 controlling an {\tt mdrun} running locally or on a remote cluster. The port for the
2468 connection can be specified with the {\tt -imdport} switch of {\tt mdrun}, 8888 is
2469 the default. If a port number of 0 or smaller is provided, {\gromacs} automatically
2470 assigns a free port to use with IMD.
2472 Every $N$ steps, the {\tt mdrun} client receives the applied forces from VMD and sends the new
2473 positions to the client. VMD permits increasing or decreasing the communication frequency
2474 interactively.
2475 By default, the simulation starts and runs even if no IMD client is connected. This
2476 behavior is changed by the {\tt -imdwait} switch of {\tt mdrun}. After startup and
2477 whenever the client has disconnected, the integration stops until reconnection of
2478 the client.
2479 When the {\tt -imdterm} switch is used, the simulation can be terminated by pressing
2480 the stop button in VMD. This is disabled by default.
2481 Finally, to allow interacting with the simulation (i.e. pulling from VMD) the {\tt -imdpull}
2482 switch has to be used.
2483 Therefore, a simulation can only be monitored but not influenced from the VMD client
2484 when none of {\tt -imdwait}, {\tt -imdterm} or {\tt -imdpull} are set. However, since
2485 the IMD protocol requires no authentication, it is not advisable to run simulations on
2486 a host directly reachable from an insecure environment. Secure shell forwarding of TCP
2487 can be used to connect to running simulations not directly reachable from the interacting host.
2488 Note that the IMD command line switches of {\tt mdrun} are hidden by default and show
2489 up in the help text only with {\tt gmx mdrun -h -hidden}.
2491 \subsection{Connecting from VMD}
2492 In VMD, first the structure corresponding to the IMD group has to be loaded ({\it File
2493 $\rightarrow$ New Molecule}). Then the IMD connection window has to be used
2494 ({\it Extensions $\rightarrow$ Simulation $\rightarrow$ IMD Connect (NAMD)}). In the IMD
2495 connection window, hostname and port have to be specified and followed by pressing
2496 {\it Connect}. {\it Detach Sim} allows disconnecting without terminating the simulation, while
2497 {\it Stop Sim} ends the simulation on the next neighbor searching step (if allowed by
2498 {\tt -imdterm}).
2500 The timestep transfer rate allows adjusting the communication frequency between simulation
2501 and IMD client. Setting the keep rate loads every $N^\mathrm{th}$ frame into VMD instead
2502 of discarding them when a new one is received. The displayed energies are in SI units
2503 in contrast to energies displayed from NAMD simulations.
2505 \section{\normindex{Embedding proteins into the membranes}}
2506 \label{sec:membed}
2508 GROMACS is capable of inserting the protein into pre-equilibrated
2509 lipid bilayers with minimal perturbation of the lipids using the
2510 method, which was initially described as a ProtSqueeze
2511 technique,\cite{Yesylevskyy2007} and later implemented as g\_membed
2512 tool.\cite{Wolf2010} Currently the functionality of g\_membed is
2513 available in mdrun as described in the user guide.
2515 This method works by first artificially shrinking the protein in the
2516 $xy$-plane, then it removes lipids that overlap with that much smaller
2517 core. Then the protein atoms are gradually resized back to their
2518 initial configuration, using normal dynamics for the rest of the
2519 system, so the lipids adapt to the protein. Further lipids are removed
2520 as required.
2523 % LocalWords: PMF pmf kJ mol Jarzynski BT bilayer rup mdp AFM fepmf fecalc rb
2524 % LocalWords: posre grompp fs Verlet dihedrals hydrogens hydroxyl sulfhydryl
2525 % LocalWords: vsitehydro planarity chirality pdb gmx virtualize virtualized xz
2526 % LocalWords: vis massless tryptophan histidine phenyl parameterizing ij PPPM
2527 % LocalWords: parameterization Berendsen rlist coulombtype rcoulomb vdwtype LJ
2528 % LocalWords: rvdw energygrp mdrun pre GMXLIB MOPAC GAMESS CPMD ONIOM
2529 % LocalWords: Morokuma iJ AQ AJ initio atomtype QMatom MMatom QMMM grps et al
2530 % LocalWords: QMmethod QMbasis QMMMscheme RHF DFT LYP CASSCF MMVB CASelectrons
2531 % LocalWords: CASorbitals planewavecutoff STO QMcharge QMmult diabatic edr
2532 % LocalWords: hyperline delocalized Coulombic indices nm ccc th ps
2533 % LocalWords: GTX CPUs GHz md sd bd vv avek tcoupl andersen tc OPLSAA GROMOS
2534 % LocalWords: OBC obc CCMA tol pbc xyz barostat pcoupl acc gpu PLUGIN Cmake GX
2535 % LocalWords: MSVC gcc installpath cmake DGMX DCMAKE functionalities GPGPU GTS
2536 % LocalWords: OpenCL DeviceID gromacs gpus html GeForce Quadro FX Plex CX GF
2537 % LocalWords: VMD DCD GROningen MAchine BIOSON Groningen der Spoel Drunen Comp
2538 % LocalWords: Phys Comm moltype intramol vdw Waals fep multivector pf
2539 % LocalWords: pymbar dhdl xvg LINCS Entropic entropic solutes ref com iso pm
2540 % LocalWords: rm prefactors equipotential potiso potisopf potpm trr
2541 % LocalWords: potrm potrmpf midplanes midplane gaussians potflex vars massw av
2542 % LocalWords: shure observables rccccccc vec eps dist min eqn transl nstsout
2543 % LocalWords: nstrout rotangles rotslabs rottorque RMSD rmsdfit excl NH amine
2544 % LocalWords: positionrestraint es SH phenylalanine solvated sh nanometer QM
2545 % LocalWords: Lennard Buckingham UK Svensson ab vsitetop co UHF MP interatomic
2546 % LocalWords: cg grp coords SPC userpot
2547 % LocalWords: itp sitesn atomtypes ff csg ndx Tesla CHARMM AA gauss
2548 % LocalWords: CMAP nocmap fators Monte performant lib LD DIR llllcc
2549 % LocalWords: CMake homepage DEV overclocking GT dlopen vmd VMDDIR
2550 % LocalWords: versa PME atomperatom graining forcefields hy spc OPLS
2551 % LocalWords: topol multi