basic monte carlo (chapter 3) algorithm detailed balance other points

36
Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

Upload: daisy-nash

Post on 01-Jan-2016

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

Basic Monte Carlo(chapter 3)

Algorithm

Detailed Balance

Other points

Page 2: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

2

Molecular Simulations

Molecular dynamics: solve equations of motion

Monte Carlo: importance sampling

r1

MD

MC

r2rn

r1

r2

rn

Page 3: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

3

Does the basis assumption lead to something that is consistent with classical

thermodynamics?

1ESystems 1 and 2 are weakly coupled such that they can exchange energy.

What will be E1?

( ) ( ) ( )1 1 1 1 2 1,E E E E E EΩ − = Ω ×Ω −

BA: each configuration is equally probable; but the number of states that give an energy E1 is not know.

2 1E E E= −

Page 4: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

4

( ) ( ) ( )1 1 1 1 2 1,E E E E E EΩ − = Ω ×Ω −

( ) ( ) ( )1 1 1 1 2 1ln , ln lnE E E E E EΩ − = Ω + Ω −

( )1 1

1 1

1 ,

ln ,0

N V

E E E

E

⎛ ⎞∂ Ω −=⎜ ⎟

∂⎝ ⎠

∂lnΩ1 E1( )∂E1

⎝⎜

⎠⎟

N1 ,V1

+∂lnΩ2 E −E1( )

∂E1

⎝⎜

⎠⎟

N2 ,V2

=0

( ) ( )1 1 2 2

1 1 2 1

1 2, ,

ln ln

N V N V

E E E

E E

⎛ ⎞ ⎛ ⎞∂ Ω ∂ Ω −=⎜ ⎟ ⎜ ⎟

∂ ∂⎝ ⎠ ⎝ ⎠

Energy is conserved!dE1=-dE2

This can be seen as an equilibrium

condition

( ),

ln

N V

E

⎛ ⎞∂ Ω≡ ⎜ ⎟

∂⎝ ⎠

1 2β β=

Page 5: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

5

Canonical ensemble

Consider a small system that can exchange heat with a big reservoir

iE iE E− ( ) ( ) lnln lni iE E E E

E

∂ ΩΩ − = Ω − +

∂L

( )( )

ln i i

B

E E E

E k T

Ω −= −

Ω

1/kBT

Hence, the probability to find Ei:

( ) ( )( )

( )( )

exp

expi i B

i

j j Bj j

E E E k TP E

E E E k T

Ω − −= =

Ω − −∑ ∑( ) ( )expi i BP E E k T∝ −

Boltzmann distribution

Page 6: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

7

Statistical Thermodynamics

( )NVTQF ln−=β

( ) ( )[ ]NNNN

NVTNVT

UANQ

A rexprdr!

113

β−Λ

= ∫€

QNVT =1

Λ3N N!drN∫ exp −βU rN

( )[ ]

Partition function

Ensemble average

Free energy

( ) ( ) ( ) ( )3

1 1N r dr' r' r exp r' exp r

!N N N N N N

NNVT

U UQ N

δ β β⎡ ⎤ ⎡ ⎤= − − ∝ −⎣ ⎦ ⎣ ⎦Λ ∫

Probability to find a particular configuration

Page 7: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

8

Monte Carlo simulation

Page 8: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

9

Ensemble averageA

NVT=

1QNVT

1Λ3NN!

drN∫ A rN( )exp −βU rN( )⎡⎣ ⎤⎦

= drN A rN( )P rN( )∫ =drN A rN( )P rN( )∫

drN P rN( )∫

=drN A rN( )C∫ exp −βU rN( )⎡⎣ ⎤⎦

drNC exp −βU rN( )⎡⎣ ⎤⎦∫=

drN A rN( )∫ exp −βU rN

( )⎡⎣ ⎤⎦drN exp −βU rN

( )⎡⎣ ⎤⎦∫Generate configuration using MC:

PMC rN( ) =CMC exp −βU rN( )⎡⎣ ⎤⎦

r1

N , r2N , r3

N , r4N L ,rM

N{ } A =1M

Ai=1

M

∑ riN( )

with

=drN A rN( )PMC rN( )∫

drN PMC rN( )∫

=drN A rN

( )C MC exp −βU rN( )⎡⎣ ⎤⎦∫

drNC MC exp −βU rN( )⎡⎣ ⎤⎦∫

=drN A rN

( )exp −βU rN( )⎡⎣ ⎤⎦∫

drN exp −βU rN( )⎡⎣ ⎤⎦∫

( ) ( )[ ]!

rexpr

3 NQ

UP

NNVT

NN

Λ

−=

β

Page 9: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

10

Monte Carlo simulation

Page 10: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

11

Page 11: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

12

Page 12: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

13

Questions

• How can we prove that this scheme generates the desired distribution of configurations?

• Why make a random selection of the particle to be displaced?

• Why do we need to take the old configuration again?

• How large should we take: delx?

Page 13: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

14

Detailed balance

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

=N(n) ×α(n→ o)N(o) ×α(o→ n)

=N(n)N(o)

K(o → n) =K (n→ o)

K(o → n) =N(o) ×α(o→ n) ×acc(o→ n)

o n

K(n→ o) =N(n) ×α(n→ o) ×acc(n→ o)

Page 14: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

15

NVT-ensemble

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

=N(n)N(o)

N (n) ∝exp −βU n( )⎡⎣ ⎤⎦

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

=exp −β U n( )−U o( )⎡⎣ ⎤⎦⎡⎣

⎤⎦

Page 15: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

16

Page 16: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

17

Questions

• How can we prove that this scheme generates the desired distribution of configurations?

• Why make a random selection of the particle to be displaced?

• Why do we need to take the old configuration again?

