25
4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari 3.320 Lecture 18 (4/12/05) Monte Carlo Simulation II and free energies Figure by MIT OCW.

Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

Embed Size (px)

Citation preview

Page 1: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

3.320 Lecture 18 (4/12/05)

Monte Carlo Simulation II and

free energies

Figure by MIT OCW.

Page 2: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

References

D. Chandler, “Introduction to Modern Statistical Mechanics”

D.A. McQuarrie, “Statistical Thermodynamics” OR “Statistical

Mechanics”

General Statistical Mechanics

D. Frenkel and B. Smit, "Understanding Molecular Simulation", Academic

Press.

Fairly recent book. Very good background and theory on MD,

MC and Stat Mech. Applications are mainly on molecular

systems.

M.E.J. Newman and G.T. Barkema, “Monte Carlo Methods in Statistical

Physics”

K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

Physics”

Monte Carlo

Page 3: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Monte Carlo is Efficient Sampling of Ensemble

Ensemble is collection of possible microscopic states

Pexp( H )

Q

U Pe

E

V Pe

V

Simple Sampling

Pick states randomly and weigh their property proportional to P

A P A1

M

Pexp( H )

exp( H )1

M

Importance Sampling

Pick states with a frequency proportional to their probability P

Probability

weighted sampleA A1

M

Page 4: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Metropolis Algorithm

Put it all together: The Metropolis Monte Carlo Algorithm

1. Start with some configuration

2. Choose perturbation of the system

3. Compute energy for that perturbation

4. If accept perturbation

If accept perturbation, accept perturbation with

probability

5. Choose next perturbation

Property will be average over these states

expE

k

Metropolis, Rosenbluth, Rosenbluth, Teller and Teller, The Journal of Chemical

Physics, 21, 1087 (1953).

Page 5: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Ising Model

But first, a model system: The Ising Model

At every lattice site i, a spin variable i = +1 or -1

H1

2J i

i, jj

Also used for other “two-state” systems: e.g. alloy ordering

Which perturbation ? Pick spin and flip over

1. Start with some spin configuration

2. Randomly pick a site and consider flipping the spin

over on that site

3. Compute energy for that perturbation

4. If accept perturbation

If accept perturbation, accept

perturbation with probability

5. Go back to 2exp

E

k

Implemented by random numbers

Page 6: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Random Numbers

Most random number generators generate integers between 0 and 2N - 1

To generate real numbers in interval [0,1], division by 2N is performed

0 11

2N

2

2N

3

2N

The probability that “0” is given for the random number is 1/2N

When rand = 0, any excitation occurs, since exp (- E) > 0, for

any E

Page 7: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

What exactly is the quantity in the exponential ?

E.g. Ising Model

At every lattice site i, a spin variable i = +1 or -1

H1

2J i

i, jj i i

i

If average spin of system is not conserved, then probability need to be

weighted by exp1

2J i

i, j

j i i

i

Page 8: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Legendre Transform of Energy and Entropy

Energy formulation

dU TdS ( pdV) dN ...

F U TS

G U TS pV

Legendre

transforms

Different variables F(V,N,T),

G(P,N,T)

dS1

TdU (

p

TdV)

TdN ...

A(1

T,V, N) S

1

TU

K(1

T,

p

T,N) S

1

TU

p

TV

L(1

T,V,

T) S

1

TU

TN

Entropy formulation

These are the form of the

Hamiltonians !

Page 9: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Lab problem: H adsorption phase diagram on Pd (100)

Simple transformation to a lattice model -> spin can be used to indicate

whether a lattice site is occupied or not. E.g. Adsorption on surface sites

pi = 1 when site is occupied by H, =0 when not

H1

2W1 pi pj

i, j

Ea pii

H1

2V1 i

i, jj i i

i

Can be transformed to:V1

W1

4Ea

2

zW1

4

with

Can use canonical or grand-canonical ensemble to get

H/Pd(100) phase diagram

Page 10: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Why work grand canonical instead of canonical ?

Page 11: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Accuracy of Monte Carlo to obtain Ensemble Properties

Not worry about accuracy of model or Hamiltonian. Only ask question:

Given H, how good is Monte Carlo sampling to get properties of ensemble ?

As good as you want !

Sources of error: Finite sample (time in MC); Finite Size (Periodic

Boundaries)

Sampling Error

error on the average for random

sampling ?

A

A

