Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Molecular Dynamics Lecture Notes: G Oran Wahnstr Om

Download as pdf or txt
Download as pdf or txt
You are on page 1of 65

Göran Wahnström

MOLECULAR DYNAMICS
Lecture notes

Göteborg, 11 November 2018


Molecular dynamics simulation

Molecular dynamics (MD) is a computer simulation technique where the


time evolution of a set of interacting particles is followed by integrating
their equation of motion. The technique has been applied to systems of
several hundreds to millions of particles and has given much insight into
the behaviour of interacting classical many-particle systems. The physical
movements of atoms and molecules are investigated by numerically solv-
ing Newton’s equation of motion using a description for the inter-atomic
interaction. Equilibrium and transport properties are obtained using the
theoretical approach developed within statistical mechanics.
The method was originally conceived within theoretical physics in the
late 1950s and is today applied extensively in various scientific disciplines
as materials and nano-sciences, and for biomolecular systems. For a general
background to the technique we refer to the excellent books by Frenkel and
Smit [1] and Allen and Tildesley [2]. A more elementary introduction can
be found in the book by Haile [3].

Contents
1 Classical mechanics 3
1.1 Newton’s equation of motion . . . . . . . . . . . . . . . . . . 3
1.2 Hamilton’s formulation of classical mechanics . . . . . . . . . 3

2 Statistical averaging 7

3 Physical models of the system 9


3.1 The potential energy surface . . . . . . . . . . . . . . . . . . . 9
3.2 Noble gas systems . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.1 Ionic systems . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.2 Metallic systems . . . . . . . . . . . . . . . . . . . . . 12
3.2.3 Covalent systems . . . . . . . . . . . . . . . . . . . . . 13
3.3 The system size . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4 The time integration algorithm 16


4.1 The Verlet algorithm . . . . . . . . . . . . . . . . . . . . . . . 16
4.2 Accurate predictions and the Lyaponov instability . . . . . . 17
4.3 The time step . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

5 Average properties 21
5.1 Kinetic, potential and total energies . . . . . . . . . . . . . . 22
5.2 Temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

1
5.3 Pressure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

6 A program 25
6.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.2 Equilibration . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.3 Production . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.4 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

7 Static properties 28
7.1 Mechanic properties . . . . . . . . . . . . . . . . . . . . . . . 28
7.1.1 Simple average properties . . . . . . . . . . . . . . . . 28
7.1.2 Fluctuations . . . . . . . . . . . . . . . . . . . . . . . 29
7.2 Entropic properties . . . . . . . . . . . . . . . . . . . . . . . . 29
7.3 Static structure . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.3.1 Pair distribution function . . . . . . . . . . . . . . . . 29
7.3.2 Static structure factor . . . . . . . . . . . . . . . . . . 31

8 Dynamic properties 34
8.1 Time-correlation function . . . . . . . . . . . . . . . . . . . . 34
8.1.1 Velocity correlation function . . . . . . . . . . . . . . 35
8.2 Spectral function and power spectrum . . . . . . . . . . . . . 37
8.3 Space-time correlation functions . . . . . . . . . . . . . . . . 38
8.4 Transport coefficients . . . . . . . . . . . . . . . . . . . . . . . 41
8.4.1 Generalized Einstein relation . . . . . . . . . . . . . . 42
8.4.2 Green-Kubo relations . . . . . . . . . . . . . . . . . . 43
8.4.3 The self-diffusion coefficient . . . . . . . . . . . . . . . 44

A Elements of ensemble theory 45


A.1 The Liouville equation . . . . . . . . . . . . . . . . . . . . . . 45
A.2 Liouville’s theorem . . . . . . . . . . . . . . . . . . . . . . . . 47
A.3 Equilibrium distribution functions . . . . . . . . . . . . . . . 48
A.4 Microcanonical ensemble . . . . . . . . . . . . . . . . . . . . . 48
A.5 Canonical ensemble . . . . . . . . . . . . . . . . . . . . . . . . 49

B Symplectic integrators 51

C Error estimate 55

D Temperature and pressure 58


D.1 The temperature . . . . . . . . . . . . . . . . . . . . . . . . . 58
D.2 The pressure . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

E Equilibration 61

2
1 Classical mechanics
1.1 Newton’s equation of motion
In molecular-dynamics (MD) simulations Newton’s equation of motion is
solved for a set of interacting particles

mi r̈ i (t) = F i ; i = 1, . . . , N (1)

where mi is the mass of particle i, r i (t) its position at time t, F i the force
acting on particle i, and N the number of particles. We will mainly consider
the case when the force is conservative. It can then be expressed in terms
of the gradient of a potential Vpot ,

F i (r 1 , . . . , r N ) = −∇i Vpot (r 1 , . . . , r N ) (2)

where ∇i = ∂/∂r i . The total energy for the system


N
X mi v 2 i
E= + Vpot (r 1 , . . . , r N ) (3)
2
i=1

will then be conserved. The first term is the kinetic energy, where v i is the
velocity for particle i, and the second term is the potential energy. Exam-
ple of a non-conservative system is if e.g. friction is introduced through a
velocity dependent force as in Brownian dynamics.
Eq. (1), together with the force in Eq. (2), corresponds to a set of 3N cou-
pled second order ordinary differential equations. Given a set of initial con-
ditions for the positions (r 1 (0), . . . , r N (0)) and velocities (v 1 (0), . . . , v N (0))
a unique solution can formally be obtained.

1.2 Hamilton’s formulation of classical mechanics


It is often more convenient to use the Hamilton’s formulation of classical
mechanics [4]. The connection to statistical mechanics becomes more direct
and transparent as well as the transition to quantum mechanics. The sys-
tem is then defined in terms of a set of F generalized coordinates qα and
generalized momenta pα , where F is the number of degrees of freedom. For
a system with N particles in three dimensions F = 3N . The Hamilton’s
equations of motion is
∂H ∂H
q̇α = , ṗα = − ; α = 1, . . . , F (4)
∂pα ∂qα
where H is the Hamiltonian for the system and is given by the total energy

H(qα , pα ) = Ekin + Epot , (5)

3
the sum of the kinetic Ekin and potential Epot energies. The total energy
for the system is a conserved quantity. This can shown be taking the time-
derivative of the Hamiltonian
XF  
d ∂H ∂H
H(qα , pα ) = q̇α + ṗα
dt ∂qα ∂pα
α=1
XF  
∂H ∂H ∂H ∂H
= − =0 (6)
∂qα ∂pα ∂pα ∂qα
α=1

where in the second line the Hamilton’s equation of motion has been used.
For a system of N particles in three dimensions using Cartesian coordi-
nates we have
XN
mi v 2i
H= + Vpot (r 1 , . . . , r N ) (7)
2
i=1

where, in this case, r i is the generalized coordinates and mi v i the generalized


momenta. Using Eq. (4) we obtain


ṙ i = v i , mi v̇ i = − Vpot (r 1 , . . . , r N ) ; i = 1, . . . , N (8)
∂r i
or
mi r̈ i (t) = −∇i Vpot (r 1 , . . . , r N ) ; i = 1, . . . , N (9)
which is equal to Newton’s equation of motion (1) with the force given by
Eq. (2)
Hamilton’s equation of motion describes the unique evolution of the co-
ordinates and momenta subject to a set of initial conditions. More precisely,
Eq. (4) specifies a trajectory

x(t) ≡ (q1 (t), . . . , qF (t), p1 (t), . . . , pF (t)) (10)

in phase-space, starting from an initial point x(0). For a system of N


particles in three dimensions the phase-space is 6N -dimensional. The energy
conservation condition restricts the motion on a (6N -1)-dimensional surface
in phase-space, known as the constant-energy hypersurface or simply the
constant-energy surface, see Fig. 1. We also notice that the Hamiltonian in
Eq. (7) is invariant when replacing v i with −v i which implies that the time
evolution is reversible in time.
Hamilton’s equation of motion can also be expressed using a matrix or
symplectic notation [4]. The time derivative of the phase space vector x(t)
can be written as
 
∂H ∂H ∂H ∂H
ẋ(t) = ,..., ,− ,...,− (11)
∂p1 ∂pF ∂q1 ∂qF

4
t=0

Figure 1: A trajectory x(t) in 6N -dimensional phase-space that describes


the time-evolution of the system. The trajectory is restricted to a (6N -1)-
dimensional constant-energy surface.

and hence the Hamiltion’s equation of motion can be recast as


∂H
ẋ = M (12)
∂x
where M is a matrix expressible in block form as
 
0 I
M= (13)
−I 0

where 0 and I are the F × F zero and identity matrices, respectively. Dy-
namical systems expressible in this form are said to possess a symplectic
structure.
The time-dependence of a property A(t), that is a function of phase-
space A(t) = A(x(t)), is formally given by

XF  
d ∂A ∂A
A(x(t)) = q̇α + ṗα
dt ∂qα ∂pα
α=1
XF  
∂A ∂H ∂A ∂H
= −
∂qα ∂pα ∂pα ∂qα
α=1
= {A, H} (14)

where we have introduced the Poisson bracket notation


F 
X 
∂A ∂B ∂B ∂A
{A, B} ≡ − (15)
∂qα ∂pα ∂qα ∂pα
α=1

The Poisson bracket can be used to define the Liouville operator iL according
to
iL . . . ≡ {. . . , H} (16)

5

where i = −1. More explicitly, the Liouville operator can written as the
differential operator
F 
X 
∂ ∂
iL = q̇α + ṗα (17)
∂qα ∂pα
α=1

The time-dependence of an arbitrary phase-space function A(x(t)) is given


by
d
A = iLA (18)
dt
with the formal solution
A(t) = eiLt A(0) (19)
The operator exp (iLt) is known as the classical propagator. By introducing
the imaginary unit i into the definition of the Liouville operator the classical
propagator exp (iLt) resembles the quantum propagator exp (−iĤt/h̄). The
time evolution of the phase-space vector x(t) can be written as

x(t) = eiLt x(0) (20)

This equation describes the central numerical problem in molecular dynam-


ics simulation, to obtain the time-dependent trajectory x(t) in phase space,
given an initial condition x(0).

6
2 Statistical averaging
Molecular-dynamics (MD) simulations generate a very detailed information
of the system at the microscopic level, positions and momenta for all par-
ticles as function of time. To obtain useful information on the macroscopic
level one has to make some averaging. This is the province of statistical me-
chanics [5, 6]. In molecular dynamics one evaluates the average quantities
by performing time averaging, an average along the generated trajectory in
phase-space.
Consider some macroscopic equilibrium property A. It could be, for
instance, the temperature or pressure of a system. Suppose that a micro-
scopic, instantaneous value A can be defined, which is a function of phase-
space A(x) and when averaging the macroscopic observable quantity A is
obtained. We define the time-average according to
Z
1 T
A = hAitime = lim A(x(t))dt (21)
T→∞ T 0

where we let the observation time T goes to infinity.


Conventional statistical mechanics is not based on the time averaging
approach used in MD simulations. To facilitate a more analytical approach
Gibbs introduced the concept of an ensemble (see appendix A). An ensemble
can be viewed as a collection of systems described by the same microscopic
interactions and sharing a common set of macroscopic properties. The most
fundamental ensemble is the microcanonical ensemble. It represents an iso-
lated N -particle system with constant energy E and constant volume V .
The corresponding probability distribution function is proportional to

δ(H(x) − E)

where the delta function is supposed to select out all those states in phase
space of an N -particle system in a volume V that have the desired energy
E. The ensemble average of a quantity A is then given by
R
dx A(x)δ(H(x) − E)
hAiN V E = V R (22)
V dx δ(H(x) − E)

where we have indicated by the subscript N V E that it is an ensemble aver-


age with fixed macroscopic parameters N V E, the microcanonical ensemble
average.
The time average in Eq. (21) is also taken under the condition of constant
energy, particle number and volume. If the system, given an infinite amount
of time, is able to visit all states on the constant-energy surface it is said to
be ergodic. The time and ensemble average are then equal

