You are on page 1of 4

Monte Carlo Method

Rashi Agarwal
(Dated: November 5, 2018)
From risk analysis in business to optimising control parameters in industry, computer algorithms
based on Monte Carlo methods are now a part of problem solving tools widely used in varied
sectors. Using random sampling, the method provides numerical results for problems which might
be probabilistic or deterministic in nature. Starting with a general description of the method, the
present paper introduces the applicability of stochastic approach to obtain estimates of physical
observables of a magnetic system. In particular 2-D Ising model for a ferromagnet is solved using
Metropolis algorithm for importance sampling and estimates of spontaneous magnetisation and
susceptibility are obtained. Temperature variation of the obtained parameters is then employed to
illustrate phase transition at critical temperature.

I. INTRODUCTION motion of neutrons in it [1] .


In the following sections we will apply MCM to study
The advent of computational methods has bridged the a deterministic system under the framework of statisti-
gap between theory and experimentation. On one hand cal mechanics. The efficiency of the applied MC algo-
we can now attempt to study complex, real world sys- rithm depends upon the stochastic sampling techniques
tems, especially biological systems which once were be- implemented. The real world systems are represented by
yond the scope of theoretical treatment, on the other sampling a relatively smaller number of possible forms
hand theoretical results can now be tested where exper- that the system can take. The sample should, however,
imental realisations are not feasible, for example nuclear be selected such that it mimics the properties of the real
weapons. The Monte Carlo method is one such com- system and hence can be used to draw to inferences.
putational method which has been significantly useful Two sampling methods are:
to mathematicians, scientists, engineers and economists
Simple sampling: If all possible states of the system
alike.[2]
are equally likely then we can randomly choose a
The essence of Monte Carlo method(MCM) is to make
representative sample and use it to infer proper-
use of inferential statistics and estimate numerical val-
ties of the system by assign equal probabilities of
ues. Though the term is relatively recent, the method
occurrence to each state of the sample.
has now been used for over a century under the name of
”statistical sampling”. The earliest applications were in Importance Sampling: If of all accessible states, the
the fields of mathematics - to integrate poorly behaved system spends relatively larger time in only a few,
functions etc., and research - by Enrico Fermi, on neu- then simple sampling is not a good option. In this
tron diffusion in the early 1930s.[5] Today, the method is case each state of the chosen sample is assigned
being extensively used across all branches of contempo- a weight factor depending upon its accessibility to
rary sciences, finance and engineering to design and test the system.
optimal models, strategies and designs.
The method first caught attention of the physics com-
munity as a result of developments that took place dur- III. APPLICATION
ing the Manhattan project due to von Neumann and
Ulam followed by the publication in 1949 by Metropolis The methods of Statistical Mechanics deal with esti-
and Ulam.[4] Being a part of a secret project , the term mating any physical observable, eg. temperature, of mat-
’Monte Carlo’ was supposedly the code coined by Nico- ter in bulk on the basis of dynamics of the constituent
las Metropolis to refer to the work on neutron diffusion particles.[6]
problem. The average value of desired observable is calculated
as follows,

II. METHOD
Xi exp−Hi /kB T
P
allstates
hXi = (1)
Z
MCM is essentially concerned with experiments on
generating and treating random numbers. The problems where, X is the physical observable, Xi is its value in
which are solved can be either deterministic - such as state i, H is the Hamiltonian for the system. Expression
estimating observables in statistical physics where theo- of H contains the resultant energies due to interaction of
retical models can be formulated but not solved exactly, constituent particles and that of the system with its envi-
or probabilistic - such the performance of nuclear reac- ronment, T is the temperature, and kB is the Boltzmann
tor by choosing random number to represent the random constant.
2

The essence of this formalism lies in the calculation of A. Algorithm


