basic monte carlo (chapter 3) algorithm detailed balance other points
TRANSCRIPT
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
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= −
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
Eβ
⎛ ⎞∂ Ω≡ ⎜ ⎟
∂⎝ ⎠
1 2β β=
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
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
8
Monte Carlo simulation
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
Λ
−=
β
10
Monte Carlo simulation
11
12
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?
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)
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( )⎡⎣ ⎤⎦⎡⎣
⎤⎦
16
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?
18
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?
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
21
Keeping old configuration?
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?
23
Not too small, not too big!
24
25
Periodic boundary conditions
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
27
Phase diagrams of Lennard Jones fluids
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?
29
T1
T2
T5
T3
T4
E
P(E
)
Overlap becomes very small
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!
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( )⎡⎣ ⎤⎦
32
Conventional acceptance rule
Conventional acceptance rules leads to a bias
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α→ = × → × →
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)
?
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( )
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)
37
Modified acceptance rule
Modified acceptance rule remove the bias exactly!