• How large should we take: delx?

Page 17: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

18

Page 18: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

19

Questions

• How can we prove that this scheme generates the desired distribution of configurations?

• Why make a random selection of the particle to be displaced?

• Why do we need to take the old configuration again?

• How large should we take: delx?

Page 19: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

20

Mathematical

π(o→ n) =α(o→ n) ×acc(o→ n)Transition probability:

π(o→ n)

n∑ =1

π(o→ o) =1− π(o→ n)

n≠o∑

Probability to accept the old configuration: ≠0

Page 20: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

21

Keeping old configuration?

Page 21: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

22

Questions

• How can we prove that this scheme generates the desired distribution of configurations?

• Why make a random selection of the particle to be displaced?

• Why do we need to take the old configuration again?

• How large should we take: delx?

Page 22: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

23

Not too small, not too big!

Page 23: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

24

Page 24: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

25

Periodic boundary conditions

Page 25: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

26

Lennard Jones potentials

uLJ r( ) =4εσr

⎛⎝⎜

⎞⎠⎟

12

−σr

⎛⎝⎜

⎞⎠⎟

6⎡

⎣⎢⎢

⎦⎥⎥

u r( ) =uLJ r( ) r ≤rc

0 r > rc

⎧⎨⎩

u r( ) =uLJ r( )−uLJ rc( ) r ≤rc

0 r > rc

⎧⎨⎩

•The truncated and shifted Lennard-Jones potential

•The truncated Lennard-Jones potential

•The Lennard-Jones potential

Page 26: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

27

Phase diagrams of Lennard Jones fluids

Page 27: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

28

Non-Boltzmann sampling A

NVT1=

1QNVT1

1Λ3NN!

drN∫ A rN( )exp −β1U rN( )⎡⎣ ⎤⎦

=drN A rN( )∫ exp −β1U rN( )⎡⎣ ⎤⎦

drN exp −β1U rN( )⎡⎣ ⎤⎦∫

=drN A rN

( )∫ exp −β1U rN( )⎡⎣ ⎤⎦exp β2U rN

( ) − β2U rN( )⎡⎣ ⎤⎦

drN exp −β1U rN( )⎡⎣ ⎤⎦∫ exp β2U rN

( ) − β2U rN( )⎡⎣ ⎤⎦

=drN A rN( )∫ exp β2U rN( ) − β1U rN( )⎡⎣ ⎤⎦exp −β2U rN( )⎡⎣ ⎤⎦

drN∫ exp β2U rN( ) − β1U rN( )⎡⎣ ⎤⎦exp −β2U rN( )⎡⎣ ⎤⎦

=Aexp β2 − β1( )U⎡⎣ ⎤⎦ NVT2

exp β2 − β1( )U⎡⎣ ⎤⎦ NVT2

We perform a simulation at T=T2 and

we determine A at T=T1

T1 is arbitrary!

We only need a single

simulation!

Why are we not using this?

Page 28: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

29

T1

T2

T5

T3

T4

E

P(E

)

Overlap becomes very small

Page 29: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

30

How to do parallel Monte Carlo

• Is it possible to do Monte Carlo in parallel– Monte Carlo is sequential!– We first have to know the fait of the current

move before we can continue!

Page 30: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

31

Parallel Monte CarloAlgorithm (WRONG):1. Generate k trial configurations in parallel2. Select out of these the one with the lowest

energy

3. Accept and reject using normal Monte Carlo rule:

P n( ) =exp −β Un( )⎡⎣ ⎤⎦

exp −β U j( )⎡⎣

⎤⎦j=1

g∑

acc o→ n( ) =exp −β Un −Uo( )⎡⎣ ⎤⎦

Page 31: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

32

Conventional acceptance rule

Conventional acceptance rules leads to a bias

Page 32: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

33

Why this bias?Detailed balance!

acc( ) ( ) ( ) ( )

acc( ) ( ) ( ) ( )

o n N n n o N n

n o N o o n N o

αα

→ × →= =

→ × →

( ) ( )K o n K n o→ = →( ) ( ) ( ) acc( )K o n N o o n o nα→ = × → × →( ) ( ) ( ) acc( )K n o N n n o n oα→ = × → × →

Page 33: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

34

Detailed balance

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

=N(n) ×α(n→ o)N(o) ×α(o→ n)

=N(n)N(o)

K(o → n) =K (n→ o)

K(o → n) =N(o) ×α(o→ n) ×acc(o→ n)

o n

K(n → o) =N(n) ×α(n→ o) ×acc(n→ o)

?

Page 34: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

35

K(o→ n) =N(o) ×α(o→ n) ×acc(o→ n)

α(o→ n) =exp −β Un( )⎡⎣ ⎤⎦

exp −β U j( )⎡⎣

⎤⎦j=1

g∑

α(n→ o) =exp −β Uo( )⎡⎣ ⎤⎦

exp −β U j( )⎡⎣

⎤⎦j=1

g∑

α(o→ n) =exp −β Un( )⎡⎣ ⎤⎦

W n( )

α(n→ o) =exp −β Uo( )⎡⎣ ⎤⎦

W o( )

Page 35: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

36

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

=N(n) ×α(n→ o)N(o) ×α(o→ n)

=N(n)N(o)

( )( )

exp( )

n

n

Uo n

W

βα

⎡ ⎤−⎣ ⎦→ =( )

( )exp

( )o

o

Un o

W

βα

⎡ ⎤−⎣ ⎦→ =

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

=

N(n) ×exp −β Uo( )⎡⎣ ⎤⎦

W o( )

N(o) ×exp −β Un( )⎡⎣ ⎤⎦

W n( )

=W(n)W(o)

Page 36: Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points

37

Modified acceptance rule

Modified acceptance rule remove the bias exactly!