Science Through Thoughts

Why does this magnificient applied science which saves work and makes life easier bring us so little happiness? The simple answer runs: Because we have not yet learned to make sensible use of it.-Albert Einstein-in a speech at the California Institute of Technology, Pasadena, 1931

Saturday, July 18, 2009

MATLAB and forest fire

MATLAB is a numerical computing environment and fourth generation programming language. Developed by The MathWorks, MATLAB allows matrix manipulation, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs in other languages. Although it is numeric only, an optional toolbox uses the MuPAD symbolic engine, allowing access to computer algebra capabilities. An additional package, Simulink, adds graphical multidomain simulation and Model-Based Design for dynamic and embedded systems.

The forest fire problem that I’m going to discuss can be categorized under the class cellular automata. In this category a discrete space, discrete time, discrete values and a simple set of rules are used for update time. Forest fire is a simulation which at the end gathers information, what fraction of a forest burns on a fire depending on the density of the trees. If each point on the forest contains a tree at the beginning of the simulation the whole forest would be burnt up and if trees are separated by a significant distance only a portion of the forest would be burnt.

The forest is modeled using a grid where each grid point is one of the four sites: no tree, living tree, burning tree or a burnt tree. The next state of a particular grid point is determined by the current state of its neighbors. There are two most important definitions of “neighbor” in working with grids.


The next state of a particular grid point is determined by the following set of rules.

  • If a site has a living tree and a neighbor is burning, at the next state the current site will be a burning tree.
  • If a site has a living tree and a no neighbor is burning, at the next state the current site remains same.
  • If a site has a burning tree, at the next state the current site will be a burnt tree.
  • In any other case the site remains same as the current state.

To start building the project first a model forest was created. In this particular case a forest with square dimensions were created with N*N dimensions and each site with probability ‘p’ containing a living tree. MATLAB functions were used to visualize the forest with colors. In this particular case forest was initialized in such a way that three edges of the forest was complete treeless and the fourth edge with trees in each grid point.

  • White – no tree
  • Green – living tree
  • Red – burning tree
  • Black – burnt tree

Von Neumann neighborhood was assumed to update the forest and the simulation was driven until the fire stops. At the end of the simulation set of reading were taken in order to plot some graphs.

Graphs plotted using the data from the simulations

Graph 1 -
Fraction of trees burnt with respect to the probability of a site having a tree (200*200 grid)
Graph 2 -
number of iterations it took to completely burnout the forest with respect to the probability of a site having a tree (200*200 grid)
Graph 3 -
Fraction of trees burnt with respect to the probability of a site having a tree (500*500 grid)
Graph 4 -
number of iterations it took to completely burnout the forest with respect to the probability of a site having a tree (500*500 grid)


Video of the simulation