Molecular Dynamics Simulation: 2.1 Molecular Models and Potentials
Molecular Dynamics Simulation: 2.1 Molecular Models and Potentials
Fig. 2.1 Principle of coarse graining: A fully atomistic (left) and united-atom (right) model for
butane. Atoms of functional groups are combined into a simple united site, achieving a compromise
between computational tractability and microscopic detail
(a)
(b)
Fig. 2.2 Rigid and flexible model of a simple molecule. a Rigid model of a molecule: the positions
of the interaction sites 1 and 2 are fixed relative to the center of mass, only sites of distinct molecules
interact pairwise (dashed lines). The position of all sites is uniquely determined by position and
orientation of the molecule. b Model of a molecule with internal degrees of freedom: the interaction
sites 1 and 2 are not fixed, but interact through bond potentials (dotted lines). The positions of the
sites have to be stored explicitly with each site
To observe the time evolution of such a system of particles, where each particle has
mass m i , a system of ordinary differential equations has to be solved:
Fi = m i · r̈i . (2.1)
One way to keep a molecule or parts thereof rigid is to compute forces for each
interaction site separately, and to impose geometric constraints on bond lengths, bond
or torsion angles. These constraints have to be fulfilled by the algorithm for the time
14 2 Molecular Dynamics Simulation
integration. The most common algorithm is the Shake algorithm [1], which is based
on the Störmer-Verlet integration scheme, and also more sophisticated variants such
as QSHAKE [2] or PLINCKS [3] have been developed. However, a more efficient
way is to compute the torque on molecule i, resulting from the interactions of its
interaction sites n ∈ sitesi , and to integrate the rotational motion. In this model, only
forces between sites of different molecules are computed and the total force on a
rigid molecule equals
Fi = −∇Unm (rnm ).
j∈particles n∈sitesi m∈sites j
j =i
This force is used to solve Eq. (2.1). The forces on the sites at distance dn from the
center of mass at ri yield a torque on the molecule
τi = dn × Fn .
n∈sitesi
Then the system of equations for the rotational motion can be solved
τi
ω̇i = ,
Ii
where ω̇ is the angular acceleration, τ the torque, and I the moment of inertia.
Here, we remark that the computation of forces on a molecule involves all other
molecules in the simulation, so the complexity is O(N 2 ) for both rigid and flexible
molecular models.
Many of the fluids targeted in process engineering are composed of comparably
simple, small molecules (in the following, we use the term particle interchange-
ably), which can be approximated by rigid bodies. A rigid model enables a cheaper
implementation of the force computation as well as longer time steps. Since our
code is based on rigid-body motion, we describe rigid-body molecular dynamics
in more detail. Most other current software packages implement rigid-body MD
by constraint-motion dynamics, which is less efficient, so this is a key aspect to
distinguish ls1 mardyn from other simulation codes.
Rigid-Body Molecular Dynamics For molecules modeled as fully rigid units, both
equations for translational and rotational motion can be solved at once, if force and
torque on its center of mass are known. In ls1 mardyn, the Rotational Leapfrog
algorithm [4] is implemented.
While the orientation of a body can be expressed in Eulerian angles, it is more con-
venient to use a quaternion q = (q0 q1 q2 q3 )T , because singularities in the equations
of motion are avoided [5]. The computation of the angular acceleration is carried out
in a body-fixed coordinate system, i.e., the coordinate system is fixed relative to the
rotating molecule. This body-fixed coordinate system should be chosen such that the
mass tensor I is a diagonal matrix, simplifying the following equations. From the
2.1 Molecular Models and Potentials 15
quaternion, a rotation matrix R(q) can be defined to express a vector, given in the
global coordinate system, in the body-fixed system. The inverse operation is denoted
by R T (q).
The rate of change of the angular momentum j equals the torque τ , ∂dtj = τ , and
the angular velocity ω is related to the angular momentum by ω = I −1 j. Writing
the angular velocity as ω̂ = [0; ω]T , the rate of change of the orientation can be
expressed as ⎛ ⎞
q0 −q1 −q2 −q3
∂q ⎜q1 q0 −q3 q2 ⎟
= Q ω̂, where Q = ⎜ ⎝q2 q3 q0 −q1 ⎠ .
⎟
∂t
q3 −q2 q1 q0
Similar to the Leapfrog scheme for the translational motion, the angular momen-
tum j is stored at half time steps n − 21 , and the orientations at full time steps n.
1
Starting now at time n − 21 , the angular momentum j n− 2 is propagated to time n:
1 1
j n = j n− 2 + Δt · τ.
2
It is then rotated to the body-fixed coordinate system:
ĵ n = R T (q n ) j n ,
and the angular velocity in body-fixed coordinate frame can be determined compo-
nent wise:
ω̂αn = Iα−1 ĵαn .
1 Δt
The orientation is integrated a half time step, where q n+ 2 = q n + 2 Q(q n )ω̂n .
The remaining steps read [4]:
1 1
j n+ 2 = j n− 2 + Δtτ n ,
1 1 1
ĵ n+ 2 = R T (q n+ 2 ) j n+ 2 ,
n+ 21 n+ 1
ω̂α = Iˆα−1 jα 2 ,
1 1
q n+1 = q n + Δt Q(q n+ 2 )ω̂n+ 2 .
In the course of these computations, angular velocity and momentum are com-
puted at the full time step and can be used to apply a thermostat.
Intermolecular Potentials Theoretically, particle interaction needs to be modeled by
many-body potentials, which take the interactions between n−1 particles into account
when determining the potential energy for the n-th particle. As the construction of
16 2 Molecular Dynamics Simulation
potential functions is a highly nontrivial task, interaction models are simplified to two-
or three-body potentials, where the contributions of all pairs or triples of particles are
assumed to be strictly additive. Choosing the “right” potential functions, this results
in much lower computational cost while sufficient accuracy is maintained. In ls1
mardyn, the following effective pair potentials are used [6]:
Lennard-Jones-12-6 Potential. This potential models Van der Waals attraction and
Pauli repulsion and describes uncharged atoms:
12 6
σ σ
U rij = 4 − . (2.2)
rij rij
Consequently, this potential reproduces properties of noble gases very well, and
is both used for the study of ideal fluids as well as a building block for complex
molecular models. The potential parameters and σ are valid only for interaction
sites of the same species. For interactions of two unlike species A and B, their value
can be determined by the modified Lorentz combination rule [7]
σA + σB
σ AB = η AB , 0.95 < η AB < 1.05
2
and the modified Berthelot mixing rule [8, 9]:
1
AB = ξ AB ( A B ) 2 , 0.95 < ξ AB < 1.05,
where η AB and ξ AB are empirically determined mixing coefficient. The potential can
be truncated at a cut-off distance rc , assuming a homogeneous particle distribution
beyond rc . This truncated potential, referred to as Truncated-Shifted Lennard-Jones-
12-6, allows the construction of efficient algorithms with linear runtime O(N ). The
error of the potential truncation can be estimated by a mean-field approximation
to correct the computed quantities. For rigid-body molecules, the cut-off is applied
based on their center of mass.
Electrostatic Potentials. Another basic interaction type are Coulomb interactions:
1 qi q j
Uqq (rij ) = , (2.3)
4π 0 rij
where 1/(4π 0 ) is the Coulomb constant, and qi and q j are interacting charges. and
rij is the distance between the charges. Charge distributions with zero net charge may
be approximated by higher order point polarities, i.e., dipoles and quadrupoles as
described in [10].
If the net charge of molecules equals zero, these potentials can also be truncated
at a cut-off distance rc . The effect of the truncation on the potential energy can be
estimated by the Reaction-Field method [11, 12].
2.2 Statistical Ensembles 17
where rij denotes the distance and f ij the force between interaction sites i and j.
Simulations in the NVE ensemble are most self-evident. Energy is kept constant
automatically, as solving the Newtonian equations conserves energy and momentum.
To exclude boundary effects and to minimize finite-system effects, periodic boundary
conditions are typically imposed on simulations. If particles leave the domain on one
18 2 Molecular Dynamics Simulation
boundary, they enter the domain via the opposite boundary again, so the number of
particles does not change as well as the volume.
For NVT simulations, a thermostat is needed to keep the system at constant
temperature. Conceptually, this is achieved by coupling the simulated system to
an external heat bath, so that a weak exchange takes place, without disturbing the
system under consideration. While several algorithms have been proposed [14] and
especially relaxation schemes are popular, a very simple and effective method is to
scale all particle velocities by a factor
T target
β= .
T current
Velocity scaling does not strictly preserve the NVT ensemble; however, it is often
used assuming that the simulated system is not severely disturbed by the thermo-
stat [15]. To conserve all these ensembles, modified time integration schemes have
been developed, which solve the equations of motion in a suitable way. In ls1
mardyn, the thermostatted version of the Rotational Leapfrog algorithm [4] is used
for NVT simulations.
Δ
steps, to make sure it contains all neighboring molecules. In principle, this update is
of O(N 2 ) complexity, as again the mutual distance between all particles has to be
computed, so modern implementations combine it with the linked-cells algorithm as
explained in the next paragraph to achieve linear runtime.
It is an obvious advantage of the neighbor lists that they approximate the geometry
of the cut-off sphere well, and only few unnecessary distance computations have to be
performed. On the other hand, the complexity of the implementation is slightly higher,
as both the linked-cells and the neighbor list method have to be implemented. Verlet
lists are most efficient in static scenarios, where the movement of particles between
time steps is very slow. This holds, e.g., for simulations at very low temperatures,
at small time steps, or generally in the simulation of solid bodies such as crystals.
The overhead for large number of pointers per molecule, maybe even up to a few
hundreds, has to be considered as well. While it is usually not a serious issue on
current computers, there is a clear trade-off between memory and computational
overhead. A more severe question is the runtime-efficient implementation of neighbor
lists on current hardware. Pointers do not preserve locality, as it is required for
vectorization. In contrast to earlier vector computers, today’s vector architectures
do not support gather and scatter operations efficiently yet which would facilitate
the implementation. Apart from that, the multiple memory accesses traversing the
neighbor list can seriously degrade performance on current architectures [17].
Linked-Cells Algorithm [18, 19]. As depicted in Fig. 2.4a, the computational domain
is subdivided into cells of length rc . In every time step, the particles are sorted in
these cells according to their spatial coordinates. In order to identify all particles
within the cut-off radius around a given particle, only 8 neighboring cells in 2D or
26 cells in 3D as well as the cell of the particle itself have to be searched. Assuming
a homogeneous particle distribution, each cell contains Nc particles, where c denotes
the number of cells; so the distance computation can be done in O(N ), as long as
the particle density is kept constant. As we will see later, this algorithm is inherently
cache-friendly, as for each cell (N /c)2 computations are performed.
Since its invention, a lot of work has gone into the optimization of the linked-
cells algorithm. Evident from simple geometric considerations, roughly 78 % of the
particle distance computations are actually wasted, because the particles are sep-
arated by a larger distance than rc . One refinement is the generalized linked-cells
algorithm, which chooses cells of smaller size to better approximate the geome-
20 2 Molecular Dynamics Simulation
Fig. 2.4 Standard linked-cells algorithm and generalized linked-cells algorithm. a Schematic of
the original linked-cells idea with edge length l = rc . b Schematic of the original linked-cells idea
with edge length l = r2c
try of the cut-off sphere, cf. Fig. 2.4b. Thereby, the volume that has to be searched
for neighboring particles is decreased as well as the number of distance computa-
tions [20]. The efficiency of such schemes has also been investigated in [21], among
others. Buchholz [22] extended this idea by choosing the size of the cells adaptively,
depending on the density of the fluid: For regions with high number density, smaller
cells are chosen to decrease the overhead of distance computation, for regions with
low-number density, larger cells are chosen to avoid the overhead associated with
many small cells. That scheme is called adaptive linked-cells algorithm. A different
optimization technique is interaction sorting [23], where for each cell pair the coor-
dinates of the particles are projected onto the vector connecting the two cell centers.
Then the particles are sorted according to their position on that vector. In that way,
the distance between particles needs to be computed only as long as the distance
along the vector of the cell centers is smaller than rc , greatly reducing the number of
superfluous computations. A summary and comparison of the different approaches
can be found in [24].
In comparison to direct summation, some overhead occurs due to the cell data
structure and its update. An advantage is the seamless integration of periodic bound-
ary conditions, as depicted in Fig. 2.5. The cell structure is extended by one cell
layer at each boundary. Every time step, the particles of the opposite boundary are
replicated in these so-called halo-cells. These particles are used during the force
computation and deleted thereafter.
Linked-Cells: Parallelization based on Spatial Domain Decomposition. In a similar
way, parallelization based on spatial domain decomposition fits especially well to the
linked-cells data structure. Here, the computational domain is subdivided according
to the number of processes, so that equally sized subdomains are assigned to each
process. Similar to the integration of periodic boundaries, each subdomain is extended
by one cell layer, which contains molecules residing on neighboring processes, which
have to be communicated every iteration. Depending on the implementation, forces
for each molecule pair crossing a process boundary have to be communicated, or
2.3 Algorithms for Nearest-Neighbor Search 21
Tackling the field of process engineering, the simulation code ls1 mardyn [6, 36]
has now been developed for about a decade. Main contributors have been the
groups at the High-Performance Computing Center Stuttgart (HLRS), at the Chair
for Thermodynamics and Energy Technology (ThET) at University of Paderborn,
and the Laboratory for Engineering Thermodynamics (LTD) at the University of
24 2 Molecular Dynamics Simulation
1 http://towhee.sourceforge.net/.
2 http://www.materialsdesign.com/medea/medea-gibbs.
2.5 Simulation Code Mardyn
Fig. 2.6 Software layout of Martyn: The packages for parallelization, particleContainer, io, integration and the molecular
model are centered around the main class Simulation
25
26 2 Molecular Dynamics Simulation
integrator performs a half-step time integration to promote the velocities to the full
time step, then halo-particles are exchanged and load balancing may take place. Then
forces and potential are calculated, the thermostat as well as computations of other
thermodynamic statistical quantities are applied. At the end of the loop, the integrator
performs the second half-step integration, and i/o is performed.
Listing 2.1 Pseudocode of the main simulation loop in the class Simulation.
inputReader−>readPhaseSpace ( ) ;
domainDecomposition−>balanceAndExchangeMolecules ( ) ;
integrator−>eventNewTimestep( ) ;
domainDecomposition−>balanceAndExchangeMolecules ( ) ;
container−>traverseParticlePairs (pairs2ForceAdapter ) ;
thermostat ( ) ;
integrator−>eventForcesCalculated ( ) ;
References
1. J.-P. Ryckaert, G. Ciccotti, H.J. Berendsen, Numerical integration of the cartesian equations
of motion of a system with constraints: molecular dynamics of n-alkanes. J. Comput. Phys.
23(3), 327–341 (1977)
2. T.R. Forester, W. Smith, SHAKE, rattle, and roll: efficient constraint algorithms for linked rigid
bodies. J. Comput. Chem. 19(1), 102–111 (1998)
3. B. Hess, P-LINCS: a parallel linear constraint solver for molecular simulation. J. Chem. Theory
Comput. 4(1), 116–122 (2008)
4. D. Fincham, Leap frog rotational algorithms. Mol. Simul. 8, 165–178 (1992)
5. J.B. Kuipers, Quaternions and rotation sequences (Princeton University Press, Princeton, 1999)
6. C. Niethammer, S. Becker, M. Bernreuther, M. Buchholz, W. Eckhardt, A. Heinecke, S. Werth,
H.-J. Bungartz, C.W. Glass, H. Hasse, J. Vrabec, M. Horsch, ls1 mardyn: the massively parallel
molecular dynamics code for large systems. J. Chem. Theory Comput. (2014)
7. H.A. Lorentz, Über die Anwendung des Satzes vom Virial in der kinetischen Theorie der Gase.
Ann. Phys., 12(1):127–136, (1881). Addendum 12(4):660–661
8. D. Berthelot, Sur le mélange des gaz. Comptes rendus hebdomadaires des séances de
l’Académie des Sciences, 126:1703–1706, (1898). Addendum: vol. 126, no. 4, pp. 1857–1858
9. T. Schnabel, J. Vrabec, H. Hasse, Unlike Lennard-Jones parameters for vapor-liquid equilibria.
J. Mol. Liq. 135, 170–178 (2007)
10. C.G. Gray, K.E. Gubbins, Theory of molecular fluids, Volume 1: Fundamentals (Clarendon
Press, Oxford, 1984)
11. M.P. Allen, D.J. Tildesley, Computer Simulation of Liquids (Oxford University Press, Oxford,
1989)
12. J. Barker, R. Watts, Monte Carlo studies of the dielectric properties of water-like models. Mol.
Phys. 26(3), 789–792 (1973)
13. R. Clausius, XVI on a mechanical theorem applicable to heat. Philos. Mag. Ser. 4, 40(265):122–
127 (1870)
14. P.H. Hünenberger, Thermostat algorithms for molecular dynamics simulations, Advanced Com-
puter Simulation (Springer, Berlin, 2005), pp. 105–149
28 2 Molecular Dynamics Simulation
15. L. Woodcock, Isothermal molecular dynamics calculations for liquid salts. Chem. Phys. Lett.
10(3), 257–261 (1971)
16. L. Verlet, Computer experiments on classical fluids. I. Thermodynamical properties of Lennard-
Jones molecules. Phys. Rev. Online Arch. (Prola) 159(1), 98–103 (1967)
17. S. Pll, B. Hess, A flexible algorithm for calculating pair interactions on SIMD architectures.
Comput. Phys. Commun., (2013). Accepted for publication
18. R. Hockney, S. Goel, J. Eastwood, Quiet high-resolution computer models of a plasma. J.
Comput. Phys. 14(2), 148–158 (1974)
19. P. Schofield, Computer simulation studies of the liquid state. Comput. Phys. Commun. 5(1),
17–23 (1973)
20. M. Bernreuther, H.-J. Bungartz, Molecular simulation of fluid flow on a cluster of worksta-
tions, in Proceedings of the 18th Symposium Simulationstechnique (ASIM 2005), Volume 15
of Fortschritte in der Simulationstechnik—Frontiers in Simulation, ed. by F. Hülsemann, M.
Kowarschik, U. Rüde (SCS European Publishing House, Erlangen, 2005), pp. 117–123
21. G. Sutmann, V. Stegailov, Optimization of neighbor list techniques in liquid matter simulations.
J. Mol. Liq. 125, 197–203 (2006)
22. M. Buchholz, Framework zur Parallelisierung von Molekulardynamiksimulationen in ver-
fahrenstechnischen Anwendungen. Dissertation, Institut für Informatik, Technische Universität
München (2010)
23. P. Gonnet, A simple algorithm to accelerate the computation of non-bonded interactions in
cell-based molecular dynamics simulations. J. Comput. Chem. 28(2), 570–573 (2007)
24. U. Welling, G. Germano, Efficiency of linked cell algorithms. Comput. Phys. Commun. 182(3),
611–615 (2011)
25. J.C. Phillips, R. Braun, W. Wang, J. Gumbart, E. Tajkhorshid, E. Villa, C. Chipot, R.D. Skeel,
L. Kale, K. Schulten, Scalable molecular dynamics with NAMD. J. Comput. Chem. 26(16),
1781–1802 (2005)
26. B. Hess, C. Kutzner, D. van der Spoel, E. Lindahl, Gromacs 4: Algorithms for Highly Efficient,
Load-Balanced, and Scalable Molecular Simulation. J. Chem. Theory Comput. 4(3), 435–447
(2008)
27. K.J. Bowers, E. Chow, H. Xu, R.O. Dror, M.P. Eastwood, B.A. Gregersen, J.L. Klepeis, I.
Kolossvary, M.A. Moraes, F.D. Sacerdoti, J.K. Salmon, Y. Shan, D.E. Shaw, Scalable algo-
rithms for molecular dynamics simulations on commodity clusters. In Proceedings of the 2006
ACM/IEEE Conference on Supercomputing, SC ’06, ACM, New York, USA (2006)
28. B.R. Brooks, C.L. Brooks, A.D. Mackerell, L. Nilsson, R.J. Petrella, B. Roux, Y. Won, G.
Archontis, C. Bartels, S. Boresch et al., CHARMM: the biomolecular simulation program. J
Comput. Chem. 30(10), 1545–1614 (2009)
29. R. Salomon-Ferrer, D.A. Case, R.C. Walker, An overview of the Amber biomolecular simulation
package (Computational Molecular Science, Wiley Interdisciplinary Reviews, 2012)
30. A. Arnold, O. Lenz, S. Kesselheim, R. Weeber, F. Fahrenberger, D. Roehm, P. Košovan, C.
Holm, Espresso 3.1: molecular dynamics software for coarse-grained models, in meshfree
methods for partial differential equations VI, p. 1–23. (Springer, 2013)
31. S. Plimpton, Fast parallel algorithms for short-range molecular dynamics. J. Comput. Phys.
117(1), 1–19 (1995)
32. D.A. Case, T.E. Cheatham, T. Darden, H. Gohlke, R. Luo, K.M. Merz, A. Onufriev, C. Simmer-
ling, B. Wang, R.J. Woods, The Amber biomolecular simulation programs. J. Comput. Chem.
26(16), 1668–1688 (2005)
33. M. Griebel, S. Knapek, G.W. Zumbusch, Numerical simulation in molecular dynamics: numer-
ics, algorithms, parallelization, applications, vol 5. (Springer, 2007)
34. B. Eckl, J. Vrabec, H. Hasse, On the application of force fields for predicting a wide variety of
properties: ethylene oxide as an example. Fluid Phase Equilib. 274(1–2), 16–26 (2008)
35. T. Merker, C. Engin, J. Vrabec, H. Hasse, Molecular model for carbon dioxide optimized to
vapor-liquid equilibria. J. Chem. Phys., 132(23), (2010)
36. The ls1 mardyn website (2014), http://www.ls1-mardyn.de/
References 29
37. S. Deublein, B. Eckl, J. Stoll, S.V. Lishchuk, G. Guevara-Carrion, C.W. Glass, T. Merker,
M. Bernreuther, H. Hasse, J. Vrabec, ms2: a molecular simulation tool for thermodynamic
properties. Comput. Phys. Commun. 182(11), 2350–2367 (2011)
38. K.E. Gubbins, J.D. Moore, Molecular modeling of matter: impact and prospects in engineering.
Ind. Eng. Chem. Res. 49(7), 3026–3046 (2010)
39. E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design patterns: elements of reusable object-
oriented software. (Addison-Wesley, 1994)