Program for simulating the two-dimensional forest-fire model

Program for simulating the two-dimensional forest-fire model


Stationary state for f/p = 1/500 on a 608x608 lattice.


Warning: No liability whatsoever is taken for any damage caused by the information or the program provided here. Neither can correctness of either issue be legally guaranteed.


Introduction

This page intends to explain how to use the software to display a simulation of the two-dimensional forest-fire model on an X11 display. However, the code can also be used to do `real' simulations, and in fact some older versions of it have been used to perform the simulations in [1]. If you intend to make extended use of it in this or a similar way, you might find the information provided here insufficient. In this case, just send me a message and I will give you the necessary information.

The forest-fire model simulated by this program is defined on a quadratic lattice. Any site can have two states: It can either be empty or occupied by a tree. A Monte-Carlo step consists in selecting a site and applying the following update rules to it:
a) If it is empty, grow a tree with probability p=1.
b) If it is occupied by a tree, delete the entire geometric cluster of trees connected to it with probability f.

There are other versions of the forest-fire model. Originally, it was formulated as a three-state model with empty places, trees and fires and without a rate for lightnings [2]. This model is in the meantime in general not believed to be really critical, but rather deterministic [3,4]. However, there is some code by Michael Creutz implementing this older model [5] and it might be nice to look at simulations of it as well. In order to do so, get xfires of the xtoys collection and compile it.

How to obtain the program

  1. Get this archive with the complete sources.
  2. Unzip it using `gunzip' or `gzip -d'.
  3. Unpack it using `tar'.
  4. Type `make' to create the executables.
This program may be freely distributed and changed, provided that your changes are marked clearly and the notice in the header of the source remains unchanged.

Some remarks on the implementation

During the simulation, the state of the system is stored in words of 32 bits length such that each bit encodes the state of one lattice site. This does not only save memory (compared to storing the state of each site in a byte), but also speeds up the computation. This is mainly achieved by reducing access to external memory (making full use of the width of the data bus of recent computers when accessing the state of the system) and by using lookup tables for counting processes involved in computing global averages. For example, along the vertical axis the the correlation of all 32 sites in a word can be obtained by performing a logical `and' of the words.

Random number generation is needed only for the selection of a site and update rule b) because we have set p=1. In any case, the generation of random numbers needs only a small fraction of the time in the simulation. The two operations that consume most of the time are the following ones:
  1. Determination of the the two-point function C(y). Even when using the just mentioned word-and of two locations and lookup-tables, one needs three nested loops: One over all vertical positions, one over all horizontal word positions and one over all displacements y up to the maximal one. The option `-m' has been included in order to make at least the last loop as short as possible. Even then, these three nested loops had a total length of up to around 1010 in order to compute the contribution of one configuration to C(y) during the simulations of [1].
  2. Determination of the geometric clusters.
In order just to update the system, the main problem is the latter point, because for update rule b) one has to determine a geometric cluster. This determination of geometric clusters is a known filling problem which we solve by a recursive procedure moving from an occupied site to the four neighbours. Here, word access technologies would not help very much because it is known that the clusters are not compact (compare also the above picture).

The determination of quantities associated to clusters involves the destructive procedure of filling each cluster present in the system. This is a substantial additional effort in CPU-time and memory (not just because one needs a second copy of the system). During the filling procedure the coordinates of each tree in the cluster are stored. The contribution of small clusters (up to a few hundred trees) to K(y) is most efficiently directly extracted from this data. However, for larger clusters it is much more efficient to regroup the coordinates of the trees according to their x-coordinate and to extract the probability to find two trees with the same x-coordinate at a vertical distance y from this regrouped data. The former procedure is obviously most efficient for clusters containing only a single tree (which appears very frequently). However, the time needed in this procedure grows as s2 with the size s of the cluster. This can be reduced to an effort growing roughly as s3/2 by adding the regrouping procedure.

Warning: I have been lazy when writing the code for the filling problem and have used the stack for it. If you wish to do simulations for small f/p you have to set the stacksize as high as possible or you will get a ``Segmentation fault''.

This program has been mainly tested on DECalphas. If you notice any problems with other X11 platforms, please let me know such that I can fix them.

