MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf ·...

106
MSc in Theoretical Chemistry Applications of Statistical Mechanics: Molecular Simulation Methods in Chemistry Jonathan Doye [email protected] http://physchem.ox.ac.uk/doye/jon/teach/simulation.html 1

Transcript of MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf ·...

Page 1: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

MSc in Theoretical Chemistry

Applications of Statistical Mechanics:

Molecular Simulation Methods in Chemistry

Jonathan Doye

[email protected]

http://physchem.ox.ac.uk/∼doye/jon/teach/simulation.html

1

Page 2: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Introduction

Why computer simulations?• The inevitability of approximations in analytical work

e.g. the motion of three interacting bodies.

• Moore’s law and the increasing power of computers

• The increasing sophistication of computer simulation techniques.

• Wide-spread availability of user-friendly simulation packages.

Jonathan Doye, University of Oxford 2

Page 3: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

What can molecular simulations achieve?• Dynamics: rN(t), pN(t). I.e. a movie

n.b. rN = (r1, r2, . . . , rN)

• Thermodynamics and equilibrium propertiesrN

i ⇒ 〈Q〉ensembles of configurations and averages

Roles of computer simulations• Model systems

. As a test for theory.

. Exploring complex systems.

• Realistic models:

. Prediction of properties

. Direct visualization of molecular configurations

Limits of computer simulation• Need the potential energy function V(rN) (GIGO principle)

• Size of system limited (max O(108))

• Time scales relatively short (max O(µs))

Jonathan Doye, University of Oxford 3

Page 4: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Computer simulation: a new science

1953: Metroplis et al.: First Monte Carlo simulation of a molecular system

Jonathan Doye, University of Oxford 4

Page 5: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

1956 Alder and Wainwright: First molecular dynamics (MD) simulations.

1957 Alder and Wainwright: Hard-sphere debate

Jonathan Doye, University of Oxford 5

Page 6: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

1964 Rahman: First MD with realistic interatomic potential (Ar)

1974 Rahman and Stillinger: First MD with realistic intermolecular potential(H2O)

1977 McCammon et al.: First MD of a protein (BPTI) (500 atoms, 9.2 ps)

2006 Schulten group: MD of complete virus (STMV) (106 atoms, 50 ns)

Jonathan Doye, University of Oxford 6

Page 7: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Aims of this course

To introduce you to the principles behind computer simulation (not all thealgorithmic details).

To put you in a position so that you know what you are doing when runningsomeone else’s code/a simulation package.

To put you in a position to start writing your own simulation codes.

This course won’t cover:

• statistical mechanics basis

• how to program

• Where V(rN) comes from.

Jonathan Doye, University of Oxford 7

Page 8: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Recommended texts

Frenkel and Smit: Understanding Molecular Simulation: From Algorithms toApplications (Academic Press, 2002)

Allen and Tildesley: Computer Simulation of Liquids (Oxford, 1987)

Krauth: Algorithms and Computations (Oxford, 2006)

Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999)

Rapaport: The Art of Molecular Dynamics (Cambridge, 1995)

Press et al.: Numerical Recipes in ?: The Art of Scientific Computing, Cam-bridge

Jonathan Doye, University of Oxford 8

Page 9: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Molecular Dynamics

Molecular dynamics simulations are a method for computing the equilibriumand transport properties of a classical many-body system.

Classical: the nuclear motion of the constituent particles obeys the laws ofclassical mechanics, i.e. Newton’s laws.

Classical mechanics is a good approximation for many materials. Quantumeffects most relevant for light atoms and low temperatures.

Quantum nature of electrons enters through the potential, V(rN)

Involves numerically solving Newton’s equation by integrating them forwardin time to generate a trajectory.

Jonathan Doye, University of Oxford 9

Page 10: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Basic scheme

1. Initialize the system: choose rN(t = 0) and pN(t = 0)

2. Compute forces

3. Integrate equations of motion: from t → t + δt.

4. Repeat 3 and 4 until trajectory of desired length.

Jonathan Doye, University of Oxford 10

Page 11: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

What ensemble?

For an isolated mechanical system the total energy is conserved during themotion. Proof:

dE

dt=

d

dt

[N∑i

12mir2

i + V(rN)

]=

N∑i

miri · ri +N∑i

∂V∂ri

· ri (1)

=N∑i

ri · fi −N∑i

fi · ri = 0 (2)

Therefore, standard molecular dynamics simulates the microcanonical ensem-ble (NV E).

Newtonian dynamics also obeys time reversal symmetry. I.e. If we reverse thevelocities of all the particles, keeping the positions the same, the system willretrace its trajectory back into the past. More formally,

rN(t, rN(0),−pN(0)

)= rN

(−t, rN(0),pN(0)

)(3)

pN(t, rN(0),−pN(0)

)= −pN

(−t, rN(0),pN(0)

)(4)

Jonathan Doye, University of Oxford 11

Page 12: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Integration Scheme

All based on Taylor expansions of position in time.

A simple example. Expand position to third order in time.

ri(t + δt) = ri(t) + ri(t)δt +ri(t)

2δt2 +

...r i(t)

6δt3 +O(δt4) (5)

As ri = vi and using Newton’s 2nd law (fi = miri), rewrite as

ri(t + δt) = ri(t) + vi(t)δt +fi(t)2mi

δt2 +...r i(t)

6δt3 +O(δt4) (6)

Similarly,

ri(t− δt) = ri(t)− vi(t)δt +fi(t)2mi

δt2 −...r i(t)

6δt3 +O(δt4) (7)

Adding these two equations gives

ri(t + δt) = 2ri(t)− ri(t− δt) +fi(t)mi

δt2 +O(δt4) (8)

Jonathan Doye, University of Oxford 12

Page 13: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Note that due to the cancellation of odd time derivatives of ri:

• this expression is accurate to third order in time, even though only forces are used.

• velocities do not appear in the expression.

Get velocity, by subtracting Eq. 7 from Eq. 6.

vi(t) =1

2δt[ri(t + δt)− ri(t− δt)] +O(δt2) (9)

This is the Verlet scheme.

An alternative scheme that has identical trajectories to the Verlet algorithm,but a more convenient expression for the velocity is velocity Verlet.

ri(t + δt) = ri(t) + vi(t)δt +fi(t)2mi

δt2 (10)

vi(t + δt) = vi(t) +1

2mi[fi(t) + fi(t + δt)] δt (11)

Jonathan Doye, University of Oxford 13

Page 14: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Example: Motion of a projectile with air resistance

-0.10

-0.05

0.00

0.05

0.10

0.15

0.20

0.25

0 0.2 0.4 0.6 0.8 1 1.2 1.4

distance

heig

ht

increasing time step

Jonathan Doye, University of Oxford 14

Page 15: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Ergodic hypothesis

Q: Can we use molecular dynamics to obtain equilibrium properties for themicrocanonical ensemble?

Ergodic hypothesis: Time averages of ergodic systems in the limit of trajecto-ries of infinite length are equivalent to ensemble averages.

I.e. A = 〈A〉NV E, where

A = lim∆t→∞

∫ ∆t

0

A(rN(t),pN(t)

)dt (12)

〈A〉NV E =

∫A(rN ,pN

)δ[H(rN ,pN

)− E

]drNdpN∫

δ [H (rN ,pN)− E] drNdpN(13)

This is equivalent to saying that each point on the constant NVE manifold isequally likely to be sampled in the MD simulation.

