Aulab by Michael Creutz Physics Department Brookhaven National Laboratory Upton, NY 11973 creutz@bnl.gov Aulab is a windows simulation of a variety of simple lattice simulations. It is adapted from the xtoys package for xwindow machines. The program starts up in a totalistic cellular automaton rule mode. The Model menu gives access to three other modes: sand, Ising, and fire. I describe the various modes in more detail below. The descriptions are adapted from the xtoys package .txt files. The program is written in C++. I have compiled it with the cygwin tools. To compile, using g++ with the flags "-mwindows -mno-cygwin -e _mainCRTStartup -Wall -O2 -s -lwinmm" should do it. You might try the makefile from the aulab directory. The latest versions of this and the xtoys package are kept at http://thy.phy.bnl.gov/www/xtoys.html Mike creutz@bnl.gov -------------------------------------------------------------- The Totalistic Rule: Play God over your own universe. With AuLab you control the micro-physics of a discrete world of cellular automata. This two-dimensional land is an array of cells displayed as pixels on the screen. Each cell can be alive or empty, with evolution occurring in discrete time steps. Empty cells are black, newborn ones are red, older living ones are blue, and cells that have just died are green. When the tracer is turned on, old life leaves a legacy by shading the background color. In one time step, the fate of each cell depends on the number of living neighbors. Using Boolean gadgets, you control when a new live cell will be born on an empty site and when a living one will survive. Another gadget lets you pick which neighbors, up to the eight nearest neighbors, are counted. To be more precise, if a particular birth gadget is set and if that number of selected neighbors to a dead cell are alive, then that cell will become alive on the next time step. If a survivor gadget is set, then a living cell with that number of live neighbors will survive the updating. With mouse selections you determine whether the boundary of your universe is dead, alive, or periodic. A final boundary choice, called "flow," is alive on the bottom and dead on the sides and bottom. When the system is paused (under the speed menu), a click outside the play-field or any specific gadget will update the system a single step. Finally, you can toggle individual cells on and off by pressing a mouse button and sketching over your world. The save option of the file menu saves the current configuration in a file "aulab.bmp," a standard bmp file that you can print or manipulate with any graphics program that likes bmp files. The restore gadget will reload a previously stored configuration. The rule used to create a stored configuration is not itself stored or restored. Note that for the save feature to work you need write permission on the directory from which you are running. The scale menu determine how many screen pixels are used per cell. This defaults to two. The window can also be resized to give different lattice sizes. With the eight neighborhood there are 18 birth/survivor buttons. This means there are 2^18=262,144 possible rules in this case. Other neighborhoods give add more, all selectable with the mouse. Indeed, it is unlikely that you will be able to try them all. In addition, the number of possible universes is further doubled using the "xor past" gadget, which probably needs some explanation. When this is activated, the new state is finally XOR'ed with the history one time step back. Thus if a cell was alive in the past, the new state is the opposite of what the birth and survivor gadgets want. The reason for doing this is to produce reversible rules. If the history and current states are interchanged, the system will go backwards through the sequence of configurations from which it came. An analogy is reversing all the momenta of a bunch of atoms. This interchange is accomplished by the "reverse" gadget, which interchanges young and moribund cells. Without the xor past gadget set, the reverse gadget does not appear. If this seems confusing, try this: With the xor past gadget set, clear the screen, draw some small picture, select a random rule from the birth and survivor gadgets, and let the system evolve until the screen becomes a mess. Then hit the reverse button and watch the initial picture reappear. Try repeating this experiment, but alter a single pixel with the mouse at the time of the reversal. The starting rule is one I particularly liked at the time I last updated the program. It may change with further updates. Watch it for a while and then try other things. (at the moment it is life with an initial line of set pixels} A particularly well known rule is Conway's classic cellular automaton model "life." This uses the eight cell neighborhood and a new cell is born for exactly three live neighbors, while a living cell dies with less than 2 (lonely) or more than 4 (overcrowding) neighbors. Another well-known rule is Fredkin's modulo two model which uses the 4 cell neighborhood. Here a state flips if it has an odd number of active neighbors and is unchanged otherwise. Start with some small picture and observe how the initial state is replicated. If you want to try a rule running from a random start, run for a while with some chaotic rule (i.e. most rules with births on one neighbor) and then switch to your rule of choice. Aulab is based on Xautomalab which in turn is based on my earlier Amiga program Automalab, which appeared on the May 1991 issue of Jumpdisk. That version used direct access the Amiga graphics chips for speed. Comparing the latter versions to the previous illustrates the awesome power of the Amiga Blitter. If you have an Amiga and want a copy of Automalab, check in the WWW site mentioned below. This program and some related things are available via "http://thy.phy.bnl.gov/www/xtoys.html" on the World Wide Web. It is still evolving, and the latest version can be found there. This program and source is freely distributable. ---------------------------------------------------- The Fire Rule: This rule simulates forest fires. On each site of a lattice is either nothing, a tree, or a fire. In one time step a fire spreads to adjacent trees and leaves an empty space. Trees are born in a random matter with a probability of approximately 1/32 per time step. If no fires are active, one is started at a random location. Fires can also be started with the mouse button. The Amiga version of this program was published in the Dec. 1993 issue of Jumpdisk. -------------------------------------------------- The Ising Rule: This illustrates a Monte Carlo simulation of a simple statistical mechanical system. The Ising model demonstrates ferro-magnetism, 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 in a bit map displayed on the screen. Black and red 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 inverse temperature, beta, is displayed and updated every few iterations. The critical value for beta is exactly known to be 0.5*log(1+sqrt(2))=.44068.... Two buttons, labeled "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. The lattice dimensions can be adjusted by resizing the window. The basic algorithm, a microcanonical scheme, is described in my paper Phys. Rev. Letters 50, 1411 (1983). A "demon" circulates around the lattice trying to flip spins. He carries a sack of energy. 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 an input, but calculated from the average filling of the sack. After starting the Ising rule, 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. 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. ---------------------------------------------------- The Sand Rule: This rule simulates the sandpile automaton of Bak, Tang, and Wiesenfeld. This is a simple model originally presented to illustrate the concept of self organized criticality. The xwindow version of this program generated the pictures on page 46 of Briggs' book "Fractals -- The Patterns of Chaos." Additional pictures from this program appear in my article with Per Bak appearing in "Fractals and Disordered Systems" (Springer-Verlag, 1994). The updating rule is extremely simple. On each cell of an initially 198 by 198 lattice is an integer amount of sand between 0 to 7, inclusive. If this value exceeds 3, that cell is regarded as "unstable" and for the next time step it takes four of its grains of sand and places one on each of its neighbors. The updating is simultaneous for all cells. The total amount of sand is conserved except at the boundary. The basic idea of self organized criticality is that, after lots of random addition of sand followed by relaxation, the system will automatically enter a critical state where the size of an avalanche created by additional sand addition is unpredictable without actually running the process. The sizes of the ensuing avalanches statistically have a power law distribution without any characteristic scale. The screen opened by the program has lots of gadgets on it. Resizing fills the lattice with the selected pen color. Fill: Fills the lattice with the current pen color (height). Trace: When this is active those sites which "tumble" by being stable are flagged and colored differently when they become stable. In this way you can trace where an avalanche has gone. Clear Trace: This clears the flagged sites to their normal color. Double: This doubles all heights modulo 8. This is a convenient way to quickly add lots of sand. The color bar: This shows the colors by which the various heights are shown. These squares are also gadgets, and by clicking on one of them the corresponding color becomes the current pen color, shown in the small box near the color bar. If any mouse button is pressed while over the lattice, you can sketch with this color. To start an avalanche, just select a color larger than 3. Some experiments: 1. With the mouse, scribble some sand randomly on the system. Then repeatedly hit the double button to fill the lattice with a random mess. Wait a few minutes until the system stabilizes and activity ceases. Now you should be in the critical ensemble. Make the active color 4, and click the mouse over the lattice. This will start an avalanche, which unpredictably might be large or small. After a few avalanches, turn on the trace button and make some more. Now you can follow where the avalanche has passed. Note that the avalanche regions always wind up simply connected, with no untumbled islands left over. This is a theorem, and is true for any state in the critical ensemble, but not an arbitrary state. Select height 0 or 1 for the pen, scribble over a small region, and then go back to making some more avalanches. Now it should be easy to make islands. By removing some sand you have left the critical ensemble. 2. Select height 0 and clear the system. Then make the boundaries full until the system fills up and nothing changes any more. Switch back to empty boundaries to let the excess sand run off. Try doubling the final state and letting it relax back. Note that it returns exactly to itself. This state is the unique one in the critical ensemble with this property. Group theoretically this state represents the identity. 3. Fill the system with height 2. Now draw a picture with height 3. Put the boundaries full for a few moments, and then open them up again. Note how the picture is restored after the avalanche ends. This is a property of any state in the critical ensemble. Indeed, this is a way to test that a state is critical. Try drawing some more with height 0 or 1. Depending on the picture, the above experiment may or may not mess up your picture. 4. Save the identity from experiment 2. Draw a picture using only heights 2 and 3, as in the previous experiment. Use the "add" option from the file menu to add in the identity. After a while your picture should magically reappear. 5. Fill the system with height 2 and go to periodic boundaries. Sketch a bit with height 4. With enough sketching, the avalanches will no longer stop. The resulting dynamics can be hypnotic. Sandpile references: P. Bak, C. Tang and K. Wiesenfeld, Phys. Rev. Lett. 59, 381 (1987). D. Dhar, Phys. Rev. Lett. 64, 1613 (1990). M. Creutz, Computers in Physics 5, 198 (1991).