hAitime = hAiN V E (23)

7
This is called the ergodic hypothesis. It is generally believed that most
systems are ergodic and the ergodic hypothesis can be used for systems
studied using molecular dynamics. However, one should be aware of that
some systems are not ergodic in practise, such as glasses and metastable
phases, or even in principle such as nearly harmonic solids. To formally
prove ergodicity has turned out to be a very difficult task.
In statistical mechanics several different ensembles are introduced, ap-
propriate at different conditions. The most important is the canonical en-
semble which describes a system at constant particle number N , volume V
and temperature T . The corresponding probability distribution is propor-
tionell to
exp [−βH(x)]
and the ensemble average is given by
R
dx A(x) exp [−βH(x)]
hAiN V T = V R (24)
V dx exp [−βH(x)]

where the subscript N V T indicate a canonical ensemble average.


Analytical calculations are often more easy to perform using the canon-
ical ensemble compared with the microcanonical ensemble. The precise na-
ture of the ensemble is often not so important. For large systems the average
values from the microcanonical and the canonical ensembles will be the same
 
1
hAiN V E = hAiN V T + O (25)
N

but the fluctuations from the average values are in general different. In
appendix D we derive microscopic expressions for temperature and pressure
for a system using the canonical ensemble.

8
3 Physical models of the system
To perform an MD simulation we need a description of the forces on the
particles. That is usually obtained from the gradient of a potential

Vpot (r 1 , . . . , r N )

known as the potential energy surface. We will consider systems where the
particles are atoms and, hence, (r 1 , . . . , r N ) are atomic coordinates. The
size of the system also has to be specified together with suitable boundary
conditions.

3.1 The potential energy surface


The origin of the potential energy surface Vpot (r 1 , . . . , r N ) is quantum me-
chanical, but it is a highly nontrivial problem to determine Vpot (r 1 , . . . , r N )
quantum mechanically. Density functional theory, quantum Monte Carlo
and quantum chemistry techniques are being used but all these methods are
computationally very demanding.
Considerable effort has therefore been directed to develop simplified de-
scriptions of the potential energy surface, e.g. models for the inter-atomic
interactions. They often differ in terms of the type of bonding they are
supposed to mimic: covalent, metallic, ionic or van der Waals type. We
will here consider a few different types of models which all can be classified
as classical potentials, while they do not include the electronic degrees of
freedom explicitly.
A natural way to represent Vpot (r 1 , . . . , r N ) is to expand it in terms of
one-body, two-body, three-body and higher order terms,
X XX
Vpot (r 1 , . . . , r N ) = v1 (r i ) + v2 (r i , r j )
i i j>i
XX X
+ v3 (r i , r j , r k ) + . . . (26)
i j>i k>j>i

where the first term represents the effect of an external field and the remain-
ing terms inter-atomic interactions. Often we only keep the two-body term
and set v1 equal to zero. This approximation is used in describing systems
with predominantly ionic or van der Waals bonding. For covalent bonding
systems it is necessary to include the directional bonding through higher or-
der terms in the expansion and in metals the conduction electrons introduce
a many-body term into the description of the inter-atomic interaction.

3.2 Noble gas systems


In liquids and solids composed of noble gas atoms the electronic distribution
is only slightly perturbed from the stable atomic closed-shell configuration.

9
The interaction can be quite well represented by a sum of pair-wise interac-
tions
N X
X N
Vpot (r 1 , . . . , r N ) = v2 (rij ) (27)
i=1 j>i

with rij =| r j −r i |. The attractive part of the pair interaction v(r) is caused
by mutual polarization of each atom and can be modelled using interacting
fluctuating dipoles. It results in an attraction which varies as 1/r6 at large
inter-nuclear separations. For small separations the potential is strongly
repulsive due to overlap between the electron clouds and the Pauli exclusion
principle. The most commonly used form for v2 (r) is the Lennard-Jones
potential h σ σ i
vLJ (r) = 4 ( )12 − ( )6 (28)
r r
The parameters  and σ measure the strength of the interaction and the
radius of the repulsive core, respectively. There is no particular physical
reason for choosing the exponent in the repulsive term to be 12, other than
the resulting simplicity. Based on physical reasons we may argue in favour
of a more steeply rising repulsive potential.
The Lennard-Jones potential has been extensively used in computer sim-
ulations and may be viewed as the ”hydrogen atom” for computer simula-
tors. It was used by Aneesur Rahman in the first molecular dynamics simu-
lation study using continuous potentials [7]. Often one has concentrated on
some more generic features in many-body systems and the particular form
of the model potential is in that case not crucial.

/kB (K) σ (nm)


He 10.2 0.228
Ne 47.0 0.272
Ar 119.8 0.341
Kr 164.0 0.383

Table 1: Suitable Lennard-Jones pair potential parameters for simulation


studies [2].

The model describes quite well the interaction in liquids and solids com-
posed of rare gas atoms. The pair potential should be viewed as an effective
pair potential which, to some extent, includes contributions from higher or-
der terms. Typical numbers for  and σ used when comparing results from
simulations with real systems are given in Tab. 1 [2]. In Fig. 2 the Lennard-
Jones potential used for liquid argon in simulations is compared with the
”true” pair-potential for two isolated argon atoms with nuclear distance r
[2]. The latter has been determined using both theoretical calculations and
experimental data and represents the ”true” pair-potential for argon. The
Lennard-Jones potential used in simulations has been fitted to reproduce

10
Figure 2: Argon pair potentials [2]. The Lennard-Jones pair potential used
in simulation studies (dashed line) compared with the “true” pair potential
for two isolated argon atoms (solid line).

liquid data and therefore it incorporates in an approximate way three-body


and higher order terms. The difference between the two potentials reflects
the magnitude of the non-additive terms in the true many-body potential.

3.2.1 Ionic systems


Ionic systems can also be represented quite well with a sum of pair-potentials.
The particles are electrically charged ions and the interaction is dominated
by the interionic Coulomb interaction, which varies as the inverse first power
of the interionic distance. Special techniques have to be used to sum this
long-range interaction in a computer simulation [1]. A common form is [2]

z i zj Cij Dij
v2 (rij ) = + Aij exp (−Bij rij ) − 6 − 8 (29)
rij rij rij

where zi is the ionic charge of species i. The first term is the Coulomb
interaction, the second repulsive term prevents ions to overlap and the re-
maining terms represents the weaker dispersion interactions. Appropriate
numbers for the potential parameters Aij , Bij , Cij and Dij can be found in
the literature.

11
3.2.2 Metallic systems
Many-body aspects of the inter-atomic interaction is apparent in metals.
Assuming a two-body potential the vacancy formation energy is by necessity
equal to the sublimation energy, while it is known that in metals the vacancy
formation energy is about one third of the sublimation energy. The Cauchy
relation for two of the elastic constants c12 = c44 is satisfied to a good
approximation in van der Waals solids and often in ionic crystals but never
in metals. A description in terms of two-body potentials always leads to
the relation c12 = c44 for cubic structures. The many-body effects are also
clearly present in many properties related to the surfaces of metals.
A surprisingly simple modification of the two-body description seems to
capture many of the essential many-body effects in metals. The inter-atomic
interaction is written on the form
N
X N X
X N
Vpot (r 1 , . . . , r N ) = gi (ρi ) + v2 (rij ) (30)
i=1 i=1 j>i

where v2 (r) is a usual two-body potential and


N
X
ρi = hi (rij ) (31)
j6=i

a pair function describing the local environment of atom i in terms of con-


tributions from its neighbours. This model has been called pair functional
model [8] or glue model [9]. It can be justified both as an approximation
to either the density functional or tight binding theory. In the former case
the physical interpretation of the function gi is related to the local electron
density, while in the latter case it is related to the electron bandwidth. Var-
ious names are associated with the model as effective medium theory [10],
embedded atom method [11], and Finnis-Sinclair model [12].
The pair functional models generalize the two-body description and in-
troduce a truly many-body part in the expression for the inter-atomic inter-
action. These models have roughly the same computational speed as simple
two-body potentials and provide a much improved description of a broad
range of inhomogeneous environments. The pair functional models have
had a significant impact on the simulation of metals, but they do have limi-
tations. They are most accurate for metals with completely empty or filled
d bands, but are less reliable for transition metals, near the center of the
transition series. The partial filling of the d bands implies an angular char-
acter to the interactions which has turned out to be difficult to incorporate
into a simplified description.

12
3.2.3 Covalent systems
The situation in covalent bonded systems is more complicated. The di-
rectional bonding has to be included through angular terms but how that
should be done in practise is intricate. Silicon is an important materials
where the covalent bonding is predominant. An early attempt to model the
condensed phases of silicon was put forward by Stillinger and Weber [13].
Silicon atoms form bonds with the four nearest atoms with a local tetrahe-
dron structure. Stillinger-Weber included an explicit term that forced the
angle between nearby triples to stay close to 109 degrees. The potential was
written as a sum of a two-body and a three-body term and it was adjusted
to the lattice constant, the cohesive energy, the melting point and the liquid
structure.
Many other potentials have been suggested for silicon, but the general
wisdom is that it is difficult to construct classical potentials which are totally
transferable. With transferability is meant that the model should be appli-
cable in various atomic surroundings, in particular in situations which has
not been used in the fitting procedure. By explicitly including the electronic
degrees of freedom the accuracy of the description of the potential energy
surface can be enhanced to the price of more extensive computations.

3.3 The system size


MD simulations are usually performed on systems containing a few thousand
particles and sometimes up to a few millions are used. These number of
particles are appropriate for clusters of atoms but not for bulk systems. A
non-negligible number of atoms will be on the surface of the system and
those atoms will have a very different surrounding compared with the bulk
atoms. For a simple cubic system about half of the particles are at the
surface with N = 103 . For N = 106 it has decreased to about 6%, still a
non-negligible number of particles.
In order to simulate bulk systems it is important to choose boundary
conditions that mimics the presence of an infinite bulk surrounding. This
is achieved by employing periodic boundary conditions. The simulation cell
is replicated throughout space to form an infinite lattice (see Fig. 3). The
most commonly used simulation box is the cubic box. The volume V = L3
of the box together with the number of particles N defines the number
density n = N/V . The number density in the central box, and hence in
the entire system, is conserved. However, it is not necessary to store the
coordinates of all the images, an infinite number, just the particles in the
central box have to be stored. When a particle leaves the central box by
crossing a ”boundary”, attention can be switched to the image just entering
or one can follow the motion of the particle leaving the central box. A given
particle will interact with all other particles in the infinite periodic system,

13
i.e. all other particles in the same periodic cell as well as all particles in all
other cells, including its own periodic images. It is important realize that the
boundary of the periodic box itself has no special significance. The origin
of the periodic lattice of the primitive cells may be chosen anywhere, and
this choice will not affect any property of the model system under study. In
contrast, what is fixed is the shape of the periodic cell and its orientation.

Figure 3: Illustration of the minimum image convention [2]. The central


box contains five atoms. The ’box’ constructed with atom 1 at its centre,
the dashed square, also contain five atoms. It includes all nearest periodic
images to particle 1. The dashed circle represents a potential cutoff.

In practise, we are often dealing with relatively short-range pair inter-


actions, as for instance the Lennard-Jones potential. In that case it is per-
missible to truncate the inter-atomic interaction at a finite radial cut-off
distance rc and a particles will now only interact with a finite number of
surrounding particles. In particular, if rc < L/2 it will only interact with
at most the nearest periodic image of a surrounding particle. This is called
the minimum image convention. In Fig. 3 the dashed square encloses all
nearest periodic images to the particle located in the middle of the dashed
square. The dashed circle represents a potential cutoff. The minimum im-
age convention can be coded in an efficient way. Denote the position of
particle i and j with r i and r j . Before the pair-interaction between i and j
is calculated the distance is calculated according to

