general considerations monte carlo methods (i). averages x = (x 1, x 2, …, x n ) – vector of...

38
General considerations Monte Carlo methods (I)

Upload: augustus-waters

Post on 19-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

General considerations Monte Carlo methods (I)

Page 2: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

11

1

N

N

xx

xx

dVf

dVfAA

X

X

X

XX

Averages

X = (x1, x2, …, xN) – vector of variablesP – probability density function

Page 3: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Random variables and their distributions

A random variable: a number assigned to an event

Distribuand:

Probability density:

Any function of a random variable is a random variable.

XYPXF

dX

XdPXf

Page 4: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Moments of a distribution

n

iii

n

iii

xxPxHH(x)E

xxPxE({x})

1

1

dxxfxHxHE

dxxxfx{x}E ˆ

Continuous variables:

If H(x)=(x-xc)n then E{H(X)} is called the nth moment of x with respect to c; if c= then E is the nth central moment, n({x}).

Page 5: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Some useful central moments

Variance

dxxfx̂xxx 22

2

Skewness

dxxfx̂xx

1

x

xx 3

32/32

3

Kurtosis

3dxxfx̂x

x

13

x

xx 4

422

4

Page 6: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

For a set of points:

3

)1n(

x̂x

)1n(

x̂x

xxn1n

1x̂x

1n

1

xn

1x̂

4

n

1i

4i

3

n

1i

3i

2n

1ii

n

1i

2i

n

1i

2i

2

n

1ii

Page 7: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Some examples of central moments

Page 8: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Boltzmann distribution

E BB

NN

B

NN

B

NN

B

i

iB

ii

dETk

EEQdE

Tk

EE

QdEEP

ddTk

EQdd

Tk

E

QddP

Tk

EQ

Tk

E

QP

expexp1

,exp

,exp

1,

expexp1

pqpq

pqpq

pqpqq p

kB (Boltzmann constant) = 1.3810-23 J/K

NAkB = R (universal gas constant) = 8.3143 J/(molK)

q – positions; p – momenta; (E) – density of states with energy E

Page 9: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Thermodynamic quantities

VN

TTBV

B

BVN

Bi

iiB

TNB

i B

iiT

VNB

i B

iiT

T

UEETkC

QTkF

QkT

QTkPPTkS

V

QTk

TkVQpp

T

QTk

TkQEU

,

222

,

,

,

2

ln

lnln

ln

lnexp

1

lnexp

1

Page 10: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Ergodicity

AA

AN

A

dAt

A

N

ii

N

t

t

theoremergodic

ρ toacc.sampled

1

0

1lim

1lim

Page 11: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Trajectories in the phase space. For ergodic sampling, sub-trajectories should be part of a trajectory that passes through all points.

Page 12: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Monte Carlo methods: use of random-number generators to follows the evolution of a system according to a given probability-distribution function.

Beginnings: Antiquity (?); estimation of the results of dice game.

First documented use: G. Comte de Buffon (1777): estimation of the number p by throwing a needle on a sheet of paper with parallel lines and counting the number of hits.

First large-scale (wartime) application: J. von Neumann, S. Ulam, N. Metropolis, R.P. Feynman i in. (1940’s; the Manhattan project) calculations of neutron creation and scattering. For security, the calculations were disguised as ,,Monte Carlo” calculations.

Page 13: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Kinds of Monte Carlo methods

The von Neumann (rejection) sampling

The Metropolis (in general: Markov chain) sampling. Also known as „importance sampling”

Page 14: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Simple Monte Carlo averaging

N

iii xfxA

NA

1

1

x

f(x)

Sample a point on x from a uniform distribution

Compute f(xi)

Page 15: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Rejection or hit-and-miss sampling

x

f(x)

Sample a point on x from a uniform distrubution

Sample a point on f

accept

reject

acceptedi

iaccepted

xAN

A1

Page 16: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Algorithm

Generate a random point X in the

configurational space

Generate a random point y in [0,1]

P(X)>yAccept X

A:=A+A(X)Reject X

Page 17: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Application of the rejection sampling to compute the number

1

41

21 2

lim

totN

N

nS

S

Page 18: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Applications

• For one-dimensional integrals classical quadratures (Newton-Cotes, Gauss) are better than that.

• For multi-dimensional integrals sampling the integrations space is somewhat better; however most points have zero contributions.

• We cannot compute ensemble averages of molecular systems that way. The positions of atoms would have to generated at random, this usually leading to HUGE energies.

Page 19: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Illustration of the difference between the direct- and importance-sampling methods to measure the depth of the river of Nile

Von Neumann: all points are visited

Metropolis: The walker stays in the river

Page 20: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function
Page 21: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Perturb Xo: X1 = Xo + X

Compute the new energy (E1)

Configuration Xo, energy Eo

E1<Eo ?

Draw Y from U(0,1)

Compute W=exp[-(E1-Eo)/kT]

W>Y?

Xo=X1, Eo=E1

N

Y

Y

N

A:=A+A(Xo)

Page 22: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

E0

E1

Accept with probability exp[-(E2-E1)/kBT]

E1

Accept

Page 23: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Space representation in MC simulations

• Lattice (discrete). The particles are on lattice nodes

• Continuous. The particles move in the 3D space.

Page 24: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

On- and off-lattice representations

Page 25: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Application of Metropolis Monte Carlo

• Determination of mechanical and thermodynamic properties(density, average energy, heat capacity, conductivity, virial coefficients).

• Simulations of phase transitions. • Simulations of polymer properties.• Simulations of biopolymers.• Simulations of ligand-receptor binding.• Simulations of chemical reactions.

Page 26: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Computing averages with Metropolis Monte Carlo

N

iiAN

A1

1

It should be noted that all MC steps are considered, including those which resulted in the rejection of a new configuration. Therefore, if a configuration has a very low energy, it will be counted multiple times.

Page 27: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Detailed balance (Einstein’s theorem)

)()()()( onnnoo NN

old

new

Page 28: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

In real life the detailed balance condition is rarely satisfied…

These gates at a Seoul subway station do not satisfy the detailed-balance condition: you can go through but you cannot go back…

A famous Russian proverb states: „A ruble to get in, ten rubles to get out”

Page 29: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

I thought there was a way out….

I was sssoooo busy working for my Queen and Community….

Nature teaches us the hard way that detailed balance is not something to meet in the macro-world..

Page 30: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

It is only too easy to violate the

detailed-balance conditions

Monte Carlo with minimization: energy is minimized after each move. Transition probability is proportional to basin size.

Little chance to get from C to B

A B C

pertubation

minim

ization

pertubation

Minim

ization

brings back to C

Page 31: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Translational perturbations (straightforward)

5.0():

5.0():

5.0():

1()int:

ranfozz

ranfoyy

ranfoxx

ranfNo

new

new

new

x[o]

Page 32: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Orientational perturbations

Euler angles. We rotate the system first about the z axis by so that the new x axis is axis w, then about the w axis by so that the new z axis is z’ and finally about the z’ axis by so that the new x axis is x’ and the new y axis is y’.

Uniform sampling the Euler angles would result in a serious bias.

Page 33: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Rotational perturbations: rigid linear molecules

Orientational perturbation

uu’

Genarate a random unit vector v

Compute t:=u+v

Compute u’:= t/||t||

Page 34: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Rigid non-linear molecules

Sample a unit vector on a 4D sphere (quaternion) (E. Veseley, J. Comp. Phys., 47:291-296, 1982), then compute the Euler angles from the following formulas:

2sin

2cos

2sin

2sin

2cos

2sin

2cos

2cos

1;,,,

3

2

1

0

23

22

21

203210

q

q

q

q

qqqqqqqqQ

Page 35: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Rotation matrix

rr

qqqqqqqqqqqq

qqqqqqqqqqqq

qqqqqqqqqqqq

R

R

'

23

22

21

2010322031

103223

22

21

203021

2031302123

22

21

20

22

22

22

Page 36: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Choosing the initial configuration and step size

• Generally: avoid clashes.

• For rigid liquids molecules start from a configuration on a lattice.

• For flexible molecules: build the chain to avoid overlap with the atoms already present.

Page 37: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

MC step size

• Too small: high acceptance rate but poor ergodicity (can’t get out of a local minimum).

• Too large: low acceptance rate.

• Avoid accepting „good” advices that the acceptance rate should be 10/20/50%, etc. Do pre-production simulations to select optimal step size

• This can help:– Configurational-bias Monte Carlo,– Parallel tempering.

Page 38: General considerations Monte Carlo methods (I). Averages X = (x 1, x 2, …, x N ) – vector of variables P – probability density function

Reference algorithms for MC/MD simulations (Fortran 77)

M.P. Allen, D.J. Tildesley, „Computer Simulations of Liquids” , Oxford Science Publications, Clardenon Press, Oxford, 1987

http://www.ccp5.ac.uk/software/allen_tildersley.shtml

F11: Monte Carlo simulations of Lennard-Jones fluid.