0% found this document useful (0 votes)
43 views24 pages

Monte-Carlo Study of The 2D Ising Model

The document summarizes a Monte Carlo study of the 2D Ising model. It describes: 1) Setting up the Ising model as a 2D array of spins with nearest-neighbor interactions and calculating thermodynamics using the Metropolis algorithm to simulate random spin flipping. 2) Finding the critical temperature where the model transitions from ordered to disordered states and comparing it to the theoretical value. 3) Varying the number of thermalization sweeps and sweeps between states, finding that more thermalization sweeps produced a smoother transition between ordered and disordered phases.

Uploaded by

Jesse Ross
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)
43 views24 pages

Monte-Carlo Study of The 2D Ising Model

The document summarizes a Monte Carlo study of the 2D Ising model. It describes: 1) Setting up the Ising model as a 2D array of spins with nearest-neighbor interactions and calculating thermodynamics using the Metropolis algorithm to simulate random spin flipping. 2) Finding the critical temperature where the model transitions from ordered to disordered states and comparing it to the theoretical value. 3) Varying the number of thermalization sweeps and sweeps between states, finding that more thermalization sweeps produced a smoother transition between ordered and disordered phases.

Uploaded by

Jesse Ross
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/ 24

Monte-Carlo study of the 2D Ising Model

Theory
Aim:
To programmatically setup the Ising Model, a 2D array of spins with nearest-neighbour interactions and cal-
culate the thermodynamics of the model.
To use the Metropolis Algorithm to simulate the random fipping of spins in a lattice with nearest-neighbour
interactions.
To be able to fnd the critical temperature where the model exhibits an Order to Disorder transition and
compare this to the large lattice limit 0.4407 calculated by L. Onsager
Te 2D Ising Model is a 2D array of spins with near-
est neighbor interactions. Each spin can be either in
an up (+) or down(-) state. Te energy of the lattice
for a given state
z
is given by
For the duration of this program J=1 and B
z
=0 so the
second term will disappear.
Nearest neighbor interactions mean that the orien-
tation of the spins above, below, to the lef and to
the right of the center spin will have an efect on the
energy of the center spin and the changes that would
occur to the energy of the lattice if that spin were
fipped. Te diagonal neighboring spins do not afect
the energy of the spin.
Periodic boundary conditions are enforced. What
this means for the Ising Model, is that the energy of
the spins at the edges of the defned 2D lattice inter-
act with the spins on the opposing side.
At a temperature known as the critical temperature
the Ising model goes from disordered with spins in
random alignments to ordered where the spins are
more likely aligned with each other. Te reason this
temperature exists, is that at low temperatures (high
beta), the chances of the sort of energy that would
allow for a fip of a spin is unlikely whereas, at high
temperatures (low beta) the chances of the energy
being present for a fip of the spin is much more
likely creating the disorder. Te critical tempera-
ture is the phase transition point between these two
extremes.
Monte Carlo methods are used in the Ising Model
computation because the computation of ensemble
averages of properties (such as magnetization which
were calculated in this model) for the system usually
involves summing over all the possible states. As with
even small 2D arrays there are 2
Ns
states (where Ns
is total number of spins in the lattice) there are far to
many states to sum over all of them.
Te Metropolis algorithm is used to obtain states of
the system. Importantly though the Metropolis algo-
rithm allows the selection of states weighted by the
Boltzmann distribution (exp(-E)). By weighting
the states with the Boltzmann distribution the most
probable states will be generated. Tis is known from
statistical physics where the probability of a state
occurring is proportional to the Boltzmann distribu-
tion.
Instead of summing over all states for the generation
of an ensemble average, the property of the more
probable states can be summed over more and the
least probable states will be summed over less, once
these are summed, by the Monte-Carlo average the
ensemble average of the property (in this case mag-
netization) can be obtained by dividing the total by
the number of states used, however an error must
then be stated.
In this program when the Metropolis Algorithm is
called it visits N
s
spins located within the lattice at
random, again N
s
is the total number of spins in the
lattice. At each spin the algorithm asks if the fipping
of the spin will lower the energy of the lattice. Te
contribution one spin has to the total energy of the
lattice is given by:
Where
i,j
is the spin at position (i,j), and each

