0% found this document useful (0 votes)
58 views55 pages

Module 9: Monte Carlo Part I: Fundamentals, and The Metropolis Algorithm

This document discusses Monte Carlo simulations and the Metropolis algorithm. It begins by explaining that macroscopic properties are averages of microscopic properties over many microstates, and that molecular dynamics simulations average properties by simulating different microstates over time. Monte Carlo simulations instead randomly access microstates without regard to time or trajectory. The key points are that Monte Carlo computes averages by sampling an ensemble of microstates, and the Metropolis algorithm is introduced as the basic Monte Carlo method to calculate macroscopic potential energy.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views55 pages

Module 9: Monte Carlo Part I: Fundamentals, and The Metropolis Algorithm

This document discusses Monte Carlo simulations and the Metropolis algorithm. It begins by explaining that macroscopic properties are averages of microscopic properties over many microstates, and that molecular dynamics simulations average properties by simulating different microstates over time. Monte Carlo simulations instead randomly access microstates without regard to time or trajectory. The key points are that Monte Carlo computes averages by sampling an ensemble of microstates, and the Metropolis algorithm is introduced as the basic Monte Carlo method to calculate macroscopic potential energy.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Module 9: Monte Carlo

Part I: Fundamentals, and the Metropolis


Algorithm

Arka Lahiri

Metallurgical and Materials Engineering Department,


IIT Roorkee

April 18, 2020


Predicting Macroscopic properties of the system
Microscopic properties of a system are explicit functions of the
atomic positions and the atomic momenta. The values of the
microscopic properties would fluctuate as the atoms change
their positions and momenta. In other words, the microscopic
properties of the system change as a function of the
microstates assumed by the system.
Macroscopic properties of a system are the measurable
properties of the system at the bulk level, e.g., the measured
temperature, pressure and volume of the system.
Statistical Mechanics says that all macroscopic properties are
averages of the corresponding microscopic properties over the
duration of the bulk measurements.
The technique of Molecular dynamics is about simulating a
macroscopic measurement on a computer, i.e. allowing the
system to take up different microstates with time and averaging
the consequent microscopic properties over the duration of the
simulation to get the macroscopic properties.
Predicting Macroscopic Properties
In reality, the system goes through a series of microstates, infinite in
number, defining its trajectory, as shown by the red line.
It is important not to be misled by the apparent 3 dimensional nature
of the schematic below. In reality, the trajectory lies in a 6N
dimensional phase space which cannot be drawn. The 3 dimensional
depiction is just to facilitate the illustration of some of the important
features presented next.

Initial
Microstate
(t = 0)

Final
Microstate(t = tfin ) Trajectory
Predicting Macroscopic Properties: an MD simulation
An MD simulation tries to replicate the same trajectory of the
system by simulating the microstates at discrete time intervals
(shown by blue and green points). The time-steps
corresponding to the different microstates are mentioned
alongside the points. The MD simulation accesses 9 different
microstates, with one of them accessed twice (highlighted in
green).
(6∆t)
Initial Microstate
(7∆t) (5∆t)
(t = 0)
(2∆t), (8∆t)
(4∆t)
(∆t) (3∆t)
(9∆t)
Final Microstate
(t = tfin )
Predicting Macroscopic Properties: an MD simulation
The macroscopic pressure of the system can be given by:
R t=t fin
1
Pmacro = Pmicro (t) dt,
tfin t=0
which can also be equivalently written as,
1 P9
Pmacro = Pmicro (i∆t).
10 i=0
The integration can be replaced by a summation only because the
system is accessing a finite set of microstates during an MD
simulation.
(6∆t)
Initial Microstate
(7∆t) (5∆t)
(t = 0)
(2∆t), (8∆t)
(4∆t)
(∆t) (3∆t)
(9∆t)
Final Microstate
(t = tfin )
Predicting Macroscopic Properties: Monte-Carlo way
Monte-Carlo simulations compute Pmacro by artificially accessing the
same finite set of microstates as observed in an MD simulation and
averaging Pmicro over all those microstates. Although, we have labeled
the microstates in the following schematic in the same order as they
are accessed during an MD simulation, the trajectory of the system or
the order in which the microstates are accessed become completely
irrelevant during a Monte Carlo simulation. Instead, a Monte Carlo
simulation is just concerned with, (1). the list of microstates which the
system accessed, and, (2). how frequently they were accessed.
7
8 6
3
5
2 4 Microstate 3 is accessed twice in total,
1 9 firstly when going from microstate 2 to 4
and secondly while going from 8 to 9.
All the others microstates
are accessed just once.
Predicting Macroscopic Properties: Monte-Carlo way
Assuming for the time being that a Monte-Carlo simulation of the
same system would access the same set of microstates with the
same frequency as observed during an MD simulation, we can write,
P9
PMacro = α=1 ρα Pmicroα
(we have already seen this formula in
2
modules 7 and 8), where, ρ3 = and for all the other microstates
10
1
(α), ραα6=3 = . The value of 10 in the denominator of the definition of
10
ρ is the total number of microstates visited in this example case. As
we are averaging over the microstates in an Ensemble, Monte-Carlo
simulations are based on the concept of “Ensemble averages”.
The trajectory of the system is irrelevant
for Monte-Carlo simulations and hence
7 has been removed. Monte-Carlo deals
8 6 just with the microstates.
3 The same microstates can be accessed
5
2 4 in an order which is different
1 9 to that of Monte Carlo.
Basis of Monte Carlo: Ensemble average

