The Ising Model

Hints

Bob Silsbee and I made up this program last year, and Jörg Dräger sped it up by implementing a table lookup which saves a bunch of exponentials.

The program is in ~sethna/teaching/SolidState/Ising, and is called Ising. Choose parameters with the sliders or by typing in the boxes. Click the ``send'' button to start the simulation. You should copy all the files from my directory into your directory: Ising calls a bunch of shell scripts to do the graphics.

The Hamiltonian

The Ising model is a classic model for ferromagnetic systems, and is also used in many other contexts (binary alloys, liquid--gas transitions, ...). We consider a system of spins S[ij] which can take on only the values +1 or -1. They are distributed on a square lattice. They interact with their nearest neighbors with energy -J if the neighbor is parallel, and +J if the neighbor is antiparallel; and with an applied field with energy -H S. Note that these are not like real spins: they don't have x or y components.

The Simulation

The simulation is a Monte-Carlo calculation. We first take a 30x30 square array of spins and assign them + or - orientations at random. We also choose a temperature T and magnetic field H by adjusting the sliders on the screen (or easier, type the number into the appropriate window). The program chooses one spin, perhaps the ith spin, at random, calculates the effective field H[i] at the spin i, which is H plus J times the spins of the 4 nearest neighbors of the ith spin. It reassigns the ith spin the value +1 or - 1 with relative probability exp[+H[i]/T] or exp[-H[i]/T]. It then repeats this process 899 more times (for a 30x30 lattice) choosing new spins at random. This is one sweep. (In one sweep, on average, each spin gets adjusted according to the Boltzmann factor one time. In fact, some spins will be picked more than once, others not at all.) After a few (many?) sweeps, the simulation will be in thermal equilibrium with temperature T.

The checkerboard display gives the arrangement of spins after each sweep if the number of sweeps is less than MAX_SWEEP_DISPLAY = 50; otherwise it shows the spin arrangement after the sweeps are completed. The printed output gives averages of < |M| > , < (M- < M > )^2 >, < E > and < (E- < E > )^2 >, averaged over the sweeps in that run. M as a function of time is also plotted in the graph.

After a run, the program can be restarted to continue from where it left off, either at the old (H, T) values or new ones if you change them. Note that, as is typical with computers, everything is numbers and we've lost all the units. The convention chosen for this simulation is to measure T and H in units of J. That is, T = 3 means kT/J = 3, and H is defined such that the energies for the +1 and -1 values of S are -J H and +J H respectively. The idea is to think of the simulation as an experiment in which you are going to learn what you can about this model system, and check out some simple analytical models for its behavior.

Playing with the program

Change into my directory, and start the program:
cd
~sethna/teaching/StatPhys/ps3 
Ising
The slider package outputs new parameters to the program whenever you hit the send button. You can either move the sliders or type parameters directly into the windows.

Setting stuff up

You'll need to copy the program, shell scripts, Makefile, ...
mkdir ps3
cd ps3
cp ~sethna/teaching/StatPhys/ps3/* .
For the later parts of this problem set, you'll be making changes to the program. I'll bet, except for the most sophisticated of you, the main difficulties the first time won't be in figuring out what changes to make: it'll be in the mechanics of making the changes and recompiling the program. You'll need to know how to use an editor (vi or jove or emacs or ...). When the changes are made, presuming you haven't changed the name of the program, you can type
make Ising
and it should compile. Alternatively, you can type
cc -O -o newname newname.c ran3.o -lm

Collecting data

The program displays averages of various quantities after each sweep. You'll want to plot these versus temperature. After equilibrating at a temperature and running an average, you can copy the output line into a file (open a window and run an editor in it) using the mouse (select with the left button, insert with the middle button).

Being compulsive, I ran many sweeps per temperature (near Tc, up to 4000 sweeps, after first equilibrating for 800). Far from Tc, you need many fewer sweeps.

You can use xmgr to plot the resulting data.

xmgr -nxy data_file
will plot all the curves in datafile.

You can either edit this file to look at one curve at a time, or you can use xmgr to blow up the right regions. Make sure you can tell which curve is which!

Log-log Plots

You can use xmgr to generate log-log plots. Pick a value for Tc which is not one of the temperatures you simulated. Then, to plot log(X) versus log(T-Tc),
Edit / Transformations / Evaluate Expression / x = abs(x-Tc)
View / Graphs / Set graph type / Log-log

Links Back

Cornell Physics Undergrad Home Page
The Ising Model: The Problem Set
Entertaining Science done at
LASSP.

Last modified: September 18, 1994

Jim Sethna, sethna@lassp.cornell.edu

Statistical Mechanics: Entropy, Order Parameters, and Complexity, now available at Oxford University Press (USA, Europe).