SimulatorEducationEntertainmentDeveloper

Abelian Sandpile

Drop millions of grains on a single cell and watch a fractal assemble itself from one rule. Includes the sandpile group's identity element, four palettes, and PNG export.

0 grains

Source

Every grain dropped on one cell

Palette

5,000

Cell height

0
1
2
3

A stable pile only ever holds 0 to 3 grains per cell — a fourth always topples.

One rule, no exceptions

Every cell on the grid holds a number of grains. There is a single rule:

If a cell holds 4 or more grains, it topples — it loses four grains and sends one to each of its four neighbours. Grains that cross the edge of the grid fall off and are gone.

Keep dropping grains on the middle and toppling until nothing can topple. That is the entire model. No randomness, no physics, no tuning parameters — and yet what emerges is a fractal with nested triangular regions that looks nothing like a pile of sand.

A stable configuration can only hold 0, 1, 2 or 3 grains per cell, which is why the whole image needs just four colours. Everything you see is that four-value field.

Why "abelian"

The name comes from a genuinely surprising theorem: the final stable configuration does not depend on the order in which you topple cells. Topple them left to right, or in a random order, or all at once — the result is byte-for-byte identical. Even the total number of topplings is the same.

That commutativity is what "abelian" means, and it is not just an aesthetic fact. This simulator drops the entire batch of grains onto one cell before stabilising, rather than adding them one at a time. Under any other model that would be cheating; here it provably produces exactly the same picture, thousands of times faster. Toppling in bulk — a cell holding 4n grains topples n times in one step — is licensed by the same theorem.

The mathematics runs deeper still. Stable configurations that can be reached from an arbitrarily large pile form a finite abelian group under addition-then-stabilise, discovered by Dhar in 1990. It is a real group in the algebraic sense: associative, commutative, with inverses.

The identity element

Every group has an identity — the element that changes nothing when added. For the sandpile group it is a specific configuration on the grid, and it is one of the strangest objects in this corner of mathematics: an intricate, quasi-fractal pattern that arises from an algebraic definition with no geometry in it at all.

It is computed rather than grown, using the standard construction id = s(6·all − s(6·all)), where s is stabilisation and 6·all means six grains on every cell. Add the identity to any recurrent configuration and stabilise, and you get that configuration back unchanged.

Nobody has a closed-form description of what it looks like. The pattern changes character with grid size, and proving basic facts about its structure remains an open research problem. Select "Identity element" above to compute it.

Self-organized criticality

Per Bak, Chao Tang and Kurt Wiesenfeld introduced the model in 1987 to make a point about how nature works. Most systems reach an interesting critical state only when you tune a parameter to a precise value — the temperature at which a magnet loses magnetisation, for example. The sandpile tunes itself.

Drop grains steadily and the pile organises into a state where a single new grain can trigger an avalanche of any size. Small ones are common, huge ones are rare, and the distribution follows a power law — no characteristic scale at all. That is the signature of criticality, reached without anyone tuning anything.

The idea propagated widely because that signature turns up everywhere: earthquake magnitudes (the Gutenberg–Richter law), forest fire sizes, neuronal avalanches in cortex, traffic jams, and market crashes. Real sand, ironically, is a poor example — actual sandpiles do not show clean power-law avalanches. The model describes a mathematical phenomenon far better than it describes sand.

The scaling limit

As the number of grains grows, the pile approaches a fixed shape — proven in 2011 by Pegden and Smart to be the solution of a partial differential equation. The triangular patches are not artefacts of the grid; they persist in the continuum limit, and their structure connects to Apollonian circle packings.

What to watch for

  • The pile grows as √N. Quadrupling the grains only doubles the radius, so the picture fills the grid far more slowly than the counter suggests.
  • Fourfold symmetry, with diagonals. A single central source produces a shape symmetric under the grid's four reflections — visible immediately, and preserved at every scale.
  • Triangular patches repeat. The same motifs recur at different sizes. That self-similarity is what makes it a fractal rather than merely a complicated picture.
  • Random rain looks completely different. Scattering the source destroys the symmetry and produces a rough, uniformly critical field instead — closer to the physics the model was written for.
  • Edges matter. Grains falling off the boundary are what let the pile stabilise at all. On a closed grid it would never stop toppling.
  • Topples outrun grains. The topple counter climbs far faster than the grain counter — total toppling grows superlinearly with the number of grains added.