Jonathan Doye, University of Oxford 15

Page 16: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

On a harmonic potential energy surface this would not be true. Anharmonici-ties that couple different degrees of freedom allow energy to be redistributedbetween different modes and prevents the system getting stuck in periodicorbits. The chaotic motion causes the system to lose memory of its initialconditions.

However, if there are large barriers relative to the kinetic energy per degreeof freedom, this can prevent ergodicity being achieved on the simulation timescales.

In practice, as we have evaluated A at a series of discrete points along thetrajectory, we use

A ∼=1M

M∑m=1

A(tm) (14)

Jonathan Doye, University of Oxford 16

Page 17: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

What do we want from an integrator

Accuracy? I.e. an integrator that most closely follows the true trajectory.

Important for satellite dynamics, but not for molecular dynamics.

Molecular chaos means that the simulated trajectory quickly diverges fromthe true trajectory. I.e. the trajectories show extreme sensitivity to smalldifference in initial conditions.

For two trajectories that at t = 0 only differed by a small perturbation ε ofthe initial conditions

|∆r(t)| = |r′(t)− r(t)| ∼ ε exp(λt) (15)

where λ is the Lyapunov exponent.

⇒ Trying to achieve accuracy in MD is pointless.

New aim: representative trajectory and good statistical properties.

Jonathan Doye, University of Oxford 17

Page 18: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

In particular, important that the integration scheme obeys time reversalsymmetry, and conserves the energy over long times.

The latter is achieved by area-preserving or symplectic algorithms. The actionof such an integrator on a volume in phase space leaves the volume unchanged.

Why is this important? If Ω(E) (the density of states) is mapped onto Ω′ withdifferent volume, it will no longer simulate a microcanonical ensemble.

Verlet algorithms are symplectic.

nbΩ(E) ∝

∫δ[H(rN ,pN

)− E

]drNdpN (16)

Jonathan Doye, University of Oxford 18

Page 19: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Force evaluation

Calculating the forces is the most computationally time-consuming part of anyMD calculation.

For a pair potential

V(rN)

=N∑i

N∑j>i

v(rij) =12

N∑i

N∑j 6=i

v(rij) (17)

fi = −∂V∂ri

= −12

∑j 6=i

(∂v(rij)

∂ri+

∂v(rji)∂ri

)= −

∑j 6=i

dv(r)dr

∣∣∣∣r=rij

rij

rij(18)

The number of operations required to calculate the forces on all the atomsscales as N2.

Jonathan Doye, University of Oxford 19

Page 20: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Initialization

Need to provide initial rN and pN.

rN(0) easy if simulating an ordered state with known structure, e.g. crystal,native state of protein.

If simulating a disordered state such as a liquid, E.g.

• Create random configuration and then minimize the potential energy (so that thepotential energy is less that total energy).

• Or perform an initial simulation, where a crystal is rapidly heated to melt it, and thencooled to the desired total energy.

The velocities are assigned from a random distribution (ideally a Gaussianone, so that they satisfy the Maxwell-Boltzmann distribution).

The velocities are then scaled so that the system has the desired total energyE.

Jonathan Doye, University of Oxford 20

Page 21: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Note: Temperature can be calculated through the equipartition theorem⟨N∑

i=1

p2i

2mi

⟩=

32NkT (19)

Jonathan Doye, University of Oxford 21

Page 22: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Monte Carlo

Monte Carlo is a stochastic method to calculate integrals.

Why integrals?

Common in classical statistical mechanics

〈A〉NV T =

∫A(rN ,pN

)exp(−βE)drNdpN∫

exp(−βE)drNdpN(20)

1947: von Neumann, Metropolis and Ulam: First computational Monte Carloapplication. Diffusion of neutrons in fissile material.

1953: Metroplis et al.: First Monte Carlo simulation of a molecular system

Called Monte Carlo because of its use of random numbers.

Jonathan Doye, University of Oxford 22

Page 23: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Calculating π by MC

Throwing darts randomly at the target

limnthrows→∞

nhits

nthrows=

π

4(21)

As an integral1

nthrows

∑i

Oi =

∫ 1

−1O(x, y)dxdy∫ 1

−1dxdy

(22)

where

O(x, y) =

1 r ≤ 10 r > 1 (23)

Jonathan Doye, University of Oxford 23

Page 24: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

1e-07

1e-06

1e-05

0.0001

0.001

0.01

0.1

1

1 10 100 1000 10000 100000 1e+06 1e+07 1e+08 1e+09

number of trials

error in the estimate

Lazzarini

abso

lute

dev

iatio

n in

est

imat

e of

π

Results of MC estimation of π.

Jonathan Doye, University of Oxford 24

Page 25: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Buffon’s Needle

dl

The probability of a needleoverlapping a crack betweenfloorboards can also be usedto obtain π.

poverlap =2l

πd(24)

First suggested by Comte de Buffon in 1777.

In 1901 Lazzarini claimed an estimate of π = 3.1415929 (355/113), i.e. anaccuracy of 7SF, on the basis of 3408 trials.

Jonathan Doye, University of Oxford 25

Page 26: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Estimating 1D integrals

10 x

f(x)

MC

10 x

f(x)

Quadrature

MC estimate for the integral

I =∫ 1

0

f(x)dx ≈ 1M

M∑i=1

f(xi) (25)

where M random points xi in the interval [0, 1] have been selected.

Jonathan Doye, University of Oxford 26

Page 27: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Error analysis: MC

The error in the estimate of I, σI, obeys

σ2I =

⟨(I − 〈I〉)2

⟩(26)

=

⟨(1M

M∑i=1

f(xi)−

⟨1M

M∑i=1

f(xi)

⟩)2⟩(27)

=1

M2

⟨(M∑i=1

(f(xi)− 〈f(x)〉)

) M∑j=1

(f(xj)− 〈f(x)〉)

⟩ (28)

=1

M2

⟨M∑i=1

(f(xi)− 〈f(x)〉)2⟩

=1M

σ2f (29)

as f(xi) and xi are uncorrelated.

Jonathan Doye, University of Oxford 27

Page 28: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Error analysis: Quadrature

Integration using the simple trapezium rule gives

I =1M

(12f(0) +

N−2∑i

f(xi) +12f(1)

)+O

(1

M3

)(30)

where the xi = i/N are equally spaced.

Thus, for 1D integrals quadrature methods converge much faster than the MCapproach.

For higher dimensional integrals using the trapezium rule, the error has thesame dependence on the number of points m in each dimension, i.e. O(1/m3).However, as the total number of points M = md the error is O(1/M3/d).

The scaling for the MC error is independent of dimension, i.e. σI ∼ 1/√

M.

⇒ MC scales better than trapezium rule for d > 6.

Jonathan Doye, University of Oxford 28

Page 29: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Importance sampling

As the Boltzmann weights in the statistical mechanics integrals that we want toevaluate (Eq. 20) are non-negligible for only a small fraction of configurationspace, random uniform sampling will be of no use.

e.g. for 100 hard spheres at the freezing transition, only one in 10260

configurations have a non-zero Boltzmann weight.

Therefore, it would be useful to preferentially sample regions where anintegral has the most weight.

Back to 1D: Sample points from a probability distribution w(x). Estimate ofintegral now:

I ≈ 1M

M∑i=1

f(xi|w)w(xi|w)

(31)

where xi|w means that the xi have been drawn from the distribution w(x).The error is now:

σ2I =

1M2

⟨M∑i=1

(f(xi|w)w(xi|w)

−⟨

f(x)w(x)

⟩)2⟩

=1M

σ2f/w (32)

Jonathan Doye, University of Oxford 29

Page 30: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Even though this procedure has not changed the scaling, it’s effect on theprefactor can be useful.

If w(x) = f(x)/〈f〉, then σf/w = 0. However, this choice requires one toalready know the integral we are trying to evaluate!

A good choice of w(x) can lead to enhanced accuracy.

0

0.5

1.0

1.5

2.0

2.5

0 0.2 0.4 0.6 0.8 1

f(x)=exp(x)

x

f(x)/w(x)

w(x)=2(1+x)/3

For uniform sampling

σI ≈0.5√N

(33)

For importance sampling,using the weight functionw(x) = 2(1 + x)/3

σI ≈0.16√

N(34)

Jonathan Doye, University of Oxford 30

Page 31: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

To apply this importance sampling approach directly to our statistical mechan-ical integrals, the ideal weight function would be exp(−βE)/Q. However, togenerate such a distribution of configurations, one would first need to knowthe partition function Q.

Metropolis escaped from this impasse by introducing a Markov chain method,where one only needed to know the relative probabilities of different config-urations. It uses a biased random walk.

Jonathan Doye, University of Oxford 31

Page 32: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Metropolis Monte Carlo

Basic approach

• Start with a configuration o

• Choose and accept a new configuration n with a transition probability π(o → n)

• Calculate properties of interest for the current configuration and add to average.

• Repeat to create a trajectory through phase space

Note:

• The configuration does not have to change at each step, i.e.

π(o → o) = 1−Xn 6=o

π(o → n) 6= 0 (35)

• The trajectories generated are stochastic (cf MD trajectories are deterministic).

Jonathan Doye, University of Oxford 32

Page 33: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Detailed balance

Aim: to sample configurations from the Boltzmann distribution.

Thought experiment:

• Have a large ensemble of MC trajectories for a given system.

• Probability that a configuration appears within this ensemble obeys the Boltzmanndistribution, i.e. P (o) = exp(−βEo)/Q.

Key requirement: form of transition probabilities must maintain this distribu-tion. i.e. it is stationary, and the net probability flow into and out of everystate must balance.

P (o)∑

i

π(o → i) =∑

j

P (j)π(j → o) (36)

This equation can be satisfied, if ‘detailed balance’ is obeyed:

P (o)π(o → n) = P (n)π(n → o) (37)

Jonathan Doye, University of Oxford 33

Page 34: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

This condition guarantees equilibrium is maintained. Does not say if or howequilibrium will be reached.

π(o → n) broken into two parts.

π(o → n) = α(o → n)acc(o → n) (38)

• α(o → n): The probability of performing a trial move from o to n

• acc(o → n): The probability that the trial move is accepted. Otherwise, move isrejected and configuration o is retained.

As in the original Metropolis scheme, it is common that α is symmetrical, i.e.α(o → n) = α(n → 0).

Detailed balance implies:

π(o → n)π(n → 0)

=acc(o → n)acc(n → o)

=P (n)P (o)

= exp [−β(En − Eo)] (39)

Jonathan Doye, University of Oxford 34

Page 35: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Metropolis acceptance criterion

Many possible choices of acc(o → n) that satisfy Eq. 39.

The form proposed by Metropolis et al. (and most commonly used) is

acc(o → n) =

P (n)/P (o) P (n) < P (o)1 P (n) ≥ P (o) (40)

For the Boltzmann distribution, this is

acc(o → n) =

exp [−β(En − Eo)] En > E0

1 En ≤ Eo(41)

Downhill moves are always accepted, whereas uphill moves are accepted witha probability that decreases with the energy difference.

Jonathan Doye, University of Oxford 35

Page 36: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Integrating out the momenta

In the partition function, the integral over the momentum coordinates can beeasily performed.

Q =1

N !Λ3NZ (42)

where Λ is the thermal wavelength, and Z is the configurational partitionfunction:

Z =∫

exp[−βV

(rN)]

drN (43)

Similarly, for quantities that only depend on rN, no point using MC to performthe integral over the momenta in the average 〈A〉NV T (Eq. 20).

Therefore, in Metropolis MC only rN is considered and configurations aresampled with probability

P(rN)

=1Z

exp[−βV

(rN)]

(44)

Jonathan Doye, University of Oxford 36

Page 37: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Basic step in more detail

To move from step k to k + 1

• Select a particle i at random from rNk

• Add a random displacement to this atom: r′i = ri + ∆

• Calculate the potential energy V(rNtrial) for new trial configuration.

• Accept the move rNk → rN

trial with probability

acc(o → n) = minn

1, exph−β

“V

“rN

trial

”− V

“rN

k

””io(45)

On acceptancerN

k+1 = rNtrial (46)

On rejectionrN

k+1 = rNk (47)

• Add A(rNk+1) to average.

Jonathan Doye, University of Oxford 37

Page 38: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Notes on algorithm

Random displacement ∆ usually chosen uniformly from a cube:

∆α = ∆max (ran[0, 1]− 0.5) α = x, y, z (48)

Choice of step size, ∆max:

• If ∆max is too large, most steps will be rejected.

• If ∆max is too small, although most steps will be accepted, the system will only movevery slowly through configuration space.

Optimal step size: Lowest statistical error for given CPU time.

Rule of thumb: 50% acceptance rate reasonable for continuous potentials (20%for hard-core systems).

Optimal step size will vary with conditions. E.g. smaller in dense systems.

How to choose ∆max? One way is to adjust the step size dynamically duringthe equilibration period.

Jonathan Doye, University of Oxford 38

Page 39: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

For transition matrix to be symmetric, i.e. α(o → n) = α(o → n):

• choice of atom needs to be random

• Maximum step size needs to be constant.

Why move only one atom at a time?

Cost of N single-particle moves is similar to that for a single N-particle move.For pair potential,

V(rN

trial

)= V

(rN

k

)+∑j 6=i

v(rtrialij

)− v

(rkij

)(49)

If the probability of a single-particle move being rejected is prej, the proba-bility that a collective move of all N particles is (1− prej)N.

∴ single-particle move algorithms move more rapidly through configurationspace.

Jargon: an MC cycle or sweep corresponds to N single-particle moves.

Jonathan Doye, University of Oxford 39

Page 40: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Markov chains and ergodicity

The random walk performed by an MC simulation is an example of a Markovprocess: A stochastic process without memory, i.e. π(o → n) is independentof the previous history of moves.

Ergodicity is assumed: i.e. one can go between any two states of the systemin a finite number of steps.

In practice, to prevent errors due to incomplete sampling, this number ofsteps needs to be shorter than the simulation.

Large (much larger than kT ) barriers can make equilibrium sampling verydifficult.

Approach to equilibrium: Markov chains approach the equilibrium distributionexponentially fast. But this still can be a long time, and is dependent on thestarting configuration.

∴ need to equilibrate the system, before starting to take averages.

Jonathan Doye, University of Oxford 40

Page 41: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Equilibration in Ising model

-1.0

-0.8

-0.6

-0.4

-0.2

0.0

0.2

0.4

0.6

0.8

1.0

1 10 100 1000 10000number of MC cycles

mag

netiz

atio

n

randomconfiguration

all spinsdown

