Click on Ising Program to see an example of a 2D Ising model Monte Carlo program based on the one found in "An Introduction to Computer Simulation Methods" by Gould and Tobochnik.
The Ising model is perhaps the simplest model of magnetism which has a phase transition between a ferromagnetic phase at low temperatures and a paramagnetic phase at high temperatures. In this program you can choose between a canonical ensemble using the Metropolis algorithm or the microcanonical ensemble using the Demon algorithm. Up spins are red on the screen and down spins are green.
In the following files you can find all the code used to create this Java Applet as well as the code to convert to a Java Application. The Applet uses the simphyPackage. The classes IsingApplet (for the Applet) and Ising (for the application) set up the simulation by providing direction to any buttons pressed or numbers entered into any TextField. The class IsingLattice then does all the work of drawing the Ising lattice, flipping spins, collecting and displaying data, and setting up new configurations.
The Applet does not work on my version of Netscape for the Macintosh, but works fine using Internet Explorer and Netscape for Windows. Below are the source listings.
RND Class(random number generator)
Ising Class(Application version)