Fix -Wstrict-overflow in domdec.c
[gromacs.git] / manual / intro.tex
blobf1c46b4c22fca214634673819ea2c0e390a2bf05
1 % This file is part of the GROMACS molecular simulation package.
3 % Copyright (c) 2013, by the GROMACS development team, led by
4 % David van der Spoel, Berk Hess, Erik Lindahl, and including many
5 % others, as listed in the AUTHORS file in the top-level source
6 % directory and at http://www.gromacs.org.
8 % GROMACS is free software; you can redistribute it and/or
9 % modify it under the terms of the GNU Lesser General Public License
10 % as published by the Free Software Foundation; either version 2.1
11 % of the License, or (at your option) any later version.
13 % GROMACS is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 % Lesser General Public License for more details.
18 % You should have received a copy of the GNU Lesser General Public
19 % License along with GROMACS; if not, see
20 % http://www.gnu.org/licenses, or write to the Free Software Foundation,
21 % Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 % If you want to redistribute modifications to GROMACS, please
24 % consider that scientific software is very special. Version
25 % control is crucial - bugs must be traceable. We will be happy to
26 % consider code for inclusion in the official distribution, but
27 % derived work must not be called official GROMACS. Details are found
28 % in the README & COPYING files - if they are missing, get the
29 % official version at http://www.gromacs.org.
31 % To help us fund GROMACS development, we humbly ask that you cite
32 % the research papers on the package. Check out http://www.gromacs.org
34 \chapter{Introduction}
36 \section{Computational Chemistry and Molecular Modeling}
38 \label{sec:Compchem}
40 {\gromacs} is an engine to perform molecular dynamics simulations and
41 energy minimization. These are two of the many techniques that belong
42 to the realm of \swapindex{computational}{chemistry} and
43 \swapindex{molecular}{modeling}.
44 {\em Computational chemistry} is just a name to indicate the use of
45 computational techniques in chemistry, ranging from quantum mechanics
46 of molecules to dynamics of large complex molecular aggregates. {\em
47 Molecular modeling} indicates the general process of describing
48 complex chemical systems in terms of a realistic atomic model, with the
49 goal being to understand and predict macroscopic properties based on detailed
50 knowledge on an atomic scale. Often, molecular modeling is used to
51 design new materials, for which the accurate prediction of physical
52 properties of realistic systems is required.
54 Macroscopic physical properties can be distinguished by ($a$) {\em static
55 equilibrium properties}, such as the binding constant of an inhibitor to an
56 enzyme, the average potential energy of a system, or the radial distribution
57 function of a liquid, and ($b$) {\em
58 dynamic or non-equilibrium properties}, such as the viscosity of a
59 liquid, diffusion processes in membranes, the dynamics of phase
60 changes, reaction kinetics, or the dynamics of defects in crystals.
61 The choice of technique depends on the question asked and on the
62 feasibility of the method to yield reliable results at the present
63 state of the art. Ideally, the (relativistic) time-dependent
64 \swapindex{Schr{\"o}dinger}{equation}
65 describes the properties of molecular systems
66 with high accuracy, but anything more complex than the equilibrium
67 state of a few atoms cannot be handled at this {\em ab initio} level.
68 Thus, approximations are necessary; the higher the complexity of a
69 system and the longer the time span of the processes of interest is,
70 the more severe the required approximations are. At a certain point
71 (reached very much earlier than one would wish), the {\em ab initio}
72 approach must be augmented or replaced by {\em empirical}
73 parameterization of the model used. Where simulations based on physical
74 principles of atomic interactions still fail due to the complexity of the
75 system,
76 molecular modeling is based entirely on a similarity analysis of known
77 structural and chemical data. The \normindex{QSAR} methods (Quantitative
78 Structure-Activity Relations) and many homology-based protein structure
79 predictions belong to the latter category.
81 Macroscopic properties are always \swapindex{ensemble}{average}s over a
82 representative statistical ensemble (either equilibrium or
83 non-equilibrium) of molecular systems. For molecular modeling, this has
84 two important consequences:
85 \begin{itemize}
86 \item The knowledge of a single structure, even if it is the structure
87 of the global energy minimum, is not sufficient. It is necessary to
88 generate a representative ensemble at a given temperature, in order to
89 compute macroscopic properties. But this is not enough to compute
90 thermodynamic equilibrium properties that are based on free energies,
91 such as phase equilibria, binding constants, solubilities, relative
92 stability of molecular conformations, etc. The computation of free
93 energies and thermodynamic potentials requires special extensions of
94 molecular simulation techniques.
95 \item While molecular simulations, in principle, provide atomic details
96 of the structures and motions, such details are often not relevant for
97 the macroscopic properties of interest. This opens the way to simplify
98 the description of interactions and average over irrelevant details.
99 The science of \swapindex{statistical}{mechanics}
100 provides the theoretical framework
101 for such simplifications. There is a hierarchy of methods ranging from
102 considering groups of atoms as one unit, describing motion in a
103 reduced
104 number of collective coordinates, averaging over solvent molecules
105 with
106 potentials of mean force combined with
107 \swapindex{stochastic}{dynamics}~\cite{Gunsteren90}, to {\em
108 \swapindex{mesoscopic}{dynamics}}
109 describing densities rather than atoms and fluxes
110 as response to thermodynamic gradients rather than velocities or
111 accelerations as response to forces~\cite{Fraaije93}.
112 \end{itemize}
114 For the generation of a representative equilibrium ensemble two methods
115 are available: ($a$) {\em Monte Carlo simulations} and ($b$) {\em Molecular
116 Dynamics simulations}. For the generation of non-equilibrium ensembles
117 and for the analysis of dynamic events, only the second method is
118 appropriate. While Monte Carlo simulations are more simple than MD (they
119 do not require the computation of forces), they do not yield
120 significantly better statistics than MD in a given amount of computer time.
121 Therefore, MD is the more universal technique. If a starting
122 configuration is very far from equilibrium, the forces may be
123 excessively large and the MD simulation may fail. In those cases, a
124 robust {\em energy minimization} is required. Another reason to perform
125 an energy minimization is the removal of all kinetic energy from the
126 system: if several ``snapshots'' from dynamic simulations must be compared,
127 energy minimization reduces the thermal noise in the structures and
128 potential energies so that they can be compared better.
130 \section{Molecular Dynamics Simulations}
131 \label{sec:MDsimulations}
132 MD simulations solve Newton's \swapindex{equations of}{motion}
133 for a system of $N$ interacting atoms:
134 \beq
135 m_i \frac{\partial^2 \ve{r}_i}{\partial t^2} = \ve{F}_i, \;i=1 \ldots N.
136 \eeq
137 The forces are the negative derivatives of a potential function $V(\ve{r}_1,
138 \ve{r}_2, \ldots, \ve{r}_N)$:
139 \beq
140 \ve{F}_i = - \frac{\partial V}{\partial \ve{r}_i}
141 \eeq
142 The equations are solved simultaneously in small time steps. The
143 system is followed for some time, taking care that the temperature and
144 pressure remain at the required values, and the coordinates are
145 written to an output file at regular intervals. The coordinates as a
146 function of time represent a {\em trajectory} of the system. After
147 initial changes, the system will usually reach an {\em equilibrium
148 state}. By averaging over an equilibrium trajectory, many macroscopic
149 properties can be extracted from the output file.
151 It is useful at this point to consider the \normindex{limitations} of MD
152 simulations. The user should be aware of those limitations and always
153 perform checks on known experimental properties to assess the accuracy
154 of the simulation. We list the approximations below.
156 \begin{description}
157 \item[{\bf The simulations are classical}]\mbox{}\\
158 Using Newton's equation of motion automatically implies the use of
159 {\em classical mechanics} to describe the motion of atoms. This is
160 all right for most atoms at normal temperatures, but there are
161 exceptions. Hydrogen atoms are quite light and the motion of protons
162 is sometimes of essential quantum mechanical character. For example, a
163 proton may {\em tunnel} through a potential barrier in the course of a
164 transfer over a hydrogen bond. Such processes cannot be properly
165 treated by classical dynamics! Helium liquid at low temperature is
166 another example where classical mechanics breaks down. While helium
167 may not deeply concern us, the high frequency vibrations of covalent
168 bonds should make us worry! The statistical mechanics of a classical
169 harmonic oscillator differs appreciably from that of a real quantum
170 oscillator when the resonance frequency $\nu$ approximates or exceeds
171 $k_BT/h$. Now at room temperature the wavenumber $\sigma = 1/\lambda =
172 \nu/c$ at which $h
173 \nu = k_BT$ is approximately 200 cm$^{-1}$. Thus, all frequencies
174 higher than, say, 100 cm$^{-1}$ may misbehave in
175 classical simulations. This means that practically all bond and
176 bond-angle vibrations are suspect, and even hydrogen-bonded motions as
177 translational or librational H-bond vibrations are beyond the
178 classical limit (see \tabref{vibrations}). What can we do?
180 \begin{table}
181 \begin{center}
182 \begin{tabular}{|l|l|r@{--}rl|}
183 \dline
184 & \mcc{1}{type of} & \mcc{3}{wavenumber} \\
185 type of bond & \mcc{1}{vibration} & \mcc{3}{(cm$^{-1}$)} \\
186 \hline
187 C-H, O-H, N-H & stretch & 3000 & 3500 & \\
188 C=C, C=O & stretch & 1700 & 2000 & \\
189 HOH & bending & \mcl{2}{1600} & \\
190 C-C & stretch & 1400 & 1600 & \\
191 H$_2$CX & sciss, rock & 1000 & 1500 & \\
192 CCC & bending & 800 & 1000 & \\
193 O-H$\cdots$O & libration & 400 & 700 & \\
194 O-H$\cdots$O & stretch & 50 & 200 & \\
195 \dline
196 \end{tabular}
197 \end{center}
198 \caption[Typical vibrational frequencies.]{Typical vibrational
199 frequencies (wavenumbers) in molecules and hydrogen-bonded
200 liquids. Compare $kT/h = 200$ cm$^{-1}$ at 300~K.}
201 \label{tab:vibrations}
202 \end{table}
204 Well, apart from real quantum-dynamical simulations, we can do one
205 of two things: \\ (a) If we perform MD simulations using harmonic
206 oscillators for bonds, we should make corrections to the total
207 internal energy $U = E_{kin} + E_{pot}$ and specific heat $C_V$ (and
208 to entropy $S$ and free energy $A$ or $G$ if those are
209 calculated). The corrections to the energy and specific heat of a
210 one-dimensional oscillator with frequency $\nu$
211 are:~\cite{McQuarrie76}
212 \beq
213 U^{QM} = U^{cl} +kT \left( \half x - 1 + \frac{x}{e^x-1} \right)
214 \eeq
215 \beq
216 C_V^{QM} = C_V^{cl} + k \left( \frac{x^2e^x}{(e^x-1)^2} - 1 \right),
217 \eeq
218 where $x=h\nu /kT$. The classical oscillator absorbs too much energy
219 ($kT$), while the high-frequency quantum oscillator is in its ground
220 state at the zero-point energy level of $\frac{1}{2} h\nu$. \\ (b) We
221 can treat the bonds (and bond angles) as {\em \normindex{constraint}s}
222 in the equations of motion. The rationale behind this is that a quantum
223 oscillator in its ground state resembles a constrained bond more
224 closely than a classical oscillator. A good practical reason for this
225 choice is that the algorithm can use larger time steps when the
226 highest frequencies are removed. In practice the time step can be made
227 four times as large when bonds are constrained than when they are
228 oscillators~\cite{Gunsteren77}. {\gromacs} has this option for the
229 bonds and bond angles. The flexibility of the latter is
230 rather essential to allow for the realistic motion and coverage of
231 configurational space~\cite{Gunsteren82}.
233 \item[{\bf Electrons are in the ground state}]\mbox{}\\
234 In MD we use a {\em conservative} force field that is a
235 function of the positions of atoms only. This means that the
236 electronic motions are not considered: the electrons are supposed to
237 adjust their dynamics instantly when the atomic positions change
238 (the {\em \normindex{Born-Oppenheimer}} approximation), and remain in
239 their ground state. This is really all right, almost always. But of
240 course, electron transfer processes and electronically excited states
241 can not be treated. Neither can chemical reactions be treated
242 properly, but there are other reasons to shy away from reactions for
243 the time being.
245 \item[{\bf Force fields are approximate}]\mbox{}\\
246 Force fields \index{force field} provide the forces.
247 They are not really a part of the
248 simulation method and their parameters can be modified by the user as the
249 need arises or knowledge improves. But the form of the forces that can
250 be used in a particular program is subject to limitations. The force
251 field that is incorporated in {\gromacs} is described in Chapter 4. In
252 the present version the force field is pair-additive (apart from
253 long-range Coulomb forces), it cannot incorporate
254 polarizabilities, and it does not contain fine-tuning of bonded
255 interactions. This urges the inclusion of some limitations in this
256 list below. For the rest it is quite useful and fairly reliable for
257 biologically-relevant macromolecules in aqueous solution!
259 \item[{\bf The force field is pair-additive}]\mbox{}\\
260 This means that all {\em non-bonded} forces result from the sum of
261 non-bonded pair interactions. Non pair-additive interactions, the most
262 important example of which is interaction through atomic
263 polarizability, are represented by {\em effective pair
264 potentials}. Only average non pair-additive contributions are
265 incorporated. This also means that the pair interactions are not pure,
266 {\ie}, they are not valid for isolated pairs or for situations
267 that differ appreciably from the test systems on which the models were
268 parameterized. In fact, the effective pair potentials are not that bad
269 in practice. But the omission of polarizability also means that
270 electrons in atoms do not provide a dielectric constant as they
271 should. For example, real liquid alkanes have a dielectric constant of
272 slightly more than 2, which reduce the long-range electrostatic
273 interaction between (partial) charges. Thus, the simulations will
274 exaggerate the long-range Coulomb terms. Luckily, the next item
275 compensates this effect a bit.
277 \item[{\bf Long-range interactions are cut off}]\mbox{}\\
278 In this version, {\gromacs} always uses a \normindex{cut-off} radius for the
279 Lennard-Jones interactions and sometimes for the Coulomb interactions
280 as well. The ``minimum-image convention'' used by {\gromacs} requires that only one image of each
281 particle in the periodic boundary conditions is considered for a pair
282 interaction, so the cut-off radius cannot exceed half the box size. That
283 is still pretty big for large systems, and trouble is only expected
284 for systems containing charged particles. But then truly bad things can
285 happen, like accumulation of charges at the cut-off boundary or very
286 wrong energies! For such systems, you should consider using one of the
287 implemented long-range electrostatic algorithms, such as
288 particle-mesh Ewald~\cite{Darden93,Essmann95}.
290 \item[{\bf Boundary conditions are unnatural}]\mbox{}\\
291 Since system size is small (even 10,000 particles is small), a cluster
292 of particles will have a lot of unwanted boundary with its environment
293 (vacuum). We must avoid this condition if we wish to simulate a bulk system.
294 As such, we use periodic boundary conditions to avoid real phase
295 boundaries. Since liquids are not crystals, something unnatural
296 remains. This item is mentioned last because it is the
297 least of the evils. For large systems, the errors are small, but for
298 small systems with a lot of internal spatial correlation, the periodic
299 boundaries may enhance internal correlation. In that case, beware of, and
300 test, the influence of system size. This is especially important when
301 using lattice sums for long-range electrostatics, since these are known
302 to sometimes introduce extra ordering.
303 \end{description}
305 \section{Energy Minimization and Search Methods}
307 As mentioned in \secref{Compchem}, in many cases energy minimization
308 is required. {\gromacs} provides a number of methods for local energy
309 minimization, as detailed in \secref{EM}.
311 The potential energy function of a (macro)molecular system is a very
312 complex landscape (or {\em hypersurface}) in a large number of
313 dimensions. It has one deepest point, the {\em global minimum} and a
314 very large number of {\em local minima}, where all derivatives of the
315 potential energy function with respect to the coordinates are zero and
316 all second derivatives are non-negative. The matrix of second
317 derivatives, which is called the {\em Hessian matrix}, has non-negative
318 eigenvalues; only the collective coordinates that correspond to
319 translation and rotation (for an isolated molecule) have zero
320 eigenvalues. In between the local minima there are {\em saddle
321 points}, where the Hessian matrix has only one negative
322 eigenvalue. These points are the mountain passes through which the
323 system can migrate from one local minimum to another.
325 Knowledge of all local minima, including the global one, and of all
326 saddle points would enable us to describe the relevant structures and
327 conformations and their free energies, as well as the dynamics of
328 structural transitions. Unfortunately, the dimensionality of the
329 configurational space and the number of local minima is so high that
330 it is impossible to sample the space at a sufficient number of points
331 to obtain a complete survey. In particular, no minimization method
332 exists that guarantees the determination of the global minimum in any
333 practical amount of time. Impractical methods exist, some much faster
334 than others~\cite{Geman84}. However, given a starting configuration,
335 it is possible to find the {\em nearest local minimum}. ``Nearest'' in
336 this context does not always imply ``nearest'' in a geometrical sense
337 ({\ie}, the least sum of square coordinate differences), but means the
338 minimum that can be reached by systematically moving down the steepest
339 local gradient. Finding this nearest local minimum is all that
340 {\gromacs} can do for you, sorry! If you want to find other minima and
341 hope to discover the global minimum in the process, the best advice is
342 to experiment with temperature-coupled MD: run your system at a high
343 temperature for a while and then quench it slowly down to the required
344 temperature; do this repeatedly! If something as a melting or glass
345 transition temperature exists, it is wise to stay for some time
346 slightly below that temperature and cool down slowly according to some
347 clever scheme, a process called {\em simulated annealing}. Since no
348 physical truth is required, you can use your imagination to speed up this
349 process. One trick that often works is to make hydrogen atoms heavier
350 (mass 10 or so): although that will slow down the otherwise very rapid
351 motions of hydrogen atoms, it will hardly influence the slower motions
352 in the system, while enabling you to increase the time step by a factor
353 of 3 or 4. You can also modify the potential energy function during
354 the search procedure, {\eg} by removing barriers (remove dihedral
355 angle functions or replace repulsive potentials by {\em soft-core}
356 potentials~\cite{Nilges88}), but always take care to restore the
357 correct functions slowly. The best search method that allows rather
358 drastic structural changes is to allow excursions into
359 four-dimensional space~\cite{Schaik93}, but this requires some extra
360 programming beyond the standard capabilities of {\gromacs}.
362 Three possible energy minimization methods are:
363 \begin{itemize}
364 \item Those that require only function evaluations. Examples are the
365 simplex method and its variants. A step is made on the basis of the
366 results of previous evaluations. If derivative information is
367 available, such methods are inferior to those that use
368 this information.
369 \item Those that use derivative information. Since the partial
370 derivatives of the potential energy with respect to all
371 coordinates are known in MD programs (these are equal to minus
372 the forces) this class of methods is very suitable as modification
373 of MD programs.
374 \item Those that use second derivative information as well. These methods
375 are superior in their convergence properties near the minimum: a
376 quadratic potential function is minimized in one step! The problem
377 is that for $N$ particles a $3N\times 3N$ matrix must be computed,
378 stored, and inverted. Apart from the extra programming to obtain
379 second derivatives, for most systems of interest this is beyond the
380 available capacity. There are intermediate methods that build up the
381 Hessian matrix on the fly, but they also suffer from excessive
382 storage requirements. So {\gromacs} will shy away from this class
383 of methods.
384 \end{itemize}
387 The {\em steepest descent} method, available in {\gromacs}, is of the
388 second class. It simply takes a step in the direction of the negative
389 gradient (hence in the direction of the force), without any
390 consideration of the history built up in previous steps. The step size
391 is adjusted such that the search is fast, but the motion is always
392 downhill. This is a simple and sturdy, but somewhat stupid, method:
393 its convergence can be quite slow, especially in the vicinity of the
394 local minimum! The faster-converging {\em conjugate gradient method}
395 (see {\eg} \cite{Zimmerman91}) uses gradient information from previous
396 steps. In general, steepest descents will bring you close to the
397 nearest local minimum very quickly, while conjugate gradients brings
398 you {\em very} close to the local minimum, but performs worse far away
399 from the minimum. {\gromacs} also supports the L-BFGS minimizer, which
400 is mostly comparable to {\em conjugate gradient method}, but in some
401 cases converges faster.
403 % LocalWords: Schr dinger initio parameterization QSAR equilibria solubilities
404 % LocalWords: mesoscopic BT wavenumber rl HOH CX sciss CCC libration kT minima
405 % LocalWords: wavenumbers polarizabilities polarizability parameterized BFGS
406 % LocalWords: alkanes Compchem librational configurational Ewald
407 % LocalWords: hypersurface