i,j
=1/-1, again J=1 giving a E=-2 also remember-
ing the periodic boundary conditions stating that if
one of the spins is at the edge of the lattice it acts as
though it is interacting with a spin from the other
edge opposite edge for interactions that would cross
that edge.
If fipping the spin does lower the energy it will fip
the spin immediately. If not the algorithm will use
a uniform random number generator to generate
a number in the range [0,1] if exp(-E) is greater
than the randomly generated number, the spin is
fipped otherwise the spin remains in its current
state.
Te program goes through and calculates the mag-
netization of a lattice of some size for a hot and a
cold start, by hot and cold start it is meant that for
a cold start all the spins are aligned, and for a hot
start the spins are random. Te reason why a cold
start uses aligned spins is that as stated on the pre-
vious page for a cold temperature aligned spins are
much more likely in the lattice as the energy isnt as
readily available to fip spins. A hot start however
has a much larger chance of the spins being random-
ly oriented and so is simulated by having the spins
randomly oriented.
When calculating the magnetization of a lattice
which was done in the program the beta value con-
trols the temperature and is varied from 0.1 to 1, as:
Where k
B
is Boltzmanns constant, a beta of 0.1 is a
high temperature, and a beta of 1 is a low tempera-
ture. Each time the beta value is changed however
the Metropolis algorithm is used to sweep through
the lattice multiple times without evaluating the
magnetization of these states. Tese sweeps are to let
the lattice adjust to these new temperatures or ther-
malize. If this thermalization was not performed as
some of the states calculated as being probable may
be probable only in the transition between the old
and new temperature this would mean that the com-
bination of states which the magnetization would be
calculated from may not be weighted by the Boltz-
mann distribution for the desired temperature and
as the error function for the magnetization relies on
the states that the ensemble average of magnetization
was calculated from performing multiple sweeps
without recording the magnetization is necassary.
In this program the lattice is thermalized with 100
sweeps of the Metropolis algorithm.
Te set of states generated by the Metropolis algo-
rithm need to be statistically independent for the
method that is being used to generate the error of the
magnetization which is the square root of the bias
corrected variance given by:
where N is the number of states used to obtain the
ensemble average of the Magnetization.
To generate statistically independent states of the lat-
tice, multiple sweeps (in this program 10 sweeps) of
the Metropolis algorithm are performed every time
before the magnetization of a state is logged, this
decreases the correlation between each state used.
Results
Te following pages show the results of varying the number of thermalization sweeps and sweeps between
the used states. Te number of rows and columns is 8.
T
e
r
m
a
l
i
z
e

s
w
e
e
p
s

c
h
a
n
g
e
d
,

t
o

h
a
v
e

5

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

S
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

1
0
.
T
e
r
m
a
l
i
z
e

s
w
e
e
p
s

c
h
a
n
g
e
d
,

t
o

h
a
v
e

1
0

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

S
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

1
0
.
T
e
r
m
a
l
i
z
e

s
w
e
e
p
s

c
h
a
n
g
e
d
,

t
o

h
a
v
e

5
0

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

S
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

1
0
.
T
e
r
m
a
l
i
z
e

s
w
e
e
p
s

c
h
a
n
g
e
d
,

t
o

h
a
v
e

2
0
0

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

S
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

1
0
.
T
e
r
m
a
l
i
z
e

s
w
e
e
p
s

c
h
a
n
g
e
d
,

t
o

h
a
v
e

5
0
0

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

S
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

1
0
.
Now changing Sweeps between used states
1
0
0

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

T
e

s
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

2
1
0
0

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

T
e

s
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

4
1
0
0

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

T
e

s
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

6
1
0
0

t
h
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s
.

T
e

s
w
e
e
p
s

b
e
t
w
e
e
n

s
t
a
t
e
s

i
s

1
0
A
n

e
x
t
r
e
m
e
,

c
h
a
n
g
i
n
g

t
h
e

T
e
r
m
a
l
i
z
i
n
g

s
w
e
e
p
s

t
o

1

a
n
d

t
h
e

n
u
m
b
e
r

o
f

s
w
e
e
p
s

b
e
t
w
e
e
n

t
h
e

u
s
e
d