In the previous slides, we have briefly discussed about the


technique of Monte Carlo which is based on the concept of
Ensemble averaging. Although, Monte Carlo can be
conceptually related to Molecular Dynamics, there are also
several differences between the two.
The primary point of difference between the two techniques is
that Monte Carlo does not take into account the atomic
momenta as independent variables. Thus, a microstate for a
Monte-Carlo simulation is just made up of atomic position
vectors and is a 3N dimensional subset of the original 6N
dimensional Ensemble.
As a result, Monte Carlo can only be used to predict
macroscopic properties which are functions of atomic positions,
like the macroscopic potential energy of the system (please
refer to module 8).
Utility of Monte-Carlo
As mentioned in the previous slide, Monte Carlo can be used to
compute XMacro , when microscopically, X = X (r~1 , r~2 , · · · , r~N )
(see Module 8 for a description),
R !
U ~ri QN
X (~ri ) exp − ~
i=1 d ri
Ωr kB T
Xmacro = R ! ,
U ~ri QN
exp − ~
i=1 d ri
Ωr kB T
where, the denominator is denoted as the “Configurational
Integral (Z)”,
R Xmacro ,
!
1 U ~ri QN
Xmacro = X (~ri ) exp − ~
i=1 d ri .
Z Ωr kB T
So, this is the integral that the technique of Monte-Carlo aims to
solve.
In the following slides we will develop the “Metropolis” algorithm
of Monte Carlo through an example.
The Metropolis Monte-Carlo algorithm: The system
The most basic fundamental Monte Carlo algorithm is the
Metropolis algorithm. Let us understand this algorithm through
the problem of finding the macroscopic potential energy Umacro
of the system presented below. The system has a single
vacancy and two different kinds of solute atoms.
The green atoms denote the solvent atoms. These are called
atoms of type 1.
The red atoms correspond to one of the two kinds of solutes in
the system. These are the atoms of type 2.
The blue atom is the other type of solute. It is an atom of type 3.
The Metropolis Monte-Carlo algorithm: The system

We will assume that the atoms interact only with their first nearest
neighbours. Every atom has 4 nearest neighbours in this system.
There are three kinds of bonds in the system: green(1)-green(1),
green(1)-red(2), green(1)-blue(3). The relative bond energies are
assumed to be, φ12 < φ11 < φ13 . We have to remember that bond
energies are negative and a more negative bond energy implies a
stronger bond.
Thus, there is a much stronger bond between the solvent atom (type
1) and the red solute atom (type 2) compared to the bond between
two solvent atoms (type 1). The bond between a green atom (type 1)
and a blue atom (type 3) is the weakest. So, while a green atom
would like to stay next to a red atom, it hates to be next to a blue
atom.
The Metropolis Monte-Carlo algorithm: The system

Depending on the position of the vacancy, different bonds are


broken in the system. As the bond energies are negative and
the system wants to form as many bonds as possible to
minimize its potential energy, a broken bond results in a rise of
the potential energy. Let us discuss the relative rise in the
potential energy when either of the 1-1, 1-2 and 1-3 bonds are
broken.
As we have assumed, φ12 < φ11 < φ13 , so the dissolution of
one bond between a green and a red atom will lead to an
increase in energy which is the largest, followed by the energy
rise due to the dissolution of a bond between two green atoms,
while the dissolution of the bond between a green and a blue
atom leads to the least rise increase in energy.
The Metropolis Monte-Carlo algorithm: The problem
statement

As the vacancy moves around with time, it generates different


microstates. Different bonds are broken as the vacancy takes
up different locations and the potential energy U of the system
will also change accordingly. Our objective is to calculate the
macroscopic potential energy (Umacro ) by averaging U as the
system takes up different microstates.
It is important to mention that in this problem we are ignoring
the atomic vibrations and considering only the atomic jumps.
Hence, we do not have to average over the potential energy
fluctuations that happen due to atomic vibrations.
The Metropolis Monte-Carlo algorithm: Initial
configuration
Let the following configuration be the initial microstate of the system
(denoted by “MS0”) where a solvent (green) atom has been removed
to create the vacancy. As a result, 4 solvent-solvent bonds are
missing and the system is not at its minimum potential energy. Let us
assume that this configuration has a potential energy of U 0 . The four
nearest neighbours atoms to the vacancy are also indicated in the
schematic below,

