The Ising model in two dimension is a model for a magnetic
material. It consist of classical spins on a equally spaced
lattice in 2 dimensions. Basic statistical
physics will be used
to computer the properties of such a model at temperature .
The model consists of a set of spin degree of freedom interacting with
each other and with an external magnetic field. For example, these spins could
represent the magnetic moments of the atoms in a solid. The spins
are located on a 2D lattice of size .
Each spin is labeled by
,
where
and
refer to the position on the
lattice, and
is a generic site label. These spins are
assumed classical (i.e., not following quantum mechanics rules) and
assumed to be spin
. Therefore each spin is pointing up
(
) or down (
).
The energy of the system is written
Periodic boundary conditions are applied. The neighbor of a spin on the left of the lattice is taken as the spin on the right of the lattice and vice versa for the spin on the right. The same applies for the spins at sites at the bottom and the top of the lattice. These boundary conditions model a system of infinite dimensions. The topology of the lattice is therefore that of torus.
If is positive the energy favors the parallel spin between
neighbors, this is ferromagnetism. If
is negative, the spin will
tend to be anti-aligned or antiferromagnetism.
Any system in statistical equilibrium at temperature is such that
all possible configurations of the systems may occur with probabilities
The energy of the system depends on the spins on the
lattice. Each spin can be in two possible configurations,
.
The total number of configurations is then
.
This is an enormous number of terms to perform sums over. A very modest
lattices of
corresponds to a number of configurations
. Therefore the sums have to be done via
Monte Carlo sampling. Note that
these sums take the role of the integrals we described in previous
sections.
The needed sums are based on the simple statistics idea of averaging the
given variables over the probabilities. The energy of the system is
therefore
The program ising.c implements this solution. It uses Monte Carlo sampling obtained via the Metropolis et al algorithm based on the probability of the spin configurations to calculate the energy and magnetization of the system.
The code defaults to a 20 X 20 lattice. It samples phase space by flipping the spins at random. The issue becomes that of the step size as we discussed before. In this case the choice is to flip spins or not to flip spins. Flipping all the spins on the lattice at once would likely lead to a step that is too large; configurations would be missed in the sampling. The code uses the idea of a sweep of the lattice where spins are systematically flipped from site to site on the entire lattice with the proviso that each trial flip be accepted or rejected according to the Metropolis algorithm. This is found by experience to be a more effective way of sampling.
It also leads to an efficient way of calculating the ratio of
probability between the trial and the previous spin configuration. The
acceptance of the trial step depends on the ratio of the weight
function.
Another interesting question is to know when to stop sampling? This question is answered in the code by a special way of doing statistic. Sampling is done at every NFREQ sweeps. These sweeps are binned into groups with NSIZE members. For each group the mean and the standard deviations are calculated. Groups values for the average are then considered to be independent variables and a grand average is calculated. The standard deviation of this grand average can be calculated via the standard variance formula for the different averages of the groups or via the average of the variances of the groups. When sufficient sampling is accomplished, these two results should be the same. This provides a measure of goodness of the sampling.
Michel Vallieres 2014-04-01