2D Ising model: 40× 40 lattice, kT/J = 1.8, H = 0.1.

H = −J∑i,j

SiSj + H∑

i

Si (50)

Jonathan Doye, University of Oxford 41

Page 42: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Error analysis in MC trajectories

The variance in a quantity measured in an M step MC simulation is

σ2M(A) =

1M

M∑i=1

(Ak − 〈A〉M)2 =⟨A2⟩

M− 〈A〉2M (51)

If these measurements were independent, the variance in the average wouldbe

σ2 (〈A〉M) ≈ 1M

σ2M (52)

However, the configurations generated by a MC trajectory are correlated.

Auto-correlation functions can be used to measure how long it takes a systemto lose ‘‘memory’’ of the state it was in.

CAA(k) =1M

∑k′

(Ak′ − 〈A〉) (Ak+k′ − 〈A〉) (53)

Jonathan Doye, University of Oxford 42

Page 43: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Correlation functions typically show an exponential decay, i.e.

CAA(k) ∼ exp (−k/nτ) (54)

where 2nτ is a reasonable estimate of the number of steps between indepen-dent measurements.

∴ nm = M/2nτ is a measure of the number of statistically independentmeasurements, and

σ2 (〈A〉M) =1

nM − 1σ2

M (55)

Jonathan Doye, University of Oxford 43

Page 44: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Block averages

An alternative approach is to use block averages.

Take L partial averages 〈A〉l over blocks of length l = M/L MC steps.

σ2L(〈A〉l) =

1L

L∑i=1

(〈A〉l − 〈A〉M)2 (56)

As the block size increases, eventually l > 2nτ and the 〈A〉l become indepen-dent. ∴

σ2L(〈A〉l)L− 1

≈ σ2(〈A〉M) (57)

Plotting σ2L(〈A〉l)/(L − 1) as a function of L, this quantity will increase with

decreasing L and plateau at the correct variance for L ≤ nM.

Jonathan Doye, University of Oxford 44

Page 45: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

(<A

σ2 L

l> )

/L

−1

1e-05

0.0001

0.001

0.01

0.01 0.1 1 10 100 1000 10000

0

0.2

0.4

0.6

0.8

1

0 5 10 15 20 25

block length in MC cycles number of MC cycles

mag

netiz

atio

n au

to−

corr

elat

ion

func

tion

2D Ising model: 40× 40 lattice, kT/J = 1.8.

Jonathan Doye, University of Oxford 45

Page 46: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Systematic Errors

• Finite-size errors

If one is interested in estimating bulk properties from MC simulations, thereare often errors due to the necessarily finite size of the simulation system.

Such finite-size errors typically scale as

Error ∼ 1√N

(58)

Finite-size scaling (i.e. examining how your property depends on N) can oftenbe used to extrapolate to the bulk limit.

• Failure to reach equilibrium

Large barriers can make the convergence of averages very slowly, as passageover these barriers represent rare events.

Jonathan Doye, University of Oxford 46

Page 47: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Periodic Boundary conditions

Normally, one wants to simulate a bulk system using a simulation of a finitenumber of particles.

For small systems, the fraction of particles at any surface is high, e.g. openor hard boundary conditions

Therefore, to minimize such effects, periodic boundary conditions are used.

Jonathan Doye, University of Oxford 47

Page 48: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

The simulation cell is treated as the primitive cell of an infinite periodiclattice of identical cells.

The simulation box is often chosen to be cubic, but other choices are possible.

Vtot =12

∑i,j,n

v (|rij + nL|) , (59)

where L is the edge length of the (cubic) box, and n is any vector of threeintegers.

An infinite sum!

Minimum image convention: an atom only interacts with the nearest image ofany particle.

Potential problems with PBC: properties that depend on long wavelengths.

Jonathan Doye, University of Oxford 48

Page 49: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Truncating the interactions

The most expensive part of any calculation is evaluating the energy and itsderivatives.

For a pair potential, the cost of evaluating the potential is O(N2), as all pairsof atoms should be formally considered.

However, the interactions between distant atoms for short-ranged interactionsare often very small, and so the potential can be truncated.

For periodic boundary conditions, usually choose rc < L/2.

If v(rc) 6= 0 this leads to an error, but this can be corrected for:.

V(rN)

=∑

rij<rc

v(rij) +Nρ

2

∫ ∞

rc

4πr2v(r) (60)

Jargon: this extra term is called a tail correction.

Tail correction does not converge for v(r) ∝ r−n if (n ≤ 3). Need to use ‘Ewaldsummation’.

Jonathan Doye, University of Oxford 49

Page 50: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Common ways to truncate the potential

• Simple truncation

v′(r) =

v(r) r ≤ rc

0 r > rc(61)

MC: okay, but needs an additional impulsive correction for the pressure.

MD: problems with discontinuity in the potential.

• Truncate and shift

v′(r) =

v(r)− v(rc) r ≤ rc

0 r > rc(62)

MD: still a discontinuity in the derivatives

Jonathan Doye, University of Oxford 50

Page 51: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Code scaling

Truncation reduces the number of interactions that need to be calculatedfrom O(N2) to O(mN), where m is the average number of neighbours of anatom within the cutoff distance.

However, O(N2) distances still need to be checked at each step.

To reduce the overall scaling of the algorithm to O(N), two common methods:

• Neighbour listStore a list of the particles that are within rv of each atom, where rv > rc. Onlycalculate the interactions between particles on the neighbour lists. List needs to beupdated when atoms have moved by rv − rc.

• Cell listDivide the simulation box up into cells. Only calculate the interactions betweenparticles in the same or neighbouring cells.

Jonathan Doye, University of Oxford 51

Page 52: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Thermodynamics properties

In the canonical ensemble, the heat capacity can be calculated from fluctua-tions in the total energy:

Cv(T ) =1

kT 2

(〈E2〉 − 〈E〉2

)(63)

In the canonical ensemble,

p(E, T ) =1

Q(T )Ω(E) exp (−βE) (64)

Hence one can extract an estimate of the density of states, Ω(E) (to within amultiplicative constant) from the histogram p(E, T ).

This can then be used to calculate thermodynamic properties at any temper-

Jonathan Doye, University of Oxford 52

Page 53: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

ature, e.g.

U(T ) =∫

E Ω(E) exp (−βE) dE∫Ω(E) exp (−βE) dE

(65)

=∫

p(E, T ′)E exp ((β′ − β)E) dE∫p(E, T ′) exp ((β′ − β)E) dE

(66)

In the ‘multi-histogram’ approach p(E, T ) distributions from a number oftemperatures are used to obtain a ‘best’ estimate of Ω(E).

Jonathan Doye, University of Oxford 53

Page 54: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Pressure

In the canonical ensemble, P = −(∂A/∂V )N,T leads to the virial expressionfor the pressure:

P = ρkT +1

dV

⟨∑i<j

f(rij) · rij

⟩, (67)

where ρ is the density and d the dimension of the system.

This can be expressed in terms of the radial distribution function:

P = ρkT − 2πρ2

3

∫r3g(r)

dv(r)dr

dr (68)

This form can be used to derive a tail correction for the measurement of thepressure.

The virial expression cannot straightforwardly be applied to hard particles. InMC it is also possible to relate the pressure to the probability of acceptanceof a trial move that changes the volume of the simulation box.

Jonathan Doye, University of Oxford 54

Page 55: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Diffusion