3
2 4
1

In the next few slides, we will investigate how the energy of the
system changes due to a jump of either of the four nearest
neighbours into the vacancy.
The Metropolis Monte-Carlo Algorithm: Jump of atom
1
Let us consider the situation that atom 1 jumps into the vacancy and
the generates the following microstate (defined by the atomic
positions) henceforth indicated by “MS1” and let the corresponding
potential energy be U MS1 .

3 3
2 4 2 1 4
1

We can see that after the atom 1 has jumped into the vacancy, the
vacancy is now surrounded by 3 green atoms and 1 red atom. This is
different from the initial configuration as it was surrounded by 4 green
atoms. So, there must be a difference in potential energy between the
current and the previous microstates.
The Metropolis Monte-Carlo Algorithm: Jump of atom
1
Before proceeding further, it is important to compare the
potential energies of MS0 and MS1. In MS0, due to the
presence of the vacancy, 4 solvent(green)-solvent(green)
bonds are missing.
But in contrast, in MS1, only 3 green-green bonds are missing,
while, 1 solvent(green)-solute(red) bond is also missing.
So, the key difference between MS0 and MS1 is that 1 broken
green-green bond in MS0 is replaced by a broken green-red
bond in MS1.
As we have already discussed that dissolution of a green-red
bond would increase the potential energy of the system the
most, it is correct to write,
U MS1 > U MS0 , which indicates that MS1 is further away from
equilibrium (energy minimum) compared to MS0.
The Metropolis Monte-Carlo algorithm: Jump of atom
2
Now, let us consider the situation that instead of atom 1, atom 2
jumps into the vacancy and the generates the following
microstate henceforth indicated by “MS2” with its energy U MS2 .

3 3
2 4 2 4
1 1

We can see that the broken bonds around a vacancy after the
jump of the second atom is exactly the same as that found after
the jump of the 1st atom as in both cases the vacancy is
surrounded by three green atoms and one red atom. Let us
denote this microstate by “MS2” and note that its potential
energy U MS2 must be equal to U MS1 , i.e. UMS1 = UMS2 > U MS0 .
Example system: Jump of atom 3
Now, let us consider the situation that atom 3 jumps into the
vacancy and the generates the following microstate henceforth
indicated by “MS3”.

3
2 4 2 3 4
1 1

Again, the bonds broken due to the presence of the vacancy


are 3 green-green bonds and one green-red bond which are
exactly the same as that observed after the jumps of atoms 1
and 2. This microstate is denoted by “MS3” and note that its
potential energy U MS3 must be equal to U MS1 and U MS2 , i.e.
U MS3 = U MS1 = U MS2 > U MS0 .
Example system: Jump of atom 4
Now, let us consider the situation that atom 4 jumps into the
vacancy and the generates the following microstate henceforth
indicated by “MS4”.

3 3
2 4 2 4
1 1

The situation is now different from that observed after the


jumps of atoms 1, 2 and 3. The vacancy now removes a
green-blue bond. As the bond energy of a green-blue bond is
the least among all the bonds present in the system, the
increase in energy (denoted by U MS4 ) is also going to be the
least, i.e. U MS3 = U MS1 = U MS2 > U MS0 > U MS4 .
The Metropolis Monte-Carlo Algorithm: The first step
The system starts at the initial configuration/microstate (shown in the
schematic) and the system has 4 options of choosing the next
configuration/microstate by choosing the jump of either of the 4
nearest neighbours.

3
2 4
1

The first step in this Monte-Carlo simulation is to randomly choose


the neighbour which makes an attempt to jump into the vacancy. It is
crucial to note that at step 1, we are only selecting the atom which
tries to jump into the vacancy and whether that jump will be
successful or not will be determined in the subsequent steps. The
operation carried out in step 1 is called “Sampling”.
For the time being, let us assume that atom 1 will try to jump into the
vacancy.
The Metropolis Monte-Carlo Algorithm: Step 2

The important question which constitutes Step 2 is:


How probable is the jump of atom 1 into the vacancy ?
The answer to this question lies in determining how the energy of the
system is going to change if the jump of atom 1 is allowed. Any jump
which reduces the potential energy of the system is favoured while a
jump which increases the energy is not favourable for the system.
But this does not imply that an energetically unfavourable jump will
never happen. As jumps of atoms are random/stochastic in nature,
energetically unfavourable jumps may still take place, but with a lower
probability than favourable jumps.
A real life example where energetically unfavourable jumps actually
occur, is during the nucleation of a second phase. Several atomic
jumps are required to form a nuclei of the product phase and those
atomic jumps happen in spite of raising the energy of the system.
Thus, we can only say that atomic jumps which raise the energy of
the system are less probable, but not impossible.
The Metropolis Monte-Carlo Algorithm: Step 2
Our analysis has shown that the potential energy would increases as
a result of jump of atom 1, U MS1 > U MS0 . So, this jump is not
energetically favourable for the system and it is critical to evaluate the
probability of such a jump.
As a result of jump of atom 1, the system moves from the initial
microstate MS0 to the microstate MS1. So, the probability that the
jump of atom 1 takes place can be related to the probabilities of the
system existing in MS0 and MS1.
Please pay attention to the fact that we are now talking about
“probabilities” of microstates instead of “probability densities”. We
can do this because we are now concerned with the discrete events
of atomic jumps into the vacancy and not with atomic vibrations.
There can only be a finite number of microstates generated by the
finite number of possible atomic exchanges with the vacancy; each
atomic jump into the vacancy leads to a different microstate. On the
contrary, whenever we consider atomic vibrations we have to deal
with an infinite number of microstates and the concept of a probability
density.
The Metropolis Monte-Carlo Algorithm: Step 2