Usage of the program

There are two versions of the simulation program. `forest' is the more comprehensive one, `forestnc' is more restricted, but needs less memory and is the one you should use (at least at first).

The program is controlled via several options (type e.g. `forest -o' for a full list). The most important ones for displaying a simulation are `-s' to show something at all, `-f' to change the values of the control parameter and `-w' and `-h' to set the size of the system. These last two should always be specified.
For a complete list of options see here.

A description of the files created and used by this program can be found here.

Note that the program prints some information to standard output before actually starting the simulation.

To show a simulation on the screen, start the program with the option `-s'. The X11 window contains two parts: The top one displays the state of the system. Trees are black and empty places white. A smaller area below it displays the density of trees as a function of time. This latter information can be useful to determine how far the simulation has proceeded and if one is close to the stationary state (then it should fluctuate only very little).

Inside this window you can press the following keys:
P: Save the current state of the system in a file snapshot.lj. This file can be copied in binary form to a printer understanding HPGL. In my opinion, this is the most efficient way to make a printout.
Q: Disables displaying the state of the system. This can be used to quickly get to a later stage of the simulation.
S: Show the state of the system again. It may happen that such a key press gets stuck somewhere in the X11 messaging queues. If the display should not have been re-enabled after some time, try to expose the window e.g. by closing and opening it again - this usually helps.
X: Terminate the simulation.

If you wish to store the state of the system in an image file, you can e.g. use the `Grab' function of xv. Start xv, select `Grab' and then create a rectangle inside the simulation window e.g. in the white border around the state of the system using the middle mouse button (actually, this is one of the purposes of the white boundary). Afterwards select `Autocrop' in xv and you have a picture that you can save and print in many different ways.

Example:

We wish to perform a simulation from which the above picture could have been taken. A suitable full command is:
  forestnc -w608 -h608 -f2000 -s
The options `-w' and `-h' set the system size to 608x608. With `-f2000' the control parameter f/p is set to 1/500. The option `-s' tells the program to show the simulation in an X11 window. Without this latter option you would not see anything. The command `forestnc' is used instead of `forest' because it uses less main memory and disk storage. `forestnc' is unable to compute cluster quantities, but this shouldn't matter if you just wish to see a simulation.
Note that some information is stored in files during and at the end of the simulation. Therefore, you must be in a writable directory when invoking the simulation.

Comment on possible improvements

As already indicated, the determination of the clusters is one point where by re-writing the filling procedure one could probably somewhat speed up the present code.

However, it seems that at present a substantial lapse in the available data (or accessible system size) and thus an improvement of the accuracy considerably beyond [1] would be possible only on a parallel computer with around 102 nodes. However, the program discussed here is certainly not well suited for parallelization. In particular, writing some code for the determination and evaluation of the geometric clusters that does not need much communication between and synchronization of the processors would require efforts considerably beyond what this program was originally intended for.

Bug in original version

The original version contained an error in the implementation of periodic boundary conditions at the upper boundary of the system. This error has been corrected in the version which can be downloaded from this page. The corrections are marked in the source file forest.c with comments `Wrong !!!!!' and `Corrected'.
We have performed some tests in order to assess the impact of the error and so far obtained no indications that it would affect the results of [1].

References

  1. A. Honecker, I. Peschel, Length Scales and Power Laws in the Two-Dimensional Forest-Fire Model, Physica A239 (1997) 509-530
  2. P. Bak, K. Chen, C. Tang, A Forest-Fire Model and Some Thoughts on Turbulence, Phys. Lett. A147 (1990) 297-300
  3. P. Grassberger, H. Kantz, On a Forest Fire Model with Supposed Self-Organized Criticality, J. Stat. Phys. 63 (1991) 685-700
  4. B. Drossel, W.K. Moßner, F. Schwabl, Computer Simulations of the Forest-Fire Model, Physica A190 (1992) 205-217
  5. M. Creutz, Xtoys: Cellular Automata on Xwindows, preprint hep-lat/9508029, BNL-62123

July, 4th, 1997
Last modification: May, 5th, 2000
a.honecker@tu-bs.de