14
r ij = r j − r i
r ij = r ij − L ∗ [r ij /L]

where [X] denotes the nearest integer to X. This code will give the mini-
mum image distance, no matter how many ”box lengths” apart the original
particles may be. The code works both if the periodic boundary condition
has been implemented for the particle positions or if the motion of a particle
leaving the central box is explicitly followed.
Systems with long range interactions are computationally more demand-
ing to simulate. This is the case for instance in ionic systems with Coulomb
interactions (cf. Eq. (29)). Various techniques have been developed as Ewald
summation, fast multipole methods, and particle-mesh-based techniques [1].
The simulated system, an infinite periodic system, is not identical to
a macroscopic system which it is supposed to mimic. The differences will
depend on both the range of the inter-atomic interaction and the phenomena
under investigation. In most cases the use of periodic boundary conditions
proves to be a surprisingly effective method to simulate homogeneous bulk
systems. However, it inhibits the occurrence of long-wavelength fluctuations,
which are crucial in the vicinity of a second order phase transition. The same
limitation applies to the simulation of long-wavelength phonons in solids.
The boundary condition also enforces a certain symmetry for the system.
That is devastating if one would like to study symmetry changing phase
transitions in solids. For that case methods has been developed that allow
the simulation box to dynamically change shape as well as size [14].

15
4 The time integration algorithm
The core of an MD program is the numerical solution of Newton’s equation of
motion. We would like to determine a trajectory in 6N -dimensional phase-
space numerically.

4.1 The Verlet algorithm


In 1967 Loup Verlet introduced a central difference based algorithm into
molecular simulations [15]. In many cases, this simple algorithm has turned
out to be the best to use in MD simulations and it is extensively used.
We can derive the algorithm by making a Taylor expansion of the posi-
tion coordinate both forward and backward in time,
1
r(t + ∆t) = r(t) + v(t)∆t + a(t)∆t2 + . . . (32)
2
1
r(t − ∆t) = r(t) − v(t)∆t + a(t)∆t2 + . . . (33)
2
where v i = ṙ i , ai = r̈ i = F i /mi and ∆t the time step in the numerical
scheme. By adding these two equations we obtain

r(t + ∆t) + r(t − ∆t) = 2r(t) + a(t)∆t2 + O(∆t4 )

or
r(t + ∆t) = 2r(t) − r(t − ∆t) + a(t)∆t2 + O(∆t4 ) (34)
This equation is known as the Verlet algorithm. The algorithm is prop-
erly centered, r i (t + ∆t) and r i (t − ∆t) play symmetrical roles, making
it time-reversible and it shows excellent energy-conserving properties over
long times. It is assumed that the forces only depend on the position coordi-
nates. The velocities do not enter explicitly in the algorithm, however, they
are needed for estimating the kinetic energy and hence the temperature.
They can be obtained by subtracting Eq. (32) with Eq. (33),

r(t + ∆t) − r(t − ∆t) = 2v(t)∆t + O(∆t3 )

or
r(t + ∆t) − r(t − ∆t)
v(t) = + O(∆t2 ) (35)
2∆t
A drawback with the original Verlet algorithm is that it is not ”self-starting”.
Usually the initial conditions are given at the same time, r i (0) and v i (0),
but for the Verlet algorithm we need the positions at the present r i (0) and
previous r i (−∆t) time steps. There is also some concerns [16] that roundoff
errors may arise when implementing Eq. (34).
The original Verlet algorithm, Eqs (34) and (35), does not handle the
velocities in a fully satisfactory manner. A Verlet-equivalent algorithm that

16
store positions, velocities and accelerations at the same time and which also
minimize round-off errors was introduced in Ref. [17]. Consider Eq. (33) at
the next time step
1
r(t) = r(t + ∆t) − v(t + ∆t)∆t + a(t + ∆t)∆t2 + . . .
2
By adding these with Eq. (32) and solving for v i (t + ∆t) yields
1
v(t + ∆t) = v(t) + [a(t) + a(t + ∆t)] ∆t (36)
2
Eqs (32) and (36) are referred to as the velocity Verlet algorithm. It is equi-
valent to the original Verlet algorithm and produces the same trajectories.
It involves two stages with a force (acceleration) evaluation in between. A
time step
r(t), v(t), a(t) → r(t + ∆t), v(t + ∆t), a(t + ∆t)
can be written in the following way:
1
v(t + ∆t/2) = v(t) + a(t)∆t
2
r(t + ∆t) = r(t) + v(t + ∆t/2)∆t
calculate new accelerations/forces
1
v(t + ∆t) = v(t + ∆t/2) + a(t + ∆t)∆t
2
The algorithm only requires storage of positions, velocities and accelerations
at one time point and it can be coded as

v = v + 0.5 a dt
r = r + v dt
a = accel(r)
v = v + 0.5 a dt

where accel is a subroutine that returns the accelerations given the posi-
tions. The numerical stability, convenience and simplicity makes the velocity
Verlet algorithm attractive for MD simulation studies and is highly recom-
mended.

4.2 Accurate predictions and the Lyaponov instability


To obtain accurate predictions using the MD technique is obvious that we
need a good numerical algorithm to solve the equation of motion. However,
it is not obvious what is meant by a good algorithm.
An intriguing fact is that the systems that we study by MD simulations
in general show chaotic behaviour. The trajectory in phase-space depends

17
sensitively on the initial conditions. This means that two trajectories that
initially are very close will diverge exponentially from each other as time
progresses. In the same way, any small perturbation, even the tiny error
associated with finite precision arithmetic, will tend to cause a computer-
generated trajectory to diverge from the true trajectory with which it is
initially coincident.
PN This is shown in Fig. 4 where the time dependence of
the difference | r (t) − r0 (t) |2 between a reference trajectory r (t)
i=1 i i i
and a perturbed trajectory r0i (t) is shown. The perturbed trajectory differs
from the reference trajectory in that one of the particles has been displaced
10−10 σ in one direction. As can been seen in Fig. 4 the measure of the
distance increases expontentially with time. Presumably, both the reference
trajectory and the perturbed trajectory are diverging from the true solution
of Newton’s equation of motion. We can not predict the true trajectory over
long times in an MD simulation.

10−9

10−12
− r0i (t)]2