From Statistical Mechanics, the probability that the system is in


a particular microstate (α),

 
α 1
ρ = exp − ,
Q kB T
where Q denotes the Partition function.
The above expression can be equivalently written as,

 
1
ρα = exp − .
Q kB T
The last equivalence is possible only because we are
interested in predicting Umacro , which is obtained by doing an
ensemble average of U over all the possible microstates. U
being just a function of the atomic position vectors, its
ensemble average does not contain any kinetic energy terms,
which justifies the simplification we have made.
The Metropolis Monte-Carlo Algorithm: Step 2
The probability that
 the system exists at MS0:
MS0 MS0

1 H 1 U
ρMS0 = exp − ≡ exp − . Similarly, the
Q kB T Q kB T
probability that
 the system existsat MS1: 
MS1 U MS1

1 H 1
ρMS1 = exp − ≡ exp − .
Q kB T Q kB T
The relative probabilities of the system being in microstates
MS1 and MS0,
,
U MS1

U MS1
 
exp − Q exp −
ρMS1 kB T kB T
= , = ,
ρMS0 U MS0

MS0
 
U
exp − Q exp −
kB T kB T

ρMS1 (U MS1 − U MS0 )


   
∆U
or , MS0 = exp − = exp − ,
ρ kB T kB T

where, ∆U = U MS1 − U MS0 .


The Metropolis Monte-Carlo Algorithm: Step 2

As we have discussed before that MS1 > U MS0 , so, ∆U > 0,


 U
∆U
and as a result, exp − < 1. So, we can write,
kB T
ρMS1
 
∆U
= exp − < 1,
ρMS0 kB T
which implies,
ρMS1 < ρMS0 .
This means that the probability of the system to be found in
MS1 is smaller compared to that of the system found in MS0.
Now, based on this analysis we move on to the 3rd step of the
algorithm where we decide whether or not to allow the jump of
atom 1.
Step 2 will be referred to as the “Evaluation” step in the
following discussion.
The Metropolis Monte-Carlo Algorithm: Step 3
In order to decide whether to allow the jump of atom 1, we will
re-write the ratio of the probabilities in the following form,
 
∆U
ρMS1 = ρMS0 exp − .
kB T
The above form allows us to relate the probability
 ofbeing in the
∆U
microstate MS1 to that of MS2 with a factor exp − .
kB T
The factor is denoted by Pacc. So, forthis particular case,
∆U
Pacc = exp − .
kB T
The central idea of the above expression is that if atom 1
makes K attempts to jump into the vacancy and bring the
system into MS1 from MS0, only (Pacc K ) attempts out of K
attempts are successful.
Thus, we need to consider the effect of Pacc in deciding
whether to allow the jump of atom 1 or not.
The Metropolis Monte-Carlo Algorithm: Step 3
During a Monte-Carlo simulation, the effect of Pacc is
accounted for by randomly generating a number(R) between 0
and 1. If R <= Pacc , then we allow the jump, otherwise not.
Let us see why such an approach will work from the following
schematic of the number line. A random choice of any real
number between 0 and 1 will lie on this line. We have also
indicated the position of Pacc on this number line which is set to
0.4 in this particular case.

Not
Allowed Allowed

0 Pacc 1
= 0.4
Any randomly selected number can either be smaller than Pacc
or larger than it.
The Metropolis Monte-Carlo Algorithm: Step 3
The probability(PR ) that any randomly selected number(R)
would be smaller than Pacc can be given by the ratio of the
length of the number line till Pacc (denoted by L1 ) and that of
the entire length of the number line (denoted by L),
L1 Pacc
PR = = = Pacc .
L 1
So, the choice of a random number accurately replicates the
probability of success of the atomic jump.
L

L1

0 Pacc 1
= 0.4
We will discuss this step in more detail a bit later. We will also
refer to this step as the “Decision” step in future discussions.
The Metropolis Monte-Carlo Algorithm: Iteration
Steps 1, 2 and 3 define an iteration of the Monte-Carlo algorithm
which is called a “trial”. Let us summarize what happened in each of
those steps:

1. Sampling: Out of the 4 possible microstates the system could


