ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mattDisertation/oopse.tex
Revision: 1089
Committed: Mon Mar 8 22:15:54 2004 UTC (20 years, 4 months ago) by mmeineke
Content type: application/x-tex
File size: 99199 byte(s)
Log Message:
final draft submitted to the readers.

File Contents

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