10−15
i=1 [ri (t)
PN

10−18

10−21
0 10 20 30
Time (τ )

Figure 4: Illustration of the Lyaponov instability in a simulation of a


Lennard-Jones system. The figure shows the time dependence of the dis-
tance between two trajectories that were initially very close to each other
(see text). Note, that within this relatively short time, the two trajectories
become essentially uncorrelated.

This seems to be devastating, but it is not. It is important to realize


that what we need is to obtain a trajectory that gives accurate predictions
of average quantities, such as defined in Eq. (21), and that it provides a
time-dependence accurate over times-scales comparable with the correlation
times of interest, so that we may correctly calculate correlation functions
of interest, such as defined in Eq. (68). Experience has shown that it is
possible to obtain such trajectories numerically. MD simulations can be
used to obtain accurate results for average properties. If the MD simulation
is repeated the same, but not identical, results are obtained.

18
So what is important? To obtain accurate results from an MD simulation
we have to generate a trajectory that conserves the energy very well. That
is of primary importance in an MD simulation. The generated trajectory
has to stay on the appropriate constant-energy surface in phase-space. Of
particular importance is that the algorithm should show absence of long-
term energy drift.
The true Hamiltonian dynamics is time reversible. If we reverse the
momenta of all particles at a given instant, the system would retrace its tra-
jectory in phase space. Time reversible algorithms seem to show good energy
conservation over long time periods and we would like the numerical algo-
rithm to be time reversible. The true Hamiltonian dynamics also leaves the
magnitude of any volume element in phase-space unchanged. This volume
or area preserving property leads to the Liouville’s theorem (109), derived in
appendix A. A non-area-conserving algorithm will map a constant-energy-
surface area on a different, probably larger area, and that is not consistent
with energy conservation. Hence it is likely that reversible, area-preserving
algorithms will show little long-term energy drift.
This has lead to a more formal development of efficient algorithms to
be used in MD simulations. Based on the geometric structure of Hamil-
ton’s equation so called symplectic integrators have been developed. In
appendix B the formal development of symplectic algorithms is presented
based on the classical time evolution operator approach. A symplectic algo-
rithm is also area preserving. We show that the velocity Verlet algorithm is
a time-reversible area-preserving algorithm (see appendix B).

4.3 The time step


The size of the time step has to be determined. The optimum value is a
compromise. It should be large to sample as much of phase space as possible,
but it has to be small enough to generate trajectories that produce accurate
predictions.
One may expect that sophisticated higher-order algorithms would allow
the use of large time steps while keeping the error in energy small. However,
general higher-order algorithms tend to have very good energy conservation
for short times, but the energy drift over long times can be substantial. In
contrast, the Verlet algorithm has moderate short time energy conservation
but very little energy drift over long times, even with a quite large time
step. This seems to be a general feature for time-reversible area-preserving
algorithms. Absence of long-term energy drift is important.
Furthermore, the most time-consuming part in the time integration al-
gorithm is the evaluation of the forces. Higher-order algorithms implies the
evaluation of forces and higher order derivatives, which often makes those
algorithms less efficient. Inter-atomic interactions are also quite steep for
short distances. A high-order algorithm with a large time step may generate

19
configurations with short and therefore unfavourable inter-atomic distances.
The conclusion is that the low order time-reversible area-preserving velocity
Verlet algorithm is usually the best to use in MD simulations.
A typical size of the time step for an atomic system is a few femtoseconds.
With heavier atoms a larger time step can be used. With a tentative value
for ∆t test runs can be done to study the effect of changing the size of the
time step. Test of energy conservation is then vital.
In more complex systems the forces may generate motion with widely
different time scales. It could be a molecular system with fast motion as-
sociated with the intra-molecular forces and slower inter-molecular motion.
Multiple time-step techniques have been developed for those situations. The
power of the Liouville operator approach (see appendix B) was demonstrated
by Tuckerman et al. [18] in their derivation of a multiple time-steps method.

20
5 Average properties
We now turn to the problem of determining average properties. In MD
simulations we perform an average over a finite time interval Tprod . This
time interval has to be long enough so that a sufficient region of phase-space
is explored by the system to yield a satisfactory time average according to
Eq. (21). It is also essential to let the system ”equilibrate” in time before
the actual averaging is performed. At the end of the equilibration period Teq
the memory of the initial configuration should have been lost and a typical
equilibrium configurations should have been reached. The MD average can
therefore be written as
Z Teq +Tprod
1
A ≈ hAiMD = A(t)dt (37)
Tprod Teq

The actual averaging is done as a summation. The integration procedure


creates a sequence of values {Ai } with timespacing ∆t and
M
1 X
hAiMD = Ai (38)
M
i=1

where Ai = A(Teq + i∆t) and M = Tprod /∆t.


The result hAiMD from the MD study is subject to systematic and sta-
tistical errors. Sources of systematic errors could be system size-dependence
or poor equilibration. These errors should be reduced as much as possible.
It is also essential to obtain and estimate of the statistical significance of
the results. The MD results is obtained over a finite time period and that
causes statistical imprecision in the obtained average value. By assuming
Gaussian statistics the error can be estimated from the variance of the mean
value. If we assume that each data point Ai is independent, the variance
of the mean is simply given by σ 2 (hAiMD ) = σ 2 (A)/M . However, the data
points are not independent, they are highly correlated, and the number of
uncorrelated data points
Meff = M/s (39)
has to be estimated, where s is called the statistical inefficiency, the number
of time steps for which the correlations effectively persist. The variance of
the mean value can then be written as
1 2
σ 2 (hAiMD ) = σ (A) (40)
M/s

with
M

1 X

σ 2 (A) = δA2 MD = (Ai − hAiMD )2 = A2 MD − hAi2MD (41)
M
i=1

21
Two different methods to estimate the statistical inefficiency s are to de-
termine the correlation function or to perform block averaging. These two
techniques are presented in appendix C. We can now write our final result
as
1
A = hAiMD ± p σ(A) (42)
M/s
Here, the true value will be within the given error bars with 68% probability.
If we instead use two standard deviations the probability increases to 95%.

5.1 Kinetic, potential and total energies


The instantaneous kinetic and potential energies are given by
N
X p2 (t) i
Ekin (t) = (43)
2mi
i=1

and
Epot (t) = Vpot (r 1 (t), . . . , r N (t)) (44)
Hence *N +
X p2 (t)
i
Ekin = hEkin (t)itime = (45)
2mi
i=1 time
and
Epot = hEpot (t)itime = hVpot (r 1 (t), . . . , r N (t))itime (46)
The total energy
E = Ekin + Epot (47)
is a conserved quantity.

5.2 Temperature
In appendix D microscopic expressions for the temperature and pressure
were derived within the canonical ensemble. The instantaneous expression
for the temperature
N
2 X p2i (t)
T (t) =
3N k 2mi
i=1

is used to determine the temperature for the system


*N +
2 X p2 (t) 2
i
kT = = hEkin itime (48)
3N 2mi 3N
i=1 time

All 3N momentum coordinates are usually not independent in a MD simula-


tion. The total momentum is conserved and those three degrees of freedom

22
should be subtracted. Only the internal momenta contribute to the temper-
ature. The definition of temperature then becomes
2
kT = hEkin itime (49)
3N − 3
Using the microcanonical ensemble one can show [19] that
 −1
2 1
kT = (50)
3N − 5 Ekin time

The difference between the definitions in Eqs (48), (49), and (50) is of the
order 1/N and for large systems they will give essentially the same result.
For convenience, we will stick to the definition in Eq. (48).

5.3 Pressure
The microscopic expression for the pressure, derived in appendix D, is
N  
1 X p2i (t)
P(t) = + r i (t) · F i (t)
3V m
i=1

and
P V = N kT + W
where * +
N
1X
W = hW(t)itime = r i (t) · F i (t)
3
i=1 time
is the virial function.
For pair-wise interactions it is convenient to rewrite the virial W. The
force on particle i can be written as a sum of contributions from the sur-
rounding particles X
Fi = f ij
j6=i

where f ij is the force from particle j acting on particle i. We then have


X XX 1 XX
ri · F i = r i · f ij = [r i · f ij + r j · f ji ]
2
i i j6=i i j6=i

where the second equality follows because the indices i and j are equivalent.
Newton’s third law can then be used and
X 1 XX XX
ri · F i = r ij · f ji = r ij · f ji
2
i i j6=i i j>i

23
where r ij = r j −r i . The force can be expressed in terms of the pair-potential
v(r)
f ji = −∇r ij v(r ij )
This implies that the virial can be expressed as
1 XX 1 XX
W= r ij · f ji = − w(rij ) (51)
3 3
i j>i i j>i

where the pair virial function w(r) is

dv(r)
w(r) = r (52)
dr

24
6 A program
The most important input in a MD simulation is a description of the inter-
particle interaction. The Lennard-Jones model has been used extensively
for atomic systems. The total potential energy is represented as a sum of
pair-wise interactions, the Lennard-Jones potential
h σ σ i
vLJ (r) = 4 ( )12 − ( )6 (53)
r r
It is common to use  and σ as units for energy and length, respectively.
By
p further using the mass m as unit for mass the time unit becomes τ =
mσ 2 /. In applications, it is customary to introduce a cutoff radius rc and
disregard the interactions between particles separated by more than rc . A
simple truncation of the potential creates problem with test of energy con-
servation. Whenever a particle ”crosses” the cutoff distance, the potential
energy makes a jump and spoil energy conservation. It is therefore common
to use a truncated and shifted potential

vLJ (r) − vLJ (rc ) if r < rc
v(r) = (54)
0 if r > rc
The energy then becomes continuous, however not the forces.

6.1 Initialization
In the initialization part the number of particles, the size of the simulation
box and the initial positions and velocities for all particles are selected.
For a crystalline solid the atoms are usually placed according to the lattice
structure. For a liquid it is often most convenient to place the atoms on a
lattice to circumvent overlap between atoms. On can then either introduce
small deviations from the regular lattice positions and/or give the particles
some random initial velocities. This will fix the total energy for the system.
It is also convenient to enforce that the total linear momentum is zero in
the initial configuration.

6.2 Equilibration
The initialization procedure fixes the external parameters for the system;
the total energy, the volume, the particle number and the total linear mo-
mentum, which define the thermodynamic state for the system. However,
the initial configuration will not be in a typical equilibrium configuration
and one has to allow for a certain number of time-steps in the integration
procedure before the actual simulation can be started. This corresponds to
equilibrating the system.
The equilibration time can be a substantial part of the total simulation
time. Some system will never equilibrate and find its true equilibrium state

25
on the computer, as glassy states and various metastable phases. To deter-
mine the time for equilibration is not easy. One can investigate various ther-
modynamic quantities and look for approach to constant, time-independent
values. In Fig. 5 this is illustrated for the potential and kinetic energies.
Notice that the total energy is conserved.

350
E kin
250 E pot
E tot
150
Energy ()

-1900

-2000

-2100
0 2 4 6 8 10
Time (τ )

Figure 5: The initial time-evolution for the potential, kinetic and total ener-
gies. The data are taken from a MD simulation of a Lennard-Jones system.

Often one would like to reach another thermodynamic state, not the
one specified in the initial configuration. One can then scale the velocities
and/or the box-size to change the temperature and pressure for the system.
Techniques to perform scaling is discussed in App. E. In Fig. 6 we show the
result using the scaling suggested in App. E.

6.3 Production
Next follows the actual simulation where the output data are produced.
The equation of motion is solved for a large number of time-steps. The
most time-consuming part is the force evaluation, not the actual stepping
in the integration procedure. It is recommended to store the configurations
from the production run. That amounts to a huge set of data. Some prop-
erties are often calculated during the actual production simulation but often
one would like to reanalyse the data and determine properties which were
not considered during the production run. Too much direct evaluations of
various properties during the simulation may also make the simulation pro-
gram unnecessary complicated. It is also recommended to store sufficient
information at the end of the simulation which could be used to restart the
simulation.

26
1.4 7

Temperature (/k B ) 1.2 6

Pressure (/σ 3 )
1.0 5

0.8 4

0.6 3

0.4 2

0.2 1
0 20 40 60 80 100
Time (τ )

Figure 6: The time-evolution of the instantaneous temperature and pressure


where these are scaled to the temperature 1.15 /kB and pressure 2.0 /σ 3 .
The data are taken from a MD simulation of a Lennard-Jones system.

6.4 Analysis
In the last step one analyses the output data. The quantities that have not
been determined during the actual simulation can be evaluated provided
the configurations have been stored. Various thermodynamic quantities,
structural properties, time-dependent correlation functions and transport
coefficients can all be determined from a simulation of an equilibrium system.
An important aspect is evaluation of proper error bars. The results may be
subjected to both systematic and statistical errors. Systematic errors should
be eliminated where possible and statistical errors have to be estimated.
How the statistical error can be estimated is discussed in App. C.

27
7 Static properties
We now turn to the problem of analysing the results from the MD simulation,
to obtain properties from the generated phase-space trajectory. We can
divide this into static and dynamic properties. Static properties will depend
on one time-point while dynamic properties depend on correlations between
two different time-points. The latter will be treated in the next section.
Static properties can be divided into two different categories, sometimes
called mechanic and entropic quantities. Mechanic properties can be directly
expressed as an average over some phase-space quantity A(Γ), as in Eq. (21),
while entropic quantities are more difficult to evaluate.
The static structure of matter is measured in diffraction experiments.
This can be related to the pair distribution function which describes the
spatial organization of particles about a central particle. This function is
important in the theory for dense fluids and it can be used to identify the
lattice structure of a crystalline solid.

7.1 Mechanic properties


7.1.1 Simple average properties
We have already introduced several mechanic average properties in Sec. 5,
as for instance the potential energy
Epot = hVpot (r 1 , . . . , r N )itime
and the virial
*N +
1 X
W =− r i · ∇i Vpot (r 1 , . . . , r N )
3
i=1 time

which is related to the force, the first order derivative of the potential. We
can also introduce an effective force constant kef f , given by the second order
derivative of the potential
* N
+
1 X 2
kef f = ∇i Vpot (r 1 , . . . , r N ) (55)
N
i=1 time

Properties related to the momenta have also been introduced, as the kinetic
energy *N +
X p2 (t)
i
Ekin =
2m
i=1 time
and the temperature
*N +
2 X p2 (t)
i
T =
3N kB 2m
i=1 time

28
7.1.2 Fluctuations
One can also study fluctuations from the average quantities. These are
related to thermodynamic response functions as heat capacities, compress-
ibilities and thermal expansion. In deriving these relations using statistical
mechanics one has to be careful with the type of ensemble that is used. For
average quantities, cf. Eq. (38), the result is independent on the ensemble
used for large systems (N → ∞). However, the fluctuations, cf. Eq. (41),
will depend on the ensemble used, even for large systems. For instance,
using the canonical ensemble where N , V and T are kept constant, the heat
capacity at constant volume is given by the fluctuations in the total energy
E ≡ Ekin + Epot according to

1

CV = 2
(δE)2 N V T (56)
kB T
This can not be true in the micro-canonical ensemble where the total energy
is kept fix by definition. In the micro-canonical ensemble one can show that



3N kB2 T2  
2 2 3N kB
(δEkin ) N V E = (δEpot ) N V E = 1−
2 2CV

This can be used to determine the heat capacity in a MD simulation (at


constant N, V and E) from the fluctuations in the potential energy
 −1
3N kB 2
2

CV = 1− 2 T 2 (δEpot ) N V E (57)
2 3N kB

or from the fluctuations in the kinetic energy


 −1
3N kB 2
2

CV = 1− 2 T 2 (δEkin ) N V E (58)
2 3N kB

7.2 Entropic properties


Entropic properties as entropy free energies and chemical potentials are more
difficult to evaluate. They can not be directly expressed as a time average
over some phase-space quantity. Instead they are related to the phase-space
volume. Special techniques have been developed and we refer to Refs. [1]
and [2].

7.3 Static structure


7.3.1 Pair distribution function
Detailed information on the structure of an atomic system can be obtained
from different static distribution functions. The most important is the pair

29
distribution function
*N N +
1 XX
g(r 0 , r 00 ) = 2 δ(r 0 − r i (t))δ(r 00 − r j (t))
n
i=1 j6=i

which is equal to the probability of finding a particle at r 00 provided there


is another particle at r 0 , and relative to the probability expected for a com-
pletely random distribution at the same density. In the case of spatially
homogeneous systems, only relative separations are meaningful, leading to
sum over atom pairs
*N N +
V XX
g(r) = 2 δ(r − r ij (t)) (59)
N
i=1 j6=i

where r ij = r j − r i and r = r 00 − r 0 . If the system is also isotropic the


function can be averaged over angles without loss of information. The result
is the radial distribution function g(r). For large separations between r 0 and
r 00 the probability to find a particle at r 0 and at r 00 , respectively, becomes
independent of each other and
*N +* N +
1 X 0
X
00
g(r → ∞) = 2 δ(r − r i (t)) δ(r − r j (t))
n
i=1 j6=i
N (N − 1) 1 1
= 2 2
=1− '1
n V N
The quantity ng(r) is equal to the average density of particles at r, given
that a particle is located at the origin. By integrating the radial distribution
function one obtains the number of particles within a distance rm from the
particle at the origin
Z rm
I(rm ) = n g(r)4πr2 dr (60)
0

This value can be used to define the coordination number by choosing rm


equal to the first minimum of g(r).

Calculation algorithm The radial distribution function g(r) can be de-


termined by evaluating the distance between all pairs of particles and sort
these into a histogram. Assume that each bin has the size ∆r,
1
rk = (k − )∆r ; k = 1, 2, . . . (61)
2
and denote the average number of particles whose distance from a given par-
ticle lies in the interval [(k − 1)∆r, k∆r] with hN (rk )i. This average is done

30
over all identical particles in the system together with a time-average along
the phase-space trajectory. The average number of particles in the spherical
shell assuming a completely random distribution at the same density is

(N − 1) 4π 3
N ideal (rk ) = [k − (k − 1)3 ]∆r3
V 3
(N − 1) 4π 2
= [3k − 3k + 1]∆r3 (62)
V 3
and the radial distribution function can be evaluated as
hN (rk )i
g(rk ) = (63)
N ideal (rk )

By using the factor (N − 1)/V in the definition of N ideal (rk ) we ensure that
g(rk ) approaches exactly one when k becomes large.

2
g(r )

0
0.0 1.0 2.0 3.0 4.0
r (σ)

Figure 7: The pair distribution function for a Lennard-Jones system in the


liquid phase. Data taken from a MD simulation study.

7.3.2 Static structure factor


The measured intensity in a diffraction experiment is proportional to the so
called static structure factor
* N +
1 X
S(q) = | eiq ·r i (t) | 2 (64)
N
i=1

In a crystalline solid it will contain delta-function contributions at the re-


ciprocal lattice vectors. In a liquid it will only contain a delta-function

31
contribution for q = 0, forward scattering. We will consider the liquid case.
The static structure factor can be expressed as the Fourier transform of g(r)
according to
* +
1 X X −iq ·(r j (t)−r i (t))
S(q) = e
N
i j
* +
1 X X −iq ·(r j (t)−r i (t))
= 1+ e
N
i j6=i
Z
= 1 + n g(r)e−iq ·r dr
Z
= 1 + n [g(r) − 1]e−iq ·r dr + n(2π)3 δ(q) (65)

Conversely, g(r) is given by the Fourier transform of S(q)


Z
1 1
g(r) = [S(q) − 1]eiq ·r dq (66)
n (2π)3

For an isotropic system, neglecting the delta-function contribution, Eq. (65)


reduces to Z
sin qr
S(q) = 1 + 4πn r2 [g(r) − 1] dr (67)
qr

2.0

1.5
S(q)

1.0

0.5
5 10 15 20 25
q (σ )
−1

Figure 8: The static structure factor for a Lennard-Jones system in the


liquid phase. Data taken from a MD simulation study.

32
Calculation algorithm The static structure factor for an isotropic sys-
tem can be calculated from the radial distribution function g(r) according
to Eq. (67). However, the upper limit for the integration is limited to half
the length of the periodic simulation cell. This often prevents an accurate
Fourier transform to be performed. One can try to extend g(r) to larger dis-
tances, but that involves some further modeling [2]. Alternatively, one can
stick to the definition in Eq. (64). S(q) is then evaluated on a 3-dimensional
q-grid. The grid has to be consistent with the periodic boundary conditions,
i.e. q = (2π/L)(nx , ny , nz ) where nx , ny and nz are integers. To obtain S(q)
in 1-dimensional q-space a spherical average has to be done.

33
8 Dynamic properties
We now turn to dynamic properties, time correlation functions and transport
coefficients.

8.1 Time-correlation function


A time-correlation function measures how the value of some dynamic quan-
tity A at time t0 depends on some other (or the same) dynamic quantity B
at time t00 . For a system at equilibrium the correlation function will only
depend on the time difference t = t00 − t0 , the tim lag, not on the sepa-
rate times t0 and t00 . We define the time-correlation function as an ordinary
time-average according to
Z
1 T

CAB (t) = lim B(t + t0 )A(t0 )dt0 = B(t + t0 )A(t0 ) time (68)
T→∞ T 0

If A=B it is called an auto-correlation function and1




C(t) = A(t + t0 )A(t0 ) (69)

For large time differences the quantities usually become uncorrelated and
C(t → ∞) = hAi hAi. If hAi 6= 0 it is convenient to define the correlation
function in terms of the fluctuations

δA(t) = A(t) − hAi

instead, i.e.

C(t) = δA(t + t0 ) δA(t0 ) (70)
The correlation function then has the initial value


C(0) = δA2

and it decays to zero for large times

C(t → ∞) = 0

The time integral defines a correlation or relaxation time τrel according to


Z ∞
1
τrel = C(t)dt (71)
C(0) 0
provided the correlation function decays sufficiently rapidly. For a system in
equilibrium the correlation function is stationary, i.e. it is invariant under
a translation of the time origin,



C(t) = A(t + t0 )A(t0 ) = A(t + t0 + s)A(t0 + s)
1
For convenience, we will drop the subscript ”time” in most cases.

34
If we let s = −t it is easy to show2 that C(t) is an even function in time
C(−t) = C(t) (72)
Correlation functions can be divided into two classes: the one-particle func-
tions, in which the dynamic quantity A(t) is a property of individual parti-
cles, and the collective functions, in which A(t) depends on the accumulated
contributions from all particles in the system.

Calculational algorithm The direct approach to the calculation of time-


correlation functions is based directly on the definition Eq. (69) (or Eq. (70)).
Assume that A(t) is available at equal intervals of time
Am ≡ A(m∆τ ) ; m = 0, 1, . . . , (M − 1)
of size ∆τ . Typically ∆τ is a small multiple of the time step ∆t used in the
simulation. The correlation function can then be expressed as
−l−1
MX
1
Cl = Am+l Am ; l = 0, 1, . . . , (M − 1) (73)
M −l
m=0

We average over M time origins, but the statistical accuracy becomes less for
large time laps t = l ∆τ . Each successive data point is used as time origin.
This is not necessary, and indeed may be inefficient, since successive origins
will be highly correlated. Also the total simulation time is often considerable
longer than the typical relaxation time for the correlation function. The
index l in Eq. (73) can then be restricted to a number considerable less than
M.

8.1.1 Velocity correlation function


A typical example of a one-particle correlation function is the velocity auto-
correlation function

Φ(t) = v i (t + t0 ) · v i (t0 )
It describes how the motion of a tagged particle is correlated with itself after
a time t. If particles are identical the statistical precision of a calculation
can be improved by averaging over those particles
N
1 X

Φ(t) = v i (t + t0 ) · v i (t0 ) (74)
N
i=1

For a system in equilibrium the initial value is given by the equipartition


theorem
3kB T
Φ(0) =
m
2
We consider only classical dynamic variables A(t), so that they commute with them-
selves at different times.

35
and for long times the initial and final velocities are expected to be com-
pletely uncorrelated and
Φ(t → ∞) = 0
The short time behaviour can be obtained by making a Taylor expansion of
v i (t) around t = 0. For the velocity correlation function we get
3kB T (ωE t)2
Φ(t) = [1 − + . . .] (75)
m 2
with
2 1

ωE = | F i (t) |2 (76)
3mkB T
where F i (t) is the force acting on the tagged particle. The frequency ωE is
an effective frequency known as the Einstein frequency. It can be rewritten
as [2]
2 1
2
ωE = ∇ Vpot (77)
3m
which shows that it represents the frequency at which the tagged particle
would vibrate if it was undergoing small oscillations in the potential well
produced by the surrounding particles when they are maintained at their
mean equilibrium positions around the tagged particle. If the interaction
potential Vpot is a sum of pairwise interactions with a pair potential v(r)
Z
2 n
ωE = ∇2 v(r)g(r)dr (78)
3m
where n = N/V is the mean density.
According to the transport theory of Boltzmann and Enskog the veloc-
ity correlation function should decay exponentially at long times. It then
came as a big surprise when Alder and Wainwright [20] found in a molecular
dynamics simulation of a dense gas of hard spheres that the velocity corre-
lation function did not decay exponentially but more as a power law at long
times. Alder and Wainwright analysed their results and showed that the
tagged particle created a vortex pattern in the velocity field of the nearby
surrounding particles that made the velocity correlation function to develop
a long-time tail. Further analysis using theory and simulations showed that
[21].
Φ(t → ∞) ∝ t−3/2 (79)
in three dimensions. The magnitude of the long-time tails is very small and
it is not easy to detect them in a molecular simulation study. The discovery
of the long-time tails raised basic questions such as the assumption about
molecular chaos in the derivation of Boltzmann’s transport equation. The
foundation of hydrodynamics, which is based on the existence of two time
regimes, a short-time regime where molecular molecular relaxation takes and
a long-time regime where only macroscopic relaxation is important, also had
to be clarified.

36
1.0

Liquid
Solid

0.5
Φ(t) / Φ(0)

0.0

-0.5
0.0 0.2 0.4 0.6 0.8 1.0
Time (τ )

Figure 9: The velocity correlation function. Data taken from a MD simula-


tion study of a liquid and a solid Lennard Jones system.

8.2 Spectral function and power spectrum


It is also useful to consider the Fourier transform of a correlation function,
the spectral function, defined by
Z ∞
Ĉ(ω) = C(t)eiωt dt (80)
−∞

It can be directly related to the power spectrum of the corresponding dy-


namic quantity A(t) through what is known as the Wiener-Khintchin’s the-
orem. Let 
A(t) −T < t < T
AT (t) =
0 otherwise
Introduce the power spectrum for A according to
1
PA (ω) = lim | AT (ω) |2 (81)
T→∞ 2T
with Z ∞
AT (ω) = AT (t)eiωt dt
−∞

37
The Fourier transform of the power spectrum is given by
Z ∞

PA (ω)e−iωt
−∞ 2π
Z ∞ Z ∞
1 dω −iωt 0
= lim e AT (ω) dt0 e−iωt AT (t0 )
T→∞ 2T −∞ 2π
Z ∞ Z ∞ −∞
1 dω −iω(t+t0 )
= lim dt0 AT (t0 ) e AT (ω)
T→∞ 2T −∞ −∞ 2π
Z ∞
1
= lim dt0 AT (t0 )AT (t + t0 )
T→∞ 2T −∞


= A(t + t0 )A(t0 ) time = C(t)

This proves the Wiener-Khintchin’s theorem, the power spectrum of a dy-


namic quantity is equal to the Fourier transform of the corresponding auto-
correlation function Z ∞
PA (ω) = C(t)eiωt dt
−∞

Calculational algorithm The Power spectrum can be evaluated very


efficiently using the fast Fourier Transform (FFT) algorithm. We consider
again a discrete set of data

Am ≡ A(m∆τ ) ; m = 0, 1, . . . , (M − 1)

We can introduce the discrete Fourier Transform according to


M
X −1
Âk = Am e2πikm/M
m=0

with the inverse defined by


M −1
1 X
Am = Âk e−2πikm/M
M
k=0

and
1
P(ω) = | Âk |2
M

8.3 Space-time correlation functions


Time-correlation functions can be generalised to correlation functions in
space and time. Consider the microscopic number density
N
X
n(r, t) = δ[r − r i (t)]
i=1

38
0.6

Liquid
0.5 Solid

0.4
Φ(ω) (τ /m)

0.3

0.2

0.1

0.0
0 20 40 60 80
ω (τ −1
)

Figure 10: The spectral function, the Fourier transform of the velocity cor-
relation function. Data taken from a MD simulation study of a liquid and
a solid Lennard Jones system.

with the average defined by


Z T Z
1 1
hn(r, t)i = lim dt dr n(r, t)
T→∞ T 0 V V

and given by
N
=n hn(r, t)i =
V
As a generalisation of an ordinary time-correlation function (cf. Eq. (70)),
we construct the density-density correlation
1

G(r 00 , r 0 ; t00 , t0 ) = n(r 00 , t00 )n(r 0 , t0 )
n
For a homogeneous system at equilibrium it will depend only on the space
and time differences, r ≡ r 00 − r 0 and t ≡ t00 − t0 , and
*N N +
1 XX
G(r, t)) = δ[r − (r i (t + t0 ) − r j (t0 ))]
N
i=1 j=1