evolve to, one of them was randomly selected.
2. Evaluation: The relative potential energies of the initial and the
selected microstate were evaluated which led to an
understanding of the relative probabilities of the system at those
microstates.
3. Decision: If the selected microstate is less probable than the
initial microstate, then a decision on whether the atomic jump
should be allowed or not was taken by generating a random
number.

So, the end of the 3 steps (the 1st iteration), the system can either
take up a new microstate or remain at its initial microstate.
The above trial is specific to the case where the jump of an atom
increased the energy of the system. How would the algorithm tackle
an atomic jump which reduces the energy ?
The Metropolis algorithm: Favourable jump in Step 1

Suppose, in step 1, instead of a random selection of the jump


of atom 1, a jump of any one of the other atoms (2, 3 and 4) is
considered.
In case we consider the jump of atoms 2 (or 3), we can confirm
that such a jump would lead to a bonding environment which is
exactly the same as observed after the jump of atom 1, and all
the above steps described for the jump of atom 1 can also be
applied to the jump of atom 2 (or 3).
But the situation will be a little different in case we consider the
jump of atom 4. We will explore that situation in the next few
slides.
The Metropolis algorithm: Jump of atom 4

If the jump of atom 4 was randomly chosen, we can see that


instead of the loss of a green-green bond, the system has now
lost a green-blue bond. As the green atom hates to sit beside a
blue atom, the configuration/microstate (MS4) obtained as a
result of the jump of atom 4 should have a lower energy
compared to the initial microstate, i.e., U MS4 < U MS0 .

3 3
2 4 2 4
1 1
The Metropolis algorithm: Jump of atom 4
We can express the relative probabilities of the system being in
MS4 versus the initial microstate (MS0) as,
ρMS4 (U MS4 − U MS0 )
   
∆U
= exp − = exp − > 1,
ρMS0 kB T kB T
where the last inequality follows from the fact that,
U MS4 < U MS0 .
As a result, we can write,
ρMS4 > ρMS0 ,
which implies that the system should be found more frequently
in MS4 compared to MS0. Thus, any atomic jump which takes
the system from MS0 to MS4 has to be immediately allowed.
So, we accept the jump of atom 4 without any further
conditions.
We are now in a position to describe the full “Metropolis Monte
Carlo” algorithm.
The Metropolis algorithm: Steps
1. Given the current microstate (MS0) of the system, randomly select one
out of all the possible mircostates the system can evolve to. The
selected microstate will be called MS#. We will now examine whether
the move to MS# will be allowed or not.
2. Determine the potential energies (U) of the system at the microstates
MS0 and MS#. Based on the values for U MS0 and U MS# determine the
relative probabilities of the microstates MS0 and MS# denoted by
Pacc = ρMS# /ρMS0 .
3. If, Pacc ≥ 1, accept the move and update the configuration of the
system. If not, then randomly select another number (R). If R < Pacc ,
accept the move and update the configuration of the system. If
R > Pacc , then reject the move and keep the system in the current
microstate.
4. If the atomic jump was accepted, then update the current microstate to
MS#, i.e. MS0 ≡ MS#.
The above 4 steps constitute a “trial” of the Metropolis Monte Carlo algorithm,
where the system “tries to access” the other microstates available to the
system.
Repeat steps 1,2, and 3 for accessing the other available microstates and the
average the microscopic property over the microstates accessed during the
course of the simulation.
The Metropolis algorithm: Flowchart
Initial microstate MS0

Randomly select the


next microstate MS#
among possible ones

Determine Pacc

Is No Choose randomly
Repeat Pacc ≥ 1
(R) between 0 and 1
?

Yes
Is
Yes No Reject
Update MS0 = MS# R < Pacc
?
The Metropolis Algorithm: Key observations
Suppose, the Monte-Carlo simulation using the Metropolis algorithm
is run for 10 trials. The system accesses the following sequence of
the microstates (refer to the schematic): {1, 2, 3, 3, 4, 5, 6, 7, 8, 9}.
It is apparent that the system does not move out of the microstate 3
immediately and it stays there for 1 more trial. This happens if the
randomly selected atomic jump was rejected when the system was in
microstate 3.
What does this imply ? Check next slide !
7
8 6
3
5
2 4
1 9
The Metropolis Algorithm: Key observations
 
