ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/oopsePaper/oopsePaper.tex
Revision: 1121
Committed: Mon Apr 19 21:00:24 2004 UTC (20 years, 2 months ago) by mmeineke
Content type: application/x-tex
File size: 98240 byte(s)
Log Message:
Just copied over the changes from the dissertation.
Also converted the figures to pdf.
All revisions now take place on the oopsePaper.tex file

File Contents

# User Rev Content
1 mmeineke 1121 \documentclass[11pt]{article}
2     \usepackage{amsmath}
3     \usepackage{amssymb}
4     \usepackage{endfloat}
5     %\usepackage{berkeley}
6     \usepackage{listings}
7     \usepackage{graphicx}
8     \usepackage[ref]{overcite}
9     \usepackage{setspace}
10     \usepackage{tabularx}
11     \pagestyle{plain}
12     \pagenumbering{arabic}
13     \oddsidemargin 0.0cm \evensidemargin 0.0cm
14     \topmargin -21pt \headsep 10pt
15     \textheight 9.0in \textwidth 6.5in
16     \brokenpenalty=10000
17     \renewcommand{\baselinestretch}{1.2}
18     \renewcommand\citemid{\ } % no comma in optional reference note
19    
20     \begin{document}
21     \lstset{language=C,float,frame=tblr,frameround=tttt}
22     \renewcommand{\lstlistingname}{Scheme}
23     \title{{\sc oopse}: An Open Source Object-Oriented Parallel Simulation
24     Engine for Molecular Dynamics}
25    
26     \author{Matthew A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher J. Fennell and J. Daniel Gezelter\\
27     Department of Chemistry and Biochemistry\\
28     University of Notre Dame\\
29     Notre Dame, Indiana 46556}
30    
31     \date{\today}
32     \maketitle
33    
34     \begin{abstract}
35     We detail the capabilities of a new open-source parallel simulation
36     package ({\sc oopse}) that can perform molecular dynamics simulations
37     on atom types that are missing from other popular packages. In
38     particular, {\sc oopse} is capable of performing orientational
39     dynamics on dipolar systems, and it can handle simulations of metallic
40     systems using the embedded atom method ({\sc eam}).
41     \end{abstract}
42    
43     \section{\label{sec:intro}Introduction}
44    
45     When choosing to simulate a chemical system with molecular dynamics,
46     there are a variety of options available. For simple systems, one
47     might consider writing one's own programming code. However, as systems
48     grow larger and more complex, building and maintaining code for the
49     simulations becomes a time consuming task. In such cases it is usually
50     more convenient for a researcher to turn to pre-existing simulation
51     packages. These packages, such as {\sc amber}\cite{pearlman:1995} and
52     {\sc charmm}\cite{Brooks83}, provide powerful tools for researchers to
53     conduct simulations of their systems without spending their time
54     developing a code base to conduct their research. This then frees them
55     to perhaps explore experimental analogues to their models.
56    
57     Despite their utility, problems with these packages arise when
58     researchers try to develop techniques or energetic models that the
59     code was not originally designed to simulate. Examples of techniques
60     and energetics not commonly implemented include; dipole-dipole
61     interactions, rigid body dynamics, and metallic potentials. When faced
62     with these obstacles, a researcher must either develop their own code
63     or license and extend one of the commercial packages. What we have
64     elected to do is develop a body of simulation code capable of
65     implementing the types of models upon which our research is based.
66    
67     In developing {\sc oopse}, we have adhered to the precepts of Open
68     Source development, and are releasing our source code with a
69     permissive license. It is our intent that by doing so, other
70     researchers might benefit from our work, and add their own
71     contributions to the package. The license under which {\sc oopse} is
72     distributed allows any researcher to download and modify the source
73     code for their own use. In this way further development of {\sc oopse}
74     is not limited to only the models of interest to ourselves, but also
75     those of the community of scientists who contribute back to the
76     project.
77    
78     We have structured this chapter to first discuss the empirical energy
79     functions that {\sc oopse } implements in
80     Sec.~\ref{oopseSec:empiricalEnergy}. Following that is a discussion of
81     the various input and output files associated with the package
82     (Sec.~\ref{oopseSec:IOfiles}). Sec.~\ref{oopseSec:mechanics}
83     elucidates the various Molecular Dynamics algorithms {\sc oopse}
84     implements in the integration of the Newtonian equations of
85     motion. Basic analysis of the trajectories obtained from the
86     simulation is discussed in Sec.~\ref{oopseSec:props}. Program design
87     considerations are presented in Sec.~\ref{oopseSec:design}. And
88     lastly, Sec.~\ref{oopseSec:conclusion} concludes the chapter.
89    
90     \section{\label{oopseSec:empiricalEnergy}The Empirical Energy Functions}
91    
92     \subsection{\label{oopseSec:atomsMolecules}Atoms, Molecules and Rigid Bodies}
93    
94     The basic unit of an {\sc oopse} simulation is the atom. The
95     parameters describing the atom are generalized to make the atom as
96     flexible a representation as possible. They may represent specific
97     atoms of an element, or be used for collections of atoms such as
98     methyl and carbonyl groups. The atoms are also capable of having
99     directional components associated with them (\emph{e.g.}~permanent
100     dipoles). Charges, permanent dipoles, and Lennard-Jones parameters for
101     a given atom type are set in the force field parameter files.
102    
103     \begin{lstlisting}[float,caption={[Specifier for molecules and atoms] A sample specification of an Ar molecule},label=sch:AtmMole]
104     molecule{
105     name = "Ar";
106     nAtoms = 1;
107     atom[0]{
108     type="Ar";
109     position( 0.0, 0.0, 0.0 );
110     }
111     }
112     \end{lstlisting}
113    
114    
115     Atoms can be collected into secondary structures such as rigid bodies
116     or molecules. The molecule is a way for {\sc oopse} to keep track of
117     the atoms in a simulation in logical manner. Molecular units store the
118     identities of all the atoms and rigid bodies associated with
119     themselves, and are responsible for the evaluation of their own
120     internal interactions (\emph{i.e.}~bonds, bends, and torsions). Scheme
121     \ref{sch:AtmMole} shows how one creates a molecule in a ``model'' or
122     \texttt{.mdl} file. The position of the atoms given in the
123     declaration are relative to the origin of the molecule, and is used
124     when creating a system containing the molecule.
125    
126     As stated previously, one of the features that sets {\sc oopse} apart
127     from most of the current molecular simulation packages is the ability
128     to handle rigid body dynamics. Rigid bodies are non-spherical
129     particles or collections of particles that have a constant internal
130     potential and move collectively.\cite{Goldstein01} They are not
131     included in most simulation packages because of the algorithmic
132     complexity involved in propagating orientational degrees of
133     freedom. Until recently, integrators which propagate orientational
134     motion have been much worse than those available for translational
135     motion.
136    
137     Moving a rigid body involves determination of both the force and
138     torque applied by the surroundings, which directly affect the
139     translational and rotational motion in turn. In order to accumulate
140     the total force on a rigid body, the external forces and torques must
141     first be calculated for all the internal particles. The total force on
142     the rigid body is simply the sum of these external forces.
143     Accumulation of the total torque on the rigid body is more complex
144     than the force because the torque is applied to the center of mass of
145     the rigid body. The torque on rigid body $i$ is
146     \begin{equation}
147     \boldsymbol{\tau}_i=
148     \sum_{a}\biggl[(\mathbf{r}_{ia}-\mathbf{r}_i)\times \mathbf{f}_{ia}
149     + \boldsymbol{\tau}_{ia}\biggr],
150     \label{eq:torqueAccumulate}
151     \end{equation}
152     where $\boldsymbol{\tau}_i$ and $\mathbf{r}_i$ are the torque on and
153     position of the center of mass respectively, while $\mathbf{f}_{ia}$,
154     $\mathbf{r}_{ia}$, and $\boldsymbol{\tau}_{ia}$ are the force on,
155     position of, and torque on the component particles of the rigid body.
156    
157     The summation of the total torque is done in the body fixed axis of
158     each rigid body. In order to move between the space fixed and body
159     fixed coordinate axes, parameters describing the orientation must be
160     maintained for each rigid body. At a minimum, the rotation matrix
161     ($\mathsf{A}$) can be described by the three Euler angles ($\phi,
162     \theta,$ and $\psi$), where the elements of $\mathsf{A}$ are composed of
163     trigonometric operations involving $\phi, \theta,$ and
164     $\psi$.\cite{Goldstein01} In order to avoid numerical instabilities
165     inherent in using the Euler angles, the four parameter ``quaternion''
166     scheme is often used. The elements of $\mathsf{A}$ can be expressed as
167     arithmetic operations involving the four quaternions ($q_0, q_1, q_2,$
168     and $q_3$).\cite{allen87:csl} Use of quaternions also leads to
169     performance enhancements, particularly for very small
170     systems.\cite{Evans77}
171    
172     {\sc oopse} utilizes a relatively new scheme that propagates the
173     entire nine parameter rotation matrix. Further discussion
174     on this choice can be found in Sec.~\ref{oopseSec:integrate}. An example
175     definition of a rigid body can be seen in Scheme
176     \ref{sch:rigidBody}. The positions in the atom definitions are the
177     placements of the atoms relative to the origin of the rigid body,
178     which itself has a position relative to the origin of the molecule.
179    
180     \begin{lstlisting}[float,caption={[Defining rigid bodies]A sample definition of a rigid body},label={sch:rigidBody}]
181     molecule{
182     name = "TIP3P";
183     nAtoms = 3;
184     atom[0]{
185     type = "O_TIP3P";
186     position( 0.0, 0.0, -0.06556 );
187     }
188     atom[1]{
189     type = "H_TIP3P";
190     position( 0.0, 0.75695, 0.52032 );
191     }
192     atom[2]{
193     type = "H_TIP3P";
194     position( 0.0, -0.75695, 0.52032 );
195     }
196    
197     nRigidBodies = 1;
198     rigidBody[0]{
199     nMembers = 3;
200     members(0, 1, 2);
201     }
202     }
203     \end{lstlisting}
204    
205     \subsection{\label{sec:LJPot}The Lennard Jones Force Field}
206    
207     The most basic force field implemented in {\sc oopse} is the
208     Lennard-Jones force field, which mimics the van der Waals interaction at
209     long distances, and uses an empirical repulsion at short
210     distances. The Lennard-Jones potential is given by:
211     \begin{equation}
212     V_{\text{LJ}}(r_{ij}) =
213     4\epsilon_{ij} \biggl[
214     \biggl(\frac{\sigma_{ij}}{r_{ij}}\biggr)^{12}
215     - \biggl(\frac{\sigma_{ij}}{r_{ij}}\biggr)^{6}
216     \biggr],
217     \label{eq:lennardJonesPot}
218     \end{equation}
219     where $r_{ij}$ is the distance between particles $i$ and $j$,
220     $\sigma_{ij}$ scales the length of the interaction, and
221     $\epsilon_{ij}$ scales the well depth of the potential. Scheme
222     \ref{sch:LJFF} gives an example \texttt{.bass} file that
223     sets up a system of 108 Ar particles to be simulated using the
224     Lennard-Jones force field.
225    
226     \begin{lstlisting}[float,caption={[Invocation of the Lennard-Jones force field] A sample system using the Lennard-Jones force field.},label={sch:LJFF}]
227    
228     #include "argon.mdl"
229    
230     nComponents = 1;
231     component{
232     type = "Ar";
233     nMol = 108;
234     }
235    
236     initialConfig = "./argon.init";
237    
238     forceField = "LJ";
239     \end{lstlisting}
240    
241     Because this potential is calculated between all pairs, the force
242     evaluation can become computationally expensive for large systems. To
243     keep the pair evaluations to a manageable number, {\sc oopse} employs
244     a cut-off radius.\cite{allen87:csl} The cutoff radius can either be
245     specified in the \texttt{.bass} file, or left as its default value of
246     $2.5\sigma_{ii}$, where $\sigma_{ii}$ is the largest Lennard-Jones
247     length parameter present in the simulation. Truncating the calculation
248     at $r_{\text{cut}}$ introduces a discontinuity into the potential
249     energy and the force. To offset this discontinuity in the potential,
250     the energy value at $r_{\text{cut}}$ is subtracted from the
251     potential. This causes the potential to go to zero smoothly at the
252     cut-off radius, and preserves conservation of energy in integrating
253     the equations of motion. There still remains a discontinuity in the derivative (the forces), however, this does not significantly affect the dynamics.
254    
255     Interactions between dissimilar particles requires the generation of
256     cross term parameters for $\sigma$ and $\epsilon$. These are
257     calculated through the Lorentz-Berthelot mixing
258     rules:\cite{allen87:csl}
259     \begin{equation}
260     \sigma_{ij} = \frac{1}{2}[\sigma_{ii} + \sigma_{jj}],
261     \label{eq:sigmaMix}
262     \end{equation}
263     and
264     \begin{equation}
265     \epsilon_{ij} = \sqrt{\epsilon_{ii} \epsilon_{jj}}.
266     \label{eq:epsilonMix}
267     \end{equation}
268    
269     \subsection{\label{oopseSec:DUFF}Dipolar Unified-Atom Force Field}
270    
271     The dipolar unified-atom force field ({\sc duff}) was developed to
272     simulate lipid bilayers. The simulations require a model capable of
273     forming bilayers, while still being sufficiently computationally
274     efficient to allow large systems ($\sim$100's of phospholipids,
275     $\sim$1000's of waters) to be simulated for long times
276     ($\sim$10's of nanoseconds).
277    
278     With this goal in mind, {\sc duff} has no point
279     charges. Charge-neutral distributions were replaced with dipoles,
280     while most atoms and groups of atoms were reduced to Lennard-Jones
281     interaction sites. This simplification cuts the length scale of long
282     range interactions from $\frac{1}{r}$ to $\frac{1}{r^3}$, and allows
283     us to avoid the computationally expensive Ewald sum. Instead, we can
284     use neighbor-lists and cutoff radii for the dipolar interactions, or
285     include a reaction field to mimic larger range interactions.
286    
287     As an example, lipid head-groups in {\sc duff} are represented as
288     point dipole interaction sites. By placing a dipole at the head
289     group's center of mass, our model mimics the charge separation found
290     in common phospholipid head groups such as
291     phosphatidylcholine.\cite{Cevc87} Additionally, a large Lennard-Jones
292     site is located at the pseudoatom's center of mass. The model is
293     illustrated by the red atom in Fig.~\ref{oopseFig:lipidModel}. The
294     water model we use to complement the dipoles of the lipids is our
295     reparameterization of the soft sticky dipole (SSD) model of Ichiye
296     \emph{et al.}\cite{liu96:new_model}
297    
298     \begin{figure}
299     \centering
300     \includegraphics[width=\linewidth]{twoChainFig.pdf}
301     \caption[A representation of a lipid model in {\sc duff}]{A representation of the lipid model. $\phi$ is the torsion angle, $\theta$ %
302     is the bend angle, and $\mu$ is the dipole moment of the head group.}
303     \label{oopseFig:lipidModel}
304     \end{figure}
305    
306     We have used a set of scalable parameters to model the alkyl groups
307     with Lennard-Jones sites. For this, we have borrowed parameters from
308     the TraPPE force field of Siepmann
309     \emph{et al}.\cite{Siepmann1998} TraPPE is a unified-atom
310     representation of n-alkanes, which is parametrized against phase
311     equilibria using Gibbs ensemble Monte Carlo simulation
312     techniques.\cite{Siepmann1998} One of the advantages of TraPPE is that
313     it generalizes the types of atoms in an alkyl chain to keep the number
314     of pseudoatoms to a minimum; the parameters for a unified atom such as
315     $\text{CH}_2$ do not change depending on what species are bonded to
316     it.
317    
318     TraPPE also constrains all bonds to be of fixed length. Typically,
319     bond vibrations are the fastest motions in a molecular dynamic
320     simulation. Small time steps between force evaluations must be used to
321     ensure adequate energy conservation in the bond degrees of freedom. By
322     constraining the bond lengths, larger time steps may be used when
323     integrating the equations of motion. A simulation using {\sc duff} is
324     illustrated in Scheme \ref{sch:DUFF}.
325    
326     \begin{lstlisting}[float,caption={[Invocation of {\sc duff}]A portion of a \texttt{.bass} file showing a simulation utilizing {\sc duff}},label={sch:DUFF}]
327    
328     #include "water.mdl"
329     #include "lipid.mdl"
330    
331     nComponents = 2;
332     component{
333     type = "simpleLipid_16";
334     nMol = 60;
335     }
336    
337     component{
338     type = "SSD_water";
339     nMol = 1936;
340     }
341    
342     initialConfig = "bilayer.init";
343    
344     forceField = "DUFF";
345    
346     \end{lstlisting}
347    
348     \subsection{\label{oopseSec:energyFunctions}{\sc duff} Energy Functions}
349    
350     The total potential energy function in {\sc duff} is
351     \begin{equation}
352     V = \sum^{N}_{I=1} V^{I}_{\text{Internal}}
353     + \sum^{N-1}_{I=1} \sum_{J>I} V^{IJ}_{\text{Cross}},
354     \label{eq:totalPotential}
355     \end{equation}
356     where $V^{I}_{\text{Internal}}$ is the internal potential of molecule $I$:
357     \begin{equation}
358     V^{I}_{\text{Internal}} =
359     \sum_{\theta_{ijk} \in I} V_{\text{bend}}(\theta_{ijk})
360     + \sum_{\phi_{ijkl} \in I} V_{\text{torsion}}(\phi_{ijkl})
361     + \sum_{i \in I} \sum_{(j>i+4) \in I}
362     \biggl[ V_{\text{LJ}}(r_{ij}) + V_{\text{dipole}}
363     (\mathbf{r}_{ij},\boldsymbol{\Omega}_{i},\boldsymbol{\Omega}_{j})
364     \biggr].
365     \label{eq:internalPotential}
366     \end{equation}
367     Here $V_{\text{bend}}$ is the bend potential for all 1, 3 bonded pairs
368     within the molecule $I$, and $V_{\text{torsion}}$ is the torsion potential
369     for all 1, 4 bonded pairs. The pairwise portions of the internal
370     potential are excluded for atom pairs that are involved in the same bond, bend, or torsion. All other atom pairs within the molecule are subject to the LJ pair potential.
371    
372    
373     The bend potential of a molecule is represented by the following function:
374     \begin{equation}
375     V_{\text{bend}}(\theta_{ijk}) = k_{\theta}( \theta_{ijk} - \theta_0 )^2, \label{eq:bendPot}
376     \end{equation}
377     where $\theta_{ijk}$ is the angle defined by atoms $i$, $j$, and $k$
378     (see Fig.~\ref{oopseFig:lipidModel}), $\theta_0$ is the equilibrium
379     bond angle, and $k_{\theta}$ is the force constant which determines the
380     strength of the harmonic bend. The parameters for $k_{\theta}$ and
381     $\theta_0$ are borrowed from those in TraPPE.\cite{Siepmann1998}
382    
383     The torsion potential and parameters are also borrowed from TraPPE. It is
384     of the form:
385     \begin{equation}
386     V_{\text{torsion}}(\phi) = c_1[1 + \cos \phi]
387     + c_2[1 + \cos(2\phi)]
388     + c_3[1 + \cos(3\phi)],
389     \label{eq:origTorsionPot}
390     \end{equation}
391     where:
392     \begin{equation}
393     \cos\phi = (\hat{\mathbf{r}}_{ij} \times \hat{\mathbf{r}}_{jk}) \cdot
394     (\hat{\mathbf{r}}_{jk} \times \hat{\mathbf{r}}_{kl}).
395     \label{eq:torsPhi}
396     \end{equation}
397     Here, $\hat{\mathbf{r}}_{\alpha\beta}$ are the set of unit bond
398     vectors between atoms $i$, $j$, $k$, and $l$. For computational
399     efficiency, the torsion potential has been recast after the method of
400     {\sc charmm},\cite{Brooks83} in which the angle series is converted to
401     a power series of the form:
402     \begin{equation}
403     V_{\text{torsion}}(\phi) =
404     k_3 \cos^3 \phi + k_2 \cos^2 \phi + k_1 \cos \phi + k_0,
405     \label{eq:torsionPot}
406     \end{equation}
407     where:
408     \begin{align*}
409     k_0 &= c_1 + c_3, \\
410     k_1 &= c_1 - 3c_3, \\
411     k_2 &= 2 c_2, \\
412     k_3 &= 4c_3.
413     \end{align*}
414     By recasting the potential as a power series, repeated trigonometric
415     evaluations are avoided during the calculation of the potential energy.
416    
417    
418     The cross potential between molecules $I$ and $J$, $V^{IJ}_{\text{Cross}}$, is
419     as follows:
420     \begin{equation}
421     V^{IJ}_{\text{Cross}} =
422     \sum_{i \in I} \sum_{j \in J}
423     \biggl[ V_{\text{LJ}}(r_{ij}) + V_{\text{dipole}}
424     (\mathbf{r}_{ij},\boldsymbol{\Omega}_{i},\boldsymbol{\Omega}_{j})
425     + V_{\text{sticky}}
426     (\mathbf{r}_{ij},\boldsymbol{\Omega}_{i},\boldsymbol{\Omega}_{j})
427     \biggr],
428     \label{eq:crossPotentail}
429     \end{equation}
430     where $V_{\text{LJ}}$ is the Lennard Jones potential,
431     $V_{\text{dipole}}$ is the dipole dipole potential, and
432     $V_{\text{sticky}}$ is the sticky potential defined by the SSD model
433     (Sec.~\ref{oopseSec:SSD}). Note that not all atom types include all
434     interactions.
435    
436     The dipole-dipole potential has the following form:
437     \begin{equation}
438     V_{\text{dipole}}(\mathbf{r}_{ij},\boldsymbol{\Omega}_{i},
439     \boldsymbol{\Omega}_{j}) = \frac{|\mu_i||\mu_j|}{4\pi\epsilon_{0}r_{ij}^{3}} \biggl[
440     \boldsymbol{\hat{u}}_{i} \cdot \boldsymbol{\hat{u}}_{j}
441     -
442     3(\boldsymbol{\hat{u}}_i \cdot \hat{\mathbf{r}}_{ij}) %
443     (\boldsymbol{\hat{u}}_j \cdot \hat{\mathbf{r}}_{ij}) \biggr].
444     \label{eq:dipolePot}
445     \end{equation}
446     Here $\mathbf{r}_{ij}$ is the vector starting at atom $i$ pointing
447     towards $j$, and $\boldsymbol{\Omega}_i$ and $\boldsymbol{\Omega}_j$
448     are the orientational degrees of freedom for atoms $i$ and $j$
449     respectively. $|\mu_i|$ is the magnitude of the dipole moment of atom
450     $i$, $\boldsymbol{\hat{u}}_i$ is the standard unit orientation vector
451     of $\boldsymbol{\Omega}_i$, and $\boldsymbol{\hat{r}}_{ij}$ is the
452     unit vector pointing along $\mathbf{r}_{ij}$
453     ($\boldsymbol{\hat{r}}_{ij}=\mathbf{r}_{ij}/|\mathbf{r}_{ij}|$).
454    
455     To improve computational efficiency of the dipole-dipole interactions,
456     {\sc oopse} employs an electrostatic cutoff radius. This parameter can
457     be set in the \texttt{.bass} file, and controls the length scale over
458     which dipole interactions are felt. To compensate for the
459     discontinuity in the potential and the forces at the cutoff radius, we
460     have implemented a switching function to smoothly scale the
461     dipole-dipole interaction at the cutoff.
462     \begin{equation}
463     S(r_{ij}) =
464     \begin{cases}
465     1 & \text{if $r_{ij} \le r_t$},\\
466     \frac{(r_{\text{cut}} + 2r_{ij} - 3r_t)(r_{\text{cut}} - r_{ij})^2}
467     {(r_{\text{cut}} - r_t)^2}
468     & \text{if $r_t < r_{ij} \le r_{\text{cut}}$}, \\
469     0 & \text{if $r_{ij} > r_{\text{cut}}$.}
470     \end{cases}
471     \label{eq:dipoleSwitching}
472     \end{equation}
473     Here $S(r_{ij})$ scales the potential at a given $r_{ij}$, and $r_t$
474     is the taper radius some given thickness less than the electrostatic
475     cutoff. The switching thickness can be set in the \texttt{.bass} file.
476    
477     \subsection{\label{oopseSec:SSD}The {\sc duff} Water Models: SSD/E and SSD/RF}
478    
479     In the interest of computational efficiency, the default solvent used
480     by {\sc oopse} is the extended Soft Sticky Dipole (SSD/E) water
481     model.\cite{fennell04} The original SSD was developed by Ichiye
482     \emph{et al.}\cite{liu96:new_model} as a modified form of the hard-sphere
483     water model proposed by Bratko, Blum, and
484     Luzar.\cite{Bratko85,Bratko95} It consists of a single point dipole
485     with a Lennard-Jones core and a sticky potential that directs the
486     particles to assume the proper hydrogen bond orientation in the first
487     solvation shell. Thus, the interaction between two SSD water molecules
488     \emph{i} and \emph{j} is given by the potential
489     \begin{equation}
490     V_{ij} =
491     V_{ij}^{LJ} (r_{ij})\ + V_{ij}^{dp}
492     (\mathbf{r}_{ij},\boldsymbol{\Omega}_i,\boldsymbol{\Omega}_j)\ +
493     V_{ij}^{sp}
494     (\mathbf{r}_{ij},\boldsymbol{\Omega}_i,\boldsymbol{\Omega}_j),
495     \label{eq:ssdPot}
496     \end{equation}
497     where the $\mathbf{r}_{ij}$ is the position vector between molecules
498     \emph{i} and \emph{j} with magnitude equal to the distance $r_{ij}$, and
499     $\boldsymbol{\Omega}_i$ and $\boldsymbol{\Omega}_j$ represent the
500     orientations of the respective molecules. The Lennard-Jones and dipole
501     parts of the potential are given by equations \ref{eq:lennardJonesPot}
502     and \ref{eq:dipolePot} respectively. The sticky part is described by
503     the following,
504     \begin{equation}
505     u_{ij}^{sp}(\mathbf{r}_{ij},\boldsymbol{\Omega}_i,\boldsymbol{\Omega}_j)=
506     \frac{\nu_0}{2}[s(r_{ij})w(\mathbf{r}_{ij},
507     \boldsymbol{\Omega}_i,\boldsymbol{\Omega}_j) +
508     s^\prime(r_{ij})w^\prime(\mathbf{r}_{ij},
509     \boldsymbol{\Omega}_i,\boldsymbol{\Omega}_j)]\ ,
510     \label{eq:stickyPot}
511     \end{equation}
512     where $\nu_0$ is a strength parameter for the sticky potential, and
513     $s$ and $s^\prime$ are cubic switching functions which turn off the
514     sticky interaction beyond the first solvation shell. The $w$ function
515     can be thought of as an attractive potential with tetrahedral
516     geometry:
517     \begin{equation}
518     w({\bf r}_{ij},{\bf \Omega}_i,{\bf \Omega}_j)=
519     \sin\theta_{ij}\sin2\theta_{ij}\cos2\phi_{ij},
520     \label{eq:stickyW}
521     \end{equation}
522     while the $w^\prime$ function counters the normal aligned and
523     anti-aligned structures favored by point dipoles:
524     \begin{equation}
525     w^\prime({\bf r}_{ij},{\bf \Omega}_i,{\bf \Omega}_j)=
526     (\cos\theta_{ij}-0.6)^2(\cos\theta_{ij}+0.8)^2-w^0,
527     \label{eq:stickyWprime}
528     \end{equation}
529     It should be noted that $w$ is proportional to the sum of the $Y_3^2$
530     and $Y_3^{-2}$ spherical harmonics (a linear combination which
531     enhances the tetrahedral geometry for hydrogen bonded structures),
532     while $w^\prime$ is a purely empirical function. A more detailed
533     description of the functional parts and variables in this potential
534     can be found in the original SSD
535     articles.\cite{liu96:new_model,liu96:monte_carlo,chandra99:ssd_md,Ichiye03}
536    
537     Since SSD/E is a single-point {\it dipolar} model, the force
538     calculations are simplified significantly relative to the standard
539     {\it charged} multi-point models. In the original Monte Carlo
540     simulations using this model, Ichiye {\it et al.} reported that using
541     SSD decreased computer time by a factor of 6-7 compared to other
542     models.\cite{liu96:new_model} What is most impressive is that these savings
543     did not come at the expense of accurate depiction of the liquid state
544     properties. Indeed, SSD/E maintains reasonable agreement with the Head-Gordon
545     diffraction data for the structural features of liquid
546     water.\cite{hura00,liu96:new_model} Additionally, the dynamical properties
547     exhibited by SSD/E agree with experiment better than those of more
548     computationally expensive models (like TIP3P and
549     SPC/E).\cite{chandra99:ssd_md} The combination of speed and accurate depiction
550     of solvent properties makes SSD/E a very attractive model for the
551     simulation of large scale biochemical simulations.
552    
553     Recent constant pressure simulations revealed issues in the original
554     SSD model that led to lower than expected densities at all target
555     pressures.\cite{Ichiye03,fennell04} The default model in {\sc oopse}
556     is therefore SSD/E, a density corrected derivative of SSD that
557     exhibits improved liquid structure and transport behavior. If the use
558     of a reaction field long-range interaction correction is desired, it
559     is recommended that the parameters be modified to those of the SSD/RF
560     model (an SSD variant parameterized for reaction field). Solvent parameters can be easily modified in an accompanying
561     \texttt{.bass} file as illustrated in the scheme below. A table of the
562     parameter values and the drawbacks and benefits of the different
563     density corrected SSD models can be found in
564     reference~\cite{fennell04}.
565    
566     \begin{lstlisting}[float,caption={[A simulation of {\sc ssd} water]A portion of a \texttt{.bass} file showing a simulation including {\sc ssd} water.},label={sch:ssd}]
567    
568     #include "water.mdl"
569    
570     nComponents = 1;
571     component{
572     type = "SSD_water";
573     nMol = 864;
574     }
575    
576     initialConfig = "liquidWater.init";
577    
578     forceField = "DUFF";
579    
580     /*
581     * The following two flags set the cutoff
582     * radius for the electrostatic forces
583     * as well as the skin thickness of the switching
584     * function.
585     */
586    
587     electrostaticCutoffRadius = 9.2;
588     electrostaticSkinThickness = 1.38;
589    
590     \end{lstlisting}
591    
592    
593     \subsection{\label{oopseSec:eam}Embedded Atom Method}
594    
595     There are Molecular Dynamics packages which have the
596     capacity to simulate metallic systems, including some that have
597     parallel computational abilities\cite{plimpton93}. Potentials that
598     describe bonding transition metal
599     systems\cite{Finnis84,Ercolessi88,Chen90,Qi99,Ercolessi02} have an
600     attractive interaction which models ``Embedding''
601     a positively charged metal ion in the electron density due to the
602     free valance ``sea'' of electrons created by the surrounding atoms in
603     the system. A mostly-repulsive pairwise part of the potential
604     describes the interaction of the positively charged metal core ions
605     with one another. A particular potential description called the
606     Embedded Atom Method\cite{Daw84,FBD86,johnson89,Lu97}({\sc eam}) that has
607     particularly wide adoption has been selected for inclusion in {\sc oopse}. A
608     good review of {\sc eam} and other metallic potential formulations was written
609     by Voter.\cite{voter}
610    
611     The {\sc eam} potential has the form:
612     \begin{eqnarray}
613     V & = & \sum_{i} F_{i}\left[\rho_{i}\right] + \sum_{i} \sum_{j \neq i}
614     \phi_{ij}({\bf r}_{ij}), \\
615     \rho_{i} & = & \sum_{j \neq i} f_{j}({\bf r}_{ij}),
616     \end{eqnarray}
617     where $F_{i} $ is the embedding function that equates the energy
618     required to embed a positively-charged core ion $i$ into a linear
619     superposition of spherically averaged atomic electron densities given
620     by $\rho_{i}$. $\phi_{ij}$ is a primarily repulsive pairwise
621     interaction between atoms $i$ and $j$. In the original formulation of
622     {\sc eam}\cite{Daw84}, $\phi_{ij}$ was an entirely repulsive term,
623     however in later refinements to {\sc eam} have shown that non-uniqueness
624     between $F$ and $\phi$ allow for more general forms for
625     $\phi$.\cite{Daw89} There is a cutoff distance, $r_{cut}$, which
626     limits the summations in the {\sc eam} equation to the few dozen atoms
627     surrounding atom $i$ for both the density $\rho$ and pairwise $\phi$
628     interactions. Foiles \emph{et al}.~fit {\sc eam} potentials for the fcc
629     metals Cu, Ag, Au, Ni, Pd, Pt and alloys of these metals.\cite{FBD86}
630     These fits are included in {\sc oopse}.
631    
632     \subsection{\label{oopseSec:pbc}Periodic Boundary Conditions}
633    
634     \newcommand{\roundme}{\operatorname{round}}
635    
636     \textit{Periodic boundary conditions} are widely used to simulate bulk properties with a relatively small number of particles. The
637     simulation box is replicated throughout space to form an infinite
638     lattice. During the simulation, when a particle moves in the primary
639     cell, its image in other cells move in exactly the same direction with
640     exactly the same orientation. Thus, as a particle leaves the primary
641     cell, one of its images will enter through the opposite face. If the
642     simulation box is large enough to avoid ``feeling'' the symmetries of
643     the periodic lattice, surface effects can be ignored. The available
644     periodic cells in OOPSE are cubic, orthorhombic and parallelepiped. We
645     use a $3 \times 3$ matrix, $\mathsf{H}$, to describe the shape and
646     size of the simulation box. $\mathsf{H}$ is defined:
647     \begin{equation}
648     \mathsf{H} = ( \mathbf{h}_x, \mathbf{h}_y, \mathbf{h}_z ),
649     \end{equation}
650     where $\mathbf{h}_{\alpha}$ is the column vector of the $\alpha$ axis of the
651     box. During the course of the simulation both the size and shape of
652     the box can be changed to allow volume fluctuations when constraining
653     the pressure.
654    
655     A real space vector, $\mathbf{r}$ can be transformed in to a box space
656     vector, $\mathbf{s}$, and back through the following transformations:
657     \begin{align}
658     \mathbf{s} &= \mathsf{H}^{-1} \mathbf{r}, \\
659     \mathbf{r} &= \mathsf{H} \mathbf{s}.
660     \end{align}
661     The vector $\mathbf{s}$ is now a vector expressed as the number of box
662     lengths in the $\mathbf{h}_x$, $\mathbf{h}_y$, and $\mathbf{h}_z$
663     directions. To find the minimum image of a vector $\mathbf{r}$, we
664     first convert it to its corresponding vector in box space, and then,
665     cast each element to lie in the range $[-0.5,0.5]$:
666     \begin{equation}
667     s_{i}^{\prime}=s_{i}-\roundme(s_{i}),
668     \end{equation}
669     where $s_i$ is the $i$th element of $\mathbf{s}$, and
670     $\roundme(s_i)$ is given by
671     \begin{equation}
672     \roundme(x) =
673     \begin{cases}
674     \lfloor x+0.5 \rfloor & \text{if $x \ge 0$,} \\
675     \lceil x-0.5 \rceil & \text{if $x < 0$.}
676     \end{cases}
677     \end{equation}
678     Here $\lfloor x \rfloor$ is the floor operator, and gives the largest
679     integer value that is not greater than $x$, and $\lceil x \rceil$ is
680     the ceiling operator, and gives the smallest integer that is not less
681     than $x$. For example, $\roundme(3.6)=4$, $\roundme(3.1)=3$,
682     $\roundme(-3.6)=-4$, $\roundme(-3.1)=-3$.
683    
684     Finally, we obtain the minimum image coordinates $\mathbf{r}^{\prime}$ by
685     transforming back to real space,
686     \begin{equation}
687     \mathbf{r}^{\prime}=\mathsf{H}^{-1}\mathbf{s}^{\prime}.%
688     \end{equation}
689     In this way, particles are allowed to diffuse freely in $\mathbf{r}$,
690     but their minimum images, $\mathbf{r}^{\prime}$ are used to compute
691     the inter-atomic forces.
692    
693    
694     \section{\label{oopseSec:IOfiles}Input and Output Files}
695    
696     \subsection{{\sc bass} and Model Files}
697    
698     Every {\sc oopse} simulation begins with a Bizarre Atom Simulation
699     Syntax ({\sc bass}) file. {\sc bass} is a script syntax that is parsed
700     by {\sc oopse} at runtime. The {\sc bass} file allows for the user to
701     completely describe the system they wish to simulate, as well as tailor
702     {\sc oopse}'s behavior during the simulation. {\sc bass} files are
703     denoted with the extension
704     \texttt{.bass}, an example file is shown in
705     Scheme~\ref{sch:bassExample}.
706    
707     \begin{lstlisting}[float,caption={[An example of a complete {\sc bass} file] An example showing a complete {\sc bass} file.},label={sch:bassExample}]
708    
709     molecule{
710     name = "Ar";
711     nAtoms = 1;
712     atom[0]{
713     type="Ar";
714     position( 0.0, 0.0, 0.0 );
715     }
716     }
717    
718     nComponents = 1;
719     component{
720     type = "Ar";
721     nMol = 108;
722     }
723    
724     initialConfig = "./argon.init";
725    
726     forceField = "LJ";
727     ensemble = "NVE"; // specify the simulation ensemble
728     dt = 1.0; // the time step for integration
729     runTime = 1e3; // the total simulation run time
730     sampleTime = 100; // trajectory file frequency
731     statusTime = 50; // statistics file frequency
732    
733     \end{lstlisting}
734    
735     Within the \texttt{.bass} file it is necessary to provide a complete
736     description of the molecule before it is actually placed in the
737     simulation. The {\sc bass} syntax was originally developed with this
738     goal in mind, and allows for the specification of all the atoms in a
739     molecular prototype, as well as any bonds, bends, or torsions. These
740     descriptions can become lengthy for complex molecules, and it would be
741     inconvenient to duplicate the simulation at the beginning of each {\sc
742     bass} script. Addressing this issue {\sc bass} allows for the
743     inclusion of model files at the top of a \texttt{.bass} file. These
744     model files, denoted with the \texttt{.mdl} extension, allow the user
745     to describe a molecular prototype once, then simply include it into
746     each simulation containing that molecule. Returning to the example in
747     Scheme~\ref{sch:bassExample}, the \texttt{.mdl} file's contents would
748     be Scheme~\ref{sch:mdlExample}, and the new \texttt{.bass} file would
749     become Scheme~\ref{sch:bassExPrime}.
750    
751     \begin{lstlisting}[float,caption={An example \texttt{.mdl} file.},label={sch:mdlExample}]
752    
753     molecule{
754     name = "Ar";
755     nAtoms = 1;
756     atom[0]{
757     type="Ar";
758     position( 0.0, 0.0, 0.0 );
759     }
760     }
761    
762     \end{lstlisting}
763    
764     \begin{lstlisting}[float,caption={Revised {\sc bass} example.},label={sch:bassExPrime}]
765    
766     #include "argon.mdl"
767    
768     nComponents = 1;
769     component{
770     type = "Ar";
771     nMol = 108;
772     }
773    
774     initialConfig = "./argon.init";
775    
776     forceField = "LJ";
777     ensemble = "NVE";
778     dt = 1.0;
779     runTime = 1e3;
780     sampleTime = 100;
781     statusTime = 50;
782    
783     \end{lstlisting}
784    
785     \subsection{\label{oopseSec:coordFiles}Coordinate Files}
786    
787     The standard format for storage of a systems coordinates is a modified
788     xyz-file syntax, the exact details of which can be seen in
789     Scheme~\ref{sch:dumpFormat}. As all bonding and molecular information
790     is stored in the \texttt{.bass} and \texttt{.mdl} files, the
791     coordinate files are simply the complete set of coordinates for each
792     atom at a given simulation time. One important note, although the
793     simulation propagates the complete rotation matrix, directional
794     entities are written out using quanternions, to save space in the
795     output files.
796    
797     \begin{lstlisting}[float,caption={[The format of the coordinate files]Shows the format of the coordinate files. The fist line is the number of atoms. The second line begins with the time stamp followed by the three $\mathsf{H}$ column vectors. It is important to note, that for extended system ensembles, additional information pertinent to the integrators may be stored on this line as well. The next lines are the atomic coordinates for all atoms in the system. First is the name followed by position, velocity, quanternions, and lastly angular velocities.},label=sch:dumpFormat]
798    
799     nAtoms
800     time; Hxx Hyx Hzx; Hxy Hyy Hzy; Hxz Hyz Hzz;
801     Name1 x y z vx vy vz q0 q1 q2 q3 jx jy jz
802     Name2 x y z vx vy vz q0 q1 q2 q3 jx jy jz
803     etc...
804    
805     \end{lstlisting}
806    
807    
808     There are three major files used by {\sc oopse} written in the
809     coordinate format, they are as follows: the initialization file
810     (\texttt{.init}), the simulation trajectory file (\texttt{.dump}), and
811     the final coordinates of the simulation. The initialization file is
812     necessary for {\sc oopse} to start the simulation with the proper
813     coordinates, and is generated before the simulation run. The
814     trajectory file is created at the beginning of the simulation, and is
815     used to store snapshots of the simulation at regular intervals. The
816     first frame is a duplication of the
817     \texttt{.init} file, and each subsequent frame is appended to the file
818     at an interval specified in the \texttt{.bass} file with the
819     \texttt{sampleTime} flag. The final coordinate file is the end of run file. The
820     \texttt{.eor} file stores the final configuration of the system for a
821     given simulation. The file is updated at the same time as the
822     \texttt{.dump} file, however, it only contains the most recent
823     frame. In this way, an \texttt{.eor} file may be used as the
824     initialization file to a second simulation in order to continue a
825     simulation or recover one from a processor that has crashed during the
826     course of the run.
827    
828     \subsection{\label{oopseSec:initCoords}Generation of Initial Coordinates}
829    
830     As was stated in Sec.~\ref{oopseSec:coordFiles}, an initialization
831     file is needed to provide the starting coordinates for a
832     simulation. The {\sc oopse} package provides several system building
833     programs to aid in the creation of the \texttt{.init}
834     file. The programs use {\sc bass}, and will recognize
835     arguments and parameters in the \texttt{.bass} file that would
836     otherwise be ignored by the simulation.
837    
838     \subsection{The Statistics File}
839    
840     The last output file generated by {\sc oopse} is the statistics
841     file. This file records such statistical quantities as the
842     instantaneous temperature, volume, pressure, etc. It is written out
843     with the frequency specified in the \texttt{.bass} file with the
844     \texttt{statusTime} keyword. The file allows the user to observe the
845     system variables as a function of simulation time while the simulation
846     is in progress. One useful function the statistics file serves is to
847     monitor the conserved quantity of a given simulation ensemble, this
848     allows the user to observe the stability of the integrator. The
849     statistics file is denoted with the \texttt{.stat} file extension.
850    
851     \section{\label{oopseSec:mechanics}Mechanics}
852    
853     \subsection{\label{oopseSec:integrate}Integrating the Equations of Motion: the
854     DLM method}
855    
856     The default method for integrating the equations of motion in {\sc
857     oopse} is a velocity-Verlet version of the symplectic splitting method
858     proposed by Dullweber, Leimkuhler and McLachlan
859     (DLM).\cite{Dullweber1997} When there are no directional atoms or
860     rigid bodies present in the simulation, this integrator becomes the
861     standard velocity-Verlet integrator which is known to sample the
862     microcanonical (NVE) ensemble.\cite{Frenkel1996}
863    
864     Previous integration methods for orientational motion have problems
865     that are avoided in the DLM method. Direct propagation of the Euler
866     angles has a known $1/\sin\theta$ divergence in the equations of
867     motion for $\phi$ and $\psi$,\cite{allen87:csl} leading to
868     numerical instabilities any time one of the directional atoms or rigid
869     bodies has an orientation near $\theta=0$ or $\theta=\pi$. More
870     modern quaternion-based integration methods have relatively poor
871     energy conservation. While quaternions work well for orientational
872     motion in other ensembles, the microcanonical ensemble has a
873     constant energy requirement that is quite sensitive to errors in the
874     equations of motion. An earlier implementation of {\sc oopse}
875     utilized quaternions for propagation of rotational motion; however, a
876     detailed investigation showed that they resulted in a steady drift in
877     the total energy, something that has been observed by
878     Laird {\it et al.}\cite{Laird97}
879    
880     The key difference in the integration method proposed by Dullweber
881     \emph{et al.} is that the entire $3 \times 3$ rotation matrix is
882     propagated from one time step to the next. In the past, this would not
883     have been feasible, since the rotation matrix for a single body has
884     nine elements compared with the more memory-efficient methods (using
885     three Euler angles or 4 quaternions). Computer memory has become much
886     less costly in recent years, and this can be translated into
887     substantial benefits in energy conservation.
888    
889     The basic equations of motion being integrated are derived from the
890     Hamiltonian for conservative systems containing rigid bodies,
891     \begin{equation}
892     H = \sum_{i} \left( \frac{1}{2} m_i {\bf v}_i^T \cdot {\bf v}_i +
893     \frac{1}{2} {\bf j}_i^T \cdot \overleftrightarrow{\mathsf{I}}_i^{-1} \cdot
894     {\bf j}_i \right) +
895     V\left(\left\{{\bf r}\right\}, \left\{\mathsf{A}\right\}\right),
896     \end{equation}
897     where ${\bf r}_i$ and ${\bf v}_i$ are the cartesian position vector
898     and velocity of the center of mass of particle $i$, and ${\bf j}_i$,
899     $\overleftrightarrow{\mathsf{I}}_i$ are the body-fixed angular
900     momentum and moment of inertia tensor respectively, and the
901     superscript $T$ denotes the transpose of the vector. $\mathsf{A}_i$
902     is the $3 \times 3$ rotation matrix describing the instantaneous
903     orientation of the particle. $V$ is the potential energy function
904     which may depend on both the positions $\left\{{\bf r}\right\}$ and
905     orientations $\left\{\mathsf{A}\right\}$ of all particles. The
906     equations of motion for the particle centers of mass are derived from
907     Hamilton's equations and are quite simple,
908     \begin{eqnarray}
909     \dot{{\bf r}} & = & {\bf v}, \\
910     \dot{{\bf v}} & = & \frac{{\bf f}}{m},
911     \end{eqnarray}
912     where ${\bf f}$ is the instantaneous force on the center of mass
913     of the particle,
914     \begin{equation}
915     {\bf f} = - \frac{\partial}{\partial
916     {\bf r}} V(\left\{{\bf r}(t)\right\}, \left\{\mathsf{A}(t)\right\}).
917     \end{equation}
918    
919     The equations of motion for the orientational degrees of freedom are
920     \begin{eqnarray}
921     \dot{\mathsf{A}} & = & \mathsf{A} \cdot
922     \mbox{ skew}\left(\overleftrightarrow{\mathsf{I}}^{-1} \cdot {\bf j}\right),\\
923     \dot{{\bf j}} & = & {\bf j} \times \left( \overleftrightarrow{\mathsf{I}}^{-1}
924     \cdot {\bf j} \right) - \mbox{ rot}\left(\mathsf{A}^{T} \cdot \frac{\partial
925     V}{\partial \mathsf{A}} \right).
926     \end{eqnarray}
927     In these equations of motion, the $\mbox{skew}$ matrix of a vector
928     ${\bf v} = \left( v_1, v_2, v_3 \right)$ is defined:
929     \begin{equation}
930     \mbox{skew}\left( {\bf v} \right) := \left(
931     \begin{array}{ccc}
932     0 & v_3 & - v_2 \\
933     -v_3 & 0 & v_1 \\
934     v_2 & -v_1 & 0
935     \end{array}
936     \right).
937     \end{equation}
938     The $\mbox{rot}$ notation refers to the mapping of the $3 \times 3$
939     rotation matrix to a vector of orientations by first computing the
940     skew-symmetric part $\left(\mathsf{A} - \mathsf{A}^{T}\right)$ and
941     then associating this with a length 3 vector by inverting the
942     $\mbox{skew}$ function above:
943     \begin{equation}
944     \mbox{rot}\left(\mathsf{A}\right) := \mbox{ skew}^{-1}\left(\mathsf{A}
945     - \mathsf{A}^{T} \right).
946     \end{equation}
947     Written this way, the $\mbox{rot}$ operation creates a set of
948     conjugate angle coordinates to the body-fixed angular momenta
949     represented by ${\bf j}$. This equation of motion for angular momenta
950     is equivalent to the more familiar body-fixed forms,
951     \begin{eqnarray}
952     \dot{j_{x}} & = & \tau^b_x(t) +
953     \left(\overleftrightarrow{\mathsf{I}}_{yy} - \overleftrightarrow{\mathsf{I}}_{zz} \right) j_y j_z, \\
954     \dot{j_{y}} & = & \tau^b_y(t) +
955     \left(\overleftrightarrow{\mathsf{I}}_{zz} - \overleftrightarrow{\mathsf{I}}_{xx} \right) j_z j_x,\\
956     \dot{j_{z}} & = & \tau^b_z(t) +
957     \left(\overleftrightarrow{\mathsf{I}}_{xx} - \overleftrightarrow{\mathsf{I}}_{yy} \right) j_x j_y,
958     \end{eqnarray}
959     which utilize the body-fixed torques, ${\bf \tau}^b$. Torques are
960     most easily derived in the space-fixed frame,
961     \begin{equation}
962     {\bf \tau}^b(t) = \mathsf{A}(t) \cdot {\bf \tau}^s(t),
963     \end{equation}
964     where the torques are either derived from the forces on the
965     constituent atoms of the rigid body, or for directional atoms,
966     directly from derivatives of the potential energy,
967     \begin{equation}
968     {\bf \tau}^s(t) = - \hat{\bf u}(t) \times \left( \frac{\partial}
969     {\partial \hat{\bf u}} V\left(\left\{ {\bf r}(t) \right\}, \left\{
970     \mathsf{A}(t) \right\}\right) \right).
971     \end{equation}
972     Here $\hat{\bf u}$ is a unit vector pointing along the principal axis
973     of the particle in the space-fixed frame.
974    
975     The DLM method uses a Trotter factorization of the orientational
976     propagator. This has three effects:
977     \begin{enumerate}
978     \item the integrator is area-preserving in phase space (i.e. it is
979     {\it symplectic}),
980     \item the integrator is time-{\it reversible}, making it suitable for Hybrid
981     Monte Carlo applications, and
982     \item the error for a single time step is of order $\mathcal{O}\left(h^4\right)$
983     for timesteps of length $h$.
984     \end{enumerate}
985    
986     The integration of the equations of motion is carried out in a
987     velocity-Verlet style 2-part algorithm, where $h= \delta t$:
988    
989     {\tt moveA:}
990     \begin{align*}
991     {\bf v}\left(t + h / 2\right) &\leftarrow {\bf v}(t)
992     + \frac{h}{2} \left( {\bf f}(t) / m \right), \\
993     %
994     {\bf r}(t + h) &\leftarrow {\bf r}(t)
995     + h {\bf v}\left(t + h / 2 \right), \\
996     %
997     {\bf j}\left(t + h / 2 \right) &\leftarrow {\bf j}(t)
998     + \frac{h}{2} {\bf \tau}^b(t), \\
999     %
1000     \mathsf{A}(t + h) &\leftarrow \mathrm{rotate}\left( h {\bf j}
1001     (t + h / 2) \cdot \overleftrightarrow{\mathsf{I}}^{-1} \right).
1002     \end{align*}
1003    
1004     In this context, the $\mathrm{rotate}$ function is the reversible product
1005     of the three body-fixed rotations,
1006     \begin{equation}
1007     \mathrm{rotate}({\bf a}) = \mathsf{G}_x(a_x / 2) \cdot
1008     \mathsf{G}_y(a_y / 2) \cdot \mathsf{G}_z(a_z) \cdot \mathsf{G}_y(a_y /
1009     2) \cdot \mathsf{G}_x(a_x /2),
1010     \end{equation}
1011     where each rotational propagator, $\mathsf{G}_\alpha(\theta)$, rotates
1012     both the rotation matrix ($\mathsf{A}$) and the body-fixed angular
1013     momentum (${\bf j}$) by an angle $\theta$ around body-fixed axis
1014     $\alpha$,
1015     \begin{equation}
1016     \mathsf{G}_\alpha( \theta ) = \left\{
1017     \begin{array}{lcl}
1018     \mathsf{A}(t) & \leftarrow & \mathsf{A}(0) \cdot \mathsf{R}_\alpha(\theta)^T, \\
1019     {\bf j}(t) & \leftarrow & \mathsf{R}_\alpha(\theta) \cdot {\bf j}(0).
1020     \end{array}
1021     \right.
1022     \end{equation}
1023     $\mathsf{R}_\alpha$ is a quadratic approximation to
1024     the single-axis rotation matrix. For example, in the small-angle
1025     limit, the rotation matrix around the body-fixed x-axis can be
1026     approximated as
1027     \begin{equation}
1028     \mathsf{R}_x(\theta) \approx \left(
1029     \begin{array}{ccc}
1030     1 & 0 & 0 \\
1031     0 & \frac{1-\theta^2 / 4}{1 + \theta^2 / 4} & -\frac{\theta}{1+
1032     \theta^2 / 4} \\
1033     0 & \frac{\theta}{1+
1034     \theta^2 / 4} & \frac{1-\theta^2 / 4}{1 + \theta^2 / 4}
1035     \end{array}
1036     \right).
1037     \end{equation}
1038     All other rotations follow in a straightforward manner.
1039    
1040     After the first part of the propagation, the forces and body-fixed
1041     torques are calculated at the new positions and orientations
1042    
1043     {\tt doForces:}
1044     \begin{align*}
1045     {\bf f}(t + h) &\leftarrow
1046     - \left(\frac{\partial V}{\partial {\bf r}}\right)_{{\bf r}(t + h)}, \\
1047     %
1048     {\bf \tau}^{s}(t + h) &\leftarrow {\bf u}(t + h)
1049     \times \frac{\partial V}{\partial {\bf u}}, \\
1050     %
1051     {\bf \tau}^{b}(t + h) &\leftarrow \mathsf{A}(t + h)
1052     \cdot {\bf \tau}^s(t + h).
1053     \end{align*}
1054    
1055     {\sc oopse} automatically updates ${\bf u}$ when the rotation matrix
1056     $\mathsf{A}$ is calculated in {\tt moveA}. Once the forces and
1057     torques have been obtained at the new time step, the velocities can be
1058     advanced to the same time value.
1059    
1060     {\tt moveB:}
1061     \begin{align*}
1062     {\bf v}\left(t + h \right) &\leftarrow {\bf v}\left(t + h / 2 \right)
1063     + \frac{h}{2} \left( {\bf f}(t + h) / m \right), \\
1064     %
1065     {\bf j}\left(t + h \right) &\leftarrow {\bf j}\left(t + h / 2 \right)
1066     + \frac{h}{2} {\bf \tau}^b(t + h) .
1067     \end{align*}
1068    
1069     The matrix rotations used in the DLM method end up being more costly
1070     computationally than the simpler arithmetic quaternion
1071     propagation. With the same time step, a 1000-molecule water simulation
1072     shows an average 7\% increase in computation time using the DLM method
1073     in place of quaternions. This cost is more than justified when
1074     comparing the energy conservation of the two methods as illustrated in
1075     Fig.~\ref{timestep}.
1076    
1077     \begin{figure}
1078     \centering
1079     \includegraphics[width=\linewidth]{timeStep.pdf}
1080     \caption[Energy conservation for quaternion versus DLM dynamics]{Energy conservation using quaternion based integration versus
1081     the method proposed by Dullweber \emph{et al.} with increasing time
1082     step. For each time step, the dotted line is total energy using the
1083     DLM integrator, and the solid line comes from the quaternion
1084     integrator. The larger time step plots are shifted up from the true
1085     energy baseline for clarity.}
1086     \label{timestep}
1087     \end{figure}
1088    
1089     In Fig.~\ref{timestep}, the resulting energy drift at various time
1090     steps for both the DLM and quaternion integration schemes is
1091     compared. All of the 1000 molecule water simulations started with the
1092     same configuration, and the only difference was the method for
1093     handling rotational motion. At time steps of 0.1 and 0.5 fs, both
1094     methods for propagating molecule rotation conserve energy fairly well,
1095     with the quaternion method showing a slight energy drift over time in
1096     the 0.5 fs time step simulation. At time steps of 1 and 2 fs, the
1097     energy conservation benefits of the DLM method are clearly
1098     demonstrated. Thus, while maintaining the same degree of energy
1099     conservation, one can take considerably longer time steps, leading to
1100     an overall reduction in computation time.
1101    
1102     There is only one specific keyword relevant to the default integrator,
1103     and that is the time step for integrating the equations of motion.
1104    
1105     \begin{center}
1106     \begin{tabular}{llll}
1107     {\bf variable} & {\bf {\tt .bass} keyword} & {\bf units} & {\bf
1108     default value} \\
1109     $h$ & {\tt dt = 2.0;} & fs & none
1110     \end{tabular}
1111     \end{center}
1112    
1113     \subsection{\label{sec:extended}Extended Systems for other Ensembles}
1114    
1115     {\sc oopse} implements a number of extended system integrators for
1116     sampling from other ensembles relevant to chemical physics. The
1117     integrator can selected with the {\tt ensemble} keyword in the
1118     {\tt .bass} file:
1119    
1120     \begin{center}
1121     \begin{tabular}{lll}
1122     {\bf Integrator} & {\bf Ensemble} & {\bf {\tt .bass} line} \\
1123     NVE & microcanonical & {\tt ensemble = NVE; } \\
1124     NVT & canonical & {\tt ensemble = NVT; } \\
1125     NPTi & isobaric-isothermal & {\tt ensemble = NPTi;} \\
1126     & (with isotropic volume changes) & \\
1127     NPTf & isobaric-isothermal & {\tt ensemble = NPTf;} \\
1128     & (with changes to box shape) & \\
1129     NPTxyz & approximate isobaric-isothermal & {\tt ensemble = NPTxyz;} \\
1130     & (with separate barostats on each box dimension) & \\
1131     \end{tabular}
1132     \end{center}
1133    
1134     The relatively well-known Nos\'e-Hoover thermostat\cite{Hoover85} is
1135     implemented in {\sc oopse}'s NVT integrator. This method couples an
1136     extra degree of freedom (the thermostat) to the kinetic energy of the
1137     system, and has been shown to sample the canonical distribution in the
1138     system degrees of freedom while conserving a quantity that is, to
1139     within a constant, the Helmholtz free energy.\cite{melchionna93}
1140    
1141     NPT algorithms attempt to maintain constant pressure in the system by
1142     coupling the volume of the system to a barostat. {\sc oopse} contains
1143     three different constant pressure algorithms. The first two, NPTi and
1144     NPTf have been shown to conserve a quantity that is, to within a
1145     constant, the Gibbs free energy.\cite{melchionna93} The Melchionna
1146     modification to the Hoover barostat is implemented in both NPTi and
1147     NPTf. NPTi allows only isotropic changes in the simulation box, while
1148     box {\it shape} variations are allowed in NPTf. The NPTxyz integrator
1149     has {\it not} been shown to sample from the isobaric-isothermal
1150     ensemble. It is useful, however, in that it maintains orthogonality
1151     for the axes of the simulation box while attempting to equalize
1152     pressure along the three perpendicular directions in the box.
1153    
1154     Each of the extended system integrators requires additional keywords
1155     to set target values for the thermodynamic state variables that are
1156     being held constant. Keywords are also required to set the
1157     characteristic decay times for the dynamics of the extended
1158     variables.
1159    
1160     \begin{center}
1161     \begin{tabular}{llll}
1162     {\bf variable} & {\bf {\tt .bass} keyword} & {\bf units} & {\bf
1163     default value} \\
1164     $T_{\mathrm{target}}$ & {\tt targetTemperature = 300;} & K & none \\
1165     $P_{\mathrm{target}}$ & {\tt targetPressure = 1;} & atm & none \\
1166     $\tau_T$ & {\tt tauThermostat = 1e3;} & fs & none \\
1167     $\tau_B$ & {\tt tauBarostat = 5e3;} & fs & none \\
1168     & {\tt resetTime = 200;} & fs & none \\
1169     & {\tt useInitialExtendedSystemState = true;} & logical &
1170     true
1171     \end{tabular}
1172     \end{center}
1173    
1174     Two additional keywords can be used to either clear the extended
1175     system variables periodically ({\tt resetTime}), or to maintain the
1176     state of the extended system variables between simulations ({\tt
1177     useInitialExtendedSystemState}). More details on these variables
1178     and their use in the integrators follows below.
1179    
1180     \subsection{\label{oopseSec:noseHooverThermo}Nos\'{e}-Hoover Thermostatting}
1181    
1182     The Nos\'e-Hoover equations of motion are given by\cite{Hoover85}
1183     \begin{eqnarray}
1184     \dot{{\bf r}} & = & {\bf v}, \\
1185     \dot{{\bf v}} & = & \frac{{\bf f}}{m} - \chi {\bf v} ,\\
1186     \dot{\mathsf{A}} & = & \mathsf{A} \cdot
1187     \mbox{ skew}\left(\overleftrightarrow{\mathsf{I}}^{-1} \cdot {\bf j}\right), \\
1188     \dot{{\bf j}} & = & {\bf j} \times \left( \overleftrightarrow{\mathsf{I}}^{-1}
1189     \cdot {\bf j} \right) - \mbox{ rot}\left(\mathsf{A}^{T} \cdot \frac{\partial
1190     V}{\partial \mathsf{A}} \right) - \chi {\bf j}.
1191     \label{eq:nosehoovereom}
1192     \end{eqnarray}
1193    
1194     $\chi$ is an ``extra'' variable included in the extended system, and
1195     it is propagated using the first order equation of motion
1196     \begin{equation}
1197     \dot{\chi} = \frac{1}{\tau_{T}^2} \left( \frac{T}{T_{\mathrm{target}}} - 1 \right).
1198     \label{eq:nosehooverext}
1199     \end{equation}
1200    
1201     The instantaneous temperature $T$ is proportional to the total kinetic
1202     energy (both translational and orientational) and is given by
1203     \begin{equation}
1204     T = \frac{2 K}{f k_B}
1205     \end{equation}
1206     Here, $f$ is the total number of degrees of freedom in the system,
1207     \begin{equation}
1208     f = 3 N + 3 N_{\mathrm{orient}} - N_{\mathrm{constraints}},
1209     \end{equation}
1210     and $K$ is the total kinetic energy,
1211     \begin{equation}
1212     K = \sum_{i=1}^{N} \frac{1}{2} m_i {\bf v}_i^T \cdot {\bf v}_i +
1213     \sum_{i=1}^{N_{\mathrm{orient}}} \frac{1}{2} {\bf j}_i^T \cdot
1214     \overleftrightarrow{\mathsf{I}}_i^{-1} \cdot {\bf j}_i.
1215     \end{equation}
1216    
1217     In eq.(\ref{eq:nosehooverext}), $\tau_T$ is the time constant for
1218     relaxation of the temperature to the target value. To set values for
1219     $\tau_T$ or $T_{\mathrm{target}}$ in a simulation, one would use the
1220     {\tt tauThermostat} and {\tt targetTemperature} keywords in the {\tt
1221     .bass} file. The units for {\tt tauThermostat} are fs, and the units
1222     for the {\tt targetTemperature} are degrees K. The integration of
1223     the equations of motion is carried out in a velocity-Verlet style 2
1224     part algorithm:
1225    
1226     {\tt moveA:}
1227     \begin{align*}
1228     T(t) &\leftarrow \left\{{\bf v}(t)\right\}, \left\{{\bf j}(t)\right\} ,\\
1229     %
1230     {\bf v}\left(t + h / 2\right) &\leftarrow {\bf v}(t)
1231     + \frac{h}{2} \left( \frac{{\bf f}(t)}{m} - {\bf v}(t)
1232     \chi(t)\right), \\
1233     %
1234     {\bf r}(t + h) &\leftarrow {\bf r}(t)
1235     + h {\bf v}\left(t + h / 2 \right) ,\\
1236     %
1237     {\bf j}\left(t + h / 2 \right) &\leftarrow {\bf j}(t)
1238     + \frac{h}{2} \left( {\bf \tau}^b(t) - {\bf j}(t)
1239     \chi(t) \right) ,\\
1240     %
1241     \mathsf{A}(t + h) &\leftarrow \mathrm{rotate}
1242     \left(h * {\bf j}(t + h / 2)
1243     \overleftrightarrow{\mathsf{I}}^{-1} \right) ,\\
1244     %
1245     \chi\left(t + h / 2 \right) &\leftarrow \chi(t)
1246     + \frac{h}{2 \tau_T^2} \left( \frac{T(t)}
1247     {T_{\mathrm{target}}} - 1 \right) .
1248     \end{align*}
1249    
1250     Here $\mathrm{rotate}(h * {\bf j}
1251     \overleftrightarrow{\mathsf{I}}^{-1})$ is the same symplectic Trotter
1252     factorization of the three rotation operations that was discussed in
1253     the section on the DLM integrator. Note that this operation modifies
1254     both the rotation matrix $\mathsf{A}$ and the angular momentum ${\bf
1255     j}$. {\tt moveA} propagates velocities by a half time step, and
1256     positional degrees of freedom by a full time step. The new positions
1257     (and orientations) are then used to calculate a new set of forces and
1258     torques in exactly the same way they are calculated in the {\tt
1259     doForces} portion of the DLM integrator.
1260    
1261     Once the forces and torques have been obtained at the new time step,
1262     the temperature, velocities, and the extended system variable can be
1263     advanced to the same time value.
1264    
1265     {\tt moveB:}
1266     \begin{align*}
1267     T(t + h) &\leftarrow \left\{{\bf v}(t + h)\right\},
1268     \left\{{\bf j}(t + h)\right\}, \\
1269     %
1270     \chi\left(t + h \right) &\leftarrow \chi\left(t + h /
1271     2 \right) + \frac{h}{2 \tau_T^2} \left( \frac{T(t+h)}
1272     {T_{\mathrm{target}}} - 1 \right), \\
1273     %
1274     {\bf v}\left(t + h \right) &\leftarrow {\bf v}\left(t
1275     + h / 2 \right) + \frac{h}{2} \left(
1276     \frac{{\bf f}(t + h)}{m} - {\bf v}(t + h)
1277     \chi(t h)\right) ,\\
1278     %
1279     {\bf j}\left(t + h \right) &\leftarrow {\bf j}\left(t
1280     + h / 2 \right) + \frac{h}{2}
1281     \left( {\bf \tau}^b(t + h) - {\bf j}(t + h)
1282     \chi(t + h) \right) .
1283     \end{align*}
1284    
1285     Since ${\bf v}(t + h)$ and ${\bf j}(t + h)$ are required to caclculate
1286     $T(t + h)$ as well as $\chi(t + h)$, they indirectly depend on their
1287     own values at time $t + h$. {\tt moveB} is therefore done in an
1288     iterative fashion until $\chi(t + h)$ becomes self-consistent. The
1289     relative tolerance for the self-consistency check defaults to a value
1290     of $\mbox{10}^{-6}$, but {\sc oopse} will terminate the iteration
1291     after 4 loops even if the consistency check has not been satisfied.
1292    
1293     The Nos\'e-Hoover algorithm is known to conserve a Hamiltonian for the
1294     extended system that is, to within a constant, identical to the
1295     Helmholtz free energy,\cite{melchionna93}
1296     \begin{equation}
1297     H_{\mathrm{NVT}} = V + K + f k_B T_{\mathrm{target}} \left(
1298     \frac{\tau_{T}^2 \chi^2(t)}{2} + \int_{0}^{t} \chi(t^\prime) dt^\prime
1299     \right).
1300     \end{equation}
1301     Poor choices of $h$ or $\tau_T$ can result in non-conservation
1302     of $H_{\mathrm{NVT}}$, so the conserved quantity is maintained in the
1303     last column of the {\tt .stat} file to allow checks on the quality of
1304     the integration.
1305    
1306     Bond constraints are applied at the end of both the {\tt moveA} and
1307     {\tt moveB} portions of the algorithm. Details on the constraint
1308     algorithms are given in section \ref{oopseSec:rattle}.
1309    
1310     \subsection{\label{sec:NPTi}Constant-pressure integration with
1311     isotropic box deformations (NPTi)}
1312    
1313     To carry out isobaric-isothermal ensemble calculations {\sc oopse}
1314     implements the Melchionna modifications to the Nos\'e-Hoover-Andersen
1315     equations of motion,\cite{melchionna93}
1316    
1317     \begin{eqnarray}
1318     \dot{{\bf r}} & = & {\bf v} + \eta \left( {\bf r} - {\bf R}_0 \right), \\
1319     \dot{{\bf v}} & = & \frac{{\bf f}}{m} - (\eta + \chi) {\bf v}, \\
1320     \dot{\mathsf{A}} & = & \mathsf{A} \cdot
1321     \mbox{ skew}\left(\overleftrightarrow{I}^{-1} \cdot {\bf j}\right),\\
1322     \dot{{\bf j}} & = & {\bf j} \times \left( \overleftrightarrow{I}^{-1}
1323     \cdot {\bf j} \right) - \mbox{ rot}\left(\mathsf{A}^{T} \cdot \frac{\partial
1324     V}{\partial \mathsf{A}} \right) - \chi {\bf j}, \\
1325     \dot{\chi} & = & \frac{1}{\tau_{T}^2} \left(
1326     \frac{T}{T_{\mathrm{target}}} - 1 \right) ,\\
1327     \dot{\eta} & = & \frac{1}{\tau_{B}^2 f k_B T_{\mathrm{target}}} V \left( P -
1328     P_{\mathrm{target}} \right), \\
1329     \dot{\mathcal{V}} & = & 3 \mathcal{V} \eta .
1330     \label{eq:melchionna1}
1331     \end{eqnarray}
1332    
1333     $\chi$ and $\eta$ are the ``extra'' degrees of freedom in the extended
1334     system. $\chi$ is a thermostat, and it has the same function as it
1335     does in the Nos\'e-Hoover NVT integrator. $\eta$ is a barostat which
1336     controls changes to the volume of the simulation box. ${\bf R}_0$ is
1337     the location of the center of mass for the entire system, and
1338     $\mathcal{V}$ is the volume of the simulation box. At any time, the
1339     volume can be calculated from the determinant of the matrix which
1340     describes the box shape:
1341     \begin{equation}
1342     \mathcal{V} = \det(\mathsf{H}).
1343     \end{equation}
1344    
1345     The NPTi integrator requires an instantaneous pressure. This quantity
1346     is calculated via the pressure tensor,
1347     \begin{equation}
1348     \overleftrightarrow{\mathsf{P}}(t) = \frac{1}{\mathcal{V}(t)} \left(
1349     \sum_{i=1}^{N} m_i {\bf v}_i(t) \otimes {\bf v}_i(t) \right) +
1350     \overleftrightarrow{\mathsf{W}}(t).
1351     \end{equation}
1352     The kinetic contribution to the pressure tensor utilizes the {\it
1353     outer} product of the velocities denoted by the $\otimes$ symbol. The
1354     stress tensor is calculated from another outer product of the
1355     inter-atomic separation vectors (${\bf r}_{ij} = {\bf r}_j - {\bf
1356     r}_i$) with the forces between the same two atoms,
1357     \begin{equation}
1358     \overleftrightarrow{\mathsf{W}}(t) = \sum_{i} \sum_{j>i} {\bf r}_{ij}(t)
1359     \otimes {\bf f}_{ij}(t).
1360     \end{equation}
1361     The instantaneous pressure is then simply obtained from the trace of
1362     the Pressure tensor,
1363     \begin{equation}
1364     P(t) = \frac{1}{3} \mathrm{Tr} \left( \overleftrightarrow{\mathsf{P}}(t).
1365     \right)
1366     \end{equation}
1367    
1368     In eq.(\ref{eq:melchionna1}), $\tau_B$ is the time constant for
1369     relaxation of the pressure to the target value. To set values for
1370     $\tau_B$ or $P_{\mathrm{target}}$ in a simulation, one would use the
1371     {\tt tauBarostat} and {\tt targetPressure} keywords in the {\tt .bass}
1372     file. The units for {\tt tauBarostat} are fs, and the units for the
1373     {\tt targetPressure} are atmospheres. Like in the NVT integrator, the
1374     integration of the equations of motion is carried out in a
1375     velocity-Verlet style 2 part algorithm:
1376    
1377     {\tt moveA:}
1378     \begin{align*}
1379     T(t) &\leftarrow \left\{{\bf v}(t)\right\}, \left\{{\bf j}(t)\right\} ,\\
1380     %
1381     P(t) &\leftarrow \left\{{\bf r}(t)\right\}, \left\{{\bf v}(t)\right\} ,\\
1382     %
1383     {\bf v}\left(t + h / 2\right) &\leftarrow {\bf v}(t)
1384     + \frac{h}{2} \left( \frac{{\bf f}(t)}{m} - {\bf v}(t)
1385     \left(\chi(t) + \eta(t) \right) \right), \\
1386     %
1387     {\bf j}\left(t + h / 2 \right) &\leftarrow {\bf j}(t)
1388     + \frac{h}{2} \left( {\bf \tau}^b(t) - {\bf j}(t)
1389     \chi(t) \right), \\
1390     %
1391     \mathsf{A}(t + h) &\leftarrow \mathrm{rotate}\left(h *
1392     {\bf j}(t + h / 2) \overleftrightarrow{\mathsf{I}}^{-1}
1393     \right) ,\\
1394     %
1395     \chi\left(t + h / 2 \right) &\leftarrow \chi(t) +
1396     \frac{h}{2 \tau_T^2} \left( \frac{T(t)}{T_{\mathrm{target}}} - 1
1397     \right) ,\\
1398     %
1399     \eta(t + h / 2) &\leftarrow \eta(t) + \frac{h
1400     \mathcal{V}(t)}{2 N k_B T(t) \tau_B^2} \left( P(t)
1401     - P_{\mathrm{target}} \right), \\
1402     %
1403     {\bf r}(t + h) &\leftarrow {\bf r}(t) + h
1404     \left\{ {\bf v}\left(t + h / 2 \right)
1405     + \eta(t + h / 2)\left[ {\bf r}(t + h)
1406     - {\bf R}_0 \right] \right\} ,\\
1407     %
1408     \mathsf{H}(t + h) &\leftarrow e^{-h \eta(t + h / 2)}
1409     \mathsf{H}(t).
1410     \end{align*}
1411    
1412     Most of these equations are identical to their counterparts in the NVT
1413     integrator, but the propagation of positions to time $t + h$
1414     depends on the positions at the same time. {\sc oopse} carries out
1415     this step iteratively (with a limit of 5 passes through the iterative
1416     loop). Also, the simulation box $\mathsf{H}$ is scaled uniformly for
1417     one full time step by an exponential factor that depends on the value
1418     of $\eta$ at time $t +
1419     h / 2$. Reshaping the box uniformly also scales the volume of
1420     the box by
1421     \begin{equation}
1422     \mathcal{V}(t + h) \leftarrow e^{ - 3 h \eta(t + h /2)}.
1423     \mathcal{V}(t)
1424     \end{equation}
1425    
1426     The {\tt doForces} step for the NPTi integrator is exactly the same as
1427     in both the DLM and NVT integrators. Once the forces and torques have
1428     been obtained at the new time step, the velocities can be advanced to
1429     the same time value.
1430    
1431     {\tt moveB:}
1432     \begin{align*}
1433     T(t + h) &\leftarrow \left\{{\bf v}(t + h)\right\},
1434     \left\{{\bf j}(t + h)\right\} ,\\
1435     %
1436     P(t + h) &\leftarrow \left\{{\bf r}(t + h)\right\},
1437     \left\{{\bf v}(t + h)\right\}, \\
1438     %
1439     \chi\left(t + h \right) &\leftarrow \chi\left(t + h /
1440     2 \right) + \frac{h}{2 \tau_T^2} \left( \frac{T(t+h)}
1441     {T_{\mathrm{target}}} - 1 \right), \\
1442     %
1443     \eta(t + h) &\leftarrow \eta(t + h / 2) +
1444     \frac{h \mathcal{V}(t + h)}{2 N k_B T(t + h)
1445     \tau_B^2} \left( P(t + h) - P_{\mathrm{target}} \right), \\
1446     %
1447     {\bf v}\left(t + h \right) &\leftarrow {\bf v}\left(t
1448     + h / 2 \right) + \frac{h}{2} \left(
1449     \frac{{\bf f}(t + h)}{m} - {\bf v}(t + h)
1450     (\chi(t + h) + \eta(t + h)) \right) ,\\
1451     %
1452     {\bf j}\left(t + h \right) &\leftarrow {\bf j}\left(t
1453     + h / 2 \right) + \frac{h}{2} \left( {\bf
1454     \tau}^b(t + h) - {\bf j}(t + h)
1455     \chi(t + h) \right) .
1456     \end{align*}
1457    
1458     Once again, since ${\bf v}(t + h)$ and ${\bf j}(t + h)$ are required
1459     to caclculate $T(t + h)$, $P(t + h)$, $\chi(t + h)$, and $\eta(t +
1460     h)$, they indirectly depend on their own values at time $t + h$. {\tt
1461     moveB} is therefore done in an iterative fashion until $\chi(t + h)$
1462     and $\eta(t + h)$ become self-consistent. The relative tolerance for
1463     the self-consistency check defaults to a value of $\mbox{10}^{-6}$,
1464     but {\sc oopse} will terminate the iteration after 4 loops even if the
1465     consistency check has not been satisfied.
1466    
1467     The Melchionna modification of the Nos\'e-Hoover-Andersen algorithm is
1468     known to conserve a Hamiltonian for the extended system that is, to
1469     within a constant, identical to the Gibbs free energy,
1470     \begin{equation}
1471     H_{\mathrm{NPTi}} = V + K + f k_B T_{\mathrm{target}} \left(
1472     \frac{\tau_{T}^2 \chi^2(t)}{2} + \int_{0}^{t} \chi(t^\prime) dt^\prime
1473     \right) + P_{\mathrm{target}} \mathcal{V}(t).
1474     \end{equation}
1475     Poor choices of $\delta t$, $\tau_T$, or $\tau_B$ can result in
1476     non-conservation of $H_{\mathrm{NPTi}}$, so the conserved quantity is
1477     maintained in the last column of the {\tt .stat} file to allow checks
1478     on the quality of the integration. It is also known that this
1479     algorithm samples the equilibrium distribution for the enthalpy
1480     (including contributions for the thermostat and barostat),
1481     \begin{equation}
1482     H_{\mathrm{NPTi}} = V + K + \frac{f k_B T_{\mathrm{target}}}{2} \left(
1483     \chi^2 \tau_T^2 + \eta^2 \tau_B^2 \right) + P_{\mathrm{target}}
1484     \mathcal{V}(t).
1485     \end{equation}
1486    
1487     Bond constraints are applied at the end of both the {\tt moveA} and
1488     {\tt moveB} portions of the algorithm. Details on the constraint
1489     algorithms are given in section \ref{oopseSec:rattle}.
1490    
1491     \subsection{\label{sec:NPTf}Constant-pressure integration with a
1492     flexible box (NPTf)}
1493    
1494     There is a relatively simple generalization of the
1495     Nos\'e-Hoover-Andersen method to include changes in the simulation box
1496     {\it shape} as well as in the volume of the box. This method utilizes
1497     the full $3 \times 3$ pressure tensor and introduces a tensor of
1498     extended variables ($\overleftrightarrow{\eta}$) to control changes to
1499     the box shape. The equations of motion for this method are
1500     \begin{eqnarray}
1501     \dot{{\bf r}} & = & {\bf v} + \overleftrightarrow{\eta} \cdot \left( {\bf r} - {\bf R}_0 \right), \\
1502     \dot{{\bf v}} & = & \frac{{\bf f}}{m} - (\overleftrightarrow{\eta} +
1503     \chi \cdot \mathsf{1}) {\bf v}, \\
1504     \dot{\mathsf{A}} & = & \mathsf{A} \cdot
1505     \mbox{ skew}\left(\overleftrightarrow{I}^{-1} \cdot {\bf j}\right) ,\\
1506     \dot{{\bf j}} & = & {\bf j} \times \left( \overleftrightarrow{I}^{-1}
1507     \cdot {\bf j} \right) - \mbox{ rot}\left(\mathsf{A}^{T} \cdot \frac{\partial
1508     V}{\partial \mathsf{A}} \right) - \chi {\bf j} ,\\
1509     \dot{\chi} & = & \frac{1}{\tau_{T}^2} \left(
1510     \frac{T}{T_{\mathrm{target}}} - 1 \right) ,\\
1511     \dot{\overleftrightarrow{\eta}} & = & \frac{1}{\tau_{B}^2 f k_B
1512     T_{\mathrm{target}}} V \left( \overleftrightarrow{\mathsf{P}} - P_{\mathrm{target}}\mathsf{1} \right) ,\\
1513     \dot{\mathsf{H}} & = & \overleftrightarrow{\eta} \cdot \mathsf{H} .
1514     \label{eq:melchionna2}
1515     \end{eqnarray}
1516    
1517     Here, $\mathsf{1}$ is the unit matrix and $\overleftrightarrow{\mathsf{P}}$
1518     is the pressure tensor. Again, the volume, $\mathcal{V} = \det
1519     \mathsf{H}$.
1520    
1521     The propagation of the equations of motion is nearly identical to the
1522     NPTi integration:
1523    
1524     {\tt moveA:}
1525     \begin{align*}
1526     T(t) &\leftarrow \left\{{\bf v}(t)\right\}, \left\{{\bf j}(t)\right\} ,\\
1527     %
1528     \overleftrightarrow{\mathsf{P}}(t) &\leftarrow \left\{{\bf r}(t)\right\},
1529     \left\{{\bf v}(t)\right\} ,\\
1530     %
1531     {\bf v}\left(t + h / 2\right) &\leftarrow {\bf v}(t)
1532     + \frac{h}{2} \left( \frac{{\bf f}(t)}{m} -
1533     \left(\chi(t)\mathsf{1} + \overleftrightarrow{\eta}(t) \right) \cdot
1534     {\bf v}(t) \right), \\
1535     %
1536     {\bf j}\left(t + h / 2 \right) &\leftarrow {\bf j}(t)
1537     + \frac{h}{2} \left( {\bf \tau}^b(t) - {\bf j}(t)
1538     \chi(t) \right), \\
1539     %
1540     \mathsf{A}(t + h) &\leftarrow \mathrm{rotate}\left(h *
1541     {\bf j}(t + h / 2) \overleftrightarrow{\mathsf{I}}^{-1}
1542     \right), \\
1543     %
1544     \chi\left(t + h / 2 \right) &\leftarrow \chi(t) +
1545     \frac{h}{2 \tau_T^2} \left( \frac{T(t)}{T_{\mathrm{target}}}
1546     - 1 \right), \\
1547     %
1548     \overleftrightarrow{\eta}(t + h / 2) &\leftarrow
1549     \overleftrightarrow{\eta}(t) + \frac{h \mathcal{V}(t)}{2 N k_B
1550     T(t) \tau_B^2} \left( \overleftrightarrow{\mathsf{P}}(t)
1551     - P_{\mathrm{target}}\mathsf{1} \right), \\
1552     %
1553     {\bf r}(t + h) &\leftarrow {\bf r}(t) + h \left\{ {\bf v}
1554     \left(t + h / 2 \right) + \overleftrightarrow{\eta}(t +
1555     h / 2) \cdot \left[ {\bf r}(t + h)
1556     - {\bf R}_0 \right] \right\}, \\
1557     %
1558     \mathsf{H}(t + h) &\leftarrow \mathsf{H}(t) \cdot e^{-h
1559     \overleftrightarrow{\eta}(t + h / 2)} .
1560     \end{align*}
1561     {\sc oopse} uses a power series expansion truncated at second order
1562     for the exponential operation which scales the simulation box.
1563    
1564     The {\tt moveB} portion of the algorithm is largely unchanged from the
1565     NPTi integrator:
1566    
1567     {\tt moveB:}
1568     \begin{align*}
1569     T(t + h) &\leftarrow \left\{{\bf v}(t + h)\right\},
1570     \left\{{\bf j}(t + h)\right\}, \\
1571     %
1572     \overleftrightarrow{\mathsf{P}}(t + h) &\leftarrow \left\{{\bf r}
1573     (t + h)\right\}, \left\{{\bf v}(t
1574     + h)\right\}, \left\{{\bf f}(t + h)\right\} ,\\
1575     %
1576     \chi\left(t + h \right) &\leftarrow \chi\left(t + h /
1577     2 \right) + \frac{h}{2 \tau_T^2} \left( \frac{T(t+
1578     h)}{T_{\mathrm{target}}} - 1 \right), \\
1579     %
1580     \overleftrightarrow{\eta}(t + h) &\leftarrow
1581     \overleftrightarrow{\eta}(t + h / 2) +
1582     \frac{h \mathcal{V}(t + h)}{2 N k_B T(t + h)
1583     \tau_B^2} \left( \overleftrightarrow{P}(t + h)
1584     - P_{\mathrm{target}}\mathsf{1} \right) ,\\
1585     %
1586     {\bf v}\left(t + h \right) &\leftarrow {\bf v}\left(t
1587     + h / 2 \right) + \frac{h}{2} \left(
1588     \frac{{\bf f}(t + h)}{m} -
1589     (\chi(t + h)\mathsf{1} + \overleftrightarrow{\eta}(t
1590     + h)) \right) \cdot {\bf v}(t + h), \\
1591     %
1592     {\bf j}\left(t + h \right) &\leftarrow {\bf j}\left(t
1593     + h / 2 \right) + \frac{h}{2} \left( {\bf \tau}^b(t
1594     + h) - {\bf j}(t + h) \chi(t + h) \right) .
1595     \end{align*}
1596    
1597     The iterative schemes for both {\tt moveA} and {\tt moveB} are
1598     identical to those described for the NPTi integrator.
1599    
1600     The NPTf integrator is known to conserve the following Hamiltonian:
1601     \begin{equation}
1602     H_{\mathrm{NPTf}} = V + K + f k_B T_{\mathrm{target}} \left(
1603     \frac{\tau_{T}^2 \chi^2(t)}{2} + \int_{0}^{t} \chi(t^\prime) dt^\prime
1604     \right) + P_{\mathrm{target}} \mathcal{V}(t) + \frac{f k_B
1605     T_{\mathrm{target}}}{2}
1606     \mathrm{Tr}\left[\overleftrightarrow{\eta}(t)\right]^2 \tau_B^2.
1607     \end{equation}
1608    
1609     This integrator must be used with care, particularly in liquid
1610     simulations. Liquids have very small restoring forces in the
1611     off-diagonal directions, and the simulation box can very quickly form
1612     elongated and sheared geometries which become smaller than the
1613     electrostatic or Lennard-Jones cutoff radii. The NPTf integrator
1614     finds most use in simulating crystals or liquid crystals which assume
1615     non-orthorhombic geometries.
1616    
1617     \subsection{\label{nptxyz}Constant pressure in 3 axes (NPTxyz)}
1618    
1619     There is one additional extended system integrator which is somewhat
1620     simpler than the NPTf method described above. In this case, the three
1621     axes have independent barostats which each attempt to preserve the
1622     target pressure along the box walls perpendicular to that particular
1623     axis. The lengths of the box axes are allowed to fluctuate
1624     independently, but the angle between the box axes does not change.
1625     The equations of motion are identical to those described above, but
1626     only the {\it diagonal} elements of $\overleftrightarrow{\eta}$ are
1627     computed. The off-diagonal elements are set to zero (even when the
1628     pressure tensor has non-zero off-diagonal elements).
1629    
1630     It should be noted that the NPTxyz integrator is {\it not} known to
1631     preserve any Hamiltonian of interest to the chemical physics
1632     community. The integrator is extremely useful, however, in generating
1633     initial conditions for other integration methods. It {\it is} suitable
1634     for use with liquid simulations, or in cases where there is
1635     orientational anisotropy in the system (i.e. in lipid bilayer
1636     simulations).
1637    
1638     \subsection{\label{oopseSec:rattle}The {\sc rattle} Method for Bond
1639     Constraints}
1640    
1641     In order to satisfy the constraints of fixed bond lengths within {\sc
1642     oopse}, we have implemented the {\sc rattle} algorithm of
1643     Andersen.\cite{andersen83} The algorithm is a velocity verlet
1644     formulation of the {\sc shake} method\cite{ryckaert77} of iteratively
1645     solving the Lagrange multipliers of constraint. The system of Lagrange
1646     multipliers allows one to reformulate the equations of motion with
1647     explicit constraint forces.\cite{fowles99:lagrange}
1648    
1649     Consider a system described by coordinates $q_1$ and $q_2$ subject to an
1650     equation of constraint:
1651     \begin{equation}
1652     \sigma(q_1, q_2,t) = 0
1653     \label{oopseEq:lm1}
1654     \end{equation}
1655     The Lagrange formulation of the equations of motion can be written:
1656     \begin{equation}
1657     \delta\int_{t_1}^{t_2}L\, dt =
1658     \int_{t_1}^{t_2} \sum_i \biggl [ \frac{\partial L}{\partial q_i}
1659     - \frac{d}{dt}\biggl(\frac{\partial L}{\partial \dot{q}_i}
1660     \biggr ) \biggr] \delta q_i \, dt = 0.
1661     \label{oopseEq:lm2}
1662     \end{equation}
1663     Here, $\delta q_i$ is not independent for each $q$, as $q_1$ and $q_2$
1664     are linked by $\sigma$. However, $\sigma$ is fixed at any given
1665     instant of time, giving:
1666     \begin{align}
1667     \delta\sigma &= \biggl( \frac{\partial\sigma}{\partial q_1} \delta q_1 %
1668     + \frac{\partial\sigma}{\partial q_2} \delta q_2 \biggr) = 0 ,\\
1669     %
1670     \frac{\partial\sigma}{\partial q_1} \delta q_1 &= %
1671     - \frac{\partial\sigma}{\partial q_2} \delta q_2, \\
1672     %
1673     \delta q_2 &= - \biggl(\frac{\partial\sigma}{\partial q_1} \bigg / %
1674     \frac{\partial\sigma}{\partial q_2} \biggr) \delta q_1.
1675     \end{align}
1676     Substituted back into Eq.~\ref{oopseEq:lm2},
1677     \begin{equation}
1678     \int_{t_1}^{t_2}\biggl [ \biggl(\frac{\partial L}{\partial q_1}
1679     - \frac{d}{dt}\,\frac{\partial L}{\partial \dot{q}_1}
1680     \biggr)
1681     - \biggl( \frac{\partial L}{\partial q_1}
1682     - \frac{d}{dt}\,\frac{\partial L}{\partial \dot{q}_1}
1683     \biggr) \biggl(\frac{\partial\sigma}{\partial q_1} \bigg / %
1684     \frac{\partial\sigma}{\partial q_2} \biggr)\biggr] \delta q_1 \, dt = 0.
1685     \label{oopseEq:lm3}
1686     \end{equation}
1687     Leading to,
1688     \begin{equation}
1689     \frac{\biggl(\frac{\partial L}{\partial q_1}
1690     - \frac{d}{dt}\,\frac{\partial L}{\partial \dot{q}_1}
1691     \biggr)}{\frac{\partial\sigma}{\partial q_1}} =
1692     \frac{\biggl(\frac{\partial L}{\partial q_2}
1693     - \frac{d}{dt}\,\frac{\partial L}{\partial \dot{q}_2}
1694     \biggr)}{\frac{\partial\sigma}{\partial q_2}}.
1695     \label{oopseEq:lm4}
1696     \end{equation}
1697     This relation can only be statisfied, if both are equal to a single
1698     function $-\lambda(t)$,
1699     \begin{align}
1700     \frac{\biggl(\frac{\partial L}{\partial q_1}
1701     - \frac{d}{dt}\,\frac{\partial L}{\partial \dot{q}_1}
1702     \biggr)}{\frac{\partial\sigma}{\partial q_1}} &= -\lambda(t), \\
1703     %
1704     \frac{\partial L}{\partial q_1}
1705     - \frac{d}{dt}\,\frac{\partial L}{\partial \dot{q}_1} &=
1706     -\lambda(t)\,\frac{\partial\sigma}{\partial q_1} ,\\
1707     %
1708     \frac{\partial L}{\partial q_1}
1709     - \frac{d}{dt}\,\frac{\partial L}{\partial \dot{q}_1}
1710     + \mathcal{G}_i &= 0,
1711     \end{align}
1712     where $\mathcal{G}_i$, the force of constraint on $i$, is:
1713     \begin{equation}
1714     \mathcal{G}_i = \lambda(t)\,\frac{\partial\sigma}{\partial q_1}.
1715     \label{oopseEq:lm5}
1716     \end{equation}
1717    
1718     In a simulation, this would involve the solution of a set of $(m + n)$
1719     number of equations. Where $m$ is the number of constraints, and $n$
1720     is the number of constrained coordinates. In practice, this is not
1721     done, as the matrix inversion necessary to solve the system of
1722     equations would be very time consuming to solve. Additionally, the
1723     numerical error in the solution of the set of $\lambda$'s would be
1724     compounded by the error inherent in propagating by the Velocity Verlet
1725     algorithm ($\Delta t^4$). The Verlet propagation error is negligible
1726     in an unconstrained system, as one is interested in the statistics of
1727     the run, and not that the run be numerically exact to the ``true''
1728     integration. This relates back to the ergodic hypothesis that a time
1729     integral of a valid trajectory will still give the correct ensemble
1730     average. However, in the case of constraints, if the equations of
1731     motion leave the ``true'' trajectory, they are departing from the
1732     constrained surface. The method that is used, is to iteratively solve
1733     for $\lambda(t)$ at each time step.
1734    
1735     In {\sc rattle} the equations of motion are modified subject to the
1736     following two constraints:
1737     \begin{align}
1738     \sigma_{ij}[\mathbf{r}(t)] \equiv
1739     [ \mathbf{r}_i(t) - \mathbf{r}_j(t)]^2 - d_{ij}^2 &= 0 %
1740     \label{oopseEq:c1}, \\
1741     %
1742     [\mathbf{\dot{r}}_i(t) - \mathbf{\dot{r}}_j(t)] \cdot
1743     [\mathbf{r}_i(t) - \mathbf{r}_j(t)] &= 0 .\label{oopseEq:c2}
1744     \end{align}
1745     Eq.~\ref{oopseEq:c1} is the set of bond constraints, where $d_{ij}$ is
1746     the constrained distance between atom $i$ and
1747     $j$. Eq.~\ref{oopseEq:c2} constrains the velocities of $i$ and $j$ to
1748     be perpendicular to the bond vector, so that the bond can neither grow
1749     nor shrink. The constrained dynamics equations become:
1750     \begin{equation}
1751     m_i \mathbf{\ddot{r}}_i = \mathbf{F}_i + \mathbf{\mathcal{G}}_i,
1752     \label{oopseEq:r1}
1753     \end{equation}
1754     where,$\mathbf{\mathcal{G}}_i$ are the forces of constraint on $i$,
1755     and are defined:
1756     \begin{equation}
1757     \mathbf{\mathcal{G}}_i = - \sum_j \lambda_{ij}(t)\,\nabla \sigma_{ij}.
1758     \label{oopseEq:r2}
1759     \end{equation}
1760    
1761     In Velocity Verlet, if $\Delta t = h$, the propagation can be written:
1762     \begin{align}
1763     \mathbf{r}_i(t+h) &=
1764     \mathbf{r}_i(t) + h\mathbf{\dot{r}}(t) +
1765     \frac{h^2}{2m_i}\,\Bigl[ \mathbf{F}_i(t) +
1766     \mathbf{\mathcal{G}}_{Ri}(t) \Bigr] \label{oopseEq:vv1}, \\
1767     %
1768     \mathbf{\dot{r}}_i(t+h) &=
1769     \mathbf{\dot{r}}_i(t) + \frac{h}{2m_i}
1770     \Bigl[ \mathbf{F}_i(t) + \mathbf{\mathcal{G}}_{Ri}(t) +
1771     \mathbf{F}_i(t+h) + \mathbf{\mathcal{G}}_{Vi}(t+h) \Bigr] ,%
1772     \label{oopseEq:vv2}
1773     \end{align}
1774     where:
1775     \begin{align}
1776     \mathbf{\mathcal{G}}_{Ri}(t) &=
1777     -2 \sum_j \lambda_{Rij}(t) \mathbf{r}_{ij}(t) ,\\
1778     %
1779     \mathbf{\mathcal{G}}_{Vi}(t+h) &=
1780     -2 \sum_j \lambda_{Vij}(t+h) \mathbf{r}(t+h).
1781     \end{align}
1782     Next, define:
1783     \begin{align}
1784     g_{ij} &= h \lambda_{Rij}(t) ,\\
1785     k_{ij} &= h \lambda_{Vij}(t+h), \\
1786     \mathbf{q}_i &= \mathbf{\dot{r}}_i(t) + \frac{h}{2m_i} \mathbf{F}_i(t)
1787     - \frac{1}{m_i}\sum_j g_{ij}\mathbf{r}_{ij}(t).
1788     \end{align}
1789     Using these definitions, Eq.~\ref{oopseEq:vv1} and \ref{oopseEq:vv2}
1790     can be rewritten as,
1791     \begin{align}
1792     \mathbf{r}_i(t+h) &= \mathbf{r}_i(t) + h \mathbf{q}_i ,\\
1793     %
1794     \mathbf{\dot{r}}(t+h) &= \mathbf{q}_i + \frac{h}{2m_i}\mathbf{F}_i(t+h)
1795     -\frac{1}{m_i}\sum_j k_{ij} \mathbf{r}_{ij}(t+h).
1796     \end{align}
1797    
1798     To integrate the equations of motion, the {\sc rattle} algorithm first
1799     solves for $\mathbf{r}(t+h)$. Let,
1800     \begin{equation}
1801     \mathbf{q}_i = \mathbf{\dot{r}}(t) + \frac{h}{2m_i}\mathbf{F}_i(t).
1802     \end{equation}
1803     Here $\mathbf{q}_i$ corresponds to an initial unconstrained move. Next
1804     pick a constraint $j$, and let,
1805     \begin{equation}
1806     \mathbf{s} = \mathbf{r}_i(t) + h\mathbf{q}_i(t)
1807     - \mathbf{r}_j(t) + h\mathbf{q}_j(t).
1808     \label{oopseEq:ra1}
1809     \end{equation}
1810     If
1811     \begin{equation}
1812     \Big| |\mathbf{s}|^2 - d_{ij}^2 \Big| > \text{tolerance},
1813     \end{equation}
1814     then the constraint is unsatisfied, and corrections are made to the
1815     positions. First we define a test corrected configuration as,
1816     \begin{align}
1817     \mathbf{r}_i^T(t+h) = \mathbf{r}_i(t) + h\biggl[\mathbf{q}_i -
1818     g_{ij}\,\frac{\mathbf{r}_{ij}(t)}{m_i} \biggr] ,\\
1819     %
1820     \mathbf{r}_j^T(t+h) = \mathbf{r}_j(t) + h\biggl[\mathbf{q}_j +
1821     g_{ij}\,\frac{\mathbf{r}_{ij}(t)}{m_j} \biggr].
1822     \end{align}
1823     And we chose $g_{ij}$ such that, $|\mathbf{r}_i^T - \mathbf{r}_j^T|^2
1824     = d_{ij}^2$. Solving the quadratic for $g_{ij}$ we obtain the
1825     approximation,
1826     \begin{equation}
1827     g_{ij} = \frac{(s^2 - d^2)}{2h[\mathbf{s}\cdot\mathbf{r}_{ij}(t)]
1828     (\frac{1}{m_i} + \frac{1}{m_j})}.
1829     \end{equation}
1830     Although not an exact solution for $g_{ij}$, as this is an iterative
1831     scheme overall, the eventual solution will converge. With a trial
1832     $g_{ij}$, the new $\mathbf{q}$'s become,
1833     \begin{align}
1834     \mathbf{q}_i &= \mathbf{q}^{\text{old}}_i - g_{ij}\,
1835     \frac{\mathbf{r}_{ij}(t)}{m_i} ,\\
1836     %
1837     \mathbf{q}_j &= \mathbf{q}^{\text{old}}_j + g_{ij}\,
1838     \frac{\mathbf{r}_{ij}(t)}{m_j} .
1839     \end{align}
1840     The whole algorithm is then repeated from Eq.~\ref{oopseEq:ra1} until
1841     all constraints are satisfied.
1842    
1843     The second step of {\sc rattle}, is to then update the velocities. The
1844     step starts with,
1845     \begin{equation}
1846     \mathbf{\dot{r}}_i(t+h) = \mathbf{q}_i + \frac{h}{2m_i}\mathbf{F}_i(t+h).
1847     \end{equation}
1848     Next we pick a constraint $j$, and calculate the dot product $\ell$.
1849     \begin{equation}
1850     \ell = \mathbf{r}_{ij}(t+h) \cdot \mathbf{\dot{r}}_{ij}(t+h).
1851     \label{oopseEq:rv1}
1852     \end{equation}
1853     Here if constraint Eq.~\ref{oopseEq:c2} holds, $\ell$ should be
1854     zero. Therefore if $\ell$ is greater than some tolerance, then
1855     corrections are made to the $i$ and $j$ velocities.
1856     \begin{align}
1857     \mathbf{\dot{r}}_i^T &= \mathbf{\dot{r}}_i(t+h) - k_{ij}
1858     \frac{\mathbf{\dot{r}}_{ij}(t+h)}{m_i}, \\
1859     %
1860     \mathbf{\dot{r}}_j^T &= \mathbf{\dot{r}}_j(t+h) + k_{ij}
1861     \frac{\mathbf{\dot{r}}_{ij}(t+h)}{m_j}.
1862     \end{align}
1863     Like in the previous step, we select a value for $k_{ij}$ such that
1864     $\ell$ is zero.
1865     \begin{equation}
1866     k_{ij} = \frac{\ell}{d^2_{ij}(\frac{1}{m_i} + \frac{1}{m_j})}.
1867     \end{equation}
1868     The test velocities, $\mathbf{\dot{r}}^T_i$ and
1869     $\mathbf{\dot{r}}^T_j$, then replace their respective velocities, and
1870     the algorithm is iterated from Eq.~\ref{oopseEq:rv1} until all
1871     constraints are satisfied.
1872    
1873    
1874     \subsection{\label{oopseSec:zcons}Z-Constraint Method}
1875    
1876     Based on the fluctuation-dissipation theorem, a force auto-correlation
1877     method was developed by Roux and Karplus to investigate the dynamics
1878     of ions inside ion channels.\cite{Roux91} The time-dependent friction
1879     coefficient can be calculated from the deviation of the instantaneous
1880     force from its mean force.
1881     \begin{equation}
1882     \xi(z,t)=\langle\delta F(z,t)\delta F(z,0)\rangle/k_{B}T,
1883     \end{equation}
1884     where%
1885     \begin{equation}
1886     \delta F(z,t)=F(z,t)-\langle F(z,t)\rangle.
1887     \end{equation}
1888    
1889    
1890     If the time-dependent friction decays rapidly, the static friction
1891     coefficient can be approximated by
1892     \begin{equation}
1893     \xi_{\text{static}}(z)=\int_{0}^{\infty}\langle\delta F(z,t)\delta F(z,0)\rangle dt.
1894     \end{equation}
1895     Allowing diffusion constant to then be calculated through the
1896     Einstein relation:\cite{Marrink94}
1897     \begin{equation}
1898     D(z)=\frac{k_{B}T}{\xi_{\text{static}}(z)}=\frac{(k_{B}T)^{2}}{\int_{0}^{\infty
1899     }\langle\delta F(z,t)\delta F(z,0)\rangle dt}.%
1900     \end{equation}
1901    
1902     The Z-Constraint method, which fixes the z coordinates of the
1903     molecules with respect to the center of the mass of the system, has
1904     been a method suggested to obtain the forces required for the force
1905     auto-correlation calculation.\cite{Marrink94} However, simply resetting the
1906     coordinate will move the center of the mass of the whole system. To
1907     avoid this problem, a new method was used in {\sc oopse}. Instead of
1908     resetting the coordinate, we reset the forces of z-constrained
1909     molecules as well as subtract the total constraint forces from the
1910     rest of the system after the force calculation at each time step.
1911    
1912     After the force calculation, define $G_\alpha$ as
1913     \begin{equation}
1914     G_{\alpha} = \sum_i F_{\alpha i},
1915     \label{oopseEq:zc1}
1916     \end{equation}
1917     where $F_{\alpha i}$ is the force in the z direction of atom $i$ in
1918     z-constrained molecule $\alpha$. The forces of the z constrained
1919     molecule are then set to:
1920     \begin{equation}
1921     F_{\alpha i} = F_{\alpha i} -
1922     \frac{m_{\alpha i} G_{\alpha}}{\sum_i m_{\alpha i}}.
1923     \end{equation}
1924     Here, $m_{\alpha i}$ is the mass of atom $i$ in the z-constrained
1925     molecule. Having rescaled the forces, the velocities must also be
1926     rescaled to subtract out any center of mass velocity in the z
1927     direction.
1928     \begin{equation}
1929     v_{\alpha i} = v_{\alpha i} -
1930     \frac{\sum_i m_{\alpha i} v_{\alpha i}}{\sum_i m_{\alpha i}},
1931     \end{equation}
1932     where $v_{\alpha i}$ is the velocity of atom $i$ in the z direction.
1933     Lastly, all of the accumulated z constrained forces must be subtracted
1934     from the system to keep the system center of mass from drifting.
1935     \begin{equation}
1936     F_{\beta i} = F_{\beta i} - \frac{m_{\beta i} \sum_{\alpha} G_{\alpha}}
1937     {\sum_{\beta}\sum_i m_{\beta i}},
1938     \end{equation}
1939     where $\beta$ are all of the unconstrained molecules in the
1940     system. Similarly, the velocities of the unconstrained molecules must
1941     also be scaled.
1942     \begin{equation}
1943     v_{\beta i} = v_{\beta i} + \sum_{\alpha}
1944     \frac{\sum_i m_{\alpha i} v_{\alpha i}}{\sum_i m_{\alpha i}}.
1945     \end{equation}
1946    
1947     At the very beginning of the simulation, the molecules may not be at their
1948     constrained positions. To move a z-constrained molecule to its specified
1949     position, a simple harmonic potential is used
1950     \begin{equation}
1951     U(t)=\frac{1}{2}k_{\text{Harmonic}}(z(t)-z_{\text{cons}})^{2},%
1952     \end{equation}
1953     where $k_{\text{Harmonic}}$ is the harmonic force constant, $z(t)$ is the
1954     current $z$ coordinate of the center of mass of the constrained molecule, and
1955     $z_{\text{cons}}$ is the constrained position. The harmonic force operating
1956     on the z-constrained molecule at time $t$ can be calculated by
1957     \begin{equation}
1958     F_{z_{\text{Harmonic}}}(t)=-\frac{\partial U(t)}{\partial z(t)}=
1959     -k_{\text{Harmonic}}(z(t)-z_{\text{cons}}).
1960     \end{equation}
1961    
1962     \section{\label{oopseSec:props}Trajectory Analysis}
1963    
1964     \subsection{\label{oopseSec:staticProps}Static Property Analysis}
1965    
1966     The static properties of the trajectories are analyzed with the
1967     program \texttt{staticProps}. The code is capable of calculating a
1968     number of pair correlations between species A and B. Some of which
1969     only apply to directional entities. The summary of pair correlations
1970     can be found in Table~\ref{oopseTb:gofrs}
1971    
1972     \begin{table}
1973     \caption{THE DIFFERENT PAIR CORRELATIONS IN \texttt{staticProps}}
1974     \label{oopseTb:gofrs}
1975     \begin{center}
1976     \begin{tabular}{|l|c|c|}
1977     \hline
1978     Name & Equation & Directional Atom \\ \hline
1979     $g_{\text{AB}}(r)$ & Eq.~\ref{eq:gofr} & neither \\ \hline
1980     $g_{\text{AB}}(r, \cos \theta)$ & Eq.~\ref{eq:gofrCosTheta} & A \\ \hline
1981     $g_{\text{AB}}(r, \cos \omega)$ & Eq.~\ref{eq:gofrCosOmega} & both \\ \hline
1982     $g_{\text{AB}}(x, y, z)$ & Eq.~\ref{eq:gofrXYZ} & neither \\ \hline
1983     $\langle \cos \omega \rangle_{\text{AB}}(r)$ & Eq.~\ref{eq:cosOmegaOfR} &%
1984     both \\ \hline
1985     \end{tabular}
1986     \begin{minipage}{\linewidth}
1987     \centering
1988     \vspace{2mm}
1989     The third column specifies which atom, if any, need be a directional entity.
1990     \end{minipage}
1991     \end{center}
1992     \end{table}
1993    
1994     The first pair correlation, $g_{\text{AB}}(r)$, is defined as follows:
1995     \begin{equation}
1996     g_{\text{AB}}(r) = \frac{V}{N_{\text{A}}N_{\text{B}}}\langle %%
1997     \sum_{i \in \text{A}} \sum_{j \in \text{B}} %%
1998     \delta( r - |\mathbf{r}_{ij}|) \rangle, \label{eq:gofr}
1999     \end{equation}
2000     where $\mathbf{r}_{ij}$ is the vector
2001     \begin{equation*}
2002     \mathbf{r}_{ij} = \mathbf{r}_j - \mathbf{r}_i, \notag
2003     \end{equation*}
2004     and $\frac{V}{N_{\text{A}}N_{\text{B}}}$ normalizes the average over
2005     the expected pair density at a given $r$.
2006    
2007     The next two pair correlations, $g_{\text{AB}}(r, \cos \theta)$ and
2008     $g_{\text{AB}}(r, \cos \omega)$, are similar in that they are both two
2009     dimensional histograms. Both use $r$ for the primary axis then a
2010     $\cos$ for the secondary axis ($\cos \theta$ for
2011     Eq.~\ref{eq:gofrCosTheta} and $\cos \omega$ for
2012     Eq.~\ref{eq:gofrCosOmega}). This allows for the investigator to
2013     correlate alignment on directional entities. $g_{\text{AB}}(r, \cos
2014     \theta)$ is defined as follows:
2015     \begin{equation}
2016     g_{\text{AB}}(r, \cos \theta) = \frac{V}{N_{\text{A}}N_{\text{B}}}\langle
2017     \sum_{i \in \text{A}} \sum_{j \in \text{B}}
2018     \delta( \cos \theta - \cos \theta_{ij})
2019     \delta( r - |\mathbf{r}_{ij}|) \rangle.
2020     \label{eq:gofrCosTheta}
2021     \end{equation}
2022     Here
2023     \begin{equation*}
2024     \cos \theta_{ij} = \mathbf{\hat{i}} \cdot \mathbf{\hat{r}}_{ij},
2025     \end{equation*}
2026     where $\mathbf{\hat{i}}$ is the unit directional vector of species $i$
2027     and $\mathbf{\hat{r}}_{ij}$ is the unit vector associated with vector
2028     $\mathbf{r}_{ij}$.
2029    
2030     The second two dimensional histogram is of the form:
2031     \begin{equation}
2032     g_{\text{AB}}(r, \cos \omega) =
2033     \frac{V}{N_{\text{A}}N_{\text{B}}}\langle
2034     \sum_{i \in \text{A}} \sum_{j \in \text{B}}
2035     \delta( \cos \omega - \cos \omega_{ij})
2036     \delta( r - |\mathbf{r}_{ij}|) \rangle. \label{eq:gofrCosOmega}
2037     \end{equation}
2038     Here
2039     \begin{equation*}
2040     \cos \omega_{ij} = \mathbf{\hat{i}} \cdot \mathbf{\hat{j}}.
2041     \end{equation*}
2042     Again, $\mathbf{\hat{i}}$ and $\mathbf{\hat{j}}$ are the unit
2043     directional vectors of species $i$ and $j$.
2044    
2045     The static analysis code is also cable of calculating a three
2046     dimensional pair correlation of the form:
2047     \begin{equation}\label{eq:gofrXYZ}
2048     g_{\text{AB}}(x, y, z) =
2049     \frac{V}{N_{\text{A}}N_{\text{B}}}\langle
2050     \sum_{i \in \text{A}} \sum_{j \in \text{B}}
2051     \delta( x - x_{ij})
2052     \delta( y - y_{ij})
2053     \delta( z - z_{ij}) \rangle,
2054     \end{equation}
2055     where $x_{ij}$, $y_{ij}$, and $z_{ij}$ are the $x$, $y$, and $z$
2056     components respectively of vector $\mathbf{r}_{ij}$.
2057    
2058     The final pair correlation is similar to
2059     Eq.~\ref{eq:gofrCosOmega}. $\langle \cos \omega
2060     \rangle_{\text{AB}}(r)$ is calculated in the following way:
2061     \begin{equation}\label{eq:cosOmegaOfR}
2062     \langle \cos \omega \rangle_{\text{AB}}(r) =
2063     \langle \sum_{i \in \text{A}} \sum_{j \in \text{B}}
2064     (\cos \omega_{ij}) \delta( r - |\mathbf{r}_{ij}|) \rangle.
2065     \end{equation}
2066     Here $\cos \omega_{ij}$ is defined in the same way as in
2067     Eq.~\ref{eq:gofrCosOmega}. This equation is a single dimensional pair
2068     correlation that gives the average correlation of two directional
2069     entities as a function of their distance from each other.
2070    
2071     \subsection{\label{dynamicProps}Dynamic Property Analysis}
2072    
2073     The dynamic properties of a trajectory are calculated with the program
2074     \texttt{dynamicProps}. The program calculates the following properties:
2075     \begin{gather}
2076     \langle | \mathbf{r}(t) - \mathbf{r}(0) |^2 \rangle, \label{eq:rms}\\
2077     \langle \mathbf{v}(t) \cdot \mathbf{v}(0) \rangle, \label{eq:velCorr} \\
2078     \langle \mathbf{j}(t) \cdot \mathbf{j}(0) \rangle. \label{eq:angularVelCorr}
2079     \end{gather}
2080    
2081     Eq.~\ref{eq:rms} is the root mean square displacement function. Which
2082     allows one to observe the average displacement of an atom as a
2083     function of time. The quantity is useful when calculating diffusion
2084     coefficients because of the Einstein Relation, which is valid at long
2085     times.\cite{allen87:csl}
2086     \begin{equation}
2087     2tD = \langle | \mathbf{r}(t) - \mathbf{r}(0) |^2 \rangle.
2088     \label{oopseEq:einstein}
2089     \end{equation}
2090    
2091     Eq.~\ref{eq:velCorr} and \ref{eq:angularVelCorr} are the translational
2092     velocity and angular velocity correlation functions respectively. The
2093     latter is only applicable to directional species in the
2094     simulation. The velocity autocorrelation functions are useful when
2095     determining vibrational information about the system of interest.
2096    
2097     \section{\label{oopseSec:design}Program Design}
2098    
2099     \subsection{\label{sec:architecture} {\sc oopse} Architecture}
2100    
2101     The core of OOPSE is divided into two main object libraries:
2102     \texttt{libBASS} and \texttt{libmdtools}. \texttt{libBASS} is the
2103     library developed around the parsing engine and \texttt{libmdtools}
2104     is the software library developed around the simulation engine. These
2105     two libraries are designed to encompass all the basic functions and
2106     tools that {\sc oopse} provides. Utility programs, such as the
2107     property analyzers, need only link against the software libraries to
2108     gain access to parsing, force evaluation, and input / output
2109     routines.
2110    
2111     Contained in \texttt{libBASS} are all the routines associated with
2112     reading and parsing the \texttt{.bass} input files. Given a
2113     \texttt{.bass} file, \texttt{libBASS} will open it and any associated
2114     \texttt{.mdl} files; then create structures in memory that are
2115     templates of all the molecules specified in the input files. In
2116     addition, any simulation parameters set in the \texttt{.bass} file
2117     will be placed in a structure for later query by the controlling
2118     program.
2119    
2120     Located in \texttt{libmdtools} are all other routines necessary to a
2121     Molecular Dynamics simulation. The library uses the main data
2122     structures returned by \texttt{libBASS} to initialize the various
2123     parts of the simulation: the atom structures and positions, the force
2124     field, the integrator, \emph{et cetera}. After initialization, the
2125     library can be used to perform a variety of tasks: integrate a
2126     Molecular Dynamics trajectory, query phase space information from a
2127     specific frame of a completed trajectory, or even recalculate force or
2128     energetic information about specific frames from a completed
2129     trajectory.
2130    
2131     With these core libraries in place, several programs have been
2132     developed to utilize the routines provided by \texttt{libBASS} and
2133     \texttt{libmdtools}. The main program of the package is \texttt{oopse}
2134     and the corresponding parallel version \texttt{oopse\_MPI}. These two
2135     programs will take the \texttt{.bass} file, and create (and integrate)
2136     the simulation specified in the script. The two analysis programs
2137     \texttt{staticProps} and \texttt{dynamicProps} utilize the core
2138     libraries to initialize and read in trajectories from previously
2139     completed simulations, in addition to the ability to use functionality
2140     from \texttt{libmdtools} to recalculate forces and energies at key
2141     frames in the trajectories. Lastly, the family of system building
2142     programs (Sec.~\ref{oopseSec:initCoords}) also use the libraries to
2143     store and output the system configurations they create.
2144    
2145     \subsection{\label{oopseSec:parallelization} Parallelization of {\sc oopse}}
2146    
2147     Although processor power is continually growing roughly following
2148     Moore's Law, it is still unreasonable to simulate systems of more then
2149     a 1000 atoms on a single processor. To facilitate study of larger
2150     system sizes or smaller systems on long time scales in a reasonable
2151     period of time, parallel methods were developed allowing multiple
2152     CPU's to share the simulation workload. Three general categories of
2153     parallel decomposition methods have been developed including atomic,
2154     spatial and force decomposition methods.
2155    
2156     Algorithmically simplest of the three methods is atomic decomposition
2157     where N particles in a simulation are split among P processors for the
2158     duration of the simulation. Computational cost scales as an optimal
2159     $\mathcal{O}(N/P)$ for atomic decomposition. Unfortunately all
2160     processors must communicate positions and forces with all other
2161     processors at every force evaluation, leading communication costs to
2162     scale as an unfavorable $\mathcal{O}(N)$, \emph{independent of the
2163     number of processors}. This communication bottleneck led to the
2164     development of spatial and force decomposition methods in which
2165     communication among processors scales much more favorably. Spatial or
2166     domain decomposition divides the physical spatial domain into 3D boxes
2167     in which each processor is responsible for calculation of forces and
2168     positions of particles located in its box. Particles are reassigned to
2169     different processors as they move through simulation space. To
2170     calculate forces on a given particle, a processor must know the
2171     positions of particles within some cutoff radius located on nearby
2172     processors instead of the positions of particles on all
2173     processors. Both communication between processors and computation
2174     scale as $\mathcal{O}(N/P)$ in the spatial method. However, spatial
2175     decomposition adds algorithmic complexity to the simulation code and
2176     is not very efficient for small N since the overall communication
2177     scales as the surface to volume ratio $\mathcal{O}(N/P)^{2/3}$ in
2178     three dimensions.
2179    
2180     The parallelization method used in {\sc oopse} is the force
2181     decomposition method. Force decomposition assigns particles to
2182     processors based on a block decomposition of the force
2183     matrix. Processors are split into an optimally square grid forming row
2184     and column processor groups. Forces are calculated on particles in a
2185     given row by particles located in that processors column
2186     assignment. Force decomposition is less complex to implement than the
2187     spatial method but still scales computationally as $\mathcal{O}(N/P)$
2188     and scales as $\mathcal{O}(N/\sqrt{P})$ in communication
2189     cost. Plimpton has also found that force decompositions scale more
2190     favorably than spatial decompositions for systems up to 10,000 atoms
2191     and favorably compete with spatial methods up to 100,000
2192     atoms.\cite{plimpton95}
2193    
2194     \subsection{\label{oopseSec:memAlloc}Memory Issues in Trajectory Analysis}
2195    
2196     For large simulations, the trajectory files can sometimes reach sizes
2197     in excess of several gigabytes. In order to effectively analyze that
2198     amount of data, two memory management schemes have been devised for
2199     \texttt{staticProps} and for \texttt{dynamicProps}. The first scheme,
2200     developed for \texttt{staticProps}, is the simplest. As each frame's
2201     statistics are calculated independent of each other, memory is
2202     allocated for each frame, then freed once correlation calculations are
2203     complete for the snapshot. To prevent multiple passes through a
2204     potentially large file, \texttt{staticProps} is capable of calculating
2205     all requested correlations per frame with only a single pair loop in
2206     each frame and a single read of the file.
2207    
2208     The second, more advanced memory scheme, is used by
2209     \texttt{dynamicProps}. Here, the program must have multiple frames in
2210     memory to calculate time dependent correlations. In order to prevent a
2211     situation where the program runs out of memory due to large
2212     trajectories, the user is able to specify that the trajectory be read
2213     in blocks. The number of frames in each block is specified by the
2214     user, and upon reading a block of the trajectory,
2215     \texttt{dynamicProps} will calculate all of the time correlation frame
2216     pairs within the block. After in-block correlations are complete, a
2217     second block of the trajectory is read, and the cross correlations are
2218     calculated between the two blocks. This second block is then freed and
2219     then incremented and the process repeated until the end of the
2220     trajectory. Once the end is reached, the first block is freed then
2221     incremented, and the again the internal time correlations are
2222     calculated. The algorithm with the second block is then repeated with
2223     the new origin block, until all frame pairs have been correlated in
2224     time. This process is illustrated in
2225     Fig.~\ref{oopseFig:dynamicPropsMemory}.
2226    
2227     %\begin{figure}
2228     %\centering
2229     %\includegraphics[width=\linewidth]{dynamicPropsMem.eps}
2230     %\caption[A representation of the block correlations in \texttt{dynamicProps}]{This diagram illustrates the memory management used by \texttt{dynamicProps}, which follows the scheme: $\sum^{N_{\text{memory blocks}}}_{i=1}[ \operatorname{self}(i) + \sum^{N_{\text{memory blocks}}}_{j>i} \operatorname{cross}(i,j)]$. The shaded region represents the self correlation of the memory block, and the open blocks are read one at a time and the cross correlations between blocks are calculated.}
2231     %\label{oopseFig:dynamicPropsMemory}
2232     %\end{figure}
2233    
2234     \section{\label{oopseSec:conclusion}Conclusion}
2235    
2236     We have presented the design and implementation of our open source
2237     simulation package {\sc oopse}. The package offers novel capabilities
2238     to the field of Molecular Dynamics simulation packages in the form of
2239     dipolar force fields, and symplectic integration of rigid body
2240     dynamics. It is capable of scaling across multiple processors through
2241     the use of force based decomposition using MPI. It also implements
2242     several advanced integrators allowing the end user control over
2243     temperature and pressure. In addition, it is capable of integrating
2244     constrained dynamics through both the {\sc rattle} algorithm and the
2245     z-constraint method.
2246    
2247     These features are all brought together in a single open-source
2248     program. This allows researchers to not only benefit from
2249     {\sc oopse}, but also contribute to {\sc oopse}'s development as
2250     well.
2251    
2252    
2253     \newpage
2254     \section{Acknowledgments}
2255     The authors would like to thank espresso for fueling this work, and
2256     would also like to send a special acknowledgement to single malt
2257     scotch for its wonderful calming effects and its ability to make the
2258     troubles of the world float away.
2259    
2260     \bibliographystyle{achemso}
2261     \bibliography{oopsePaper}
2262    
2263     \end{document}