NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Sample Models/Earth Science

(back to the library)


[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web


This model shows how an oil spill can percolate down through permeable soil. It was inspired by a similar model meant to be done by hand on paper (see "Forest Fires, Oil Spills, and Fractal Geometry", Mathematics Teacher, Nov. 1998, p. 684-5).


The soil is modeled as a checkerboard of hard particles (gray squares) and semi-permeable spaces in between these hard particles (brown squares). (You may need to zoom in to see the individual squares.)

Oil cannot enter the solid gray squares, but it may pass through the brown squares.

Some soils are more porous ("holey") than other soils. In this model the porosity value of the soil determines the probability that the oil will be able to enter any given brown soil square.

The model represents an oil spill as a finite number of oil "particles", or simply oil drops.

The oil spill starts at the top of the view, and percolates downward.

The leading edge of the oil spill is represented by red squares, and every square that oil has passed through (or "saturated") is shown as black.

The oil drops sink downward through the soil by moving diagonally to the right or left, slipping between the hard gray particles.


Push the SETUP button to place the soil and start the oil spill (shown as red) at the top of the view.

Press the GO button to run the model.

The POROSITY slider controls the percent chance that oil will be able to enter each brown square, as it works its way downward.

The model can be run as long as you like; if the spill reaches the bottom of the view, the bottom row of squares is moved to the top, and the model continues to run from where it left off, starting at the top of the view. (Think of this as a camera panning downward, as necessary, to show the deeper percolation.)

The two plots show how large the leading edge of the spill is (red) and how much soil has been saturated (black).


Try different settings for the porosity. What do you notice about the pattern of affected soil? Can you find a setting where the oil just keeps sinking, and a setting where it just stops?

If percolation stops at a certain porosity, it's still possible that it would percolate further at that porosity given a wider view.

Note the plot of the size of the leading edge of oil. Does the value settle down roughly to a constant? How does this value depend on the porosity?


Give the soil different porosity at different depths. How does it affect the flow? In a real situation, if you took soil samples, Could you reliably predict how deep an oil spill would go or be likely to go?

Currently, the model is set so that the user has no control over how much oil will spill. Try adding a feature that will allow the user to specify precisely, when s/he presses SETUP, the amount of oil that will spill on that go. For instance, a slider may be useful here, but you'd have to modify the code to accommodate this new slider. Such control over the to-be-spilled amount of oil gives the user a basis to predict how deep the oil will eventually percolate (i.e. how many empty spaces it will fill up). But then again, the depth of the spill is related to the soil's porosity. Can you predict the depth of the spill before you press GO?


This is a good example of a cellular automaton, because it uses only patches. It also uses a simple random-number generator to give a probability, which in turn determines the average large-scale behavior.

This is also a simple example of how plots can be used to reveal, graphically, the average behavior of a model as it unfolds.

In the pen-and-paper activity the soil was represented by rectangles arranged in a brickwork pattern, where each rectangular cell had two neighboring rectangular cells below it. Since NetLogo's patches are always squares in an aligned grid, our replica of the model uses a checkerboard pattern instead. Can you see how the two models would have the same behavior, despite having different ways of visualizing them?


"Fire" is a similar model. In both cases, there is a rather sharp cutoff between halting and spreading forever.

This model qualifies as a "stochastic" or "probabilistic" one-dimension cellular automaton. For more information, see the "CA Stochastic" model.


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:


Copyright 1998 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.

(back to the NetLogo Models Library)