∆U
As Pacc = exp − , associated with an energetically unfavourable jump
kB T
becomes much smaller than 1, the probability of that jump being accepted
becomes quite small. From the expression of Pacc , it is evident that this can
happen when ∆U > 0, which indicates that the microstate attempted to
reach through the jump of the atom has a higher potential energy
(unfavourable) than the current microstate.
In the context of the schematic presented in the previous slide, it can be
deduced that the atomic arrangement (the atoms which are neighbouring to
the vacancy) in microstate 3 is a low energy configuration and can also be a
local minimum. That would explain why the system finds it difficult to move
out of that microstate.
It is critical to evaluate rejected atomic jumps as system’s preference for
staying in the current microstate and hence the contribution of microstate 3 is
counted twice while evaluating the macroscopic potential energy Umacro
(check the list of the microstates in the previous slide).
Atomic jumps can be rejected more than once and consequently the same
microstate may persist across several trials. We should consider all such
repetitions while calculating the ensemble average.
The Metropolis Algorithm: Key observations
It can so happen that the sequence of microstates accessed by the
Monte Carlo simulation is: {1, 2, 3, 4, 5, 6, 7, 8, 3, 9}. The microstate 3
is again accessed twice but not consecutively. It again shows that the
system prefers to be in microstate 3 and hence accesses it
repeatedly. Conceptually, there is nothing different in this situation
from the case where the microstate 3 is accessed consecutively.
So, the general expression for an ensemble average of a quantity X
from a Monte-Carlo simulation, can be given as,
PM
X macro = α=1 ρα X α ,
where, M denotes the total number of different microstates accessed
in the Monte Carlo simulation, ρα is the probability of being in a
particular microstate (α).

The probability of being in a microstate α, ρα = , where N α
Ntrials
denotes the number of times a particular microstate (α) is attained
PM
during the Monte Carlo simulation and Ntrials = α=1 N α denotes the
total number of trials during the simulation.
The Metropolis algorithm: Key observations
7
According to the
8 6 expression presented
3 macro
PM
= α=1 ρα U α .
5 in the previous slide: U
2 4
1 9 Counting the number of times
each microstate was visited,
1 α=3 2
ρα,α6=3 = ,ρ = .
10 10
macro
The final expression for U is,
1 P9 α 2 3
Umacro = U + U
10 α=1,α6=3 10
The above expression immediately establishes Monte-Carlo
simulation as a discrete version of the Ensemble average.
Thus, the same Ensemble average can be computed without
performing multi-dimensional integrations but by carrying out a
Monte-Carlo simulation instead.
But a Monte Carlo simulation can effectively substitute a theoretical
calculation of the Ensemble average only when the values of ρα
obtained from such a simulation is the same as that obtained from the
theory of Statistical Mechanics.
The Metropolis algorithm: Dealing with Randomness
How does a Monte Carlo simulation ensure that the microstates are
accessed with the same probabilities as suggested by Statistical
Mechanics ?
The Metropolis algorithm directly employs the expression of ρα from
Statistical Mechanics when evaluating the relative probabilities of
microstates in Step 2 of the algorithm,

 
1
ρα = exp − ,
Q kB T
where α denotes a microstate. So, everything looks fine here!
But in Step 1, the algorithm involves a random selection of the
microstate which the system can evolve to. So, does the
randomess/indeterminacy in Step 1 influence the value of ρα that
emerges out of the algorithm ?
Also, in Step 3, when Pacc < 1, the atomic jump is allowed only when
a randomly chosen number (R) is lower than Pacc . Does the
randomness involved in the decision to allow the atomic jump or not
influence the probabilities (ρα ) with which the microstates are
accessed during the simulation ?
The Metropolis algorithm: Dealing with Randomness

To summarize, the following two steps in the Metropolis


algorithm involve considerable indeterminacy (randomness)
and must be examined in detail in order to understand their
influence on the value ρα emerging during a Monte Carlo
simulation.
1. During Step 1, the algorithm requires a random selection
of a microstate to which the system might move to.
2. In Step 3, when the transition between the microstates is
characterized by a probability Pacc < 1, then again a
randomly selected real number decides whether the
atomic jump will be allowed or not.
We will try to understand the influence of the above two steps
on the values of ρα emerging out of the simulations in the
following slides.
The Metropolis algorithm: Dealing with randomness
Randomly chosen numbers are central to the both the steps
discussed in the previous slides. Let us first review how to
choose numbers randomly during a computer implementation
of the Monte Carlo algorithm.
Numbers can be chosen randomly with a “Random number
generator” program which pick arbitrary real numbers as and
when required. “Random numbers” are just real numbers which
are randomly chosen and they usually lie in the range of 0 → 1,
e.g. 0.123, 0.749, 0.672 etc. Also, there are some variants of
“Random number generator” programs that generate random
numbers in the range of 1 → 10, or from −1 → 1.
“Random Number Generator” programs are available in every
programming language such as, C, Fortran, etc. (also in
MATLAB). Whenever the algorithm requires a random number,
an available “Random Number Generator” program is called to
supply one.
The Metropolis algorithm: Understanding step 1
Now that we have understood how random numbers are
generated, let us look at how a microstate to which the system
can evolve to is chosen utilizing random numbers.
Going back to our example problem, at every microstate, a
vacancy could swap places with any of the 4 surrounding
atoms. The atoms are numbered from 1-4. In order to choose
one of the atomic jumps, a real number (R) between 0 − 1 is
randomly generated and the following rule is applied:
if 0 ≤ R < 0.25 then select the jump of atom 1,
if 0.25 ≤ R < 0.5 then select the jump of atom 2,
if 0.5 ≤ R < 0.75 then select the jump of atom 3, or,
if 0.75 ≤ R < 1 then select the jump of atom 4.
We have devised a way of relating R to the jump of individual
atoms and once the atomic jump is decided upon, we can move
on to Step 2 where the algorithm evaluates the probabilities of
the jump.
The Metropolis algorithm: Understanding step 1