This function was introduced by van Hove 1954 [22] to characterise the
dynamic structure measured in inelastic neutron scattering experiments. It
is known as the van Hove correlation function. It naturally separates into
two terms, usually called the ”self” (s) and the ”distinct” (d) part, according
to
G(r, t)) = Gs (r, t)) + Gd (r, t))

39
where *N +
1 X
0 0
Gs (r, t)) = δ[r − (r i (t + t ) − r i (t ))]
N
i=1

and *N N +
1 XX
Gd (r, t)) = δ[r − (r i (t + t0 ) − r j (t0 ))]
N
i=1 j6=i

The self-part is an example of a single-particle correlation function and the


distinct part a collective correlation function. The normalization is given by
Z
drGs (r, t) = 1
V

and Z
drGd (r, t) = N − 1
V
The physical interpretation of the van Hove function is that it is proportional
to the probability to find a particle i at position r 00 at time t00 , provided that
a particle j was located at position r 0 at time t0 . More precisely, it is related
to find a particle in a small region dr 0 around a point r 0 , etc. The division
into self and distinct parts then corresponds to the possibilities that i and
j are the same particles or different ones, respectively. Furthermore, if the
system is isotropic it will only depend on the scalar quantity r.
The distinct part can be viewed as a direct dynamic generalisation of
the pair-distribution function g(r). Initially Gd (r, t) is given by

