Monte Carlo
Monte Carlo
Lecture 9
Monte Carlo Simulation
David A. Kofke
Department of Chemical Engineering
SUNY Buffalo
kofke@eng.buffalo.edu
2
Review
We want to apply Monte Carlo simulation to evaluate the
configuration integrals arising in statistical mechanics
p(rN)
U (r N )
U dr
N
1
N!
U (r N ) e ZN
Trial Moves
A great variety of trial moves can be made
Basic selection of trial moves is dictated by choice of ensemble
• almost all MC is performed at constant T
no need to ensure trial holds energy fixed
• must ensure relevant elements of ensemble are sampled
all ensembles have molecule displacement, rotation; atom displacement
isobaric ensembles have trials that change the volume
grand-canonical ensembles have trials that insert/delete a molecule
Significant increase in efficiency of algorithm can be achieved
by the introduction of clever trial moves
• reptation, crankshaft moves for polymers
• multi-molecule movements of associating molecules
• many more
5
Simulation
MCMove
Select an atom
at random
9
Consider a
region about it
10
Consider a
region about it
11
Move atom to
point chosen
uniformly in
region
12
Consider
acceptance of new ?
configuration
13
Forward-step 1 1 Reverse-step 1 1
transition min(1, ) transition min(1, 1 )
N v N v
probability probability
Detailed balance
pi pij = pj pji
Limiting p (r N )dr N 1 e U (r N ) dr N
distribution ZN
16
Forward-step 1 1 Reverse-step 1 1
transition min(1, ) transition min(1, 1 )
N v N v
probability probability
Detailed balance
pi pij = pj pji
e U dr N U
old new
1 1 e dr N 1 1 1 )
ZN N v min(1, ) ZN
N v min(1,
Limiting p (r N )dr N 1 e U (r N ) dr N
distribution ZN
17
Forward-step 1 1 Reverse-step 1 1
transition min(1, ) transition min(1, 1 )
N v N v
probability probability
Detailed balance
pi pij = pj pji
e U dr N U
old new
1 1 e dr N 1 1 1 )
ZN N v min(1, ) ZN
N v min(1,
e U e U
old new
(U new U old )
e Acceptance probability
18
Space.Vector methods
public void setRandomCube() {
x = random.nextDouble() - 0.5;
y = random.nextDouble() - 0.5;
}
public void E(Vector u) {x = u.x; y = u.y;}
Select a random
value for volume
change
23
Consider acceptance
of new configuration ?
26
1 U (Vs) N ) PV N N
p (Vs) N
) e
V ds dV
Remember how volume-
scaling was used in
derivation of virial formula
27
Forward-step 1 Reverse-step 1
transition min(1, ) transition min(1, 1 )
2d V 2d V
probability probability
Detailed balance
pi pij = pj pji
1 U (Vs) N ) PV N N
Limiting
distribution
p (Vs) N
) e
V ds dV
29
Forward-step 1 Reverse-step 1
transition min(1, ) transition min(1, 1 )
2d V 2d V
probability probability
Detailed balance
pi pij = pj pji
(U old + PV old ) old
) (U new + PV new ) new
)
N N
e V 1 min(1, ) e V 1 min(1, 1 )
N 2d V N 2d V
1 U (Vs) N ) PV N N
Limiting
distribution
p (Vs) N
) e
V ds dV
30
Forward-step 1 Reverse-step 1
transition min(1, ) transition min(1, 1 )
2d V 2d V
probability probability
Detailed balance
pi pij = pj pji
(U old + PV old ) old
) (U new + PV new ) new
)
N N
e V 1 min(1, ) e V 1 min(1, 1 )
2d V 2d V
e (U old + PV old )
V )
old N
e (U new + PV new )
V )new N
1 U (Vs) N ) PV N +1 N
Limiting
distribution
p (Vs) e
N
) V ds d ln V
Acceptance
probability exp (U + PV ) + ( N + 1)ln(V new / V old )
min(1,)
32
Summary