Molecular Dynamics Lecture Notes: G Oran Wahnstr Om
Molecular Dynamics Lecture Notes: G Oran Wahnstr Om
Molecular Dynamics Lecture Notes: G Oran Wahnstr Om
MOLECULAR DYNAMICS
Lecture notes
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
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
B Symplectic integrators 51
C Error estimate 55
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 ,
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.
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
∂
ṙ 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
4
t=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)
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
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
δ(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)
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)]
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.
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.
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.
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).
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
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.
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.
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.
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),
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.
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 (τ )
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).
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
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%.
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
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 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
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
Pressure (/σ 3 )
1.0 5
0.8 4
0.6 3
0.4 2
0.2 1
0 20 40 60 80 100
Time (τ )
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.
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
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
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 (σ)
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)
2.0
1.5
S(q)
1.0
0.5
5 10 15 20 25
q (σ )
−1
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.
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
instead, i.e.
C(t) = δA(t + t0 ) δA(t0 ) (70)
The correlation function then has the initial value
C(0) = δA2
C(t → ∞) = 0
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.
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.
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 (τ )
37
The Fourier transform of the power spectrum is given by
Z ∞
dω
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)
Am ≡ A(m∆τ ) ; m = 0, 1, . . . , (M − 1)
and
1
P(ω) = | Âk |2
M
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.
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
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
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
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
lim ∆M SD (t) ∝ t
t→∞
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.
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.
43
Taking the long-time limit, we find
Z ∞ D E
[A(t) − A(0)]2
lim = dτ Ȧ(τ )Ȧ(0) (88)
t→∞ 2t 0
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.
x = (q1 , . . . , qF , p1 , . . . , pF ) (90)
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
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
is the commutator.
dρ
=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.
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
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
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
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
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
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
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 →∞)
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
iLpseudo ∆t ≡ iL∆t +
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)
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
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)
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 ]
BVar[F ]
s = lim (137)
B large Var[f ]
8
Statistical ineffiency
0
0 20 40 60 80 100
Block size
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
and
T = hT iN V T
58
D.2 The pressure
The pressure P is given by the expression
∂F
P =−
∂V N,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.
[3] J. M. Haile, Molecular Dynamics Simulation, John Wiley & Sons, 1992.
[9] F. Ercolessi, E. Tosatti, and M. Parrinello, Phys. Rev. Lett. 57, 719
(1986).
[20] B. J. Alder and T. E. Wainwright, Phys. Rev. Lett. 18, 988 (1967).
63
[22] L. van Hove, Phys. Rev. 95, 249 (1954).
64