We must note that a randomly chosen real number (R) has


equal probabilities of lying in each of the regimes,
0 ≤ R < 0.25, 0.25 ≤ R < 0.5, 0.5 ≤ R < 0.75, and,
0.75 ≤ R < 1.0,
because the length of each of these regimes is equal to 0.25.
The fact that selection of each of the atomic jumps is equally
probable in the sampling scheme presented above is a crucial
requirement of the sampling process in Step 1. If there is any
bias at this stage then it will inevitably pollute ρα obtained from
simulations and the simulation results will be wrong.
The sampling scheme used to choose one of the atomic jumps
from all the possible ones should ensure that all of the possible
atomic jumps have equal probability of being chosen. This is
the only criteria of effective sampling.
The Metropolis algorithm: Understanding Step 3
Let us move on to a discussion of the indeterminacy in Step 3. Before
attempting to understand the decision of whether to allow the jump of
a particular atom in case Pacc < 1, let us look at the distribution of
random numbers on a number line.
A number line (see the red line in the schematic below) represents all
the infinite real numbers between 0 and 1. Any point on the number
line represents a number between 0 and 1. Conversely, any number
between 0 and 1 lies on the number line.
Suppose, we randomly pick 100 numbers along the number line and
as they are selected randomly with no preference for any particular
part of the number line, we can expect these numbers (represented
by short blue tics) to be uniformly distributed along the line.

0 1
In spite of being randomly chosen, it is possible to observe some
clustering of the random numbers at certain points on the number
line. Such clusters will disappear if we plot more randomly chosen
numbers on the number line and their distribution will appear more
and more uniform.
The Metropolis Monte-Carlo Algorithm: Understanding
Step 3
Assume that a sequence of microstates accessed by a Monte Carlo
simulation is {1, 2, 3, 2, 4, 5, 3, 3, 6}, where our interest is the transformation
from microstate 3 to 2. Let Pacc = 0.3 for this transformation and let us
attempt to understand it in the context of the number line.
We will first consider the 3 → 2 transformation (highlighted in blue in the first
paragraph). In order to decide whether to allow this transformation, a random
number (R1 ) was drawn and found to be equal to 0.23 and so the jump was
accepted. Both the random number R1 and Pacc are demonstrated in the
number line.
R1

0 Pacc 1
= 0.3
As is the reality during a Monte-Carlo simulation, the transition between the
same two microstates is attempted again in a later trial (between two
repetitions of microstates 3, highlighted in red), but this time the random
number drawn (R2 ) is 0.76 (shown below) and so the jump is denied.
R1 R2

0 Pacc = 0.3 1
The Metropolis Monte-Carlo Algorithm: Understanding
Step 3
So, out of the two attempts to move from microstate 3 to microstate 2, one is
successful and the other is a failure. Thus, after 2 attempts, the Monte Carlo
simulation demonstrates a probability of transformation from microstate 3 to 2
to be 0.5. But this in huge error from the theoretical value of Pacc = 0.3. It
must be appreciated that such a difference is a result of there being just two
trials which want to take the system from microstate 3 to microstate 2. If the
simulation is run longer then there would be more instances where the
system tries to move from microstate 3 to microstate 2 and in that case the
probability of transition from microstate 3 to 2 from the simulation will
replicate Pacc very closely. This can be clarified from the schematic below
which depicts all the random numbers generated whenever a transformation
from microstate 3 to microstate 2 was attempted during the course of a
simulation. It can be confirmed from the figure that about 30% of the random
numbers fall below 0.3. It must be noted that as Pacc is a ratio of ρ for two
different microstates, realizing an accurate value of Pacc during simulations is
similar to realizing the accurate values of ρα .

0 Pacc 1
= 0.3
The Metropolis Monte-Carlo Algorithm: Dealing with
Randomness
From the discussion in the earlier slides, it is clear that we have
to take the following precautions to ensure that the simulation is
an accurate representation of reality.
1. Ensure that all the possible microstates that the system
can transition to have equal probability of getting selected
at Step 1.
2. Run a longer simulation to ensure that transitions between
microstates accurately replicate the theoretical value of
Pacc . The length of the simulation is usually determined by
checking whether the values of several quantities have
saturated or not, as done for a Molecular dynamics
simulation (we will take up this point in the next part).
The above steps will ensure that the value of ρα emerging out
of a simulation is very close to that predicted by Statistical
Mechanics.
Key benefits of a Monte-Carlo simulation over a
theoretically calculated Ensemble average
The primary benefit of a Monte Carlo simulation over a
theoretical calculation of the Ensemble average is that a Monte
Carlo simulation doesn’t require the evaluation of
multi-dimensional integrals.
As a Monte Carlo simulation is concerned with a transition
between microstates, it just deals with the ratio of the
probabilities of being in those microstates. Consider the ratio of
probabilities of being in microstate α and β,
,



 
exp − Q exp −
ρα kB T kB T
= = ,
ρβ
,