partition function Z. The general form of Z for a classical
system is A randomly allocated lattice configuration will make
transition from one state to other with a certain proba-
X bility and the required observables - energy, spontaneous
Z= exp−H/kB T (2) magnetization and susceptibility, will be averaged over
allstates the MC time steps.
A continuous transition from paramagnetic to ferro-
As the number of possible states non-degenerate micro- magnetic phase takes place at the critical temperature,
states that a system can take increases, analytical calcu- Tc and is marked by a discontinuity in the quantities
lations become difficult. Computer simulations over all like susceptibility and specific heat which depend upon
possible states also become impractical as the number in- a second order derivation of the free energy. While the
creases because of the constraints on speed and memory. order parameter, the first order derivative of free energy
An an example consider a square lattice of 25 spins in a 5 changes continuously. Order parameter comprises of any
x 5 arrangement. If each spin can take either of two value physical observable which is non-zero below critical tem-
±1, our 25 spin system has a total of 225 = 33554432 pos- perature and zero above it, spontaneous magnetization
sible states. This is when we assume that the constituent servers as the order parameter in the present case.
spins do not interact among themselves. In order to simulate the random thermal fluctuation of
Despite a large number of possible states, the proba- the system from state to state over the course of an ex-
bility of the system being in one of the all possible states periment Metropolis method is used. The system makes
follows a Boltzmann distribution which makes a small transition from an initial state A to a final state B with
fraction of states more accessible as compared to other, a probability, PAB given as:[3]
especially at low temperatures. This is the idea that is
used to select an optimum set of sample states through ( −(EB −EA )

MC simulations. exp kB T
, if ∆E>0
PAB =
The main utility of Monte Carlo methods is to study 1, if ∆E<0
the behaviour of the given system over a range external
where, pA and pB are the boltzmann probabilities of
parameters such as temperature and magnetic field and
the system being in states A and B respectively and
deal with problems pertaining to phenomena like phase
∆E = EB − EA .
transitions where interactions play a key role and the
determination of partition function becomes even more
Thus, the transition takes place if the energy of final
difficult.
state is less than that of initial state. However, we also
We will use MCM to study equilibrium phase transi-
accept transition to higher energy states with a proba-
tions in a 2-D ferromagnet at a finite temperature using
bility PAB , the relative Boltzmann probability.
Ising Model.
For simplicity we set kB Tc /J = C, some dimensionless
The Ising model is the simplest model to study phase constant and study the dynamics of lattice spins at
transitions in a magnetic system as a consequence of in- temperatures above and below Tc .
teractions among the constituent spins. Following are
the important considerations of Ising model:

• Each constituent dipole is localized at a site of the B. Metropolis importance sampling Monte Carlo
square lattice. scheme

• Each spin can take only two value +1 or -1. [3]

• Each spin interacts only with its nearest neighbors. 1. Choose a randomly allocated initial lattice state
2. Choose a site i
• Hamiltonian for Ising model is given as:
3. Calculate the energy change ∆E which results if
the spin at site is overturned
X
H = −J si sj (3) 4. Generate a random number r such that 0 < r < 1
<i,j> − k∆ET
5. If r < exp B , flip the spin
6. Go to the next site and go to (3)
where, J is the interaction energy between nearest
neighbors and the summation runs over all nearest For a square lattice, each spin has 4 nearest neighbors.
neighbors. To maximize interaction consider that the spins at oppo-
site geometric ends interact.
3

IV. RESULTS

The results obtained for a 100 by 100 square lattice us-


ing single spin flip Metropolis algorithm in zero external
field condition are presented here.

(a) t=0 (b) t=64

A. Lattice configurations

Starting with an initial configuration, the lattice dis-


tribution of spins at different MC time steps,t for T > Tc (c) t=8192
and T < Tc is shown below.
FIG. 2: T < Tc .

The system starts with a random distribution of op-


posite spins. As it proceeds towards equilibrium it forms
clusters of like spins and as t increases the cluster of one
type of spin grows at the expense of other. At equilib-
rium, the internal energy is minimized and almost all
the spins are aligned in the same direction. The system
should, therefore, be in ferromagnetic phase with a non-
(a) t=0 (b) t=6
zero magnetization as t → ∞.
Once the system is in equilibrium state, we can measure
any macroscopic parameter of interest. The question,
however, arises - How do we know that the equilibrium
state has been reached? The next subsection aims to
present the answer.

(c) t=128

FIG. 1: T > Tc

B. Equilibrium State

Initially all spins are in the same direction(i.e., have For any physical system, the equilibrium condition is
value +1 or -1) as the system reaches its equilibrium marked by no time variation of the parameters under
state by maximizing entropy, disorder in the system in- observation or rather a small fluctuation about an aver-
creases and the opposite spins are uniformly distributed age value. Here we will examine the variation of average
over the lattice sites. Hence, the system should behave spontaneous magnetization, m with t to identify the equi-
as a paramagnet with no net magnetization when it is in librium state. The value of m can be obtained easily from
equilibrium with the environment. the average spin of the system.
4

FIG. 4: Plots of m vs T and χ vs T(in units J/kB T ).


The solid line represents the exact results where as the
circles represent the MCS results.

The continuous change in m and the discontinuity in


susceptibility at the transition temperature illustrates
that the system undergoes a continuous transition from
para to ferromagnetic phase at a critical temperature.
Accuracy of the results obtained can be improved by in-
creasing the lattice size. The constraints on computa-
FIG. 3: Plot of m vs t for T < Tc tional speed and memory are, however, to be taken into
consideration.
Starting with a randomly allocated lattice, initially m
is zero and the system is in paramagnetic state. But
since T is below Tc , the disordering tendency of entropy
is overcome by the ordering tendency of internal energy V. CONCLUSIONS
and in equilibrium all spins are in parallel alignment,
thereby, minimizing internal energy in accordance with Computer algorithms based on Monte Carlo methods
equation 3. are of significant importance for developing theoretical
model for complex real world systems or for virtual real-
izations of available theoretical models. As seen for the
C. Phase Transition
Ising model, simulations for lattice of size much smaller
than the systems otherwise encountered in nature, were
The time variation of m can help us identify whether in good agreement to the exact solutions. Hence, the
the system is in para or ferromagnetic state. Temper- method provide an alternative to tedious and approxi-
ature dependence of m and average susceptibility, χ is mate numerical treatments. Being inherently paralleliz-
what we need to visualize the transition itself. For a able, MC algorithms can be used to improve the existing
particular lattice configuration, the average value of spin models by simultaneously testing different independent
gives the magnetization, m and susceptibility per lattice interaction parameters. In order to widen the class of
2 2
site, χ = <m >−<m>
kB T . At a particular temperature, the solvable problems or to improve the existing approaches
equilibrium value(t→ ∞) of parameters is averaged over efforts need to made to develop new algorithms to over-
many random initial configurations for more reliable re- come the limitations due to computational speeds and
sults. available memory spaces.

[1] John Hammersley. Monte carlo methods. Springer Science press, 2014.
& Business Media, 2013. [4] Nicholas Metropolis and Stanislaw Ulam. The monte carlo
[2] Dirk P Kroese, Tim Brereton, Thomas Taimre, and method. Journal of the American statistical association,
Zdravko I Botev. Why the monte carlo method is so im- 44(247):335–341, 1949.
portant today. Wiley Interdisciplinary Reviews: Compu- [5] M Newman and G Barkema. Monte carlo methods in sta-
tational Statistics, 6(6):386–392, 2014. tistical physics chapter 1-4. Oxford University Press: New
[3] David P Landau and Kurt Binder. A guide to Monte Carlo York, USA, 1999.
simulations in statistical physics. Cambridge university [6] RK Patharia. Statistical mechanics, 2nd edi, 1996.

You might also like