Gd (r, 0) = ng(r)

and for large times t it approaches a constant value, the mean density
N 1
lim Gd (r, t) = ( − )'n
t→∞ V V
The self part follows the motion of a single particle. Initially, it is a delta
function in space
Gs (r, 0) = δ(r)
and it will then broaden in space when time proceeds and finally it will reach
the value
1
lim Gs (r, t) = '0
t→∞ V
The broadening can be described by its second moment
Z *N +
2 1 X 0 0 2
∆M SD (t) = r Gs (r, t)dr = [r i (t + t ) − r i (t )] (82)
V N
i=1

40
This function is called the mean-squared displacement and its time depen-
dence gives information about the single particle dynamics. For short times
it increases as
 
3kB T 2 (ΩE t)2
∆M SD (t) = t 1− + ...
m 12
The first term describes the initial free particle motion while the second
term describes the initial effect of the restoring force from the surrounding
particles. At long times it will approach a constant value for a solid

lim ∆M SD (t) = 6 d2th


t→∞

where dth is the mean thermal displacement of a particle from its lattice
position. However, in a liquid or dense gas it will diffuse away from its initial
position. Assume that the position of the particle becomes uncorrelated after
a time-scale τc and divide the total tim lag t into M uncorrelated pieces

∆r i (j) = r i (tj + τc ) − r i (tj ) ; j = 1, . . . , M , t1 = t0

with t = M τc . The mean squared displacement can now be written as

N
* M 2 +
N M M
1 X X 1 XX X

∆M SD (t) =  ∆r i (j)  = ∆r i (j)∆r i (j 0 )
N N 0
i=1 j=1 i=1 j=1 j =1

1 XXD E
N M
(∆r)2
= [∆r i (j)]2 ≡ M (∆r)2 = t∝t
N τc
i=1 j=1

i.e. for a liquid or dense gas we have the limiting behaviour

lim ∆M SD (t) ∝ t
t→∞

8.4 Transport coefficients


The transport of mass, energy, momentum and charge in matter is described
phenomenologically by various transport coefficients. They are introduced
by linear relations of the form

Flux = − coefficient × gradient

The flux measures the transfer per unit area and unit time, the gradient
provides the driving force for the flux, and the coefficient characterizes the
resistance to flow. Examples includes Newton’s law of viscosity, Fick’s law
of diffusion, Fourier’s law of heat conduction and Ohm’s law of electrical
conduction. We normally think of these laws applied to nonequilibrium
situations were we apply a gradient which then results in a flux. An example

41
could be that we apply a electric potential to a material. This gives rise to
a current, which magnitude is determined by the resistivity of the material.
However, in addition to nonequilibrium situations linear transport relations
also apply to microscopic fluctuations that occur in a system at equilibrium
[23]. Thus, transport coefficients, which are properties of matter, can be
extracted from equilibrium molecular dynamics simulations.

8.4.1 Generalized Einstein relation


To illustrate a typical transport phenomenon, consider diffusion of a tagged
particle, so called self-diffusion. It is described by Fick’s law of diffusion.
The microscopic density of the tagged particle with position r i (t) is de-
scribed by
ns (r, t) = δ(r − r i (t))
with the corresponding current or flux,
j s (r, t) = v i (t) δ(r − r i (t))
The self-diffusion coefficient Ds is introduced through Fick’s law of diffusion
j s (r, t) = −Ds ∇ns (r, t) (83)
We expect this equation to be valid in the hydrodynamic regime, i.e. for
distances r  l and times t  τ , where l is of the order an inter-particle
distance and τ a typical collision time. If we combine Fick’s law of diffusion
with the continuity equation

ns (r, t) + ∇ · j s (r, t) = 0 (84)
∂t
we obtain the diffusion equation

ns (r, t) = Ds ∇2 ns (r, t)
∂t
or

Gs (r, t) = Ds ∇2 Gs (r, t) , valid if r  l and t  τ (85)
∂t
We can solve this by making a Fourier transform in space
Z
dq −Ds q2 t iq ·r
Gs (r, t) = e e
(2π)3
 
1 r2
= √ exp −
4πDs t 4Ds t
This equation is valid if r  l and t  τ and hence
1
Ds = lim ∆M SD (t) (86)
t→∞ 6t

42
0.5

Liquid
0.4 Solid
∆MSD (σ 2 )

0.3

0.2

0.1

0.0
0.0 0.2 0.4 0.6 0.8 1.0
Time (τ )

Figure 11: The mean squared displacment. Data taken from a MD simula-
tion study of a liquid and a solid Lennard Jones system.

8.4.2 Green-Kubo relations


Consider the dynamic quantity A(t). At time t the displacement of A from
its value at t = 0 is Z t
[A(t) − A(0)] = dt0 Ȧ(t0 )
0
Squaring both sides and averaging over time origins gives
Z t Z t D E

00
[A(t) − A(0)]2
= dt dt0 Ȧ(t00 )Ȧ(t0 )
0 0
Z t Z t00 D E
00
= 2 dt dt0 Ȧ(t00 )Ȧ(t0 )
0 0

where we in the last line have used the fact


D that the Eintegrand is symmetric
in t0 and t00 . The correlation function Ȧ(t00 )Ȧ(t0 ) only depends on the
time difference and we introduce τ ≡ t00 − t0 and we can write the inegral as
Z t Z t−τ D E


[A(t) − A(0)]2
= 2 dτ dt0 Ȧ(τ )Ȧ(0)
0 0
Z t D E Z t−τ
= 2 dτ Ȧ(τ )Ȧ(0) dt0
0 0
Z t D E
= 2 dτ Ȧ(τ )Ȧ(0) (t − τ )
0
or
Z t D
[A(t) − A(0)]2 E τ
= dτ Ȧ(τ )Ȧ(0) 1 − (87)
2t 0 t

43
Taking the long-time limit, we find

Z ∞ D E
[A(t) − A(0)]2
lim = dτ Ȧ(τ )Ȧ(0) (88)
t→∞ 2t 0

8.4.3 The self-diffusion coefficient


We can apply this to the case A(t) = r i (t). This implies that Ȧ(t) = v i (t)
and hence Z ∞
3Ds = dτ Φ(τ )
0
We now have two different ways to determine the self-diffusion coefficient,
either from the mean-squared displacement according to Eq. (86)
1
Ds = lim ∆M SD (t)
t→∞ 6t
or from the time-integral of the velocity correlation function
Z
1 ∞ 1
Ds = dτ Φ(τ ) = Φ̂(ω = 0) (89)
3 0 6

44
A Elements of ensemble theory
In Eq. (21) we introduced a time average procedure to obtain macroscopic
properties of a system based on the underlying microscopic equation of mo-
tion. This is what is used in the molecular dynamics (MD) simulation
technique. However, it is not so commonly used in more conventional statis-
tical mechanics due to the complexity of the time evolution of a system with
many degrees of freedom. Gibbs suggested to replace the time average with
an ensemble average, an average over a set of ”mental copies” of the real
system [5]. All copies are governed by the same set of microscopic interac-
tions and they are all characterized by the same macrostate as the original
system (e.g. the same total energy, volume and number of particles), and
the time evolution of each member of the ensemble is governed by classical
mechanics, the Hamilton’s equation of motion.

A.1 The Liouville equation


Consider an ensemble of systems. Each system in the ensemble is defined
by its position x in phase-space

x = (q1 , . . . , qF , p1 , . . . , pF ) (90)

and each system is moving in phase-space according to Hamilton’s equation


of motion
∂H ∂H
q̇α = , ṗα = − ; α = 1, . . . , F (91)
∂pα ∂qα
We denote the number of systems in a small volume dx at a point x in phase-
space and at time t as ρ0 (x, t)dx. We can then introduce the probability to
find a system in a small volume dx at a point x and at time t according to
1 0
ρ(x, t)dx = ρ (x, t)dx (92)
Nens
where Nens is the total number of systems in the ensemble. The density
function ρ(x, t) is a probability distribution function, properly normalized
over the entire phase-space volume
Z
ρ(x, t) dx = 1 ρ(x, t) ≥ 0 (93)

To derive the Liouville equation we consider a small arbitrary volume ω in


phase-space and we denote the surface enclosing this volume by σ. The
change Z

ρ(x, t)dx
∂t ω

45
is given by the difference of the flux of systems into and out from the volume
ω. There are no sources or sinks of systems in phase space. The flux is given
by the vector
v = ẋ = (q̇1 , . . . , q̇F , ṗ1 , . . . , ṗF ) (94)
hence, Z Z

ρ(x, t)dx = − ρ(x, t)(v · n̂)ds (95)
∂t ω σ
where n̂ is the outward unit vector normal to the surface element ds. Using
the divergence theorem the surface integral can be converted to a volume
integral Z Z
ρ(v · n̂)ds = div(ρv)dx (96)
σ ω
The volume ω is arbitrary and hence we obtain the equation of continuity
in phase-space
∂ρ
+ div(ρv) = 0 (97)
∂t
More explicitly div(ρv) can be written as

XF  
∂ ∂
div(ρv) = (ρq̇α ) + (ρṗα )
∂qα ∂pα
α=1
XF   XF  
∂ρ ∂ρ ∂ ∂
= q̇α + ṗα +ρ q̇α + ṗα
∂qα ∂pα ∂qα ∂pα
α=1 α=1

We now use the fact that each system in the ensemble is moving according
to Hamilton’s equation of motion. The first term in the expression for the
divergence can then be written as
F 
X  F 
X 
∂ρ ∂ρ ∂H ∂ρ ∂H ∂ρ
q̇α + ṗα = − = {ρ, H}
∂qα ∂pα ∂pα ∂qα ∂qα ∂pα
α=1 α=1

where we have used the Poisson bracket notation


XF  
∂A ∂B ∂B ∂A
{A, B} ≡ − (98)
∂qα ∂pα ∂qα ∂pα
α=1

The second term is equal to zero, according to


F 
X  F 
X 
∂ ∂ ∂ ∂H ∂ ∂H
ρ q̇α + ṗα = ρ − =0
∂qα ∂pα ∂qα ∂pα ∂pα ∂qα
α=1 α=1

To summarize, we have derived the Liouville equation


∂ρ
+ {ρ, H} = 0 (99)
∂t

