Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views8 pages

Project 4 - Computational Physics

Uploaded by

Chica Rock
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)
5 views8 pages

Project 4 - Computational Physics

Uploaded by

Chica Rock
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/ 8

Critical temperature of a ferromagnetic

system applying the Markov chain Monte


Carlo method to the Ising model
Julián Guerrero Cánovas, María Pérez Martínez, Elena Pujante Martínez and Iván Villegas Pérez
(Dated: 22nd November 2021)
We have studied the probability distribution function of the energy per spin () on the Ising model,
obtaining an approximation of its mean and its standard deviation, finding that it depends on the
temperature. We have also looked for the critical temperature (Tc ) in which the system undergoes
a phase transition from a magnetize state to another one with no net magnetization. For making
an estimation of this temperature, we have used an approximation of the heat capacity (CV ) and
the susceptibility (χ).

I. INTRODUCTION implemented in any programming language1 to pursue


our main objectives: study the probability distribution
of the energy per spin() and the critical temperature of
The Ising model was originally contrived for modelling our system. In section III we present and discuss in detail
ferromagnetism, but has been used to model many the obtained results related to the probability approxima-
phenomena since it is one of the few exactly solvable tion and the phase transition at the critical temperature.
methods that allows to compute thermodynamic quan- Finally, in section IV we provide a short summary and
tities and interpret them. It is a really useful system outlook of all of our work.
to understand all sorts of behaviours relating to phase
transitions[2].
II. METHODS
This model in two dimensions has been used to explore
the temperature-dependent behaviour in ferromagnets. Background
The main purpose of this report is the estimation of the
critical temperature Tc , being this the one at which our As we have already said in section I, we will start by
system undergoes a phase transition, from a magnetized introducing the mathematical and physical background
phase to a phase with no net magnetization. at which our system is subjected.

An approximation of the energy per spin’s probability The total energy of the system is given by Equation 1
distribution in our system () can be found using the
probability function for a given state ~s by approaching N
it through a numerical method. (1)
X
E(~s) = −J sk sl
hkli

Our 2D system consists of a squared lattice of length


where J is the coupling constant and hkli means that the
L which contains N (N = L2 ) spins, either up or down.
sum goes over all “neighbouring” pair of spins, without
These 2D square lattices of spins si have been repre-
double-counting.
sented as LxL matrices, where the spins are represented
by the integer 1 if they are up or −1 if they are down
If there is no external magnetic field, the total system
(si = ±1). This matrices have allowed us to represent
energy is determined by the interaction between the
the spin configuration, which refers to the spin state of
neighbouring pairs of spins, and J is just a constant
the entire system.
which sets the energy associated with each such interac-
tion.
Periodic boundary conditions are used for our lattice,
which means all of our spins will have four “neighbours”
(left, right, up, down).
1 We have implemented this algorithm in C++ and we have gen-
In section II we describe the mathematical background erated the plots using Python. Every program we used can
for our system and we will formulate a concrete algorithm be found in our public GitHub repository in the following link:
(the Markov chain Monte Carlo algorithm) which can be https://github.com/JulianElToro/Project-4
2

The total magnetization of the system is given by the


sum over all the spins in the system (see Equation 2):
(9)
X
Z= e−βE(~s)
all possible~
s
N
(2)
X
M (~s) = si
i

While doing our study, we will mostly use the energy In a situation in which the values of a variable are
per spin (), described in Equation 3, and magnetization discrete, like ours, and being them given by a probability
per spin (m), defined in Equation 4, to ease the compar- function p(x), the expected value of a function A(x) is
ison of results for different lattice sizes: defined as:

E(~s)
(3)
X
(~s) = hA(x)i = (A(x) · p(x)).
N
all possible x

M (~s) We have also used the variance, given by


m(~s) = (4)
N
We will also study the heat capacity (CV ) and the sus- VarA(x) = hA(x) i − hA(x)i2 ,
2

ceptibility (χ), whose expressions can be found in Equa-


tions 5 and 6, respectively for which we need to calculate hA(x) i. Using the same
2

expression as the used for calculating the expected value,


1 we get
CV = (hE 2 i − hEi2 ) (5)
kB T 2 N
2
X 2
hA(x) i = (A(x) · p(x)).
1 all possible x
χ= (hM 2 i − h|M |i2 ) (6)
kB T 2 N
where the symbols “hi” stand for the expected value,
which is a really useful probability concept.
In relation to the critical temperature, it was found
analytically by Lars Onsager in 1944 for an infinite size
lattice, i.e. L = ∞[1]:
The probability for the system state s, given a system
temperature T , is given by the Boltzmann distribution Tc (L = ∞) =
2
√  J/kB ≈ 2.269J/kB (10)
(defined in Equation 7). This distribution is a probability ln 1 + 2
distribution which gives the probability that a system will
be in a certain state as a function of that state’s energy The critical behaviour of this phenomenon is illus-
and the temperature of the system: trated by the following power laws:

1 −βE(~s)
p(~s; T ) = e (7) h|m|i ∝ |T − Tc (L = ∞)|β (11)
Z
CV ∝ |T − Tc (L = ∞)| −α
(12)
where the normalization constant Z is the partition func-
tion (you can check it taking a look at Equation 9), and χ ∝ |T − Tc (L = ∞)| −γ
(13)
β is the “inverse temperature”, whose expression is in ξ ∝ |T − Tc (L = ∞)| −ν
(14)
Equation 8:
with the critical exponents β = 1/8, α = 0, γ = 7/4 and
1 ν = 1. Clearly CV , χ and ξ (the correlation length, which
β= (8) for a finite system is: ξ = L) diverge when T = Tc (L).
kB T
With this behaviour it is easy to find the scaling relation:
where kB is the Boltzmann constant, whose value is
kB = 1.38 · 10−23 .
Tc (L) − Tc (L = ∞) = aL−1 (15)
The partition function Z, which describes the statisti-
cal properties of a system in thermodynamic equilibrium, which can be used in a linear regression to find our ap-
is given by: proximated result for Tc (L = ∞).
3

• hi = −1.992 J
Algorithm 1 Markov chain Monte Carlo (MCMC)
• h|m|i = 0.9973
s0 ← −si . Flip a spin from the lattice spin
r ← U (0, 1) . Save a random number r for the acceptance. • CV = 0.06391 kB
s0 )
A ← min{1, p(~ } . Save the acceptance for later.
• χ = 0.7989
p(~
s) 1
si+1 ← s if r ≤ A
0
. Accept s0 . J
si+1 ← si if r > A . Reject s0
As for the results obtained with the Markov chain
Monte Carlo algorithm:

For T = 1.0 J/kB :


The algorithm
• hi = −1.996 J
Now, we will introduce the Markov chain Monte Carlo • h|m|i = 0.9987
algorithm, the method we have used to estimate both,
the energy per spin probability distribution, and the • CV = 0.03030 kB
critical temperature.
• χ = 0.003779 1
J
The Markov chain Monte Carlo method (summarized
in Algorithm 1) is a method that produces a chain of
steps/samples whose stationary distribution is a given
The values of hi and h|m|i are very similar to the ana-
probability distribution. In other words, it generates
lytical ones, but the values obtained for CV and χ differ
samples s ∼ p(s) by recording steps in the already
in a much more noticeable way. This is due to how the
mentioned chain and using them to produce the new
equations of these two last magnitudes look (Equations
sample.
5 and 6). As you can see by taking a look at them, a tiny
difference between the values of hi and h|m|i obtained
The basic idea behind the algorithm is to, given a by ourselves and the analytical ones, cause the error on
current state si , generate a new candidate s0 using a CV and χ to scale much more faster.
proposal pdf that only depends on si . Then, apply an
Once that it’s been already proven that we get
acceptance rule to change the state of the system to
acceptable results using this method, we will study its
s0 (if accepted) and use it as our new si+1 or keep the
burning time in order to obtain better results. The
current state si (if s0 is not accepted), repeating this
burn-in time is the time required before the equilibrium
process as many times as possible.
zone is reached, in our study, we have measured it in
number of Monte Carlo cycles.
The rule/algorithm used for the acceptance step is
called the Metropolis algorithm. This rule ensures the In order to study the burn-in time, we have chosen
detailed balance is satisfied and you can also take a look a lattice with size L = 20 and we have made some
on how it works looking at the Algorithm 1. plots that show how the numerical estimates of hi and
h|m|i evolve with the number of Monte Carlo cycles.
In our case we have first generated an initial candidate This has been done for temperatures T = 1.0J/kB and
state s0 and then we have produced a new state by T = 2.4J/kB , starting from ordered (all spins pointing
flipping one of the spins of the lattice. After this we have the same way) and unordered (random) initial states.
generated a random number r ∼ U (0, 1) and carried Those mentioned plots can be see in Figures 1, 2, 3, 4,
out the acceptance step. In every step, we have also 5, 6, 7, 8.
obtained the energy and magnetization per spin, being
able to calculate their sample means after repeating the We expect to see that the graphs converge to the
algorithm several times. Using this means is how we are values of hi and h|m|i obtained analytically. We can
able to approximate the probability distribution for  clearly see that this happens for T = 1.0J/kB for both
and the critical temperature as we have already detailed ordered and unordered, but not for T = 2.4J/kB . This
before. is probably due to some error in our C++ code2 , but, as
the behaviour of out objects of study stays the same, we
We have first tested its effectiveness calculating will continue with the study considering a much more
hi, h|m|i, CV and χ of a L = 2 lattice. Using the
formulas from the above subsection, we have calculated
the following analytical values(you can see the detailed
calculations in section V A): 2 After a really deep searching through the code, we couldn’t find
the mistake, but we were able to do a major improvement on its
For T = 1.0 J/kB : efficiency
4

larger number of MCMC cycles (and then a consequent


burn-in time). Evolution of with the number of Monte Carlo cycles for T=1J/kB (ordered)
1.9970
Apart from that, we can see that every plot converges
to a value around the step 300000 of 500000, so the
1.9975
burn-in time is around 3/5 of the total time. The plots
1.9980
for unordered initial states converge to a value slightly
closer to the analytical one, so we will start from an 1.9985

/J
unordered state.
1.9990
The samples generated during the burn-in time
correspond to regions that are far away from the mean 1.9995
value of the distribution, i.e. regions that actually have a
very low probability. In order to give the Markov chain 2.0000
time to reach its equilibrium distribution it is needed to 0 100000 200000 300000 400000 500000
start at a point closer to the equilibrium distribution, so Monte Carlo cycles
these samples generated during the burn-in time need to
be discarded. FIG. 1. Evolution of hi with the number of Monte Carlo
cycles starting from all the spins pointing the same way and
for a temperature of T = 1J/kB .

III. RESULTS AND DISCUSSION


the code, probably the one that we already mentioned in
The probability approximation the section II. In Figures 13 and 14 we can see the pre-
dicted behaviour near the analytical Tc (L = ∞), with a
In first place, we have used the MCMC to estimate the sudden increase for both magnitudes and different peaks
full probability distribution for . We have implemented for each lattice size. Here the noise has increased signif-
the algorithm to a L = 20 size lattice, studying the proba- icantly, which can interfere with our final result, but, as
bility function p (; T ) for the temperatures T = 1.0J/kB we already said, the behaviour is similar to the expected
and T = 2.4J/kB by creating normalized histograms of one, so we should get results without a extremely big
generated  samples, as can be seen in Figures 9 and error.
10. If we compare both of them, we can clearly see that Extracting the temperatures where the peaks of CV
the probability function depends on the temperature. As and χ appear for each lattice (which correspond to Tc (L))
the expected value of the energy per spin depends on the we can find the approximate value of Tc (L = ∞) with a
probability function, it can be said that hi depends on linear regression using the relation 15, where Tc (L = ∞)
the temperature. As the temperature increases, the en- will be the intercept and a the slope. As we can see
ergy per spin also increases, and because of that the en- in Figures 15 and 16(which correspond to the linear re-
ergy will oscillate between a wider range of values. This gressions) that the obtained values are Tc (L = ∞) =
is why more bars appear in the figure which shows the 2.289±0.026 J/kB and Tc (L = ∞) = 2.457±0.028 J/kB .
normalized histogram for T = 2.4J/kB . Despite that Figure 16 has a higher correlation coefficient
The actual values for the expected value and the stan- R2 , the second value approximates better to the analyt-
dard deviation are µ = −1.9974 J with σ = 0.0074 J ical value 10. The already several times mentioned mis-
for T = 1 J/kB , and µ = −1.23 J with σ = 0.14 J for take in the code may have changed the value Tc (L) for
T = 2.6 J/kB . L = 60 as the other points seems to be in line. The
appropriate correction could improve this second linear
regression, confirming it is the better way to approximate
Phase transition and critical temperature Tc (L = ∞).

We have also studied the phase transition from a mag-


netized state to one with no net magnetization, for lat- IV. CONCLUSION
tices of size 40, 60, 80 and 100 we have made plots of
hi, h|m|i, CV and χ as a function of T . The results of We have studied the Ising model in two dimensions
each magnitude, between T = 2.1J/kB and T = 2.4J/kB to explore the temperature-dependent behaviour of
for different sizes lattices can be seen in Figures 11, 12, ferromagnets.
13 and 14. In Figure 11, the expected value of the en-
ergy per spin increases with temperature. In Figure 12, Firstly, we have estimated the full probability dis-
the magnetization descends to zero near Tc (L = ∞) as tribution for  using our MCMC algorithm. This
expected, but some noise appears due to a mistake in has been done for two temperatures, T = 1.0J/kB
5

Evolution of |m| with the number of Monte Carlo cycles for T=1J/kB (ordered)
1.0000
0.9999
0.9998
0.9997
|m|

0.9996
0.9995
0.9994
0.9993
0.9992
0 100000 200000 300000 400000 500000
Monte Carlo cycles

FIG. 2. Evolution of h|m|i with the number of Monte Carlo FIG. 4. Evolution of h|m|i with the number of Monte Carlo
cycles starting from all the spins pointing the same way and cycles starting from all the spins pointing the same way and
for a temperature of T = 1J/kB . for a temperature of T = 2.4J/kB .

Evolution of with the number of Monte Carlo cycles for T=2.4J/kB (ordered)
1.3
1.4
1.5
1.6
/J

1.7
1.8
1.9
2.0
0 100000 200000 300000 400000 500000
Monte Carlo cycles

FIG. 3. Evolution of hi with the number of Monte Carlo


cycles starting from all the spins pointing the same way and
for a temperature of T = 2.4J/kB .
FIG. 5. Evolution of hi with the number of Monte Carlo
cycles starting from all the spins pointing at random initial
and T = 2.4J/kB . A very particular variance in the states and for a temperature of T = 1J/kB .
distributions was observed, more bars appeared in
the figure which showed the normalized histogram for
T = 2.4J/kB , being the reason of this a larger energy per
spin for higher temperatures. Furthermore, the energy
will oscillate between a wider range of values. Finally,
we have obtained that the actual values for the expected
value and the standard deviation are µ = −1.9974 J temperatures near the analytical value Tc (L = ∞), we
with σ = 0.0074 J for T = 1.0 J/kB , and µ = −1.23 J have studied the corresponding expected values of the
with σ = 0.14 J for T = 2.4 J/kB . energy and the magnetization per spin, the heat capac-
ity and the susceptibility for each temperature. With
After that, we have tried to estimate the critical tem- the obtained values for Tc (L), the temperatures in which
perature (Tc (L = ∞)), for which the studied collection CV and χ reach a maximum, we have performed a lin-
of spins suffer a phase transition from a not a magnetized ear regression to obtain the final result: Tc (L = ∞) =
state to one with no net magnetization. For a range of 2.289 ± 0.026 J/kB
6

FIG. 6. Evolution of h|m|i with the number of Monte Carlo FIG. 8. Evolution of h|m|i with the number of Monte Carlo
cycles starting from all the spins pointing at random initial cycles starting from all the spins pointing at random initial
states and for a temperature of T = 1J/kB . states and for a temperature of T = 2.4J/kB .

Histogram of for T = 1 J/kB


p ( ; T)
50 Histogram of

40
1
Probability density/J

30

20

10

0
2.03 2.02 2.01 2.00 1.99 1.98 1.97 1.96 1.95
/J
FIG. 7. Evolution of hi with the number of Monte Carlo
cycles starting from all the spins pointing at random initial
FIG. 9. Normalized histogram of hi for T = 1.0J/kB
states and for a temperature of T = 2.4J/kB .

V. APPENDIX Histogram of for T = 2.4 J/kB


3.0
p ( ; T)
A. All possible states and analytical expressions for
Histogram of
2.5
a 2x2 lattice system:
1

2.0
Probability density/J

In Table I you can see all possible states of the system.


1.5
Then:
1.0

0.5
X
Z= e−βE(s) =
all possible s
0.0
1.8 1.6 1.4 1.2 1.0 0.8
/J
= e8βJ + 4e0 + 4e0 + 2e−8βJ + 4e0 + e−8βJ =
FIG. 10. Normalized histogram of hi for T = 2.4J/kB
= 3e−8βJ + 12 + e8βJ
7

Energy per spin at different temperatures for diffferent lattice sizes Susceptibility at different temperatures for diffferent lattice sizes
1.2 L=40 L=40
L=60 60 L=60
L=80 L=80
1.3 L=100 50 L=100
Energy per spin ( ) [J]

Susceptibility ( ) [J 1]
40
1.4
30
1.5
20
1.6 10
0
2.10 2.15 2.20 2.25 2.30 2.35 2.40 2.10 2.15 2.20 2.25 2.30 2.35 2.40
Temperature [J/kb] Temperature [J/kb]

FIG. 11. Energy per spin () for different temperatures and FIG. 14. Susceptibility (χ) for different temperatures and
lattice sizes. lattice sizes.

Magnetization per spin at different temperatures for diffferent lattice sizes Linear regression of Tc(L) and L 1 (CV results)
0.9
L=40 2.285
0.8 L=60
L=80 2.280 R 2 = 0.53
Magnetization per spin (|m|)

0.7 L=100
0.6 2.275
Tc(L)/ J kB 1

2.270
0.5
2.265
0.4
2.260
0.3
2.255
0.2
2.250
0.1
2.245
2.10 2.15 2.20 2.25 2.30 2.35 2.40 0.010 0.012 0.014 0.016 0.018 0.020 0.022 0.024
Temperature [J/kb] L 1

FIG. 12. Magnetization per spin (|m|) for different tempera- FIG. 15. Linear regression of Tc and L−1 for the results of
tures and lattice sizes. the heat capacity (CV ).

Heat capacity at different temperatures for diffferent lattice sizes Linear regression of Tc(L) and L 1 ( results)
L=40 2.38
3.0 L=60 2.36 R 2 = 0.97
L=80
L=100 2.34
Heat capacity (Cv) [kb]

2.5
2.32
Tc(L)/ J kB 1

2.0
2.30
1.5
2.28
1.0 2.26
2.24
0.5
2.10 2.15 2.20 2.25 2.30 2.35 2.40 0.010 0.012 0.014 0.016 0.018 0.020 0.022 0.024
Temperature [J/kb] L 1

FIG. 13. Heat capacity (CV ) for different temperatures and FIG. 16. Linear regression of Tc and L−1 for the results of
lattice sizes. the heat capacity (χ).
BIBLIOGRAPHY 8

N of spins +1 Total energy (E) Total magnetization (M ) Degeneracy 4 + e8βJ + e−8βJ


4↓ 0 −8J −4 1 =
3 ↓ and 1 ↑ 1 0 −2 4 Z
2 ↓ and 2 ↑ 2 0 0 4
2 ↓ and 2 ↑(diagonal) 2 8J 0 2
1 ↓ and 3 ↑ 3 0 2 4
4↑ 4 8J 4 1
X
hM 2 i = (M 2 (s) · p(s)) =
TABLE I. All possible states of the system in a 2x2 lattice. all s
Here you can see the total energy (E), the total magnetization
(M ) and the degeneracy for each case. The total energy can
be 8J when there are 2 ↑ and 2 ↓ if each pair is in a diagonal. 1
= (16e8βJ + 2 · 16 + 16e−8βJ ) =
Z

16
X = (2 + e8βJ + e−8βJ )
hEi = E(s) · p(s) = Z
all possible s

1 1
= (−8Je8βJ + 2 · 8Je−8βJ + 8Je−8βJ ) = CV = (hE 2 i − hEi2 ) =
Z kB · T 2 · N

8J
= (3e−8βJ − e8βJ ) 64J 2 (3e−8βJ − e8βJ )2
Z = 2
[e8Jβ + 3e−8Jβ − ]=
N · Z · kB · T Z
Then

E(s) · p(s) 16J 2


(12 + 12e8Jβ + 36e−8Jβ ) =
X
hi = = =
N Z 2 · kB · T 2
all possible s

2J 192J 2
= (3e−8βJ − e8βJ ) = (1 + e8Jβ + 3e−8Jβ )
Z Z 2 · kB · T 2

X
hE 2 i = (E 2 (s) · p(s)) =
1
all possible s χ= (hM 2 i − h|M |i2 ) =
kB · T · N

1
= (64J 2 e8βJ + 64J 2 e−8βJ + 2 · 64J 2 e−8βJ ) =
Z 16
= [Z(e8βJ +2+e−8βJ −(4+e8βJ +e−8βJ )2 ] =
Z 2 · kB · T · N
64J 2 8Jβ
= (e + 3e−8Jβ )
Z
8
= [e−16Jβ + 3e8Jβ + 5(1 + e−8Jβ )]
X Z 2 · kB · T
h|M |i = M (s) · p(s) =
all s

1
= (4eβ8J + 2 · 4 + 0 + 2 · 4 + 4e−8Jβ ) = BIBLIOGRAPHY
Z

[1] Morten Hjorth-Jensen. “Computational Physics; Lecture


4
= (4 + e8βJ + e−8βJ ) Notes Fall 2015”. In: Department of Physics, University
Z of Oslo, 2015. Chap. 13.4, pp. 429–432.
Then [2] Jeffrey Chang. The Ising Model. url: https : / /
stanford.edu/~jeffjar/statmech/intro4.html. (ac-
X M (s) · p(s) cessed: 04.11.2021).
h|m|i = =
N
all s

You might also like