Diffusion can be related to the mean-square displacement through the Einsteinrelation:

∆r2(t) =⟨(ri(t)− ri(0))2

⟩= 2dDt (69)

where the average is over an equilibrium ensemble of initial conditions.

At short times, the motion of the particles is ballistic, so the limiting slope ofa plot of ∆r2(t) versus time is used to compute D.

The diffusion coefficient can also be related to the velocity auto-correlationfunction. As

ri(t)− ri(0) =∫ t

0

vi(t′)dt′ (70)

d

dt∆r2(t) =

d

dt

∫ t

0

∫ t

0

〈v(t′) · v(t′′)〉 dt′dt′′ = 2∫ t

0

〈v(t) · v(t′)〉 dt′ (71)

Using the invariance of such correlation functions to the origin of time

D =12d

limt→∞

d

dt∆r2(t) =

1d

∫ ∞

0

〈v(τ) · v(0)〉 dτ (72)

Jonathan Doye, University of Oxford 55

Page 56: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Constant pressure Monte Carlo

For the isobaric ensemble, the relevant thermodynamic functions are theenthalpy H = U + PV and the Gibbs free energy G.

〈A〉NPT =1

ZNPT

∫ ∞

0

V N exp(−βPV )dV

∫A(sN ;V

)exp

[−βV

(sN ;V

)]dsN

(73)Scaled coordinates (si = ri/V 1/3) have been used to separate out the volumedependence of the integral over rN.

A NPT MC scheme must sample configurations with the probability distribution:

PNPT

(sN ;V

)∝ exp

[−β(V(sN)

+ PV −N log(V )/β)]

(74)

and must involve two kinds of moves

• moves that randomly displace a particle

• moves that randomly change the volume V

for both of which the transition matrix α is symmetric.

Jonathan Doye, University of Oxford 56

Page 57: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

The choice of move type must be random to maintain detailed balance.

For particle moves the acceptance criterion reduces to that for the canonicalensemble.

For volume moves the acceptance criterion is

acc(o → n) = min

1, exp[−β

(V(sN ;Vn

)− V

(sN ;Vo

)+ P∆V − N

βlog[Vn

Vo

])](75)

where ∆V = Vn − Vo.

The P∆V term which favours a shrinkage of the volume is opposed by thelog(Vn/Vo) term.

For potentials, such as the soft-sphere potential:

V(rN)

= ε∑i<j

rij

)m

(76)

Jonathan Doye, University of Oxford 57

Page 58: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

the effect of the volume change on the energy is simple to compute

V(sN ;Vn

)=(

Vo

Vn

)m/d

V(sN ;Vo

)(77)

However, for more complex potentials, it may be necessary to recomputethe full potential. In this case, a volume move is roughly as expensive as Nsingle-particle moves.

The relative frequency with which the two move types are chosen shouldreflect their relative expense.

The average size of the volume move should be optimized to give reasonableacceptance ratios.

Jonathan Doye, University of Oxford 58

Page 59: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Grand Canonical Monte Carlo

In the grand canonical ensemble, the system can exchange particles with a‘particle bath’, thus fixing the chemical potential µ.

In this ensemble, the weight of each state is exp [−β (Ei − µNi)] After inte-grating over the momenta, the probability distribution that the MC needs tosample is obtained:

P(sN ;N

)∝ V N

Λ3NN !exp

[−β(V(sN)− µN

)](78)

Nb: as the integral over the momentum depends on N it has to be explicitlyconsidered.

In addition to particle displacement moves, there are two new move types

• Removal of a randomly chosen particle

• Addition of a particle at a random position

These moves are performed with equal probability so that α(N → N + 1) =α(N + 1 → N).

Jonathan Doye, University of Oxford 59

Page 60: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

The acceptance criteria are given by

acc(N → N − 1) = min

1,Λ3N

Vexp

[−β(µ + V

(sN−1

)− V

(sN))]

(79)

acc(N → N − 1) = min

1,V

Λ3(N + 1)exp

[−β(−µ + V

(sN+1

)− V

(sN))]

(80)Pros of grand-canonical ensemble:

• Direct access to µ

• Natural ensemble for processes, such as adsorption.

Cons

• Insertion probabilities can be very low for dense systems. Biasing techniques need tobe used.

Jonathan Doye, University of Oxford 60

Page 61: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Widom Insertion

An alternative way to access the chemical potential is to measure it in acanonical simulation using ‘Widom insertion’.

µ =(

∂A

∂N

)V,T

≈ −kT log[QN+1

QN

](81)

Rewriting this in terms of scaled coordinates

µ = −kT log[

V

Λ3(N + 1)

]− kT log

[∫exp

[−βV

(sN+1

)]dsN+1∫

exp [−βV (sN)] dsN

](82)

= µid + µex (83)

µid = −kT log[ρΛ−3

]is the chemical potential of an ideal gas.

µex = −kT log

[∫ (∫exp [−β∆V] exp

[−βV

(sN)]

dsN∫exp [−βV (sN)] dsN

)dsN+1

](84)

= −kT log[∫

〈exp [−β∆V]〉NV T dsN+1

](85)

Jonathan Doye, University of Oxford 61

Page 62: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

where ∆V = V(sN+1

)− V

(sN).

Therefore, the excess chemical potential can be related to the averageBoltzmann factor for inserting an extra particle into an N-particle system.The extra particle is a ‘ghost’ particle whose only purpose is to measure thechemical potential. It is never actually added to the system.

As with grand-canonical MC the insertion probability can be very low for densesystems leading to bad statistics.

Jonathan Doye, University of Oxford 62

Page 63: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Computing Phase Diagrams

One important use of simulation techniques is to calculate phase diagrams.

Tc

Tt

Tt Tcdensity

L + V

S + V

V L

S +

LS

+ F

tem

pera

ture

F

S

temperature

pres

ssur

e

S

V

LF

Direct simulation approaches hindered by:

• dynamics of phase transition may be slow

• the effect of the interface between the two phases

Jonathan Doye, University of Oxford 63

Page 64: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Points on coexistence lines are defined by where the free energies or chemicalpotentials of the two phases are equal.

However, computing free energies is hard because it is equivalent to knowingthe partition function, e.g. A = −kT log Q(N,V, T ).

Computing free energies differences is more tractable.

Jonathan Doye, University of Oxford 64

Page 65: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Thermodynamic Integration

Trick: Compute the difference in free energy between the system of interestand a reference system for which the free energy is known (e.g. ideal gas,harmonic crystal).

A path between these states can be defined.

V (λ) = Vref + λ (Vsys − Vref) (86)

The partition function for a given λ is

Q(N,V, T ;λ) =1

Λ3NN !

∫exp [−βV (λ)] drN (87)

Hence,

(∂A(λ)

∂λ

)=∫

(∂V (λ)/∂λ) exp [−βV (λ)] drN∫exp [−βV (λ)] drN

=⟨

∂V (λ)∂λ

⟩λ

(88)

Jonathan Doye, University of Oxford 65

Page 66: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Integrating gives

A(λ = 1) = A(λ = 0) +∫ λ=1

λ=0

⟨∂V (λ)∂λ)

⟩λ

dλ (89)

In practice, simulations at a number of different values of λ are performedand the above equation integrated numerically.

n.b. the path must be reversible, i.e. not cross a phase transition line.

To locate a single point on the phase boundary, need to compute the freeenergies of both phase at a number of different state points, and then locatewhere they cross. i.e. lots of work!