46
the most fundamental equation of statistical mechanics. The Liouville equa-
tion is often written as
∂ρ
+ iLρ = 0 (100)
∂t
where
iL . . . ≡ {. . . , H} (101)
is the Liouville operator.
For a system with N particles and in Cartesian coordinates the Liouville
equation takes the form
" N N
#
∂ X ∂ X ∂
+ vi · + ai · ρ(r 1 , . . . , r N , v 1 , . . . , v N , t) = 0 (102)
∂t ∂r i ∂v i
i=1 i=1

where
Fi 1
ai = = − ∇i Vpot (r 1 , . . . , r N ) (103)
mi mi
is the acceleration for particle number i and the Liouville operator is given
by
XN  
∂ ∂
iL = vi · + ai · (104)
∂r i ∂v i
i=1

In the quantum case the probability distribution is replaced by the den-


sity matrix ρ̂ and the Liouville equation by the equation
∂ 1 h i
ρ̂ + ρ̂, Ĥ = 0 (105)
∂t ih̄
where h i
Â, B̂ ≡ ÂB̂ − B̂ Â (106)

is the commutator.

A.2 Liouville’s theorem


Since ρ = ρ(x, t) its total time derivative can be written as
F 
X 
dρ ∂ρ ∂ρ ∂ρ
= ++ q̇α + ṗα (107)
dt ∂t ∂qα ∂pα
α=1
∂ρ
= + {ρ, H} (108)
∂t
By using the Liouville equation (99) we obtain


=0 (109)
dt

47
which is known as the Liouville’s theorem and is of fundamental importance
for statistical mechanics. It states that the change in density as viewed by
an observer moving along with the trajectory is zero. The density function
along a flow line stays constant in time. Thus, the swarm of the systems
in an ensemble moves in phase-space in essentially the same manner as an
incompressible fluid moves in physical space. The occupied volume in phase-
space does not change in time.
On the other hand, ∂ρ/∂t is the change of the density function at a fixed
point in phase-space and that may change in time. The Liouville’s theorem
follows from classical mechanics, the Hamilton’s equation of motion. It is the
volume in phase-space that is constant in time. This shows the importance to
use the phase-space in describing the microscopic state of a system. Phase-
space plays a privileged role in statistical mechanics.

A.3 Equilibrium distribution functions


The Liouville equation (99) is quite generally true. If we are interested in a
system in equilibrium the density function has to be stationary in time
∂ρ
=0
∂t
i.e. it can not have an explicit dependence on time, ρ = ρ(x). The Liouville
equation (99) is reduced to
{ρ, H} = 0 (110)
The ensemble average of some dynamical quantity A(x) is then given by
Z
hAiens = A(x)ρ(x)dx (111)

where the integration is over all phase space.


The condition in Eq. (110) can be satisfied in many different ways. If
we assume that the dependence of ρ on x comes only through an explicit
dependence on the Hamiltonian H(x) i.e.

ρ(x) = f (H(x)) (112)

where f (. . .) is some arbitrary function, the condition in Eq. (110) will be


automatically satisfied.

A.4 Microcanonical ensemble


Consider a system with N particles in a volume V . We assume that the sys-
tem is isolated from the surrounding and hence, its energy E is conserved.
If there are no further restrictions on the system its macroscopic state is
therefore characterized by N , V and E. We can then construct an ensemble

48
of systems that all have the particle number N , volume V and energy E.
This ensemble is called the microcanonical ensemble. We then make the fun-
damental assumption that each accessible microscopic state in phase space
has the same probability

ρ(x) ∝ δ(H(x) − E) (113)

The ensemble average is then given by


R
A(x)δ(H(x) − E)dx
hAiN V E = V R (114)
V δ(H(x) − E)dx

where the integration is restricted to the volume V and to N particles. The


expression for ρ(x) in Eq. (113) depends only explicitly on H(x) and will
therefore correspond to an equilibrium ensemble according to the Liouville
equation (110). For mathematical reasons one sometimes consider a system
not with a definite energy E but with an energy in a thin shell ∆E around
E and one then let ∆E goes to zero.
The fundamental assumption that each accessible microscopic state has
the same probability is known as the assumption of equal a priori proba-
bilities. This assumption is very reasonable. We know from the Liouville’s
theorem that there is no tendency for phase points to crowd into one region
in phase space rather than another, and hence, it would be arbitrary to make
any assumption other than that of equal a priori probabilities for different
regions of equal extent in the phase space. The assumption of equal a priori
probabilities is the only hypothesis that can reasonably be chosen [24].
If Hamilton’s equation of motion is being solved in time that would
generate microscopic configurations with constant energy E. Suppose that
given an infinite amount of time the system is able to visit all configurations
on the constant energy surface. A system with this property is said to be
ergodic. The time and ensemble average are then equal

hAitime = hAiN V E (115)

This is called the ergodic hypothesis. It is generally believed that most


systems are ergodic but it has turned out to be very difficult to formally
prove ergodicity.

A.5 Canonical ensemble


Many more ensembles can be introduced that can be used to study systems
in equilibrium. The condition (112) provides a recipe to obtain stationary
distributions.
The microcanonical ensemble is of fundamental importance. However,
for applications other ensembles are more important. To keep a system
at constant energy is not easy. It is more natural to consider a system at

49
constant temperature T by keeping it in contact with an appropriate heat
reservoir. The corresponding ensemble is the canonical ensemble. In this
case the macroscopic state of the system is defined by the parameters N , V
and T . The energy of the system can vary be exchanging energy with the
surrrounding, the heat reservoir. The precise nature of the reservoir is not
important, it only has to be much larger than the system
Starting with the microcanonical description one can then derive that
for this system the density function is given by

ρ(x) ∝ exp [−βH(x)] (116)

where β = 1/kT and k is Boltzmann’s constant. Also in this case the


expression for ρ(x) is on the form in (112) and it will describe an equilibrium
distribution. The ensemble average is given by
R
A(x) exp [−βH(x)]dx
hAiN V T = V R (117)
V exp [−βH(x)]dx

Analytical calculations are often more easy to perform using the canon-
ical ensemble compared with the microcanonical ensemble. The precise na-
ture of the ensemble is often not so important. For large systems the average
values from the microcanonical and the canonical ensembles will be the same
 
1
hAiN V E = hAiN V T + O (118)
N

but the fluctuations from the average values can be different.

50
B Symplectic integrators
In Sec. 4 numerical integration methods where derived based on Taylor
expansions. A more formal and more powerful technique has been developed,
based on the classical time evolution operator approach.
The time evolution of the phase-space point x(t) is formally given by

x(t) = eiLt x(0)

where iL is the classical Liouville operator. For a system of N point particles


using Cartesian coordinates we have
N 
X 
∂ ∂
iL = vi · + ai · (119)
∂r i ∂v i
i=1

We can divide the operator into two parts

iL = iLr + iLv (120)

where
N
X ∂
iLr = vi · (121)
∂r i
i=1
XN

iLv = ai · (122)
∂v i
i=1

The two corresponding propagators, eiLr t and eiLv t , can be evaluated ana-
lytically. Consider the operator exp (c∂/∂z) acting on an arbitrary function
g(z), where c is independent on z. The action of the operator can be worked
out by expanding the exponential in a Taylor series
  ∞
X  
∂ 1 ∂ k
exp c g(z) = c g(z)
∂z k! ∂z
k=0

X 1 k dk
= c g(z)
k! dz k
k=0

The second line is just the Taylor expansion of g(z + c) about c = 0. Thus,
we have the general result
 

exp c g(z) = g(z + c)
∂z
which shows that the operator gives rise to a pure translation. Therefore,
the propagator exp (iLr t) only translates all position coordinates

ri → ri + vi t ∀i

51
and the propagator exp (iLv t) only all velocity coordinates

v i → v i + ai t ∀i

We can now write that

x(t) = ei(Lr +Lv )t x(0) (123)

However, the two operators iLr and iLv do not commute

iLr iLv 6= iLv iLr

and hence
ei(Lr +Lv )t 6= eiLr t eiLv t
and Eq. (123) is not easily solved.
To show that they do not commute consider a single particle moving in
one dimension. Its phase-space is described by two coordinates (x, v) and

iLx = v (124)
∂x

iLv = a(x) (125)
∂v
The action of iLx iLv on some arbitrary function g(x, v) is
   
∂ ∂ 0 ∂ ∂2
v a(x) g(x, v) = va (x) + va(x) g(x, v)
∂x ∂v ∂v ∂x∂v
and the action of iLv iLx is
   
∂ ∂ ∂ ∂2
a(x) v g(x, v) = a(x) + a(x)v g(x, v)
∂v ∂x ∂x ∂x∂v
The function g(x, v) is arbitrary, hence
∂ ∂
[iLx , iLv ] = va0 (x) − a(x)
∂v ∂x
and they do not in general commute.
For noncommuting operators A and B,

e(A+B) 6= eA eB

we can make use of the Trotter identity


h iP
e(A+B) = lim eA/P eB/P (126)
P →∞

where P is an integer. It is somewhat better to use the symmetric version


h iP
e(A+B) = lim eB/2P eA/P eB/2P (127)
P →∞

52
We can apply this to the classical propagator exp (iLt). If we define the
time step ∆t = t/P , we can write
h iP
eiLt = lim eiLv ∆t/2 eiLr ∆t eiLv ∆t/2 (128)
∆t→0(P →∞)

For large but finite P we then get an approximation to exp (iLt),


h iP
eiLt = eiLv ∆t/2 eiLr ∆t eiLv ∆t/2 + O(P ∆t3 ) (129)

which can be used in a numerical propagation scheme. To see how this


works in practise, consider again a single particle moving in one dimension.
One time step is the given by
   
x(t + ∆t) iLv ∆t/2 iLr ∆t iLv ∆t/2 x(t)
= e e e
v(t + ∆t) v(t)
 
iLv ∆t/2 iLr ∆t x(t)
= e e
v(t) + ∆t2 a[x(t)]
 
x(t) + ∆tv(t)
= eiLv ∆t/2
v(t) + ∆t2 a[x(t) + ∆tv(t)]
 
x(t) + ∆t{v(t) + ∆t 2 a[x(t)]}
  
=
v(t) + ∆t ∆t ∆t
2 a[x(t)] + 2 a x(t) + ∆t v(t) + 2 a[x(t)]
 2 
x(t) + ∆tv(t) + ∆t2 a[x(t)]
=
v(t) + ∆t2 {a[x(t)] + a[x(t + ∆t)]}

The resulting algorithm is identical to the velocity Verlet algorithm, pre-


sented in Eq. (130)

v = v + 0.5 a dt
r = r + v dt
a = accel(r)
v = v + 0.5 a dt

The above analysis demonstrates how the velocity Verlet algorithm can be
obtained via the powerful Trotter factorization scheme. The first step is a
velocity translation (a half time-step). It is sometimes called a ”kick”, since
it impulsively changes the velocity without altering the positions. The sec-
ond step is a position translation (a full time-step). This is often denoted
a ”drift” step, because it advances the positions without changing the ve-
locities. The accelerations are then updated and, finally, the velocities are
translated (a half time-step) with the new accelerations. These are just the
steps required by the above operator factorization scheme. The fact that the
instructions in the computer code can be written directly from the operator

53
factorization scheme, by-passing the lengthy algebra needed to derive ex-
plicit finite-difference equations, has created the powerful direct translation
method [25].
Moreover, it is now clear that the velocity Verlet algorithm constitutes a
symplectic integrator, that preserves the important symmetries of classical
mechanics. It is area preserving [1] and time reversible. Each individual part
of the product implied by Eq. (128), is symplectic and hence the overall time
evolution is symplectic.
Finally, let us try to understand the absence of long-term energy drift in
the Verlet algorithm. When we use the Verlet algorithm the true Liouville
operator e(iLt) is replaced by the factorization in Eq. (129) In doing so we
make an approximation. We can write

eiLv ∆t/2 eiLr ∆t eiLv ∆t/2 = e(iL∆t+)

where  is an operator that can be expressed in terms of the commutators