β
 
U exp −
exp − Q kB T
kB T

Even the partition function Q does not need to be calculated as


it cancels off during the process of defining a ratio.
Key differences of the Monte-Carlo method from
Molecular Dynamics

Due to the equivalence of the concepts of Ensemble and Time


averaging, it is a very natural question at this point that why should
we opt for a Monte Carlo simulation at all where the same prediction
can be obtained from a Molecular dynamics simulation ?
The first response to such a question is based directly on the
example used in this section. Here, we have a developed a Monte
Carlo algorithm which considered atomic jumps into vacancies
without considering the oscillatory nature of the atoms. This is
impossible to do in an MD simulation where by default the atomic
vibrations are simulated.
As MD simulations need to resolve atomic vibrations for being
accurate, the value of ∆t that can be used in simulations is quite
small ≈ 10−15 s. As a result, the total simulation time can barely
exceed several nanoseconds, which is insufficient for studying
diffusional phase transformations.
Key differences of the Monte-Carlo method from
Molecular Dynamics

The fact that we could disregard atomic vibrations while still


being able to simulate atomic jumps during Monte Carlo
simulations allows us to study phenomena over much larger
time scales compared to a conventional MD simulation. Thus,
Monte Carlo simulations are great tools for studying diffusional
phase transformations.
It is important to mention that the Metropolis Algorithm is not
directly used for simulating diffusional phase transformations
and a variant of it called “Kinetic Monte Carlo” is the most
appropriate technique for such problems. Kinetic Monte Carlo
is based on the conventional Monte Carlo which we studied in
this module, but has some additional features whose
discussion is beyond the scope of the course.
Key differences of the Monte-Carlo method from
Molecular Dynamics
“Microstructure” is defined by an arrangement of phases and
their topologies at the micron level. So, if we want to
understand the process of microstructure formation, our length
scale of interest is several microns. As discussed in an earlier
module, an MD simulation of a cube of material whose edge is
several micron long can be computationally very expensive.
Monte Carlo simulation offers a huge advantage in this regard
that we don’t have spend computational power on resolving the
oscillatory motion of every atom and can rather deal with the
problem directly at the phase level. This idea will become
clearer in the next part where we will present a few specific
applications of the Metropolis algorithm.
The other crucial advantage of a Monte Carlo simulation over
MD is that Monte Carlo can be used to study phenomena which
happen at a length scale higher than the atomic length scale.
Key differences of the Monte-Carlo method from
Molecular Dynamics
If the Monte Carlo method is so great then why do people still
do MD ? Why not do Monte-Carlo for every problem ?
The answer lies in the fact that in Monte Carlo the choice of the
atomic jumps or the choice of the microstate which the system
can evolve to is artificial (recall that it is chosen randomly) and
hence provide almost no insight about the behaviour of a real
system at the atomic level.
On the other hand, in an MD simulation, the atomic positions
and velocities evolve following Newton’s laws. The microstates
taken up by the system can be completely determined by
solving Newton’s laws and there is no requirement of randomly
selecting any microstate. Thus, in an MD simulation, as the
system evolves, we can track the atoms to understand the
formation and interaction of defects, which is not possible in a
Monte Carlo simulation.
Monte Carlo simulation: Concept of time

The Monte-Carlo method deals only with atomic positions and


does not consider atomic velocities/momenta. As Monte Carlo
doesn’t consider the rate at which atoms move (i.e. atomic
velocities), there is no possibility to calculate the time taken by
an atom to move from one position to another. The algorithm is
just concerned with reaching one microstate from another and
the process of transitioning from one microstate to another is
totally artificial.
Although there is no concept of time in the conventional
Monte-Carlo algorithm, there is a way to associate a certain
time increment with every discrete event in Kinetic Monte Carlo.
But we will not go into the details.
Finally, some trivia!
By now you must be wondering why the technique is called
“Monte Carlo”. Let me present what I knew till now:
Monte Carlo is a city which is famous for its casinos. Getting
rich by gambling at Monte Carlo is a hallmark of one’s
understanding of probabilities. On the other hand, using the
powerful computational technique discussed here also requires
significant knowledge of probabilities which can only be
matched by the folks at Monte Carlo. Hence the name!
But the textbook gives a different, albeit related story (Check
the footnote in page 131).
Please feel free to believe either story as long as it doesn’t
motivate you to start gambling.
The Metropolis algorithm is just named after its developer
Nicholas Metropolis.
Thank You

You might also like