Jonathan Doye, University of Oxford 66

Page 67: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Gibbs Ensemble

Direct simulation of phase coexistence is hindered by the problems of nucle-ation and the role of the interface in a small system.

One way round this is the Gibbs Ensemble introduced by Panagiotopoulos,where separate boxes contain the two phases and particles and volume canbe exchanged between the two boxes.

Gives thermodynamic contact without physical contact.

1N , V12N , V2

Jonathan Doye, University of Oxford 67

Page 68: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Standard method for liquid-vapour coexistence.

Partition function for this ‘Gibbs ensemble’

QG(N,V, T ) =N∑

N1=0

∫ V

0

Q1(N1, V1, T ) Q2(N −N1, V − V1, T )dV1 (90)

=N∑

N1=0

1Λ3NN1!(N −N1)!

∫ V

0

V N11 (V − V1)N−N1dV1

×∫

exp[−βV

(sN1)]

dsN1

∫exp

[−βV

(sN−N1

)]dsN−N1(91)

Hence the distribution we wish to sample is:

P (N1, V1, sN1 , sN−N1) ∝ V N1

1 (V − V1)N−N1

N1!(N −N1)!exp

[−β(V(sN1)

+ V(sN−N1

))](92)

Jonathan Doye, University of Oxford 68

Page 69: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Types of move:

• random particle displacement

• transfer of a randomly selected particle

• coupled volume change of the boxes (total volume constant)

Standard Metropolis acceptance criterion for particle displacements.

Volume move:

acc(o → n) = min

1,

(V n1 )N1 (V − V n

1 )N−1

(V o1 )N1 (V − V o

1 )N−1exp

[−β(V(sNn

)− V

(sNo

))](93)

Particle move from 1 to 2:

acc(o → n) = min

1,N1(V − V1)

(N −N1 + 1)V1exp

[−β(V(sNn

)− V

(sNo

))](94)

nb: box selected at random, then a particle from that box randomly selected.

Problems:

Jonathan Doye, University of Oxford 69

Page 70: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

• Particle insertion slow when one system dense (worse for liquid as T is decreased)

• Identity of the boxes can change close to the critical point

• Magnitude of fluctuations and correlation lengths increase close to the critical point

Jonathan Doye, University of Oxford 70

Page 71: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Tracing coexistence curves

Idea:

• First find one point on the coexistence curve.

• Then trace the curve by integrating the Clausius Clapeyron equation:

dP

dT=

∆H

T∆V(95)

n.b. All these quantities can be calculated direct from simulation withoutfurther free energy calculations.

Method often called Gibbs-Duhem integration.

Analogous equations can be derived for tracing the phase boundaries asa function of other variables, e.g. the parameters of the intermolecularpotential.

Jonathan Doye, University of Oxford 71

Page 72: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Water phase diagrams

Experimental water phase diagram (middle) compared to that for TIP4P(left) and SPC/E (right) water models.

Jonathan Doye, University of Oxford 72

Page 73: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Clever tricks to speed up simulations

Free energy barriers that are significantly larger than kT make sampling anequilibrium distribution with standard simulation techniques tricky.

Possible solutions:

• Methods to enhance barrier crossings.

• Cleverly chosen non-local moves that take much bigger steps in configuration space.

Jonathan Doye, University of Oxford 73

Page 74: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Parallel tempering

Barriers that are prohibitively high at low temperature can be easily crossedat sufficiently high temperature.

Basic idea: maintain equilibrium at low temperature by coupling runs to highertemperature through the occasional swapping of configurations between par-allel simulations at different temperatures.

The partition function for this extended system of M coupled simulations is

Qextended (N,V, Tk) =M∏

k=1

Q(N,V, Tk) =M∏

k=1

1Λ3N

k N !

∫exp

[−βkV

(rN

k

)]drN

k

(96)For the swapping moves, chose α(o → n) to be symmetric. E.g. by randomlychoosing two of the M systems, and then switching their temperatures.

Jonathan Doye, University of Oxford 74

Page 75: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

The acceptance criterion must satisfy:

acc((

rNa , Ta

),(rN

b , Tb

)→(

rNb , Ta

),(rN

a , Tb

))acc((

rNb , Ta

), (rN

a , Tb)→(rN

a , Ta) ,(rN

b , Tb

)) =P ((rN

b , Ta

)P ((rN

a , Tb

)P ((rN

a , Ta) P ((rN

b , Tb

)=

exp[−βaV

(rN

b

)− βbV

(rN

a

)]exp

[−βaV (rN

a )− βbV(rN

b

)] = exp[(βa − βb)

(V(rN

a

)− V

(rN

b

))](97)

0

potential energy

prob

abili

tyT1T T2 T3 4

The probability of a switching move will be very low unless the potentialenergy distributions for the two temperatures being switched have sufficientoverlap. ∴ choice of temperatures important.

Jonathan Doye, University of Oxford 75

Page 76: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Umbrella sampling

Basic idea: Bias the system to sample configurations near the top of thebarrier by modifying the Hamiltonian.

Need to know the reaction coordinate/order parameter, Q, for which the freeenergy barrier is a function.

The free energy as a function of Q is defined as

A(Q′) = −kT log∫

δ(Q′ −Q

(rN))

exp[−βV

(rN)]

drN (98)

and is related to p(Q) by

A(Q) = A− kT log p(Q) (99)

p(Q) can then be related to the probability distribution in a biased non-

Jonathan Doye, University of Oxford 76

Page 77: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Boltzmann simulation with an effective potential V + W .

p(Q′) =exp[βW (Q′)]

Z

∫δ(Q′ −Q

(rN))

exp[−β(V(rN)

+ W (Q))]

drN

=ZW

Zexp[βW (Q′)]pW (Q′) (100)

The ideal choice for the biasing distribution is W (Q) = −A(Q) since thenpW (Q) is constant.

In practice, only need a reasonable estimate to sufficiently facilitate passagebetween the free energy minima. It can be obtained iteratively.

Z

ZW=

∫exp

[−βV

(rN)]

drN∫exp [−β (V (rN) + W (Q))] drN

=

∫exp[βW (Q)] exp

[−β(V(rN)

+ W (Q))]

drN∫exp [−β (V (rN) + W (Q))] drN

= 〈exp[βW (Q)]〉W (101)

Jonathan Doye, University of Oxford 77

Page 78: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

〈A〉 =1Z

∫A exp

[−βV

(rN)]

drN

=ZW

Z

1ZW

∫A exp[βW (Q)] exp

[−β(V(rN)

+ W (Q))]

drN

=〈A exp[βW (Q)]〉W〈exp[βW (Q)]〉W

(102)

-1

-0.5

0

0.5

1

0 20000 40000 60000 80000 1000000

5

10

15

20

25

30

35

-1 -0.5 0 0.5 1

mag

netiz

atio

n

MC cyclesstandard MC

umbrella sampling

magnetization

Free

ene

rgy

/ J

kT=2.2J

kT=1.8J

kT=2.0J

kT=1.8J

2D Ising model: 20× 20 lattice.

Jonathan Doye, University of Oxford 78

Page 79: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Widom insertion and multiple staging

In the Widom insertion method, the probability of insertion is very low fordense configurations.

E.g. For hard spheres: One way to improve is to use insertion of a small sphereas an intermediate.

Stage 2Stage 1

Stage 1: Measure fraction of time that small sphere finds no overlap.

Stage 2: Measure fraction of time that there is no overlap when small sphereis grown to full size.

Jonathan Doye, University of Oxford 79

Page 80: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Biased moves

If techniques such as Widom insertion can be problematic for dense spheres,problems much greater for complex molecules such as polymers.

Need more sophisticated means of generating configurations.

Use general Metropolis recipe, but do not choose α to be symmetric.

I.e. acc(o → n) = min1, χ and acc(n → o) = min1, 1/χ, where

χ =Pn α(n → o)Po α(o → n)

(103)

E.g. For polymers ‘‘configurational bias Monte Carlo’’ involves regrowing asection of polymer at each MC step. At each step in the regrowth processa number of directions for the new chain are explored, and the directionselected is biased towards those with lower energy.

Jonathan Doye, University of Oxford 80

Page 81: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Association Bias Monte Carlo

In a low density system where the interparticle attraction is strong, the systemwill typically form clusters.

Standard MC with random displacements inefficiently samples phase space,both because the acceptance probability for break-up of the clusters will below, and because most moves for the free particles will give lead to freediffusion and not association.

Jonathan Doye, University of Oxford 81

Page 82: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Adding cluster association moves and cluster breakup moves could accelerateconvergence.

Cluster association moves:

• Choose a random particle (probability = 1/N)

• Move this particle from ro to a random trial position rn in Va, where Va is the union ofall the bonding regions around each particle. (probability = 1/Va)

αa(o → n) =1

NVa(104)

Cluster breakup moves:

• Choose a random particle from those that are involved in clusters (probability = 1/Na)

• Move this particle from ro to a random trial position rn (probability = 1/V )

αb(n → o) =1

NaV(105)

Jonathan Doye, University of Oxford 82

Page 83: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

If the probability of performing association and break-up moves are equal,then the acceptance criteria for cluster association follows from

χ =NVa

NaVexp

[−β(V(rn

N)− V

(ro

N))]

(106)

The Boltzmann factor will tend to favour association, but the prefactor thereverse.

In practice determining Va is not straightforward, but methods are available.

Jonathan Doye, University of Oxford 83

Page 84: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Molecules

If work with a fully atomistic representation, then can simply treat the atomswithin a molecule in the same way as any other atom.

One practical difficulty with this approach is that the bonds within a moleculeare much stiffer than the interactions between non-bonded atoms.

In standard molecular dynamics, these stiff interactions will determine thetime step, and constrain it to be much smaller than is necessary for theintermolecular interactions. ∴ inefficient.

Other issues: Volume scaling moves in MC need to be reformulated. E.g. scalethe centre of mass coordinates.

Jonathan Doye, University of Oxford 84

Page 85: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Rigid molecules

Removes the times scale separation between intra- and intermolecular degreesof freedom.

Each molecule now has three degrees of freedom associated with the positionof the centre of mass, and two (linear) or three (non-linear) degrees offreedom associated with the orientation of the molecule.

Orientational degrees of freedom are most easily handled using quaternions(not Euler angles).

In MD angular velocities and accelerations need to be incorporated.

In MC, need rotational moves as well as translational moves. Need to begenerated uniformly.

Jonathan Doye, University of Oxford 85

Page 86: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Partially rigid molecules

For non-rigid molecules, such as polymers, some internal degrees of freedomare much stiffer than others. e.g. bond stretches compared to bond torsions.

Very stiff coordinates can be treated as rigid. E.g. constrain some bondlengths to be constant.

In MD, these constraints can be implemented by algorithms, such as SHAKE.

However, such constraints do change the system, as now no longer any kineticenergy in that degree of freedom.

A more recent alternative is to use a multiple time step integration algorithm,e.g. RESPA (reference system propagator algorithm).

They take multiple steps in the fast degrees of freedom (short-range forces)for every step in the slow degrees of freedom (long-range forces).

Jonathan Doye, University of Oxford 86

Page 87: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Constant temperature Molecular Dynamics

Two ways:

1) Introduce stochastic collisions with a ‘‘heat bath’’ to thermalize the system.

2) Introduce a deterministic ‘non-Newtonian’ dynamics that generates thecorrect ensemble.

Jonathan Doye, University of Oxford 87

Page 88: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Andersen Thermostat

Coupling to the heat bath is represented by stochastic impulsive forces thatoccasionally act on randomly selected particles.

These stochastic collisions move the system between different constant energyshells.

Strength of coupling controlled by ν, the frequency of stochastic collisions.

Algorithm:

• integrate the equations of motion: rN(t) → rN(t + ∆t)

• Check whether any particles are selected to undergo a collision with the heat bath.The probability that a particle is selected is ν∆t.

• If a particles has been selected to undergo a collision, its new velocity is drawn froma Maxwell-Boltzmann distribution.

Pros: Simple,

Cons: The dynamics is not so realistic.

Jonathan Doye, University of Oxford 88

Page 89: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

The Lagrangian

The Lagrangian formulation of classical mechanics is based on a variationalprinciple.

The trajectory followed by a system between two points is the one thatminimizes the classical action S, where

S =∫ tf

ti

L(q, q)dt (107)

and the Lagrangian isL(q, q) = K(q)− V(q) (108)

It can be shown that the action is minimized when

d

dt

(∂L(q, q)

∂q

)=

∂L(q, q)∂q

(109)

This is the Lagrangian equation of motion.

Jonathan Doye, University of Oxford 89

Page 90: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

We can write this in terms of a generalized momentum

p =∂L(q, q)

∂q(110)

Hencep =

∂L(q, q)∂q

(111)

As a check, for standard Cartesian coordinates

L(x, x) =12mx2 − V(x) (112)

p =∂L(x, x)

∂x= mx (113)

and the equation of motion is

mx = −∂V(x)∂x

(114)

Jonathan Doye, University of Oxford 90

Page 91: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Hamiltonian mechanics

The Hamiltonian is related to the Lagrangian by

H(q, p) = pq − L(q, q, t) (115)

To derive the equations of motion in terms of H

dH(q, p) =∂H∂p

dp +∂H∂q

dq +∂H∂t

dt (116)

dH(q, p) = d(pq)− dL(q, q, t)

= pdq + qdp−[∂L∂q

dq +∂L∂q

dq +∂L∂t

dt

]= pdq + qdp− pdq − pdq − ∂L

∂tdt

= qdp− pdq − ∂L∂t

dt (117)

Jonathan Doye, University of Oxford 91

Page 92: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Comparing the above equations gives:

∂H∂p

= q (118)

∂H∂q

= −p (119)

When the Lagrangian does not explicitly depend on time, the Hamiltonian isconserved

dH(q, p)dt

=∂H∂p

p +∂H∂q

q = −∂H∂p

∂H∂q

+∂H∂q

∂H∂p

= 0 (120)

and expresses the conservation of energy.

In Cartesians

H(x, px) = pxx− L(x, x) =p2

x

2m+ V(x) (121)

Jonathan Doye, University of Oxford 92

Page 93: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

and the equations of motion are

x =∂H∂px

=px

m(122)

px = −∂H∂x

= −∂V(x)∂x

(123)

Note, that this formulation gives the equations of motion in terms of two first-order differential equations, rather than a single second-order differentialequation.

Jonathan Doye, University of Oxford 93

Page 94: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Nose-Hoover thermostat

We use an extended Lagrangian, where the extra degree of freedom acts asa reservoir and allows energy to flow back and forth between the system andthe reservoir.

LNose =N∑

i=1

mi

2s2r2

i − V(rN)

+Q

2s2 − L

βlog(s) (124)

L is a parameter and Q is an effective mass associated with s that controlsthe rate of temperature fluctuations. The momenta are

pi =∂L∂ri

= mis2ri (125)

ps =∂L∂s

= Qs (126)

The Hamiltonian of this extended system is

HNose =N∑

i=1

p2i

2mis2+ V

(rN)

+p2

s

2Q+

L

βlog(s) (127)

Jonathan Doye, University of Oxford 94

Page 95: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

The partition function of this system of 6N + 2 degrees of freedom in themicrocanonical ensemble is

QNose =1

N !

∫δ (E −HNose) dps ds drNdpN (128)

It can be shown that this is proportional to the canonical partition functionwhen L = 3N + 1.

The equations of motion are

dri

dt=

∂HNose

∂pi=

pi

mis2(129)

dpi

dt= −∂HNose

∂ri=

∂V(rN)

∂ri(130)

ds

dt=

∂HNose

∂ps=

ps

Q(131)

dps

dt= −∂HNose

∂s=

1s

(N∑

i=1

p2i

2mis2− L

β

)(132)

Jonathan Doye, University of Oxford 95

Page 96: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

These equations can be reformulated in terms of the real momenta, p′i = pi/sand time t′ = t/s, and a friction coefficient ξ = ps/Q.

Jonathan Doye, University of Oxford 96

Page 97: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Constant pressure molecular dynamics

An extended Lagrangian method can also be introduced to generate trajecto-ries in the isobaric (NPT ) ensemble in an analogous way.

It involves the introduction of a kinetic energy term QV V 2/2 and a term inthe potential PV . The momentum associated with the volume coordinate ispV = QV V .

QV again plays the role of an effective mass regulating the fluctuations involume.

(In practice, as with constant pressure MC, better to work in log V ).

Jonathan Doye, University of Oxford 97

Page 98: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Action and the Verlet algorithm

Classical trajectories correspond to ones where the action S is a minimum.

For a trajectory of discrete steps (e.g. as generated by MD) one could insteadtry to minimize a discretized version of the action.

Sdisc =if−1∑

ii

∆t

[12m

(xi+1 − xi

∆t

)2

− V(xi)

](133)

Minimizing this gives:

m

(2xi − xi+1 − xi−1

∆t

)−∆t

∂V(xi)∂xi

= 0 (134)

which on rearranging gives the Verlet algorithm

xi+1 = 2xi − xi−1 −∆t2

m

(∂V(xi)

∂xi

)(135)

Jonathan Doye, University of Oxford 98

Page 99: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

‘Car-Parrinello’ Approaches

For certain systems, evaluation of the energy requires an optimization ofinternal degrees of freedom (e.g. electrons, induced dipoles of polarizableatoms) of the atoms.

As the time scales associated with these internal degrees of freedom aremuch faster than those associated with the nuclear motion, it is assumed thatthey respond adiabatically to changes in the positions of the atoms. i.e. theelectrons are always in their ground state.

Thus, in a standard molecular dynamics one would need to perform an iterativeoptimization at each time step.

Problems:

• Computationally expensive

• Incomplete convergence leads to the exertion of a drag on the nuclei.

Car-Parrinello molecular dynamics treats the electrons using density functionaltheory in the local density approximation.

Jonathan Doye, University of Oxford 99

Page 100: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

It circumvents these problems using an extended Lagrangian that includes theelectronic density. I.e. there are equations of motion for the electron densitythat are integrated in an analogous way to those for the nuclear coordinates.

Although the electron density is not always optimal - instead it fluctuatesaround this optimal value - it does not exert any systematic drag on thenuclei.

Optimization of the electron density occurs ‘on-the-fly’, rather than byiteration at each step.

Note that although CPMD computes the potential energy at each point usingelectronic density functional theory (rather than using a potential function)the nuclear motion is still treated classically.

Jonathan Doye, University of Oxford 100

Page 101: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Application to polarizable atoms

For a system of polarizable atoms (say with permanent dipoles), the totalpotential energy can be written as V = V0 +Vind the induction energy is givenby

Vind = −∑

i

Ei · µi +12α

∑i

µ2i (136)

where µi is the induced dipole on atom i, Ei is the electric field at atom i dueto the other atoms, and α is the polarizability.

Minimization of Vind with respect to the µi implies that the induced dipolesmust satisfy

µi = αEi (137)

Calculation of these induced dipoles, and hence the induction energy, requiresthe solution of these 3N linear equations, typically by iteration to self-consistency.

To avoid this iteration in an MD simulation, one can use the extended

Jonathan Doye, University of Oxford 101

Page 102: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Lagrangian

L(rN , µN

)=

12

∑i

mr2i +

12

∑i

Mµ2i − V

(rN , µN

)(138)

where M is the inertial ‘mass’ associated with the dipoles.

The equations of motion for the dipoles is then

Mµi =∂L∂µi

= Ei −µi

α(139)

The RHS of this equation represents the forces on the dipoles and is zero whenthey take their optimal value (Eq. 137).

Writing µi = µopti + ∆µi, gives Mµi = −∆µi/α.

Therefore, the induced dipoles will oscillate around their optimal values.

To ensure that the dipoles respond rapidly to changes in the atomic positions:M m

Jonathan Doye, University of Oxford 102

Page 103: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

To ensure that the dipoles only exhibit small oscillations about their optimalvalue: Tµ Tr (temperatures defined through kinetic energies)

Latter achieved by two Nosé-Hoover thermostats.

Jonathan Doye, University of Oxford 103

Page 104: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Other quantum simulation methods

Other simulation methods that attempt to solve the Schrodinger equation:

• Variational Monte CarloA trial wave-function is optimized according to the variational principle using MC.

• Diffusion Monte CarloThe Schrodinger equation is rewritten as a diffusion equation in imaginary time, whichis then solved using a set of random walkers.

• Path-integral Monte CarloBased on the path integral formulation of quantum mechanics. Exploits an isomorphismbetween quantum mechanics and the statistical mechanics of ring polymers.

Jonathan Doye, University of Oxford 104

Page 105: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

Coarse-grained simulations

So far, mainly considered atomic and molecular systems.

But can apply simulation methods to systems where (many) degrees of free-dom have been coarse-grained, and where the interactions are described byeffective potentials.

E.g. Under certain conditions colloidal particles can behave like hard spheres.

Can apply Monte Carlo techniques straightforwardly to the coarse-grainedsystems.

However, the systems may no longer follow Newton’s equations of motion atthis coarse-grained level.

E.g. colloidal particles undergo Brownian motion due to collisions with thesolvent (which in the coarse-grained description is usually ‘integrated out’).

Langevin equation more appropriate:

mr = F (r)− βv + η(t) (140)

Jonathan Doye, University of Oxford 105

Page 106: MSc in Theoretical Chemistry Applications of Statistical ...doye.chem.ox.ac.uk/jon/teach/MSc.pdf · Newman and Barkema: Monte Carlo Methods in Statistical Physics (Ox-ford,1999) Rapaport:

• −βv is a viscous drag force due to motion through the solvent.

• η(t) is a random force that represents the effects of collisions with the solvent.

Brownian dynamics is a simulation method that generates trajectories thatobey this stochastic differential equation.

Jonathan Doye, University of Oxford 106