0% found this document useful (0 votes)
72 views33 pages

Monte Carlo

1. Monte Carlo simulation uses Markov processes to generate configurations according to the desired probability distribution by applying single-step transition probabilities that satisfy detailed balance. 2. A basic Monte Carlo simulation procedure involves generating a trial configuration by perturbing the current configuration, then accepting or rejecting the trial based on the Metropolis criterion. 3. Common trial moves in molecular simulation include displacement moves where an atom is randomly displaced within a local region, but other moves like rotation and insertion/deletion are also used depending on the ensemble.

Uploaded by

David Donoso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views33 pages

Monte Carlo

1. Monte Carlo simulation uses Markov processes to generate configurations according to the desired probability distribution by applying single-step transition probabilities that satisfy detailed balance. 2. A basic Monte Carlo simulation procedure involves generating a trial configuration by perturbing the current configuration, then accepting or rejecting the trial based on the Metropolis criterion. 3. Common trial moves in molecular simulation include displacement moves where an atom is randomly displaced within a local region, but other moves like rotation and insertion/deletion are also used depending on the ensemble.

Uploaded by

David Donoso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 33

1

CE 530 Molecular Simulation

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

 Importance-sampling Monte Carlo is the only viable approach


• unweighted sum of U with configurations generated according to
 U
distribution e / ZN

 Markov processes can be used to generate configurations


according to the desired distribution p(rN).
• Given a desired limiting distribution, we construct single-step
transition probabilities that yield this distribution for large samples
• Construction of transition probabilities is aided by the use of
detailed balance: p ip ij  p jp ji
• The Metropolis recipe is the most commonly used method in
molecular simulation for constructing the transition probabilities
3

Monte Carlo Simulation


State k
 MC techniques applied to molecular simulation
 Almost always involves a Markov process
• move to a new configuration from an existing one
according to a well-defined transition probability
 Simulation procedure
• generate a new “trial” configuration by making a
perturbation to the present configuration e  U
new

• accept the new configuration based on the ratio of e   U old


the probabilities for the new and old State k+1
configurations, according to the Metropolis
algorithm
• if the trial is rejected, the present configuration is
taken as the next one in the Markov chain
• repeat this many times, accumulating sums for
averages
4

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

General Form of Algorithm


Monte Carlo Move
Entire Simulation
New configuration
Initialization

Reset block sums Select type of trial move


each type of move has fixed
“cycle” or probability of being selected
“sweep” New configuration
moves per cycle “block”
Move each atom
Add to block sum 100’s or 1000’s
once (on average) Perform selected trial
cycles per block of cycles
move
Compute block average Independent
blocks per simulation
“measurement”

Compute final results


Decide to accept trial
configuration, or keep
original
6

Monte Carlo in the Molecular Simulation API


User's Perspective on the Molecular Simulation API

Simulation

Space Controller Phase Species Potential Display Device

IntegratorMC Meter Boundary Configuration

MCMove

 IntegratorMC (examine code)


• performs selection of type of move to conduct at each trial
 MCMove (examine code)
• methods to implement the Monte Carlo trial and make acceptance
decision
• different subclasses perform different types of moves
• usually several of these associated with IntegratorMC
7

Displacement Trial Move


1. Specification
 Gives new configuration of same volume and number of molecules
 Basic trial:

8

Displacement Trial Move


1. Specification
 Gives new configuration of same volume and number of molecules
 Basic trial:
• displace a randomly selected atom to a point chosen with uniform
probability inside a cubic volume of edge 2d centered on the current
position of the atom

Select an atom
at random
9

Displacement Trial Move


1. Specification
 Gives new configuration of same volume and number of molecules
 Basic trial:
• displace a randomly selected atom to a point chosen with uniform
probability inside a cubic volume of edge 2d centered on the current
position of the atom 2d

Consider a
region about it
10

Displacement Trial Move


1. Specification
 Gives new configuration of same volume and number of molecules
 Basic trial:
• displace a randomly selected atom to a point chosen with uniform
probability inside a cubic volume of edge 2d centered on the current
position of the atom

Consider a
region about it
11

Displacement Trial Move