dist

(True average)

av

2A A

2dist2

m

A2 A 2

m

How accurate is the average ?

Sample size

“A” is quantity being sampled

Page 12: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

But sample is correlated

States in Markov chain are not independent. State is obtained from

previous state through some perturbation mechanism !

Convergence is not as good as random sampling formula would

indicate.

Correlation Time

CA ( ) limt

1

t

A(t) A A(t ) A

A2

A2 dt

0

t

Correlation function

e.g. velocity in harmonic oscillator

Correlation time A CA( )d0

av

2 A2 A 2

m(1 2 A )Quality of average gets

diluted by correlation time

Page 13: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Correlation time in Ising models

long tail is spurious

Page 14: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Size effectsOnly important near second order transitions and for phases to “fit”

within the periodic boundary conditions

5 L

10 L

20 L

30 L

50 L

100

20

40

60

80

0.9 1.0 1.1 1.2 1.3 T/Tc

XL

Figure by MIT OCW.

Page 15: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

It is your move !

“Dynamics” in Monte Carlo is not real, hence you can pick any “perturbations” that

satisfy the criterion of detailed balance and a priori probabilities.

e.g. mixing of A and B atoms on a lattice (cfr. regular and

ideal solution in thermodynamics)

Could pick nearest neighbor A-B interchanges (“like” diffusion)

-> Glauber dynamics

Could “exchange” A for B

-> Kawasaki dynamics

For Kawasaki dynamics Hamiltonian needs to reflect fact that number of A and B

atoms can change (but A+B number remains the same) -> add chemical potential

term in the Hamiltonian

H1

2(V

AB(pi

Apj

B

i, j

pi

Bp j

A) V

AApi

Apj

AV

BBpi

Bpj

B) ( A B) pi

A

i

Page 16: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

With more difficult system, algorithms that can easily access

the low energy states are most efficient

Example: Heisenberg Model: continuously rotating magnetic moment

Coordinates

Should I pick and randomly ?

x

y

z

r

θ

φFigure by MIT OCW.

Page 17: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Proper distribution of and

Random distribution of and does not give random distribution of vector

orientation in space. For small all give spin oriented along the z-axis

Area is proportional to 2 sin(

Need to pick proportional to sin(

d

d

Page 18: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Sampling variables that are not homogeneously distributed in

phase space

-1 1

P(x)

1/2

x

P

0 90 180

Distribute as 1/2 sin( )

(x) ?Homogeneous distribution of

random numbers

= cos-1 (-x)

Page 19: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Low Temperature Spin Waves

More efficient to perturb spins slightly by picking their new orientation

from a narrow cone around the old orientation

Figure by MIT OCW.

Page 20: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Page 21: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Long chain molecules

Fixed dihedral angle, but still

rotation possible

Sample configuration space by sampling possible

values of free rotations. Often only small

perturbations possible

ω

Figure by MIT OCW.

Page 22: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Polymers on a lattice

Possible algorithms ?

Page 23: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Non-Boltzmann sampling and Umbrella sampling

Simple Sampling Importance Sampling

Sample with Boltzmann weightSample randomly

A A1

M

Aexp( H )

exp( H )1

M A1

M

Non Boltzmann SamplingH = H - Ho

Sample with some Hamiltonian Ho

A

exp( (H Ho )) A1

M

exp( (H H o ))1

M

[end of this day’s lecture…to be continued next lecture.]

Page 24: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

Monte Carlo

•Conceptually simple

•Easy to implement

•Can Equilibrate any degree of freedom/No Dynamics needed

•Accurate Statistical Mechanics

•No Kinetic Information

•Requires many Energy Evaluations

•Stochastic nature gives noise in data

•Not easy to get entropy/free energy

Advantages

Disadvantages

Page 25: Monte Carlo Simulation II and free energies · Monte Carlo Simulation II and free energies Figure by MIT OCW. ... K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

4/12/05 3.320 Atomistic Modeling of Materials G. Ceder and N Marzari

References

D. Frenkel and B. Smit, "Understanding Molecular Simulation", Academic

Press.

Fairly recent book. Very good background and theory on MD,

MC and Stat Mech. Applications are mainly on molecular

systems.

M.E.J. Newman and G.T. Barkema, “Monte Carlo Methods in Statistical

Physics”

K. Binder and D.W. Heerman, “Monte Carlo Simulation in Statistical

Physics”