packages icon
                    Michael Creutz   
                     March 1994


This is an Xwindow program to illustrate a Monte Carlo simulation of
a simple statistical mechanical system.  The Ising model demonstrates
ferromagnetism, displaying a second order phase transition from a
disordered state at high temperature to an ordered state when cool.
The program allows dynamical observation of this system under two 
simple microcanonical Monte Carlo algorithms.

The system is a two dimensional array of spins, each of which is 
represented by a bit in a bit map displayed on the screen.  Black and
white represent the two possible states of a given spin.  The energy
of the system is entirely determined by nearest neighbor pairs.
If two neighbors are the same, then the energy has one value, and
if they differ, it is higher by two units.

The source is freely distributable.  It is available for 
anonymous FTP at []
in the directory /freehep/lattice_field_theory/xising


The program should run on anything supporting Xwindows.  If you
find an exception, please let me know.  To compile, 
"cc -O xising.c -lm -lX11" should work.  If not, possibly 
the X11 includes are not being found.  Then you need to compile 
with a -I option to where they are and possibly change the -lX11 
to help the linker.   Remember, as with any Xwindow program, 
you need to have "xhost" and "DISPLAY" set up properly.


The Xwindow display shows the spins in the image labeled "spins."
This is above another bit map labeled "changes," representing the 
spins being changed under the current algorithm.  The display
has a thermometer to indicate the temperature and various buttons 
for controlling the updating.  The inverse temperature, beta, is 
displayed above the thermometer.  The critical value for beta is 
exactly known to be 0.5*log(1+sqrt(2))=.44068.... The critical 
temperature is marked on the thermometer.

One set of three buttons, labeled "conserve E," "heat," and "cool,"
are for adjusting the temperature.  Normal running is with the
energy conserved, but to heat or cool the system press the 
appropriate button.  

Another set of buttons controls the boundary conditions.  The choices 
include "periodic," wherein the spin neighbors at an edge are those 
on the opposite edge, and "antiperiodic," which is similar but with the
the wrapped neighbors inverted.  The other two boundary choices 
are constant white or black.  The latter two are not permitted when 
the cluster algorithm, discussed below, is in operation.

The algorithm button toggles between two alternatives.  The program
starts with the "local" case as described in some detail in my paper  
Phys. Rev. Letters 50, 1411 (1983).  A set of "demons" circulates 
around the lattice trying to flip spins.  Each carries a two bit sack of 
energy ranging from 0 to 16 units in steps of 4.  Any energy change 
associated with a spin flip is compensated by a change in this sack.  
If the demon's sack cannot accommodate the change, the flip is rejected.  
The behavior under this algorithm is quite close to that of a conventional 
Metropolis et al. simulation.  The program attains its speed by updating
spins one word at a time using multispin coding and bit manipulation.

The alternative algorithm operates by constructing a large "cluster" 
of spins and flipping them in unison.  This is based on the approach
of  R.H. Swendsen and J.-S. Wang, Phys. Rev. Letters 58, 86 (1987),
as adapted to a single cluster by U. Wolfe, Phys. Rev. Letters 62, 
361 (1989).  The particular implementation here is a microcanonical 
variation I discussed in Phys. Rev. Letters 69, 1002 (1992).

The remaining buttons, "quit," and the "pause" "run" toggle are 
self explanatory.  Finally, a mouse click elsewhere in the main window
toggles on and off a short "about" message.


After starting the program, press the heat button and observe how
the domains get small and the acceptance, as shown in the "changes"
display, gets large.  Then press the cool button until the temperature,
as displayed in the thermometer, is a couple of tic marks below the
critical value.  Watch the domains grow as the system magnetizes.
Note how the acceptance is largest at the domain boundaries.

In many cases a single domain will grow to dominate the system.
If, however, bands of different phases wrap around the lattice
in either a horizontal or vertical direction, then the system
can have a hard time deciding which phase will dominate and it
can remain metastable  for a long time.  

Switching the boundary conditions to antiperiodic will force the 
system to have at least one domain wall.  Switching between black 
and white edges allows one to create large included domains which 
gradually shrink away.

Returning the system to near the critical temperature, switch to
the cluster algorithm.  In this case a few iterations quickly give
independent configurations.  Heat the system and observe how
the typical cluster size becomes quite small.  Cooling the system
below the critical temperature gives single clusters covering most
of the system, which then flashes between dominantly black and 
dominantly white.  

To illustrate the power of the cluster algorithm, use the local 
algorithm to heat the system to a high temperature and then rapidly 
quench it to somewhat below the critical value.  Before the local 
approach has had time to have the smaller domains dissolve in the 
dominant one, change to the cluster approach.  Note how quickly
the cluster sweeps anneal out the included domains.