1. Specification
 Gives new configuration of same volume and number of molecules
 Basic trial:
• displace a randomly selected atom to a point chosen with uniform
probability inside a cubic volume of edge 2d centered on the current
position of the atom

Move atom to
point chosen
uniformly in
region
12

Displacement Trial Move


1. Specification
 Gives new configuration of same volume and number of molecules
 Basic trial:
• displace a randomly selected atom to a point chosen with uniform
probability inside a cubic volume of edge 2d centered on the current
position of the atom

Consider
acceptance of new ?
configuration
13

Displacement Trial Move


1. Specification
 Gives new configuration of same volume and number of molecules
 Basic trial:
• displace a randomly selected atom to a point chosen with uniform
probability inside a cubic volume of edge 2d centered on the current
position of the atom
 Limiting probability distribution
• canonical ensemble
Examine underlying
transition ?
1   U (r N ) N
p (r N )dr N  e dr probabilities to
ZN formulate
acceptance criterion
• for this trial move, probability ratios are the same in other common
ensembles, so the algorithm described here pertains to them as well
14

Displacement Trial Move


2. Analysis of Transition Probabilities
 Detailed specification of trial move and transition probabilities
Event Probability
Forward-step 1 1
[reverse event] [reverse probability]   min(1,  )
transition
N v
probability
Select molecule k 1/N
[select molecule k] [1/N]
Reverse-step 1 1
new v = (2d)d transition   min(1, 1 )
Move to r 1/v N v
probability
[move back to rold] [1/v]

Accept move min(1,)  is formulated to satisfy


[accept move] [min(1,1/)] detailed balance
15

Displacement Trial Move


3. Analysis of Detailed Balance

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

Displacement Trial Move


3. Analysis of Detailed Balance

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

Displacement Trial Move


3. Analysis of Detailed Balance

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

Displacement Trial Move


4a. Examination of Java Code
public void thisTrial(Phase phase) {
double uOld, uNew;
if(phase.atomCount==0) {return;} //no atoms to move

int i = (int)(rand.nextDouble()*phase.atomCount); //pick a random number from 1 to N


Atom a = phase.firstAtom();
for(int j=i; --j>=0; ) {a = a.nextAtom();} //get ith atom in list

uOld = phase.potentialEnergy.currentValue(a); //calculate its contribution to the energy


a.displaceWithin(stepSize); //move it within a local volume
phase.boundary().centralImage(a.coordinate.position()); //apply PBC
uNew = phase.potentialEnergy.currentValue(a); //calculate its new contribution to energy

if(uNew < uOld) { //accept if energy decreased


nAccept++;
return;
}
if(uNew >= Double.MAX_VALUE || //reject if energy is huge or doesn’t pass test
Math.exp(-(uNew-uOld)/parentIntegrator.temperature) < rand.nextDouble()) {
a.replace(); //...put it back in its original position
return;
}
nAccept++; //if reached here, move is accepted
}

Have a look at a simple MC simulation applet


19

Displacement Trial Move


4b. Examination of Java Code
 Atom methods
public final void displaceWithin(double d) {
workVector.setRandomCube();
displaceBy(d,workVector);}
public final void displaceBy(double d, Space.Vector u) {
rLast.E(r);
translateBy(d,u);}
public final void translateBy(double d, Space.Vector u) {r.PEa1Tv1(d,u);}
public final void replace() {r.E(rLast);}

 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;}

public void PEa1Tv1(double a1, Vector u) {


x += a1*u.x;
y += a1*u.y;}
20

Displacement Trial Move


5. Tuning
 Size of step is adjusted to reach a target rate of acceptance of
displacement trials
• typical target is 50%
• for hard potentials target may be lower (rejection is efficient)
Large step leads to Small step leads to
less acceptance but less movement but
bigger moves more acceptance
21

Volume-change Trial Move


1. Specification
 Gives new configuration of different volume and same N and sN
 Basic trial:

22

Volume-change Trial Move


1. Specification
 Gives new configuration of different volume and same N and sN
 Basic trial:
• increase or decrease the total system volume by some amount within ±dV,
scaling all molecule centers-of-mass in proportion to the linear scaling of
the volume +dV
dV

