474988727f8dcf799d6c742b816b46d2b01b2c5d
[alexxy/gromacs.git] / manual / analyse.tex
1 %
2 % This file is part of the GROMACS molecular simulation package.
3 %
4 % Copyright (c) 2013,2014, by the GROMACS development team, led by
5 % Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 % and including many others, as listed in the AUTHORS file in the
7 % top-level source directory and at http://www.gromacs.org.
8 %
9 % GROMACS is free software; you can redistribute it and/or
10 % modify it under the terms of the GNU Lesser General Public License
11 % as published by the Free Software Foundation; either version 2.1
12 % of the License, or (at your option) any later version.
13 %
14 % GROMACS is distributed in the hope that it will be useful,
15 % but WITHOUT ANY WARRANTY; without even the implied warranty of
16 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 % Lesser General Public License for more details.
18 %
19 % You should have received a copy of the GNU Lesser General Public
20 % License along with GROMACS; if not, see
21 % http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 % Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23 %
24 % If you want to redistribute modifications to GROMACS, please
25 % consider that scientific software is very special. Version
26 % control is crucial - bugs must be traceable. We will be happy to
27 % consider code for inclusion in the official distribution, but
28 % derived work must not be called official GROMACS. Details are found
29 % in the README & COPYING files - if they are missing, get the
30 % official version at http://www.gromacs.org.
31 %
32 % To help us fund GROMACS development, we humbly ask that you cite
33 % the research papers on the package. Check out http://www.gromacs.org.
34
35 \chapter{Analysis}
36 \label{ch:analysis}
37 In this chapter different ways of analyzing your trajectory are described. 
38 The names of the corresponding analysis programs are given. 
39 Specific information on the in- and output of these programs can be found 
40 in the online manual at {\wwwpage}.
41 The output files are often produced as finished Grace/Xmgr graphs.
42
43 First, in \secref{usinggroups}, the group concept in analysis is explained. 
44 \ssecref{selections} explains a newer concept of dynamic selections,
45 which is currently supported by a few tools.
46 Then, the different analysis tools are presented.
47
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Groups in Analysis
49
50 \section{Using Groups}
51 \label{sec:usinggroups}\index{groups}
52 {\tt gmx make_ndx, gmx mk_angndx, gmx select}\\
53 In \chref{algorithms}, it was explained how {\em groups of
54 atoms} can be used in {\tt mdrun} (see~\secref{groupconcept}).
55 In most analysis programs, groups
56 of atoms must also be chosen. Most programs can generate several default
57 index groups, but groups can always be read from an index file. Let's
58 consider the example of a simulation of a binary mixture of components A and B. When
59 we want to calculate the radial distribution function (RDF)
60 $g_{AB}(r)$ of A with respect to B, we have to calculate:
61 \beq
62 4\pi r^2 g_{AB}(r)      ~=~     V~\sum_{i \in A}^{N_A} \sum_{j \in B}^{N_B} P(r)
63 \eeq
64 where $V$ is the volume and $P(r)$ is the probability of finding a B atom
65 at distance $r$ from an A atom.
66
67 By having the user define the {\em atom numbers} for groups A and B in
68 a simple file, we can calculate this $g_{AB}$ in the most general way, without
69 having to make any assumptions in the RDF program about the type of 
70 particles. 
71
72 Groups can therefore consist of a series of {\em atom numbers}, but in
73 some cases also of {\em molecule numbers}.  It is also possible to
74 specify a series of angles by {\em triples} of {\em atom numbers},
75 dihedrals by {\em quadruples} of {\em atom numbers} and bonds or
76 vectors (in a molecule) by {\em pairs} of {\em atom numbers}. When
77 appropriate the type of index file will be specified for the following
78 analysis programs.  To help creating such \swapindex{index}{file}s ({\tt
79 index.ndx}), there are a couple of programs to generate them, using
80 either your input configuration or the topology.  To generate an
81 index file consisting of a series of {\em atom numbers} (as in the
82 example of $g_{AB}$), use {\tt \normindex{gmx make_ndx}} or
83 {\tt \normindex{gmx select}}.  To generate an index file
84 with angles or dihedrals, use {\tt \normindex{gmx mk_angndx}}.
85 Of course you can also
86 make them by hand. The general format is presented here:
87
88 \begin{verbatim}
89 [ Oxygen ]
90    1       4       7
91
92 [ Hydrogen ]
93    2       3       5       6
94    8       9
95 \end{verbatim}
96
97 First, the group name is written between square brackets. The following
98 atom numbers may be spread out over as many lines as you like. The
99 atom numbering starts at 1.
100
101 \swapindexquiet{choosing}{groups}%
102 Each tool that can use groups will offer the available alternatives
103 for the user to choose. That choice can be made with the number of the
104 group, or its name. In fact, the first few letters of the group
105 name will suffice if that will distinguish the group from all others.
106 There are ways to use Unix shell features to choose group names
107 on the command line, rather than interactively. Consult {\wwwpage}
108 for suggestions.
109
110 \subsection{Default Groups}
111 \label{subsec:defaultgroups}
112 When no index file is supplied to analysis tools or {\tt grompp},
113 a number of \swapindex{default}{groups} are generated to choose from:
114 \begin{description}
115 \item[{\tt System}]\mbox{}\\
116         all atoms in the system
117 \item[{\tt Protein}]\mbox{}\\
118         all protein atoms
119 \item[{\tt Protein-H}]\mbox{}\\
120         protein atoms excluding hydrogens
121 \item[{\tt C-alpha}]\mbox{}\\
122         C$_{\alpha}$ atoms
123 \item[{\tt Backbone}]\mbox{}\\
124         protein backbone atoms; N, C$_{\alpha}$ and C
125 \item[{\tt MainChain}]\mbox{}\\
126         protein main chain atoms: N, C$_{\alpha}$, C and O, including
127         oxygens in C-terminus
128 \item[{\tt MainChain+Cb}]\mbox{}\\
129         protein main chain atoms including C$_{\beta}$
130 \item[{\tt MainChain+H}]\mbox{}\\
131         protein main chain atoms including backbone amide hydrogens and
132         hydrogens on the N-terminus
133 \item[{\tt SideChain}]\mbox{}\\
134         protein side chain atoms; that is all atoms except N,
135         C$_{\alpha}$, C, O, backbone amide hydrogens, oxygens in
136         C-terminus and hydrogens on the N-terminus
137 \item[{\tt SideChain-H}]\mbox{}\\
138         protein side chain atoms excluding all hydrogens
139 %\ifthenelse{\equal{\gmxlite}{1}}{}{
140 \item[{\tt Prot-Masses}]\mbox{}\\
141         protein atoms excluding dummy masses (as used in virtual site
142         constructions of NH$_3$ groups and tryptophan side-chains),
143         see also \secref{vsitetop}; this group is only included when
144         it differs from the ``{\tt Protein}'' group
145 %} % Brace matches ifthenelse test for gmxlite
146 \item[{\tt Non-Protein}]\mbox{}\\
147         all non-protein atoms
148 \item[{\tt DNA}]\mbox{}\\
149         all DNA atoms
150 \item[{\tt RNA}]\mbox{}\\
151         all RNA atoms
152 \item[{\tt Water}]\mbox{}\\
153         water molecules (names like {\tt SOL}, {\tt WAT}, {\tt HOH}, etc.)  See
154         {\tt \normindex{residuetypes.dat}} for a full listing
155 \item[{\tt non-Water}]\mbox{}\\
156         anything not covered by the {\tt Water} group
157 \item[{\tt Ion}]\mbox{}\\
158         any name matching an Ion entry in {\tt \normindex{residuetypes.dat}}
159 \item[{\tt Water_and_Ions}]\mbox{}\\
160         combination of the {\tt Water} and {\tt Ions} groups 
161 \item[{\tt molecule_name}]\mbox{}\\
162         for all residues/molecules which are not recognized as protein,
163         DNA, or RNA; one group per residue/molecule name is generated
164 \item[{\tt Other}]\mbox{}\\
165         all atoms which are neither protein, DNA, nor RNA.
166 \end{description}
167 Empty groups will not be generated.
168 Most of the groups only contain protein atoms.
169 An atom is considered a protein atom if its residue name is listed
170 in the {\tt \normindex{residuetypes.dat}} file and is listed as a
171 ``Protein'' entry.  The process for determinding DNA, RNA, etc. is
172 analogous. If you need to modify these classifications, then you
173 can copy the file from the library directory into your working
174 directory and edit the local copy.
175
176 \subsection{Selections}
177 \label{subsec:selections}
178 {\tt \normindex{gmx select}}\\
179 Currently, a few analysis tools support an extended concept of {\em
180 (dynamic) \normindex{selections}}.  There are three main differences to
181 traditional index groups:
182 \begin{itemize}
183   \item The selections are specified as text instead of reading fixed
184     atom indices from a file, using a syntax similar to VMD.  The text
185     can be entered interactively, provided on the command line, or from
186     a file.
187   \item The selections are not restricted to atoms, but can also specify
188     that the analysis is to be performed on, e.g., center-of-mass
189     positions of a group of atoms.
190     Some tools may not support selections that do not evaluate to single
191     atoms, e.g., if they require information that is available only for
192     single atoms, like atom names or types.
193   \item The selections can be dynamic, i.e., evaluate to different atoms
194     for different trajectory frames.  This allows analyzing only a
195     subset of the system that satisfies some geometric criteria.
196 \end{itemize}
197 As an example of a simple selection,
198 {\tt resname ABC and within 2 of resname DEF}
199 selects all atoms in residues named ABC that are within 2\,nm of any
200 atom in a residue named DEF.
201
202 Tools that accept selections can also use traditional index files
203 similarly to older tools: it is possible to give an {\tt .ndx} file to
204 the tool, and directly select a group from the index file as a
205 selection, either by group number or by group name.  The index groups
206 can also be used as a part of a more complicated selection.
207
208 To get started, you can run {\tt gmx select} with a single structure,
209 and use the interactive prompt to try out different selections.
210 The tool provides, among others, output options {\tt -on} and
211 {\tt -ofpdb} to write out the selected atoms to an index file and to a
212 {\tt .pdb} file, respectively.  This does not allow testing selections
213 that evaluate to center-of-mass positions, but other selections can be
214 tested and the result examined.
215
216 The detailed syntax and the individual keywords that can be used in
217 selections can be accessed by typing {\tt help} in the interactive
218 prompt of any selection-enabled tool, as well as with
219 {\tt gmx help selections}.  The help is divided into subtopics that can
220 be accessed with, e.g., {\tt help syntax} / {\tt gmx help selections
221 syntax}.  Some individual selection keywords have extended help as well,
222 which can be accessed with, e.g., {\tt help keywords within}.
223
224 The interactive prompt does not currently provide much editing
225 capabilities.  If you need them, you can run the program under
226 {\tt rlwrap}.
227
228 For tools that do not yet support the selection syntax, you can use
229 {\tt gmx select -on} to generate static index groups to pass to the
230 tool.  However, this only allows for a small subset (only the first
231 bullet from the above list) of the flexibility that fully
232 selection-aware tools offer.
233
234 It is also possible to write your own analysis
235 tools to take advantage of the flexibility of these selections: see the
236 {\tt template.cpp} file in the {\tt share/gromacs/template} directory of
237 your installation for an example.
238
239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Looking at your trajectory
240
241 \section{Looking at your trajectory}
242 \label{sec:lookwhostalking}
243 \begin{figure}
244 \centerline{
245 {\includegraphics[width=8cm,angle=90]{plots/ngmxdump}}}
246 \caption{The window of {\tt gmx view} showing a box of water.}
247 \label{fig:ngmxdump}
248 \end{figure}
249 {\tt gmx view}\\
250 Before analyzing your trajectory it is often informative to look at
251 your trajectory first. {\gromacs} comes with a simple trajectory
252 viewer {\tt \normindex{gmx view}}; the advantage with this one is that it does not
253 require OpenGL, which usually isn't present on {\eg} supercomputers.
254 It is also possible to generate a
255 hard-copy in Encapsulated Postscript format (see
256 \figref{ngmxdump}). If you want a faster and more fancy viewer
257  there are several programs
258 that can read the {\gromacs} trajectory formats -- have a look at our
259 homepage ({\wwwpage}) for updated links. 
260
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% General properties
262
263 \section{General properties}
264 \label{sec:genprop}
265 {\tt gmx energy, gmx traj}\\
266 To analyze some or all {\em energies} and other properties, such as
267 {\em total pressure}, {\em pressure tensor}, {\em density}, {\em
268 box-volume} and {\em box-sizes}, use the program {\tt \normindex{gmx energy}}.  A
269 choice can be made from a list a set of energies, like potential,
270 kinetic or total energy, or individual contributions, like
271 Lennard-Jones or dihedral energies.
272
273 The {\em center-of-mass velocity}, defined as
274 \beq
275 {\bf v}_{com} = {1 \over M} \sum_{i=1}^N m_i {\bf v}_i
276 \eeq
277 with $M = \sum_{i=1}^N m_i$ the total mass of the system, can be
278 monitored in time by the program {\tt \normindex{gmx traj} -com -ov}. It is however
279 recommended to remove the center-of-mass velocity every step (see
280 \chref{algorithms})!
281
282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Radial distribution functions 
283
284 \section{Radial distribution functions}
285 \label{sec:rdf}
286 {\tt gmx rdf}\\
287 The {\em radial distribution function} (RDF) or pair correlation
288 function $g_{AB}(r)$ between particles of type $A$ and $B$ is defined
289 in the following way:
290 \newcommand{\dfrac}[2]{\displaystyle \frac{#1}{#2}}
291 \beq
292 \begin{array}{rcl}
293 g_{AB}(r)&=&    \dfrac{\langle \rho_B(r) \rangle}{\langle\rho_B\rangle_{local}}         \\
294          &=&    \dfrac{1}{\langle\rho_B\rangle_{local}}\dfrac{1}{N_A}
295                 \sum_{i \in A}^{N_A} \sum_{j \in B}^{N_B} 
296                 \dfrac{\delta( r_{ij} - r )}{4 \pi r^2}         \\
297 \end{array}
298 \eeq
299 with $\langle\rho_B(r)\rangle$ the particle density of type $B$ at a distance $r$
300 around particles $A$, and $\langle\rho_B\rangle_{local}$ the particle density of
301 type $B$ averaged over all spheres around particles $A$ with radius
302 $r_{max}$ (see \figref{rdfex}C).
303
304 \begin{figure}
305 \centerline{
306 {\includegraphics[width=7cm,angle=270]{plots/rdf}}}
307 \caption[Definition of slices in {\tt gmx rdf}.]{Definition of slices
308 in {\tt gmx rdf}: A. $g_{AB}(r)$. B. $g_{AB}(r,\theta)$. The slices are
309 colored gray. C. Normalization $\langle\rho_B\rangle_{local}$. D. Normalization
310 $\langle\rho_B\rangle_{local,\:\theta }$. Normalization volumes are colored gray.}
311 \label{fig:rdfex}
312 \end{figure}
313
314 Usually the value of $r_{max}$ is half of the box length.  The
315 averaging is also performed in time.  In practice the analysis program
316 {\tt \normindex{gmx rdf}} divides the system into spherical slices (from $r$ to
317 $r+dr$, see \figref{rdfex}A) and makes a histogram in stead of
318 the $\delta$-function. An example of the RDF of oxygen-oxygen in
319 SPC water~\cite{Berendsen81} is given in \figref{rdf}.
320
321 \begin{figure}
322 \centerline{
323 {\includegraphics[width=8cm]{plots/rdfO-O}}}
324 \caption{$g_{OO}(r)$ for Oxygen-Oxygen of SPC-water.}
325 \label{fig:rdf}
326 \end{figure}
327
328 % TODO: This functionality isn't there...
329 With {\tt gmx rdf} it is also possible to calculate an angle dependent rdf
330 $g_{AB}(r,\theta)$, where the angle $\theta$ is defined with respect to a 
331 certain laboratory axis ${\bf e}$, see \figref{rdfex}B.
332 \bea 
333 g_{AB}(r,\theta) &=& {1 \over \langle\rho_B\rangle_{local,\:\theta }} {1 \over N_A} \sum_{i \in A}^{N_A} \sum_{j \in B}^{N_B} {\delta( r_{ij} - r ) \delta(\theta_{ij} -\theta) \over 2 \pi r^2 sin(\theta)}\\
334 cos(\theta_{ij}) &=& {{\bf r}_{ij} \cdot {\bf e} \over \|r_{ij}\| \;\| e\| }
335 \eea
336 This $g_{AB}(r,\theta)$ is useful for analyzing anisotropic systems. 
337 {\bf Note} that in this case the normalization $\langle\rho_B\rangle_{local,\:\theta}$ is 
338 the average density in all angle slices from $\theta$ to $\theta + d\theta$ 
339 up to $r_{max}$, so angle dependent, see \figref{rdfex}D.
340
341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Correlation functions 
342 %\ifthenelse{\equal{\gmxlite}{1}}{}{
343
344 \section{Correlation functions}
345 \label{sec:corr}
346
347 \subsection{Theory of correlation functions}
348 The theory of correlation functions is well established~\cite{Allen87}.
349 We describe here the implementation of the various 
350 \normindex{correlation} function flavors in the {\gromacs} code.
351 The definition of the \index{autocorrelation function} (ACF)
352 $C_f(t)$ for a property $f(t)$ is:
353 \beq
354 C_f(t)  ~=~     \left\langle f(\xi) f(\xi+t)\right\rangle_{\xi}
355 \label{eqn:corr}
356 \eeq
357 where the notation on the right hand side indicates averaging over $\xi$, {\ie} over
358 time origins.
359 It is also possible to compute cross-correlation function from two properties
360 $f(t)$ and $g(t)$:
361 \beq
362 C_{fg}(t) ~=~   \left\langle f(\xi) g(\xi+t)\right\rangle_{\xi}
363 \eeq
364 however, in {\gromacs} there is no standard mechanism to do this
365 ({\bf note:} you can use the {\tt \normindex{xmgr}} program to compute cross correlations).
366 The integral of the correlation function over time is the 
367 correlation time $\tau_f$:
368 \beq
369 \tau_f  ~=~     \int_0^{\infty} C_f(t) {\rm d} t
370 \label{eqn:corrtime}
371 \eeq
372
373 In practice, correlation functions are calculated based on data points with
374 discrete time intervals {$\Delta$t}, so that the ACF from an MD simulation is:
375 \beq
376 C_f(j\Delta t)  ~=~     \frac{1}{N-j}\sum_{i=0}^{N-1-j} f(i\Delta t) f((i+j)\Delta t)
377 \label{eqn:corrmd}
378 \eeq
379 where $N$ is the number of available time frames for the calculation.
380 The resulting ACF is
381 obviously only available at time points with the same interval {$\Delta$t}.
382 Since, for many applications, it is necessary to know the short time behavior
383 of the ACF ({\eg} the first 10 ps) this often means that we have to save the
384 data with intervals much shorter than the time scale of interest.
385 Another implication of \eqnref{corrmd} is that in principle we can not compute
386 all points of the ACF with the same accuracy, since we have $N-1$ data points
387 for $C_f(\Delta t)$ but only 1 for $C_f((N-1)\Delta t)$. However, if we decide to
388 compute only an ACF of length $M\Delta t$, where $M \leq N/2$ we can compute 
389 all points with the same statistical accuracy:
390 \beq
391 C_f(j\Delta t)  ~=~ \frac{1}{M}\sum_{i=0}^{N-1-M} f(i\Delta t)f((i+j)\Delta t)
392 \eeq
393 Here of course $j < M$.
394 $M$ is sometimes referred to as the \normindex{time lag} of the correlation function. 
395 When we decide to do this, we intentionally do not use all the available points
396 for very short time intervals ($j << M$), but it makes it easier to interpret
397 the results.
398 Another aspect that may not be neglected when computing
399 ACFs from simulation is that usually the time origins $\xi$ (\eqnref{corr})
400 are not statistically independent, which may introduce a bias in the results.
401 This can be tested using a block-averaging procedure, where only time origins
402 with a spacing at least the length of the time lag are included, {\eg} using 
403 $k$ time origins with spacing of $M\Delta t$ (where $kM \leq N$):
404 \beq
405 C_f(j\Delta t)  ~=~ \frac{1}{k}\sum_{i=0}^{k-1} f(iM\Delta t)f((iM+j)\Delta t)
406 \eeq
407 However, one
408 needs very long simulations to get good accuracy this way, because there are 
409 many fewer points that contribute to the ACF.
410
411 \subsection{Using FFT for computation of the ACF}
412 The computational cost for calculating an ACF according to \eqnref{corrmd}
413 is proportional to $N^2$, which is considerable. However, this can be improved
414 by using fast Fourier transforms to do the convolution~\cite{Allen87}.
415
416 \subsection{Special forms of the ACF}
417 There are some important varieties on the ACF, {\eg} the ACF of a vector \ve{p}:
418 \beq
419 C_{\ve{p}}(t) ~=~       \int_0^{\infty} P_n(\cos\angle\left(\ve{p}(\xi),\ve{p}(\xi+t)\right) {\rm d} \xi
420 \label{eqn:corrleg}
421 \eeq
422 where $P_n(x)$ is the $n^{th}$ order Legendre polynomial
423 \footnote{$P_0(x) = 1$, $P_1(x) = x$, $P_2(x) = (3x^2-1)/2$}.
424 Such correlation times 
425 can actually be obtained experimentally using {\eg} NMR or other relaxation 
426 experiments. {\gromacs} can compute correlations using 
427 the 1$^{st}$ and 2$^{nd}$ order Legendre polynomial (\eqnref{corrleg}).
428 This can also be used for rotational autocorrelation
429 ({\tt \normindex{gmx rotacf}})
430 and dipole autocorrelation ({\tt \normindex{gmx dipoles}}).
431
432 In order to study torsion angle dynamics, we define a dihedral 
433 autocorrelation function as~\cite{Spoel97a}:
434 \beq
435 C(t)    ~=~     \left\langle \cos(\theta(\tau)-\theta(\tau+t))\right\rangle_{\tau}
436 \label{eqn:coenk}
437 \eeq
438 {\bf Note} that this is not a  product of two functions 
439 as is generally used for correlation
440 functions, but it may be rewritten as the sum of two products:
441 \beq
442 C(t)    ~=~     \left\langle\cos(\theta(\tau))\cos(\theta(\tau+t))\,+\,\sin(\theta(\tau))\sin(\theta(\tau+t))\right\rangle_{\tau}
443 \label{eqn:cot}
444 \eeq
445
446 \subsection{Some Applications}
447 The program {\tt \normindex{gmx velacc}} calculates the {\em velocity autocorrelation 
448 function}.
449 \beq
450 C_{\ve{v}} (\tau) ~=~ \langle {\ve{v}}_i(\tau) \cdot {\ve{v}}_i(0) \rangle_{i \in A}
451 \eeq
452 The self diffusion coefficient can be calculated using the Green-Kubo 
453 relation~\cite{Allen87}:
454 \beq
455 D_A ~=~ {1\over 3} \int_0^{\infty} \langle {\bf v}_i(t) \cdot {\bf v}_i(0) \rangle_{i \in A} \; dt
456 \eeq
457 which is just the integral of the velocity autocorrelation function.
458 There is a widely-held belief that the velocity ACF converges faster than the mean
459 square displacement (\secref{msd}), which can also be used for the computation of 
460 diffusion constants. However, Allen \& Tildesley~\cite{Allen87} 
461 warn us that the long-time 
462 contribution to the velocity ACF can not be ignored, so care must be taken.
463
464 Another important quantity is the dipole correlation time. The {\em dipole 
465 correlation function} for particles of type $A$ is calculated as follows by 
466 {\tt \normindex{gmx dipoles}}:
467 \beq
468 C_{\mu} (\tau) ~=~
469 \langle {\bf \mu}_i(\tau) \cdot {\bf \mu}_i(0) \rangle_{i \in A}
470 \eeq
471 with ${\bf \mu}_i = \sum_{j \in i} {\bf r}_j q_j$. The dipole correlation time 
472 can be computed using \eqnref{corrtime}.
473 For some applications see~\cite{Spoel98a}.
474
475 The \normindex{viscosity} of a liquid can be related to the correlation 
476 time of the Pressure tensor $\ve{P}$~\cite{PSmith93c,Balasubramanian96}.
477 {\tt \normindex{gmx energy}} can compute the viscosity,
478 but this is not very accurate~\cite{Hess2002a}, and 
479 actually the values do not converge.
480 %} % Brace matches ifthenelse test for gmxlite
481
482 \section{Mean Square Displacement}
483 \label{sec:msd}
484 {\tt gmx msd}\\
485 To determine the self \index{diffusion coefficient} $D_A$ of
486 particles of type $A$, one can use the \normindex{Einstein
487 relation}~\cite{Allen87}:
488 \beq 
489 \lim_{t \rightarrow \infty} \langle
490 \|{\bf r}_i(t) - {\bf r}_i(0)\|^2 \rangle_{i \in A} ~=~ 6 D_A t 
491 \eeq
492 This {\em mean square displacement} and $D_A$ are calculated by the
493 program {\tt \normindex{gmx msd}}. Normally an index file containing
494 atom numbers is used and the MSD is averaged over these atoms.  For
495 molecules consisting of more than one atom, ${\bf r}_i$ can be taken
496 as the center of mass positions of the molecules. In that case, you
497 should use an index file with molecule numbers. The results will be
498 nearly identical to averaging over atoms, however. The {\tt gmx msd}
499 program can
500 also be used for calculating diffusion in one or two dimensions. This
501 is useful for studying lateral diffusion on interfaces.
502
503 An example of the mean square displacement of SPC water is given in
504 \figref{msdwater}.
505
506 \begin{figure}
507 \centerline{
508 {\includegraphics[width=8cm]{plots/msdwater}}}
509 \caption{Mean Square Displacement of SPC-water.}
510 \label{fig:msdwater}
511 \end{figure}
512
513 %\ifthenelse{\equal{\gmxlite}{1}}{}{
514
515 %%%%%%%%%%%%%%%%%%%%% Bonds, angles and dihedral %%%%%%%%%%%%%%%%%%%
516
517 \section{Bonds/distances, angles and dihedrals}
518 \label{sec:bad}
519 {\tt gmx distance, gmx angle, gmx gangle}\\
520 To monitor specific {\em bonds} in your modules, or more generally
521 distances between points, the program
522 {\tt \normindex{gmx distance}} can calculate distances as a function of
523 time, as well as the distribution of the distance.
524 With a traditional index file, the groups should consist of pairs of
525 atom numbers, for example:
526 \begin{verbatim}
527 [ bonds_1 ]
528  1     2
529  3     4
530  9    10
531
532 [ bonds_2 ]
533 12    13
534 \end{verbatim}
535 Selections are also supported, with first two positions defining the
536 first distance, second pair of positions defining the second distance
537 and so on.  You can calculate the distances between CA and CB atoms in
538 all your residues (assuming that every residue either has both atoms, or
539 neither) using a selection such as:
540 \begin{verbatim}
541 name CA CB
542 \end{verbatim}
543 The selections also allow more generic distances to be computed.
544 For example, to compute the distances between centers of mass of two
545 residues, you can use:
546 \begin{verbatim}
547 com of resname AAA plus com of resname BBB
548 \end{verbatim}
549
550 The program {\tt \normindex{gmx angle}} calculates the distribution of {\em angles} and
551 {\em dihedrals} in time. It also gives the average angle or dihedral. 
552 The index file consists of triplets or quadruples of atom numbers:
553
554 \begin{verbatim}
555 [ angles ]
556  1     2     3
557  2     3     4
558  3     4     5
559
560 [ dihedrals ]
561  1     2     3     4
562  2     3     5     5
563 \end{verbatim}
564
565 For the dihedral angles you can use either the ``biochemical convention'' 
566 ($\phi = 0 \equiv cis$) or ``polymer convention'' ($\phi = 0 \equiv trans$), 
567 see \figref{dih_def}.
568
569 \begin{figure}
570 \centerline{
571 {\includegraphics[width=3.5cm,angle=270]{plots/dih-def}}}
572 \caption[Dihedral conventions.]{Dihedral conventions: A. ``Biochemical
573 convention''. B. ``Polymer convention''.}
574 \label{fig:dih_def}
575 \end{figure}
576
577 The program {\tt \normindex{gmx gangle}} provides a selection-enabled
578 version to compute angles.  This tool can also compute angles and
579 dihedrals, but does not support all the options of {\tt gmx angle}, such
580 as autocorrelation or other time series analyses.
581 In addition, it supports angles between two vectors, a vector and a
582 plane, two planes (defined by 2 or 3 points, respectively), a
583 vector/plane and the $z$ axis, or a vector/plane and the normal of a
584 sphere (determined by a single position).
585 Also the angle between a vector/plane compared to its position in the
586 first frame is supported.
587 For planes, {\tt \normindex{gmx gangle}} uses the normal vector
588 perpendicular to the plane.
589 See \figref{sgangle}A, B, C) for the definitions.
590
591 \begin{figure}
592 \centerline{
593 {\includegraphics{plots/sgangle}}}
594 \caption[Angle options of {\tt gmx gangle}.]{Angle options of {\tt gmx gangle}:
595 A. Angle between two vectors.
596 B. Angle between two planes.
597 C. Angle between a vector and the $z$ axis.
598 D. Angle between a vector and the normal of a sphere.
599 Also other combinations are supported: planes and vectors can be used
600 interchangeably.}
601 \label{fig:sgangle}
602 \end{figure}
603 %} % Brace matches ifthenelse test for gmxlite
604
605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Radius of gyration and distances
606
607 \section{Radius of gyration and distances}
608 \label{sec:rg}
609 {\tt gmx gyrate, gmx distance, gmx mindist, gmx mdmat, gmx xpm2ps}\\
610 To have a rough measure for the compactness of a structure, you can calculate 
611 the {\em radius of gyration} with the program {\tt \normindex{gmx gyrate}} as follows:
612 \beq
613 R_g ~=~ \left({\frac{\sum_i \|{\bf r}_i\|^2 m_i}{\sum_i m_i}}\right)^{\half}
614 \label{eqn:rg}
615 \eeq
616 where $m_i$ is the mass of atom $i$ and ${\bf r}_i$ the position of 
617 atom $i$ with respect to the center of mass of the molecule. It is especially 
618 useful to characterize polymer solutions and proteins.
619
620 Sometimes it is interesting to plot the {\em distance} between two atoms,
621 or the {\em minimum} distance between two groups of atoms
622 ({\eg}: protein side-chains in a salt bridge). 
623 To calculate these distances between certain groups there are several 
624 possibilities:
625 \begin{description}
626 \item[$\bullet$] 
627 The {\em distance between the geometrical centers} of two groups can be 
628 calculated with the program
629 %\ifthenelse{\equal{\gmxlite}{1}}{
630 {{\tt \normindex{gmx distance}}, as explained in \secref{bad}.}
631 \item[$\bullet$] 
632 The {\em minimum distance} between two groups of atoms during time 
633 can be calculated with the program {\tt \normindex{gmx mindist}}. It also calculates the 
634 {\em number of contacts} between these groups 
635 within a certain radius $r_{max}$.
636 \item[$\bullet$] 
637 To monitor the {\em minimum distances between amino acid residues} 
638 within a (protein) molecule, you can use 
639 the program {\tt \normindex{gmx mdmat}}. This minimum distance between two residues
640 A$_i$ and A$_j$ is defined as the smallest distance between any pair of 
641 atoms (i $\in$ A$_i$, j $\in$ A$_j$).
642 The output is a symmetrical matrix of smallest distances 
643 between all residues.
644 To visualize this matrix, you can use a program such as {\tt xv}.
645 If you want to view the axes and legend or if you want to print
646 the matrix, you can convert it with 
647 {\tt xpm2ps} into a Postscript picture, see \figref{mdmat}.
648 \begin{figure}
649 \centerline{
650 \includegraphics[width=6.5cm]{plots/distm}}
651 \caption{A minimum distance matrix for a peptide~\protect\cite{Spoel96b}.}
652 \label{fig:mdmat}
653 \end{figure}
654
655 Plotting these matrices for different time-frames, one can analyze changes 
656 in the structure, and {\eg} forming of salt bridges.
657 \end{description}
658
659 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Root mean square deviations 
660
661 \section{Root mean square deviations in structure}
662 \label{sec:rmsd}
663 {\tt gmx rms, gmx rmsdist}\\
664 The {\em root mean square deviation} ($RMSD$) of certain atoms in a molecule
665 with respect to a reference structure can be calculated with the program 
666 {\tt \normindex{gmx rms}} by least-square fitting the structure to the reference structure
667 ($t_2 = 0$) and subsequently calculating the $RMSD$ (\eqnref{rmsd}).
668 \beq
669 RMSD(t_1,t_2) ~=~ \left[\frac{1}{M} \sum_{i=1}^N m_i \|{\bf r}_i(t_1)-{\bf r}_i(t_2)\|^2 \right]^{\frac{1}{2}}
670 \label{eqn:rmsd}
671 \eeq
672 where $M = \sum_{i=1}^N m_i$ and ${\bf r}_i(t)$ is the position of atom $i$ at time $t$.
673 {\bf Note} that fitting does not have to use the same atoms as the calculation
674 of the $RMSD$; {\eg} a protein is usually fitted on the backbone atoms
675 (N,C$_{\alpha}$,C), but the $RMSD$ can be computed of the backbone
676 or of the whole protein.
677
678 Instead of comparing the structures to the initial structure at time $t=0$ 
679 (so for example a crystal structure), one can also calculate \eqnref{rmsd} 
680 with a structure at time $t_2=t_1-\tau$.
681 This gives some insight in the mobility as a function of $\tau$.
682 A matrix can also be made with the $RMSD$ as a function of $t_1$ and $t_2$,
683 which gives a nice graphical interpretation of a trajectory.
684 If there are transitions in a trajectory, they will clearly show up in
685 such a matrix.
686
687 Alternatively the $RMSD$ can be computed using a fit-free method with the 
688 program {\tt \normindex{gmx rmsdist}}:
689 \beq
690 RMSD(t) ~=~     \left[\frac{1}{N^2}\sum_{i=1}^N \sum_{j=1}^N    \|{\bf r}_{ij}(t)-{\bf r}_{ij}(0)\|^2\right]^{\frac{1}{2}}
691 \label{eqn:rmsdff}
692 \eeq
693 where the {\em distance} {\bf r}$_{ij}$ between atoms at time $t$ 
694 is compared with the distance between the same atoms at time $0$.
695
696 %\ifthenelse{\equal{\gmxlite}{1}}{}{
697 \section{Covariance analysis\index{covariance analysis}}
698 \label{sec:covanal}
699 Covariance analysis, also called
700 \seeindex{principal component analysis}{covariance analysis}
701 or \seeindex{essential dynamics}{covariance analysis}
702 \cite{Amadei93}{,} can find correlated motions.
703 It uses the covariance matrix $C$ of the atomic coordinates:
704 \beq
705 C_{ij} = \left \langle 
706 M_{ii}^{\frac{1}{2}} (x_i - \langle x_i \rangle)
707 M_{jj}^{\frac{1}{2}}  (x_j - \langle x_j \rangle)
708 \right \rangle
709 \eeq
710 where $M$ is a diagonal matrix containing the masses of the atoms
711 (mass-weighted analysis) or the unit matrix (non-mass weighted analysis).
712 $C$ is a symmetric $3N \times 3N$ matrix, which can be diagonalized with
713 an orthonormal transformation matrix $R$:
714 \beq
715 R^T C R = \mbox{diag}(\lambda_1,\lambda_2,\ldots,\lambda_{3N})
716 ~~~~\mbox{where}~~\lambda_1 \geq \lambda_2 \geq \ldots \geq \lambda_{3N}
717 \eeq
718 The columns of $R$ are the eigenvectors, also called principal or
719 essential modes.
720 $R$ defines a transformation to a new coordinate system. The trajectory
721 can be projected on the principal modes to give the principal components
722 $p_i(t)$:
723 \beq
724 {\bf p}(t) = R^T M^{\frac{1}{2}} ({\bf x}(t) - \langle {\bf x} \rangle)
725 \eeq
726 The eigenvalue $\lambda_i$ is the mean square fluctuation of principal
727 component $i$. The first few principal modes often describe 
728 collective, global motions in the system.
729 The trajectory can be filtered along one (or more) principal modes.
730 For one principal mode $i$ this goes as follows:
731 \beq
732 {\bf x}^f(t) =
733 \langle {\bf x} \rangle + M^{-\frac{1}{2}} R_{*i} \, p_i(t)
734 \eeq
735
736 When the analysis is performed on a macromolecule, one often wants to
737 remove the overall rotation and translation to look at the internal motion
738 only. This can be achieved by least square fitting to a reference structure.
739 Care has to be taken that the reference structure is representative for the
740 ensemble, since the choice of reference structure influences the covariance
741 matrix.
742
743 One should always check if the principal modes are well defined.
744 If the first principal component resembles a half cosine and
745 the second resembles a full cosine, you might be filtering noise (see below).
746 A good way to check the relevance of the first few principal
747 modes is to calculate the overlap of the sampling between
748 the first and second half of the simulation.
749 {\bf Note} that this can only be done when the same reference structure is
750 used for the two halves.
751
752 A good measure for the overlap has been defined in~\cite{Hess2002b}.
753 The elements of the covariance matrix are proportional to the square
754 of the displacement, so we need to take the square root of the matrix
755 to examine the extent of sampling. The square root can be
756 calculated from the eigenvalues $\lambda_i$ and the eigenvectors,
757 which are the columns of the rotation matrix $R$.
758 For a symmetric and diagonally-dominant matrix $A$ of size $3N \times 3N$
759 the square root can be calculated as:
760 \beq
761 A^\frac{1}{2} = 
762 R \, \mbox{diag}(\lambda_1^\frac{1}{2},\lambda_2^\frac{1}{2},\ldots,\lambda_{3N}^\frac{1}{2}) \, R^T
763 \eeq
764 It can be verified easily that the product of this matrix with itself gives
765 $A$.
766 Now we can define a difference $d$ between covariance matrices $A$ and $B$
767 as follows:
768 \begin{eqnarray}
769 d(A,B) & = & \sqrt{\mbox{tr}\left(\left(A^\frac{1}{2} - B^\frac{1}{2}\right)^2\right)
770 }
771 \\ & = &
772 \sqrt{\mbox{tr}\left(A + B - 2 A^\frac{1}{2} B^\frac{1}{2}\right)}
773 \\ & = &
774 \left( \sum_{i=1}^N \left( \lambda_i^A + \lambda_i^B \right)
775 - 2 \sum_{i=1}^N \sum_{j=1}^N \sqrt{\lambda_i^A \lambda_j^B}
776 \left(R_i^A \cdot R_j^B\right)^2 \right)^\frac{1}{2}
777 \end{eqnarray}
778 where tr is the trace of a matrix.
779 We can now define the overlap $s$ as:
780 \beq
781 s(A,B) = 1 - \frac{d(A,B)}{\sqrt{\mbox{tr}A + \mbox{tr} B}}
782 \eeq
783 The overlap is 1 if and only if matrices $A$ and $B$ are identical.
784 It is 0 when the sampled subspaces are completely orthogonal.
785
786 A commonly-used measure is the subspace overlap of the first few
787 eigenvectors of covariance matrices.
788 The overlap of the subspace spanned by $m$ orthonormal vectors 
789 ${\bf w}_1,\ldots,{\bf w}_m$ with a reference subspace spanned by 
790 $n$ orthonormal vectors ${\bf v}_1,\ldots,{\bf v}_n$
791 can be quantified as follows:
792 \beq
793 \mbox{overlap}({\bf v},{\bf w}) =
794 \frac{1}{n} \sum_{i=1}^n \sum_{j=1}^m ({\bf v}_i \cdot {\bf w}_j)^2
795 \eeq
796 The overlap will increase with increasing $m$ and will be 1 when
797 set ${\bf v}$ is a subspace of set ${\bf w}$.
798 The disadvantage of this method is that it does not take the eigenvalues
799 into account. All eigenvectors are weighted equally, and when
800 degenerate subspaces are present (equal eigenvalues), the calculated overlap
801 will be too low.
802
803 Another useful check is the cosine content. It has been proven that the
804 the principal components of random diffusion are cosines with the number of
805 periods equal to half the principal component index~\cite{Hess2000,Hess2002b}.
806 The eigenvalues are proportional to the index to the power $-2$.
807 The cosine content is defined as:
808 \beq
809 \frac{2}{T}
810 \left( \int_0^T \cos\left(\frac{i \pi t}{T}\right) \, p_i(t) \mbox{d} t \right)^2
811 \left( \int_0^T p_i^2(t) \mbox{d} t \right)^{-1}
812 \eeq
813 When the cosine content of the first few principal components
814 is close to 1, the largest fluctuations are not connected with
815 the potential, but with random diffusion.
816
817 The covariance matrix is built and diagonalized by
818 {\tt \normindex{gmx covar}}.
819 The principal components and overlap (and many more things)
820 can be plotted and analyzed with {\tt \normindex{gmx anaeig}}.
821 The cosine content can be calculated with {\tt \normindex{gmx analyze}}.
822 %} % Brace matches ifthenelse test for gmxlite
823
824 %\ifthenelse{\equal{\gmxlite}{1}}{}{
825 \section{Dihedral principal component analysis}
826 {\tt gmx angle, gmx covar, gmx anaeig}\\
827 Principal component analysis can be performed in dihedral
828 space~\cite{Mu2005a} using {\gromacs}. You start by defining the
829 dihedral angles of interest in an index file, either using {\tt
830  gmx mk_angndx} or otherwise. Then you use the {\tt gmx angle} program
831 with the {\tt -or} flag to produce a new {\tt .trr} file containing the cosine and
832 sine of each dihedral angle in two coordinates, respectively. That is,
833 in the {\tt .trr} file you will have a series of numbers corresponding to:
834 cos($\phi_1$), sin($\phi_1$), cos($\phi_2$), sin($\phi_2$), ...,
835 cos($\phi_n$), sin($\phi_n$), and the array is padded with zeros, if
836 necessary.  Then you can use this {\tt .trr} file as input for the {\tt
837  gmx covar} program and perform principal component analysis as usual.
838 For this to work you will need to generate a reference file ({\tt .tpr}, 
839 {\tt .gro}, {\tt .pdb} etc.) containing the same number of ``atoms'' 
840 as the new {\tt .trr} file, that is for $n$ dihedrals you need 2$n$/3 atoms 
841 (rounded up if not an integer number). 
842 You should use the {\tt -nofit} option for {\tt
843 gmx covar} since the coordinates in the dummy reference file do not
844 correspond in any way to the information in the {\tt .trr} file. Analysis of
845 the results is done using {\tt gmx anaeig}.
846 %} % Brace matches ifthenelse test for gmxlite
847  
848 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Hydrogen bonds
849
850 \section{Hydrogen bonds}
851 {\tt gmx hbond}\\
852 The program {\tt \normindex{gmx hbond}} analyzes the {\em hydrogen bonds} (H-bonds)
853 between all possible donors D and acceptors A. To determine if an
854 H-bond exists, a geometrical criterion is used, see also
855 \figref{hbond}:
856 \beq
857 \begin{array}{rclcl}
858 r       & \leq  & r_{HB}        & = & 0.35~\mbox{nm}    \\
859 \alpha  & \leq  & \alpha_{HB}   & = & 30^o              \\
860 \end{array}
861 \eeq
862
863 \begin{figure}
864 \centerline{\includegraphics[width=2.5cm,angle=270]{plots/hbond}}
865 \caption{Geometrical Hydrogen bond criterion.}
866 \label{fig:hbond}
867 \end{figure}
868
869 The value of $r_{HB} = 0.35$~nm corresponds to the first minimum of the RDF of 
870 SPC water (see also \figref{rdf}).
871
872 The program {\tt gmx hbond} analyzes all hydrogen bonds existing
873 between two groups of atoms (which must be either identical or
874 non-overlapping) or in specified donor-hydrogen-acceptor triplets, in
875 the following ways:
876
877 \begin{figure}
878 \centerline{
879 {\includegraphics[width=5cm,angle=270]{plots/hbond-insert}}}
880 \caption[Insertion of water into an H-bond.]{Insertion of water into
881 an H-bond. (1) Normal H-bond between two residues. (2) H-bonding
882 bridge via a water molecule.}
883 \label{fig:insert}
884 \end{figure}
885
886 \begin{itemize}
887 \item
888 Donor-Acceptor distance ($r$) distribution of all H-bonds
889 \item
890 Hydrogen-Donor-Acceptor angle ($\alpha$) distribution of all H-bonds 
891 \item
892 The total number of H-bonds in each time frame
893 \item
894 \newcommand{\nn}[1]{$n$-$n$+$#1$}
895 The number of H-bonds in time between residues, divided into groups
896 \nn{i} where $n$ and $n$+$i$ stand for residue numbers and $i$ goes
897 from 0 to 6. The group for $i=6$ also includes all H-bonds for
898 $i>6$. These groups include the \nn{3}, \nn{4} and \nn{5} H-bonds,
899 which provide a measure for the formation of $\alpha$-helices or
900 $\beta$-turns or strands.
901 \item
902 The lifetime of the H-bonds is calculated from the average over all
903 autocorrelation functions of the existence functions (either 0 or 1)
904 of all H-bonds:
905 \beq
906 C(\tau) ~=~ \langle s_i(t)~s_i (t + \tau) \rangle
907 \label{eqn:hbcorr}
908 \eeq
909 with $s_i(t) = \{0,1\}$ for H-bond $i$ at time $t$. The integral of
910 $C(\tau)$ gives a rough estimate of the average H-bond lifetime
911 $\tau_{HB}$:
912 \beq
913 \tau_{HB} ~=~ \int_{0}^{\infty} C(\tau) d\tau
914 \label{eqn:hblife}
915 \eeq
916 Both the integral and the complete autocorrelation function $C(\tau)$
917 will be output, so that more sophisticated analysis ({\eg}\@ using
918 multi-exponential fits) can be used to get better estimates for
919 $\tau_{HB}$. A more complete analysis is given in ref.~\cite{Spoel2006b};
920 one of the more fancy option is the Luzar and Chandler analysis
921 of hydrogen bond kinetics~\cite{Luzar96b,Luzar2000a}. 
922 \item
923 An H-bond existence map can be generated of dimensions {\em
924 \#~H-bonds}$\times${\em \#~frames}. The ordering is identical to the index 
925 file (see below), but reversed, meaning that the last triplet in the index
926 file corresponds to the first row of the existence map.
927 \item
928 Index groups are output containing the analyzed groups, all
929 donor-hydrogen atom pairs and acceptor atoms in these groups,
930 donor-hydrogen-acceptor triplets involved in hydrogen bonds between
931 the analyzed groups and all solvent atoms involved in insertion.
932
933 \end{itemize}
934
935 %\ifthenelse{\equal{\gmxlite}{1}}{}{
936 %
937 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Protein related items 
938
939 \section{Protein-related items}
940 {\tt gmx do_dssp, gmx rama, gmx wheel}\\
941 To analyze structural changes of a protein, you can calculate the radius of 
942 gyration or the minimum residue distances over time 
943 (see \secref{rg}), or calculate the RMSD (\secref{rmsd}).
944
945 You can also look at the changing of {\em secondary structure elements} 
946 during your run. For this, you can use the program {\tt \normindex{gmx do_dssp}}, which is 
947 an interface for the commercial program {\tt DSSP}~\cite{Kabsch83}. For 
948 further information, see the {\tt DSSP} manual. A typical output plot of 
949 {\tt gmx do_dssp} is given in \figref{dssp}.
950
951 \begin{figure}
952 \centerline{
953 \includegraphics[width=12cm]{plots/dssp}}
954 \caption{Analysis of the secondary structure elements of a peptide in time.}
955 \label{fig:dssp}
956 \end{figure}
957
958 One other important analysis of proteins is the so-called 
959 {\em Ramachandran plot}. 
960 This is the projection of the structure on the two dihedral angles $\phi$ and 
961 $\psi$ of the protein backbone, see \figref{phipsi}.
962
963 \begin{figure}
964 \centerline{
965 \includegraphics[width=5cm]{plots/phipsi}}
966 \caption{Definition of the dihedral angles $\phi$ and $\psi$ of the protein backbone.}
967 \label{fig:phipsi}
968 \end{figure}
969
970 To evaluate this Ramachandran plot you can use the program {\tt
971 \normindex{gmx rama}}.
972 A typical output is given in \figref{rama}.
973
974 \begin{figure}
975 \centerline{
976 {\includegraphics[width=8cm]{plots/rama}}}
977 \caption{Ramachandran plot of a small protein.}
978 \label{fig:rama}
979 \end{figure}
980
981 When studying $\alpha$-helices 
982 it is useful to have a {\em helical wheel} projection
983 of your peptide, to see whether a peptide is amphipathic. This can be done
984 using the {\tt \normindex{gmx wheel}} program. Two examples are
985 plotted in \figref{wheel}.
986
987 \begin{figure}
988 \centerline{\includegraphics[width=\htw]{plots/hpr-wheel}}
989 \caption{Helical wheel projection of the N-terminal helix of HPr.}
990 \label{fig:wheel}
991 \end{figure}
992
993 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Membrane Related Items
994
995 \section{Interface-related items}
996 {\tt gmx order, gmx density, gmx potential, gmx traj}\\
997 When simulating molecules with long carbon tails, it can be
998 interesting to calculate their average orientation. There are several
999 flavors of order parameters, most of which are related. The program
1000 {\tt \normindex{gmx order}} can calculate order parameters using the equation:
1001
1002 \begin{equation}
1003 S_{z} = \frac{3}{2}\langle {\cos^2{\theta_z}} \rangle - \frac{1}{2}
1004 \label{eqn:Sgr}
1005 \end{equation}
1006 where $\theta_z$ is the angle between the $z$-axis of the simulation
1007 box and the molecular axis under consideration. The latter is defined as the
1008 vector from C$_{n-1}$ to C$_{n+1}$. The parameters $S_x$
1009 and $S_y$ are defined in the same way. The brackets imply averaging over time
1010 and molecules. Order parameters can vary between 1 (full order along
1011 the interface normal) and $-1/2$ (full order perpendicular to the
1012 normal), with a value of zero in the case of isotropic orientation.
1013
1014 The program can do two things for you. It can calculate the order
1015 parameter for each CH$_2$ segment separately, for any of three axes,
1016 or it can divide the box in slices and calculate the average value of
1017 the order parameter per segment in one slice. The first method gives
1018 an idea of the ordering of a molecule from head to tail, the second
1019 method gives an idea of the ordering as function of the box length.
1020
1021 The electrostatic potential ($\psi$) across the interface can be
1022 computed from a trajectory by evaluating the double integral of the
1023 charge density ($\rho(z)$):
1024 \beq
1025 \psi(z) - \psi(-\infty) = - \int_{-\infty}^z dz' \int_{-\infty}^{z'} \rho(z'')dz''/ \epsilon_0 
1026 \label{eqn:elpotgr}
1027 \eeq
1028 where the position $z=-\infty$ is far enough in the bulk phase such that
1029 the field is zero.  With this method, it is possible to ``split'' the
1030 total potential into separate contributions from lipid and water
1031 molecules. The program {\tt \normindex{gmx potential}} divides the box in slices and
1032 sums all charges of the atoms in each slice. It then integrates this
1033 charge density to give the electric field, which is in turn integrated to
1034 give the potential. Charge density, electric field, and potential are written
1035 to {\tt xvgr} input files.
1036
1037 The program {\tt \normindex{gmx traj}} is a very simple analysis program. All it
1038 does is print the coordinates, velocities, or forces of selected atoms.
1039 It can also calculate the center of mass of one or more
1040 molecules and print the coordinates of the center of mass to three
1041 files. By itself, this is probably not a very useful analysis, but
1042 having the coordinates of selected molecules or atoms can be very
1043 handy for further analysis, not only in interfacial systems.
1044
1045 The program {\tt \normindex{gmx density}} calculates the mass density of
1046 groups and gives a plot of the density against a box
1047 axis. This is useful for looking at the distribution of groups or
1048 atoms across the interface.
1049
1050 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chemical shifts
1051
1052 % \section{Chemical shifts}
1053 % {\tt total, do_shift}\\
1054 % You can compute the NMR chemical shifts of protons with the program
1055 % {\tt \normindex{do_shift}}. This is just an {\gromacs} interface to
1056 % the public domain program {\tt total}~\cite{Williamson93a}. For
1057 % further information, read the article. Although there is limited
1058 % support for this in {\gromacs}, users are encouraged to use the
1059 % software provided by David Case's group at Scripps because it seems
1060 % to be more up-to-date.
1061
1062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1063 %} % Brace matches ifthenelse test for gmxlite
1064
1065 % LocalWords:  Xmgr ndx mk angndx rdf dihedrals grompp hydrogens MainChain Prot
1066 % LocalWords:  oxygens SideChain tryptophan vsitetop aminoacids dat ngmx dr SPC
1067 % LocalWords:  OO ACF fg xmgr corrmd ACFs kM iM FFT th NMR nd corrleg rotacf dt
1068 % LocalWords:  velacc Kubo msd Tildesley corrtime msdwater sgangle cis dih xpm
1069 % LocalWords:  mindist mdmat rms rmsdist rmsd jj diag eigenvectors covar anaeig
1070 % LocalWords:  macromolecule trr tpr gro pdb nofit hbond rclcl HB multi Luzar
1071 % LocalWords:  dssp rama xrama rg Ramachandran phipsi amphipathic HPr xvgr pvd
1072 % LocalWords:  Scripps RDF online usinggroups mdrun groupconcept HOH
1073 % LocalWords:  residuetypes determinding OpenGL traj ov rcl ij ps nm
1074 % LocalWords:  autocorrelation interfacial