Barista's Secret

by Dirk Brockmann

This explorable illustrates a process known as percolation. Percolation is a topic very important for understanding processes in physics, biology, geology, hydrology, horstology, epidemiology, and other fields. Percolation theory is the mathematical tool designed for understanding these processes.

Percolation is best understood in terms of the following physical situation: Let's say you have a porous medium, e.g. ground coffee in your percolator or porous soil of some depth. You pour a liquid on the medium and would like to know whether the liquid can make it through the medium and if so how this depends on the porosity of the medium (i.e. the fraction of the material that is empty).

The model

The situation can be modeled by a two-dimensional square lattice in which individual sites can be occupied by the medium (e.g. a grain of ground coffee and depicted in black above) or they can be empty (depicted in white). The porosity \(p\) is the fraction of empty sites. The liquid (depicted in blue) can pass through the medium across adjacent empty sites. By adjacent we mean the 4 next neighbors (north-west-south-east) of a site in a square lattice.

Asking "Does the liquid make it all the way to the bottom?" is then equivalent to asking "Is there a path of adjacent empty sites that connects top and bottom?". It turns out that this is an easy question that, however, is tyically very difficult to answer. The particular system above (square 2-d lattice with 4 neighbors) has a critical porosity


and if \(p < p_c\) the liquid almost never makes it to the bottom, whereas if \(p > p_c\) it almost always does. This is why \(p_c\) is called a percolation threshold.

How it works

Intially the system is set up such that every site is occupied with a probability of \(1-p\). You can vary the porosity with slider in the control panel. Liquid is supplied continuously at the top layer. At every interation the liquid expands to all empty neighboring sites until no more empty sites can be reached. For sufficiently high porosity, the liquid will make it all the way to the bottom. If \(p\) is too small the liquid doesn't get very far.

You start the simulation by pressing the play button. Press the reload button to re-initialize the system.

Try to find the critical porosity \(p_c\), the point at which the liquid sometimes makes it to the bottom and some times does not.

This explorable has Orli's magic switch to make things prettier. For an explanation of it, check out the Explorable Orli's Flock'n Roll.

Difficult math

Although the model above is conceptually straightforward and can be easily generalized to more than 2 dimensions and other types of lattices, e.g. hexagonal and triangular lattices, and more esoteric types of lattices, computing the value of \(p_c\) is mathematically quite challenging in most cases and for many systems the exact value is still unknown. Entire books have been written about it.


The physical metaphor of a liquid expanding through a porous medium is only one way to think of percolation. Another application is the spread of infectious disease in which the liquid becomes an infectious disease, empty sites are susceptible individuals and occupied sites are immune. In this case the percolation threshold is the epidemic threshold.

Another application is the dynamics of forest fires in which the liquid is a fire that expands across an area of vegetation and the porosity is equivalent to the density of trees.