NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo User Community Models

(back to the NetLogo User Community Models)


by Luís César da Costa and James Steiner (Submitted: 02/28/2007)

[screen shot]

Download Example-HPP-3D
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it requires NetLogo 3D Preview 3, or later, to run.)


This model demonstrates circular wave propagation using a cellular automaton on a square grid. The behavior of the waves approximates the Navier-Stokes equation, a well established fluid dynamics equation discovered in 1823.

In the model, space is divided in to cells which are occupied by the gas particles. Each particle has the same mass and absolute velocity (each particle will move only a single cell at each time step). Space is broken up into neighborhoods of 2x2 cell squares. Collisions occur when multiple particles are in the same square and occur instantaneously, conserving both mass and momentum.

The model is implemented using a Margolus neighborhood of 2x2 cell squares in which the particles belong to two separate spacetime sublattices, propagation and collision, (sometimes refered to as "even" and "odd" lattices), which evolve independently of each other.


The CA can be summarized with the following core rules: with two cases of collisions

case 1: arrows positioned like this:

in this case, next move will cause both arrows to occupy same patch so, to detect
collision, arrows check for another arrow on the same patch with the opposite heading
after this reflection, arrows will collide again

case 2:

in this case, the next move will cause the arrows to swap places so, at no time are both arrows on the same patch if this case should be counted as a collision, if is required for arrows to check for arrow on next patch with opposite heading

It applies these rules to the even lattice of 2x2 squares followed by the odd lattice of 2x2 squares. Specifically, this means that the top left patch of four applies one of the above rules, then the bottom right patch of four does the same. To run the model in reverse, we simply switch the order of those two operations. No patch gets changed more then twice per tick. That means that each patch sees only one possible even rule and one possible odd rule each iteration.


The basic controls for the model are:
SETUP - Sets up screen with a given percentage of particles
GO - Run the model
MOVE - For move the particles with the mouse


Can you create obstacles that deflect the movement of particles?

This particular model is known as the HPP model. The HPP model is very limited. The FHP (Frisch, Hasslacher and Pomeau) model was invented in the mid-eighties in order to improve the accuracy of the HPP model. The underlying rules of the FHP model are similar to that of the HPP model except that the FHP model has a symmetry-group order of six. The hexagonal lattice allows for more advanced modeling, such as hydrodynamical simulations. Can you write a model that emulates a hexagonal lattice in NetLogo?


In order for the algorithm to operate correctly, the size of the lattice must be even in both dimensions. However, the current version of NetLogo only supports odd sized grids. Therefore, it was necessary to add special code to this model to ignore the top row and rightmost column of the grid, effectively converting an odd-sized grid into an even-sized one.

See also the "Even Grid Example" and "Lattice Gas Automaton" in the Code Examples and Chemistry & Physics sections of the Models Library.


Thanks to Ethan Bakshy for his help with this model.

For more information about lattice gas automata, see:

J. Hardy, Y. Pomeau & O. de Pazzis, Time evolution of two-dimensional model system. I. Invariant states and time correlation functions, J. Math. Phys. 14 (1973), pp. 1746-1759.

U. Frisch, B. Hasslacher & Y. Pomeau, Lattice-gas automata for the Navier-Stokes equation, Phys. Rev. Lett. 56 (1986), pp. 1505-1508.

T. Toffoli and N. Margolus. 1987. "Cellular Automata Machines: A New Environment for Modeling".

Wolfram, S. 2002. A New Kind of Science. Wolfram Media Inc. Champaign, IL.

To refer to this model in academic publications, please use: Wilensky, U. (2002). NetLogo Lattice Gas Automaton model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use: Copyright 2002 by Uri Wilensky. All rights reserved. See for terms of use.

(back to the NetLogo User Community Models)