s
t
a
t
e
s
Discussion of results of varying the sweeps
Te efect of varying the number of sweeps between
each state that is used on the graphs seem low to
non-existent. All the graphs show a random variation
in the selected values of the average magnetization
and no discernible reduction in the error bars is evi-
dent either. However although there is no descernible
diference, the error bars generated are not nearly as
relevant to the low sweep graph as to the high sweep
graphs.
As the way that the error bars were generated as-
sumed that the states used were statistically inde-
pendent, and if the number of sweeps between used
states is low than there is a correlation between the
previous state and the current one implying the states
are not statistically independent, then the aproxima-
tion to the standard deviation is low. Hence the error
bars shown for low sweeps between used states are
not very accurate as to the real error of the ensemble
average magnetization
Varying the number of sweeps for thermalization
does change the graphs. Looking at the two extremes
of 5 thermalization sweeps and 500 thermalization
sweeps and in particular how smoothly the graphs
transition between the two phases of order and
disorder (the sets of points hovering around 64 and
0 respectively more on that later) the graph with
500 thermaliztion sweeps performs the transition
a lot smoother than the graph with 5 thermaliztion
sweeps.
Tis makes sense as stated before the number of
states that make up the results need to be weight-
ed by the Boltzmann distribution, however by not
giving enough sweeps between changes in beta the
accuracy of the ensemble averages of magnetization
is reduced as the frst few magnetization values (not
the ensemble average) obtained will be transition
values between the old and the new temperatures,
and the most probable magnetization values may not
be selected.
Te next set of results shown are for the changing of size from a 44 lattice to a 88 lattice. Te thermaliza-
tion sweeps have been reset to 100, and the sweeps between used states for the calculation is 10.
IMPORTANT NOTE TO THE READER: Te results given by the program for a 44 lattice and a 66 lattice
give a strange graph that is the same as if you are not correctly setting the limits of the graphing program,
however it only afects what appears to be the frst point. I have checked it over numerous times and per-
formed debugging, it only afects these two examples. As the results for the two graphs draw over each other
due to this fault I have Photoshopped out the lines drawn from this fault. I have included at the end of the
report the two pages so it can be clearly seen what has been photoshoped. Please forgive this.
Te starting states of the lattices are as follows:
44
Cold Spin initial
- - - -
- - - -
- - - -
- - - -
Hot Spin initial
+ + - -
- - + -
+ - + -
+ + + -
55
Cold Spin initial
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
Hot Spin initial
+ + + + +
+ - - - -
+ - - + -
- + - - -
+ - - - -
66
Cold Spin initial
- - - - - -
- - - - - -
- - - - - -
- - - - - -
- - - - - -
- - - - - -
Hot Spin initial
+ + - + - +
+ + - + - -
- - - - - +
- + + - - +
- + + - + -
- - - + + -
77
Cold Spin initial
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
Hot Spin initial
- - + + - - +
+ - - + + + +
+ + - - - - +
+ - + + - - +
- - + - - - -
- + - - - + +
+ - + + - - +
88
Cold Spin initial
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
Hot Spin initial
- - + - + + - +
+ - - - - + - +
- - + + + + + -
- + + - + - - +
+ - + + + + - -
+ + + + - - - -
+ + + + - + + +
- + - + + - - +
4

4

l
a
t
t
i
c
e
5

5

l
a
t
t
i
c
e
6

6

l
a
t
t
i
c
e
7

7

l
a
t
t
i
c
e
8

8

l
a
t
t
i
c
e
Discussion of the results of chang-
ing the size of the lattice
Most discernable about changing the size of the
lattice is that on the graph the magnetization at the
lower beta values hovers around a diferent value.
Tis is caused by the maximum ensemble average
magnetism achieveable (despite what the error bars
may list) is the total number of spins in the system.
Tis is visible in the graphs, the graph for the 88
lattice afer the system transitions into order hov-
ers around 64 (88=64), this also confrms that the
system is in a state of order as most of the states used
(and hence the most probable) are ones that have
the spins aligned. Te same trend can be seen in the
other lattice sizes.
Te critical temperatures for each system can be
determined by looking at the beta values that the
system spikes from around 0 to the total number of
spins in the system (disorder to order as discussed in
the last paragraph).
Te critical temperatures are as listed:
88 lattice, beta = 0.42
77 lattice, beta = 0.41
66 lattice, beta = 0.39
55 lattice, beta = 0.38
44 lattice, beta = 0.37
Te critical temperatures show an increasing be-
haviour and appear to converge to the large lattice
limit determined analytically by Onsager 0.4407 with
increasing size of the lattice.
Te critical temperatures above were determined
by eye, the error bars were observed and the critical
temperature was recorded as the beta value where
the error bar dropped below the maximum value of
the magnetization. As the critical temperature is the
point where the system transitions from disordered
to ordered and the max value is as ordered as the
system can become this was fgured to be the value of
beta that was the critical temperature.
Te next two graphs show how the efect of increasing the number of states used to calculate the ensemble
average magnetization, the frst shows a low number and the second shows a high number, all other values
are kept constant. Te lattice size was 88 and the termalization sweeps was 100, the number of sweeps be-
tween used states was 10.
Observing the two graphs it can be seen that the
error bars of the frst graph jump to a value of 20 for
the frst few values, whereas the error bars for the
second graph only go to 10. Te number of states
used to calculate the Magnetization controls the sta-
tistical error. Systematic errors are also controlled by
the varying of the number of states used, this can be
seen by the points on the graph being closer to zero
for small beta on the second graph whereas the frst
graphs points are much more erratic and are posi-
tioned much higher than the second graphs points.
As the points and their divergence from their accept-
ed value (at low beta a value of zero and at high beta
a value of the total number of spins) the number of
states used to calculate the magnetization controls
the statistical and the systematic errors.
Conclusion
Te Ising model by all observations was correctly
setup using Monte-Carlo methods, and a weighting
function was generated using the Metropolis Algo-
rithm.
Te critical temperatures obtained were:
88 lattice, beta = 0.42
77 lattice, beta = 0.41
66 lattice, beta = 0.39
55 lattice, beta = 0.38
44 lattice, beta = 0.37
Te values do appear to converge to the analytically
obtained value by Onsager of 0.4407.

You might also like