Xising

                    Michael Creutz   
                    creutz@bnl.gov 

WHAT IT IS:

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 several
simple 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
grey 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 program source is freely distributable.  The latest version is
kept on our WWW server at

  "http://thy.phy.bnl.gov/www/xtoys/xtoys.html"

along with some related programs.

COMPILING:

The program should run on anything supporting Xwindows.  If you find
an exception, please let me know.  To compile, try the xtoys Makefile.
Otherwise, "cc -O -o xising -L/usr/X11R6/lib xising.c -lm -lX11"
usually works.  On Sun workstations the X stuff is in an
unconventional place; try "cc -O -I/usr/openwin/include
-L/usr/openwin/lib newxising.c -lm -lX11".  Replacing "cc" with "gcc"
may also help.  If either of these doesn't work try using the makefile
found at the above web site.  If you still have problems, possibly the
X11 includes are not being found.  Then you need to compile with a -I
option to where them 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 to run it.

WHAT THE SCREEN SHOWS:

The 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 "run free," "heat," and "cool," are
for adjusting the temperature.  Normal running is with the
energy/temperature conserved, but to heat or cool the system toggle
the appropriate button.  In a canonical mode (see below) the
temperature can also be adjusted by clicking on the thermometer.

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 a "local" updating scheme.  This can be toggled into a
variation of the "cluster" algorithm of R.H. Swendsen and J.-S. Wang,
Phys. Rev. Letters 58, 86 (1987), where a large block of spins is
grown and then flipped in unison.

At the bottom of the display is a button that switches between a
canonical and a microcanonical updating.  The latter case is 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.  In this mode the temperature is not
fixed, but calculated from the average demon energy.  Note the thermal
fluctuations on the thermometer when in a microcanonical mode.  The
microcanonical version of the cluster algorithm is discussed in
Phys. Rev. Letters 69, 1002 (1992).

The program attains its speed by updating spins one word at a time
using multispin coding and bit manipulation.  The canonical modes are
obtained by allowing the demons to be occasionally refreshed by
visiting a heat bath.  When in one of these, a mouse click near the
thermometer will adjust the temperature to the value pointed at by the
cursor.  Clicking elsewhere in the main window when the system is
paused with any algorithm does a single step.  The remaining buttons,
"quit" and "pause" should be self explanatory, as should the "speed"
slider.  The lattice dimensions can be adjusted by resizing the
window.

SOME EXPERIMENTS:

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 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 forces 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 spin up and 
down.  

To illustrate the power of the cluster approach, 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.