Loading the engineShared by all simulations, so the next one opens instantly.
The physics

Fill a square grid at random, site by site, and ask when a path of neighboring filled sites first connects the top edge to the bottom. Simon Broadbent and John Hammersley posed the question in 1957, thinking of gas masks: how porous must a filter be before gas finds a way through? The answer is sharp. On a large grid, below a critical fraction pc≈0.5927 every cluster stays finite, and above it one cluster spans the whole grid, however large the grid is. The same transition describes fluid seeping through rock, current through a disordered conductor, and an epidemic that does or does not reach everyone.

What you see

A 150 by 150 grid fills up in a random order, 8 sites per frame, until the fraction of filled sites reaches the target p. Each cluster of filled sites connected through their four nearest neighbors (up, down, left, right) gets a color; the cluster that touches both the top and the bottom edge is drawn in gold. Empty sites are black.

Because the filling order is fixed for a run, the grid at any moment is a random sample at the current fill level, and watching it fill is a sweep through p. On this grid the gold cluster first appears at about 58% filled: earlier than pc in some runs, later in others, since on a finite grid the transition is smeared over a few percent.

Theory

At pc the spanning cluster is a fractal: it has holes on every scale, and its mass grows with the grid size L as

M∝Ldf,df=9148≈1.896.

Below pc the number of clusters of s sites falls off as ns∝s−τ up to a cutoff size that diverges at pc, with τ=187/91≈2.05. These exponents are exact for every two-dimensional lattice; the threshold itself is not, and is known only numerically for site percolation on the square lattice.

Presets

Below critical (p = 0.40): only small, separate clusters; nothing connects top to bottom.

At critical (p = 0.593): a spanning cluster forms after about 27 seconds of filling, once 58% of the sites are filled. At the end it holds about half of all filled sites, a ragged network with large holes and dead ends.

Above critical (p = 0.70): the spanning cluster appears at the same point and then absorbs almost everything: at p=0.70 it holds 98% of the filled sites.

Parameters

Occupation p: the target fraction of filled sites, 0 to 1. Moving it while the grid is shown fills or empties sites in the same random order, so the gold cluster can be watched appearing and breaking up around pc.

Fill speed: sites added or removed per frame, 1 to 50.

Resolution: grid size; changing it starts a new grid.