Select a random
value for volume
change
23

Volume-change Trial Move


1. Specification
 Gives new configuration of different volume and same N and sN
 Basic trial:
• increase or decrease the total system volume by some amount within ±dV,
scaling all molecule centers-of-mass in proportion to the linear scaling of
the volume

Perturb the total


system volume
24

Volume-change Trial Move


1. Specification
 Gives new configuration of different volume and same N and sN
 Basic trial:
• increase or decrease the total system volume by some amount within ±dV,
scaling all molecule centers-of-mass in proportion to the linear scaling of
the volume

Scale all positions in


proportion
25

Volume-change Trial Move


1. Specification
 Gives new configuration of different volume and same N and sN
 Basic trial:
• increase or decrease the total system volume by some amount within ±dV,
scaling all molecule centers-of-mass in proportion to the linear scaling of
the volume

Consider acceptance
of new configuration ?
26

Volume-change Trial Move


1. Specification
 Gives new configuration of different volume and same N and sN
 Basic trial:
• increase or decrease the total system volume by some amount within ±dV,
scaling all molecule centers-of-mass in proportion to the linear scaling of
the volume
 Limiting probability distribution
• isothermal-isobaric ensemble
Examine underlying
transition
probabilities to
formulate
acceptance criterion

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

Volume-change Trial Move


2. Analysis of Transition Probabilities
 Detailed specification of trial move and transition probabilities

Event Probability Forward-step 1


[reverse event] [reverse probability] transition  min(1,  )
2d V
probability
Select Vnew 1/(2 dV)
[select Vold] [1/(2 dV)] Reverse-step 1
transition  min(1, 1 )
2d V
Accept move Min(1,) probability
[accept move] [Min(1,1/)]
 is formulated to satisfy
detailed balance
28

Volume-change Trial Move


3. Analysis of Detailed Balance

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

Volume-change Trial Move


3. Analysis of Detailed Balance

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

Volume-change Trial Move


3. Analysis of Detailed Balance

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

  exp   (U + PV ) + N ln(V new / V old )  Acceptance probability


31

Volume-change Trial Move


4. Alternative Formulation
 Step in ln(V) instead of V
• larger steps at larger volumes, smaller steps at smaller volumes

1  U  (Vs) N )   PV N +1 N
Limiting
distribution 
p (Vs)  e
N

) V ds d ln V

V new  V old e  )  ln V )new   ln V )old + d  ln V )


Trial move d lnV

Acceptance
probability   exp   (U + PV ) + ( N + 1)ln(V new / V old ) 
min(1,)
32

Volume-change Trial Move


5. Examination of Java Code
public void thisTrial(Phase phase) {
double hOld, hNew, vOld, vNew;
vOld = phase.volume();
hOld = phase.potentialEnergy.currentValue() //current value of the enthalpy
+ pressure*vOld*Constants.PV2T; //PV2T is a conversion factor

double vScale = (2.*rand.nextDouble()-1.)*stepSize; //choose step size


vNew = vOld * Math.exp(vScale); //Step in ln(V)
double rScale = Math.exp(vScale/(double)Simulation.D); //evaluate linear scaling
phase.inflate(rScale); //scale all center-of-mass coordinates

hNew = phase.potentialEnergy.currentValue() //new value of the enthalpy


+ pressure*vNew*Constants.PV2T;
if(hNew >= Double.MAX_VALUE || //decide acceptance
Math.exp(-(hNew-hOld)/parentIntegrator.temperature+(phase.moleculeCount+1)*vScale)
< rand.nextDouble())
{ //reject; put coordinates back to original positions
phase.inflate(1.0/rScale);
}
nAccept++; //accept
}

Have a look at a simple NPT MC simulation applet


33

Summary

 Monte Carlo simulation is the application of MC integration


to molecular simulation
 Trial moves made in MC simulation depend on governing
ensemble
• many trial moves are possible to sample the same ensemble
 Careful examination of underlying transition matrix and
limiting distribution give acceptance probabilities
• particle displacement
• volume change
 Next up: molecular dynamics

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy