Está en la página 1de 15

MONTE CARLO SIMULATIONS OF THE ISING MODEL IN 2D, 3D, 4D, AND 5D

PHYSICS 171: STATISTICAL MECHANICS AND THERMODYNAMICS


FINAL PROJECT WINTER 2015
ALEJANDRO SANCHEZ

I.

INTRODUCTION
The Ising model is a mathematical representation of the behavior of a magnetic material at its most basic form. The model consists of a system of spins on a lattice with each site
containing a spin ! of value +1 or -1. These spins interact with each other according to the
systems Hamiltonian, which is:
=

! !
!!,!!

!
!

Here J is the coupling constant. J > 0 describes a ferromagnetic system, while J < 0 describes
an antiferromagnetic system. h represents the external magnetic field. And <i, j> represents
the nearest neighbor interaction between spins.
The focus of this paper will be to study the phase transitions of this model in different
dimensions. In particular to locate the critical point, which in the case of a magnet is the Curie
temperature, determine the spin spin correlation function, and the critical exponent . A Monte
Carlo simulation is used to recreate a magnets behavior during a phase transition in order to
study these parameters. Given the large number of particles and their exponential increase in
numbers with respect to the dimension of the lattice, it is critical to use the appropriate type of
algorithm to ensure that the computations can be carried out in a timely manner. Therefore
two algorithms are considered for this paper, the single-spin flip model Metropolis Algorithm
and the Wolff cluster spin flip algorithm.

II.

Theory
a. Critical Exponents: The Study of Parameters around the Curie Temperature
The Ising model exhibits a phase transition at the critical point, which is also known as
the Curie temperature ! . The phase transition corresponds to the moment where the macroscopic behavior of a material changes. These changes can be observed in the canonical partition function or in the free energy of the system under the form of singularities. These singularities are best understood through the study of critical exponents. Three of the most commonly used ones are: Order parameters, Correlation length, and Response Functions. It is important to note that the behavior this paper seeks to analyze is around and close to the critical
temperature. Furthermore, what follows will focus in the case of the N-Dimensional Cubic
lattice Ising Model with h = 0. To avoid edge cases and maximize the spin interaction the
model will use periodic boundary conditions. In other words the square lattice will live on a
circular torus.

Order Parameters:
An order parameter is a thermodynamic quantity that, as it names suggests, helps us
understand the order of the system. More specifically it helps us understand in which phase
our magnet is. As the phase transition occurs, order parameters are those that have changed
value markedly. For a magnet, this can be seen through its magnetization.
=

! !

and = !

N represents the total number of spins in the lattice.


When a magnet is at a temperature below the Curie temperature ! , in which case it is ferromagnetic (characterized by aligned spins), the magnetization is nonzero. In contrast, when

above ! , the magnet is paramagnetic (characterized with alternating spins) and has a magnetization of zero. In particular, below ! , magnetization behaves as:
!

!
With =

!!!!
!!

= ||!

the reduced temperature and the critical exponent associated with the magnet-

ization.

Response Functions:
Other parameters such as the Susceptibility and the Heat Capacity C also respond to the
phase transition. These quantities are related to both the magnetization m and the energy E of
the system as follow:
=

1
=
! !
!

1
=
! !
! !

The focus is however in their divergence at the critical temperature. Both of these functions
diverge around the critical temperature and are described as

Where we look at in order to understand the behavior at both sides of the singularity.

Correlation Function and Length:


The macroscopic behavior of these parameters is linked to fluctuations in microscopic interactions. In particular, the correlation function G determines the correlation between two different
spins in our lattice at a distance r.

() = ! !!! ! !!!
These correlations are usually studied with respect to a characteristic distance named the correlation length and the correlation function decays in the order of !!/! for r 0.
Similarly to the other parameter, the correlation length also diverges at ! and behaves in the
order of

One important property of these critical exponents is that they depend only the symmetry of
the order parameters and the dimensionality of space. According to the critical scaling hypothesis, due to the domination of large distance fluctuation the details of the system at short distances, such as lattice shape and interaction range can be ignored. Thus the systems with the
same dimensions and symmetry of order parameters will have the same critical exponents and
thus are part of the same universality class. One objective will be to verify if this holds for the
simulations that will be performed.

b. Critical Slowing down


The Ising model is designed to respond to nearest neighbor interactions. As the temperature decreases, it becomes favorable from an energy point of view for spins to align with
their nearest neighbors. Thus with the decrease of temperature toward ! , the Ising system
shifts from an unordered to an ordered phase (or vice versa) and begins to form many large
clusters of spins of both +1 and -1. Since the spins in a cluster are surrounded by many similarly oriented spins there is a very low probability that any spin away from the boundaries will
flip. Because only the peripheral spins will be flipping, the time required to flip an entire cluster increases proportionally to a power of the correlation length. This is better illustrated by

looking at the correlation length, which we defined above, as the size of the largest cluster.
This phenomenon is called slowing down and it will be crucial for the implementation because
it will be the main impediment to getting results in a timely manner. Moving forward, the focus will lie on using simulations to recreate the phase transition and study the various quantities and concepts mentioned above.

III.

Monte Carlo Simulation


When calculating an expectation value for some quantity in the Ising model as
< > =
{!}

1
() = !!"(!)

it is necessary to sum over all possible states. Looking at a N-Dimensional lattice of size L the
!

numbers of states is ~ 2! which even for medium sized lattices becomes intractable to calculate. The Monte Carlo simulation recreates a distribution of states corresponding to that of the
canonical ensemble by performing a random walk through phase space. For this, the simulation establishes a transition probability matrix that will represent the stochastic change from
one configuration of the lattice to the other. Loosely speaking, the simulation looks to use a
sample of configurations in order to get a good approximation of the desired quantity. This
paper focuses on two particular implementations of the Monte Carlo Simulation: the Metropolis single-spin flip algorithm and the Wolff cluster algorithm.

i. Metropolis Algorithm
This algorithm seeks to update one spin at a time with the following transition probability matrix
!" = !!

!!(!! ! !! )

for ! > !
for ! < !

The steps used to implement the algorithm for this paper were as follow:
1. Initialize the system by creating a lattice with flips randomly oriented as +1 or -1
2. Go through every spin in the lattice and calculate the change in energy of the system
that would result from flipping that spin. If the change in energy is negative, flip the
spin; otherwise flip the spin with probability !! (!! ! !! ) .
3. Repeat step 2 as many times as necessary or until system has stabilized

The spins were visited in a linear sequence for every temperature, N times, where N represents
the number of Monte Carlo Steps required to create a new state to follow in the random walk.
The magnetization is averaged after visiting every spin in the lattice and each value is stored
in an array to later be averaged over N loops to get the average magnetization for a given temperature. Similarly, after having visited all the spins during a Monte Carlo loop, the product of
spins ! !!! is calculated for varying values of r. These are then averaged over N loops to get
the spin spin correlation function at the given temperature. Note that the length between spins
cannot surpass half the length of the lattice since we are working in periodic boundary conditions and any r greater than this would be double counting interactions.
Given that the magnetization serves as the order parameter, we measured the difference between consecutive values of average magnetization. The largest difference corresponds to the
critical temperature.

While this model can be applied to various circumstances and conditions, such as a varying
magnetic field, it is however very sensitive to the critical slowing down phenomenon described above. In particular going through every spin in the lattice, exponentially grows the
number of calculations as the dimensions of the lattice increase. Furthermore, having to over-

come the large cluster formation close to the critical temperature flipping one spin at a time
makes this process intractable. Thus above 3D this process was too slow to get any realistic
results.

ii. Wolff Algorithm


The Wolff algorithm, derived from the Swendsen-Wang algorithm, is a cluster-based algorithm. A cluster is created by grouping bonds among parallel spins and by flipping the entire
cluster at once, this method greatly reduces the impact of the critical slowing down.
To implement the algorithm, the following steps were followed:
1. Initialize the system by creating a lattice with flips randomly oriented as +1 or -1
2. Pick a spin at random to become the center of the cluster that will be created and eventually flipped. Look at all of its neighbors and add those that are parallel to it to a
queue.
3. Pop an element from the queue. Look at all of its neighbors: if a neighbor is in the
cluster, check if a connection was already attempted during the current Monte Carlo
loop. If such an attempt has not been made, add the popped element to the cluster with
probability 1 - !!! and stop the search through neighboring spins.
4. If the previous step resulted in an added spin to the cluster, look at all the neighbors of
the newly added spin. If the neighbor is not in the cluster and not in the queue, add it to
the queue. Otherwise, do nothing.
5. Repeat steps 3 and 4 until the queue is empty. Flip all the spins in the cluster.
6. Repeat 2 through 5 as many times as necessary to stabilize the system.

The implementation of this code uses three global variables: the lattice, created in the same
way as when implementing the metropolis algorithm, a map of neighboring states, and the total energy of the system.
A lattice is created, followed by the initialization of the nearest neighbor map and calculating
the total initial energy using the latter.
For each temperature, the Wolff algorithm is run N Monte Carlo loops. At each loop the total
energy is updated with every flip of a spin. The spin spin correlation is also measured for various ! !!! . In order to get good results, all spins at a distance r with r ranging from 0 to
length/2 are considered. Finally, the magnetization is calculated by summing over all the elements in the lattice.
Following N loops, an average of each quantity is taken for the given temperature and the values are stored in a file to reproduce the rest of the calculations at a later point.
In order to make the code run faster and the results more accurate, parallel computing is used
to run the entire process several times and average the values of each quantity over various
runs. More details can bee seen in the source code attached.

IV.

Results
a. Critical Temperature
The study of the phase transition occurs around the critical temperature ! . Thus the first step
consists of identifying ! for different dimensions. As mentioned before, an order parameter
changes values when moving from one phase to another. For a magnet, this order parameter is
the magnetization. In theory, there is a singularity at = ! which means that we are looking
for a sharp change in values of the magnetization. As stated previously, taking the difference

of successive magnetization measurements and finding the index with the highest absolute difference did this. Below are the results obtained for the various dimensions:

Magnetization as function of Temperature for the 2D lattice. On the left is the result from the Wolff
algorithm on a 80x80 lattice with a Tc = 2.30 and on the right the result form the Metropolis algorithm
on a 50x50 lattice with a Tc = 2.32

2D
3D
4D
5D

Curie Temperature for Square Lattice Ising Model


Metropolis
Accuracy
Wolff
Accuracy
2.24
0.987
2.30
0.987
4.44
0.976
4.49
0.987
6.67
0.999
8.60
0.989

Theoretical
2.27
4.551
6.68
8.7

The results obtained were pretty accurate. Given the computation time required and the inefficiency of the code due to an unfound bug, the step taken between temperatures was not small
enough to get more precise results.

b. Correlation Function
The correlation function measures the correlation between two spins at a distance r.
Above the critical point, in the paramagnetic phase it is expected that the spins alternate in
sign thus there should be almost no correlation among spins. Close to the critical point and
below however, the spins are expected to align and hence show strong correlation. Measuring

the correlation at various temperatures and for the various dimensions, we get the following
graphs:

Spin Spin Correlation as a function of temperature. On the right are the results from the Wolff algorithm in all dimensions for different lattice sizes. On the left is the result from the metropolis algorithm
using for 2 dimensions on a 50x50 lattice

The behavior is in accordance with what is expected, fluctuating around 0 for high temperatures and plateauing at 1 below Tc.
The Metropolis algorithm had great success in measuring the correlation function compared to
the Wolff algorithm. The main reasoning for this was the presence of a bug in the code for the
Wolff algorithm, which introduced large amounts of noise at high temperatures. To counteract
for this, instead of measuring the spin spin correlation between the spin at 0 and r as in the
Metropolis algorithm, every spin at a distance r was considered and the values were averaged.
This reduced the noise, but did not correct the inherent bug within the code. As the dimensions
grew it also became harder to run enough iterations to reach equilibrium and to swipe larger
ranges of temperatures, which is why there is a shrinking in the size of the correlation function
from the Wolff algorithm. However there is a sharp drop around the appropriate critical temperature for each dimension in the Wolff algorithm results.

c. Correlation Length and Critical Exponent


From the correlation function we can get the correlation length for large values of r, which, as
mentioned previously, behaves as a power of . To consider the largest possible values, r was
taken from the range length/4 to length/2. Given the relation between correlation length and
correlation function, the following reasoning was used to calculate .
= !!/!
ln ( ) =

Using a linear regression on ln ( ), was determined as the slope of the ensuing regression. Repeating this process for the various temperatures resulted in (). Based on the above
formula

another regression was used on ln ( ln

= ln ( ) to obtain as

the slope. Below are an example of the correlation length of the 3D Ising model as well as a
chart with the various values obtained with their respective errors.

Correlation Length of a 15x15x15 3D cubic lattice using Wolff

2D
3D
4D
5D

Correlation Length Critical Exponent for Square Lattice Ising Model


Metropolis
Accuracy
Wolff
Accuracy
Theoretical
0.96
0.96
0.71
0.71
1
0.65
1.03
0.63
1.00
0.63
0.87
0.87
1
0.13
0.13
1

As expected, the correlation length shows symmetrically diverging behavior at the critical
temperature.
The Metropolis algorithm was more accurate than the Wolff algorithm in its calculation of the
correlation length. As mentioned previously, this is attributed to an error in the code for the
Wolff algorithm that introduced large amounts of noise making it very difficult to carry out
effective regressions.

d. Susceptibility and Heat Capacity

3D 15x15x15 Lattice using Wolff. Heat Capacity on the right and Susceptibility on the left.

To better understand the phase transition and the concept of universality through the critical
exponents as mentioned in the beginning of this paper, we looked at the susceptibility and heat
capacity and calculated their exponents using the same methods as for finding the critical exponent for the correlation length, namely performing a linear regression on a log log function.
While the divergence of both quantities occurred at the critical temperature as predicted by the
theory, the results were not convincing. The results for susceptibility were mostly accurate,
but they broke down in higher dimensions; the results from the heat capacity were consistently
off. This can be partly explained by the fact that susceptibility depends on the magnetization

whereas the heat capacity depends in the energy, which might have been miscalculated in the
code.
However the consistency of all parameters despite the varying of lattice sizes, specifically for
those with low error seem to support the concept of universality.

Values for critical exponents for varying lattice sizes


Alpha Error Beta Error Mu Error

-
2D Wolff length 30
0.95
0.10 0.20 0.24 1.24

-
2D Wolff length 40
0.94
0.18 0.44 0.71 1.71

-
2D Wolff length 50
0.99
0.12 0.04 0.51 1.51

-
2D Wolff length 80
1.26
0.11 0.12 0.48 1.48

-
3D Wolff length 10
0.60 4.45 0.23 0.29 0.57 1.90
-
3D Wolff length 12
0.55 4.00 0.30 0.08 0.62 1.98
-
3D Wolff length 15
0.59 4.36 0.30 0.08 0.86 2.37
-
3D Wolff length 17
0.69 5.27 0.20 0.39 0.63 2.00
-
4D Wolff length 7
0.50
0.17 0.66 0.11 1.11

-
4D Wolff length 10
0.28
0.34 0.32 0.87 1.87
4D Wolff length 12
0.40
0.42 0.16 0.81 0.19

-
5D Wolff length 4
0.29
0.30 0.40 0.17 1.17

-
5D Wolff length 5
0.52
0.25 0.50 0.13 1.13

-
2D Metropolis length 30
-
0.18 0.44 1.00 2.00

-
2D Metropolis length 40
0.07 0.44 0.80 1.80


-
2D Metropolis length 50
0.18 0.44 0.96 1.96


-
2D Metropolis length630
0.16 0.28 1.11 2.11

Gamma Error
1.76 0.01
1.92 0.10
1.96 0.12
2.28 0.30
1.08 0.12
1.15 0.07
1.25 0.02
1.23 0.00
0.56 0.44
1.40 0.40
0.99 0.01
0.58 0.42
0.64 0.36
-

3D Metropolis length 20
3D Metropolis length 17
3D Metropolis length 12
3D Metropolis length 15
V.

0.26
0.27
0.17
0.28

0.20
0.17
0.48
0.14

0.49
0.52
0.37
0.65

0.22
0.17
0.41
0.03

Conclusion
To conclude, the Monte Carlo Simulation yielded the approximations of the Curie Temperatures for the various dimensions modeled to a reasonable accuracy. Furthermore, both the
Wolff and the Metropolis algorithms presented spin spin correlation functions in accordance
with their expected behavior, being, no correlation at high temperatures and complete correlation below the critical temperature with a sharp fall at the critical temperature. However, the
inherent nature of bugs in code made the calculation of this function extremely noisy in the
Wolff algorithm. While several measures were taken to take this into account, such as averaging over more samples, the error could not be completely eliminated. Despite this, the calculation of the correlation function was reasonably accurate, especially for the Metropolis algorithm, which made the calculation of the critical exponent possible though the errors were
pretty significant. But on a more general note, after looking at other parameters such as susceptibility and heat capacity, and their respective critical exponents for varying lattice sizes in
the different dimensions, there was a trend of consistency. This seems to be in accordance
with the theory of universality and scaling mentioned in the theory. The implementation of the
Monte Carlo Simulation was challenging due to the volume of computation and its sensitivity
to the critical slowing down around the critical temperature. However, implementing the
Wolff algorithm made the calculation in 4 and 5 dimensions tractable. This is without a doubt
a very useful tool in verifying the theoretical concepts as well as to give a strong visual representation of some of the underlying physical phenomena.

VI.

References
Meyer, Peter, Computational Studies of Pure and Dilute Spin Models, July 2000
< http://www.hermetic.ch/compsci/thesis/index.html>
Hammel, Ben. "Monte Carlo Simulation of the Ising Model using Python". TheBrokendesk.com 06 January 2014. 21 March 2015.
< http://www.thebrokendesk.com/post/monte-carlo-simulation-of-the-ising-model-usingpython/>
Rongfen Sun, Cluster Algorithms for the Ising model and the Widom-Rowlinson Model,
May 1999
< http://www.math.nus.edu.sg/~matsr/papers/ClarkThesis.pdf>
Wolfhard Janke Monte Carlo Simulations of Spin Systems
< http://www.physik.uni-leipzig.de/~janke/Paper/spinmc.pdf>
M. Kardar, Statistical Mechanics of Fields

También podría gustarte