of Lr and Lv . We can then define a pseudo-Liouville operator

iLpseudo ∆t ≡ iL∆t + 

that corresponds to a pseudo Hamiltonian. The energy for this pseudo


Hamiltonian is rigorously conserved by the Verlet style algorithm and the
difference between the pseudo Hamiltonian and the true Hamiltonian can
be made as small as we like by choosing ∆t sufficiently small. As the true
Hamiltonian is forced to remain close to a conserved quantity, we can now
understand why there is no long-term drift in the energy with Verlet type
of algorithms.

54
C Error estimate
It is important to find error bounds associated with evaluated quantities in
a simulation. Consider a variable f . Assume that M measurements have
been made {fi } and denote the average as
M
1 X
I= fi (130)
M
i=1

We would like to determine the error bounds for I, its variance. If the values
{fi } are independent on each others, i.e. uncorrelated data, the variance for
1
I is given by Var[I] = M Var[f ] where



Var[f ] = σ 2 (f ) = (f − hf i)2 = f 2 − hf i2 (131)

However, in a simulation subsequent data are often highly correlated. The


variance of I will depend on the number of independent samples Meff gen-
erated by the simulation. We can introduce the statistical inefficiency s
according to
Meff = M/s
The variance of I can then be written as
1 s
Var[I] = Var[f ] = Var[f ] (132)
Meff M
and the problem is reduced to determine s. We will consider two methods,
one based on a direct evaluation of the corresponding correlation function
and one based on data blocking.
The variance of I can be written as
* M
!2 +
1 X
Var[I] = fi − hf i
M
i=1

1 XXh i
M M
2
= hfi fj i − hf i
M2
i=1 j=1


If the data are uncorrelated we have that hfi fj i − hf i2 = [ f 2 − hf i2 ]δij and
1
Var[I] = M Var[f ]. If the data are correlated we introduce the correlation
function
hfi fi+k i − hf i2
Φk = (133)
hf 2 i − hf i2
This is normalized such that

Φk=0 = 1

55
We also assume that we study a stationary system and hence Φk = Φ−k .
For large k, k > Mc , Φk will decay,

Φk>Mc → 0

We assume that the total length of the simulation is considerably longer,


M > Mc . By introducing k = i − j we can now write the variance as
 
|k| h i
M M −1
1 X X
Var[I] = 1− hfi fi+k i − hf i2
M2 M
i=1 k=−(M −1)
M M −1  
1 X X |k|
= Var[f ] 1− Φk
M2 M
i=1 k=−(M −1)
M Mc
1 X X
= Var[f ] Φk
M2
i=1 k=−Mc
Mc
X
1
= Var[f ] Φk
M
k=−Mc

and hence
Mc
X
s= Φk (134)
k=−Mc

By comparing with the definition of the relaxation time τrel in Eq. (71) we
find that the statistical inefficiency s is equal to 2 times the relaxation time

s = 2τrel (135)

If we assume that the correlation function decays exponentially,


Φk = exp (−k/τrel ), we notice that

Φk=s = e−2 = 0.135 ∼ 0.1

The statistical inefficiency can then be determined as the ”time” when the
corresponding correlation function has decayed to about 10% of its initial
value.
Another way to determine the statistical inefficiency s is to use so called
block averaging. Divide the total length M of the simulation into MB blocks
of size B,
M = BMB
Determine the average in each block
B
1 X
Fj = fi+(j−1)B for j = 1, . . . , MB (136)
B
i=1

56
and the corresponding variance Var[F ]. If the block size B is larger than s
{Fj } will be uncorrelated and hence

1
Var[I] = Var[F ] if B > s
MB
However, if the block size is smaller than s we have that
1
Var[I] > Var[F ] if B < s
MB
and we obtain the following relation for s
1
Var[I] ≥ Var[F ]
MB
s B
Var[f ] ≥ Var[F ]
M M
BVar[F ]
s ≥
Var[f ]

We can then obtain the statistical inefficiency

BVar[F ]
s = lim (137)
B large Var[f ]

by plotting BVar[F ]/Var[f ] as function of the block size B. In Fig. 12 we


show a typical result from a simulation.

8
Statistical ineffiency

0
0 20 40 60 80 100
Block size

Figure 12: Illustration of the calculation of s using block averaging. The


figure shows the approach to the plateau value s = 7 when the block size B
is increased.

57
D Temperature and pressure
Expressions for temperature and pressure can be derived using the canonical
ensemble. Consider a system of N identical particles with mass m moving
in a volume V at temperature T and assume that the interaction is given by
the potential Vpot (r 1 , . . . , r N ). In the classical limit the partition function
is then given by
Z
1 dx
Q(N, V, T ) = exp [−βH(x)]
N! h3N
where dx = dr 1 , . . . , dr N , dp1 , . . . , dpN and
N
X p2i
H(x) = + Vpot (r 1 , . . . , r N )
2m
i=1

The momentum part of the partition function can be done analytically


Z
1 1
Q(N, V, T ) = dr 1 . . . dr N exp [−βVpot (r 1 , . . . , r N )] (138)
N ! λ3N
1 1
= Z(N, V, T ) (139)
N ! λ3N
where then Z(N, V, T ) is the configurational part of the partition function
and p
λ = h2 /2πmkT
is the thermal deBroglie wavelength.

D.1 The temperature


The temperature is related to the random motion of the particles, contained
in the kinetic part of the total energy. Consider the average of the kinetic
energy
*N + Z N
X p2 1 1 dx X p2i
i
= exp [−βH(x)]
2m Q N! h3N 2m
i=1 NV T i=1
 3N Z N
X N
X
λ p2i p2i
= dp1 . . . dpN exp [−β ]
h 2m 2m
i=1 i=1
3N kT
= (140)
2
We can then define the instantaneous temperature as
N
2 X p2i
T =
3N k 2m
i=1

and
T = hT iN V T

58
D.2 The pressure
The pressure P is given by the expression
 
∂F
P =−
∂V N,T

where the Helmholtz’s energy is given by

F (N, V, T ) = −kB T ln Q(N, V, T )

This implies that


   
1 ∂Q 1 ∂Z
P = kB T = kB T
Q ∂V N,T Z ∂V N,T

To evaluate the volume derivate we introduce scaled coordinates si according


to
r i = Lsi i = 1, . . . , N
where L is the length of the cubic box, V = L3 . The scaled coordinates
are not influenced by a change of the volume V , only the real coordinates
r i change when the volume changes. The configurational partition function
can be writtes as
Z
Z(N, V, T ) = V N ds1 . . . dsN exp [−β Vpot (V 1/3 s1 , . . . , V 1/3 sN )]

which implies that


Z
kB T N −1
P = NV ds1 . . . dsN exp [−β Vpot ]
Z
Z  
VN dVpot
+ kB T ds1 . . . dsN −β exp [−β Vpot ]
Z dV
Z
N kB T VN dVpot
= − ds1 . . . dsN exp [−β Vpot ]
V Z dV
Z N
N kB T VN V −2/3 X
= − ds1 . . . dsN (∇i Vpot · si ) exp [−β Vpot ]
V Z 3
i=1
Z XN
N kB T 1 VN
= + ds1 . . . dsN (r i · F i ) exp [−β Vpot ]
V 3V Z
i=1
Z XN
N kB T 1 1
= + dr 1 . . . dr N (r i · F i ) exp [−β Vpot ]
V 3V Z
i=1
*N +
N kB T 1 X
= + ri · F i (141)
V 3V
i=1 NV T

59
We can then define the instanteneous pressure as
N  
1 X p2i
P= + ri · F i
3V m
i=1

and
P V = N kT + W
where * +
N
1X
W = hWiN V T = ri · F i
3
i=1 NV T
is called the virial function.

60
E Equilibration
To start a simulation we need to give the initial positions and velocities for
all particles. This will give rise to a certain temperature and pressure after
some initial equilibration time Teq . However, there is no explicit expression
for the obtained temperature and pressure expressed in terms of the initial
positions and velocities. To obtain a certain temperature and pressure one
can scale the position coordinates and velocities during the equilibration
run and then turn off the scaling, during the production run when average
quantities are being computed.
We consider here one type of scaling technique to obtain a certain tem-
perature Teq and pressure Peq . Consider first the temperature. Initially, it
is equal to T (0), where T (t) is the instantaneous temperature. We would
like it to decay exponentially to Teq ,
T (t) = Teq + (T (0) − Teq )e−t/τT
with some decay time constant τT . We can change the instantaneous tem-
perature by scaling the velocities at each time-step according to
1/2
v new
i = αT v old
i
By choosing
2∆t Teq − T (t)
αT (t) = 1 + (142)
τT T (t)
the instantaneous temperature will approximately decay exponentially with
time constant τT to the desired temperature Teq .
In the same way we can modify the pressure. In this case we have to
scale the positions (and the box size). We again would like to obtain an
exponential decay
P(t) = Peq + (P(0) − Peq )e−t/τP
to the desired pressure Peq . The positions are scaled according to
1/3
r new
i = αP r old
i
and by choosing
∆t
αP (t) = 1 − κT [Peq − P(t)] (143)
τP
the desired exponential decay is obtained. Here
 
1 ∂V
κT = − (144)
V ∂P T
is the isothermal compressibility.

61
Acknowledgements
I would like to thank Anders Lindman for providing most of the figures.

62
References
[1] D. Frenkel and B. Smit, Understanding Molecular Simulation, 2nd ed.,
Academic Press, 2002.

[2] M. P. Allen and D. J. Tildesley, Computer Simulations of Liquids,


Clarendon Press, 1989.

[3] J. M. Haile, Molecular Dynamics Simulation, John Wiley & Sons, 1992.

[4] H. Goldstein, C. Poole, and J. Safko, Classical Mechanics, 3rd ed.,


Addison Wesley, 2002.

[5] R. K. Pathria and P. D. Beale, Statistical Mechanics, Academic Press,


2011.

[6] S.-K. Ma, Statistical Mechanics, World Scientific, 1985.

[7] A. Rahman, Phys. Rev. 136A, 405 (1964).

[8] A. E. Carlsson, Solid State Phys. 43, 1 (1990).

[9] F. Ercolessi, E. Tosatti, and M. Parrinello, Phys. Rev. Lett. 57, 719
(1986).

[10] K. W. Jacobsen, Comments Cond. Mat. Phys. 14, 129 (1988).

[11] M. S. Daw, S. M. Folies, and M. I. Baskes, Materials Sci. Rep. 9, 251


(1993).

[12] M. Finnis and J. Sinclair, Philos. Mag. A 50, 45 (1984).

[13] F. H. Stillinger and T. A. Weber, Phys. Rev. B 31, 5262 (1985).

[14] M. Parrinello and A. Rahman, J. Appl. Phys. 52, 7182 (1981).

[15] L. Verlet, Phys. Rev. 159, 98 (1967).

[16] G. Dahlquist and A. Björk, Numerical methods (Prentice Hall, 1974).

[17] W. C. Swope and H. C. Andersen, J. Phys. Chem. 88, 6548 (1984).

[18] M. E. Tuckerman, G. J. Martyna, and B. J. Berne, J. Chem. Phys. 97,


1990 (1992).

[19] J. M. Thijssen, Computational Physics, 2nd ed., Cambridge, 2007.

[20] B. J. Alder and T. E. Wainwright, Phys. Rev. Lett. 18, 988 (1967).

[21] J. P. Boon and S. Yip, Molecular Hydrodynamics, Dover 1992.

63
[22] L. van Hove, Phys. Rev. 95, 249 (1954).

[23] R. Zwanzig, Ann. Rev. Phys. Chem. 16, 67 (1965).

[24] R. C. Tolman, The principles of statistical mechanics, Clarendon Press,


1938.

[25] G. J. Martyna, M. E. Tuckerman, D. J. Tobias, and M. L. Klein, Mol.


Phys. 87, 1117 (1996).

64

You might also like