Abelian Sandpile Simulator

Four grains is too many, so it spills, and art appears.

  • Millions of grains
  • Sandpile addition
  • Avalanche statistics
A square tabletop mosaic of tiny tiles in four colors forming an intricate symmetric fractal pattern, seen from above at an angle

The guide

The Sandpile Was Sold as a Theory of Everything. Its Lasting Value Is That the Order Does Not Matter

A toy model from 1987 promised to explain noise in nature. What mathematicians kept from it is stranger and firmer: a pile of grains that can be added like numbers.

  • 1987 Bak, Tang and Wiesenfeld publish the sandpile
  • 4 grains on one cell make it topple, one grain to each neighbour
  • 192 recurrent piles on a 2 by 2 grid, a group under addition
  • 77,107,818 topplings to settle 65,536 grains dropped on one cell
  • 6/5 and 5/4 conjectured avalanche exponents, still unproved
Read the full guide Fold the guide 8 min · 14 sources

Put grains of sand on the squares of a grid. A square that holds 4 grains or more is too full: it gives one grain to each of its four neighbours and keeps the rest. Repeat until every square holds three or fewer. That is the whole model. It has occupied physicists and mathematicians for nearly forty years. The two groups wanted different things from it. Physicists hoped it would explain why so much of nature looks the same at every scale. Mathematicians found that the pile obeys an arithmetic of its own. The argument here is that the second discovery has aged better than the first, and that the pictures are honest evidence for it.

A model built to explain everything

Per Bak, Chao Tang and Kurt Wiesenfeld introduced the model in 1987, in a paper whose title promised an explanation of flicker noise. Their idea was that a slowly driven system could tune itself to the edge of instability with nobody turning a dial. Drop grains at random and the pile grows until it is just barely stable. After that, one more grain may do nothing at all, or it may start an avalanche that crosses the whole grid.

They called the idea self-organized criticality. In an ordinary critical point, such as a magnet at the temperature where it loses its magnetism, someone has to set the temperature exactly. Here the system was meant to find that point alone. If that happened widely in nature, it would account for the many measurements whose big events and small events follow one power law.

The reach of that claim is disputed, and it should be said plainly. A review written by five authors twenty five years later, sympathetic to the idea, has a section titled with the question of why it is controversial. Their answers include confusion between the thing to be explained and the mechanism proposed for it, the habit of treating any power law as proof, and the fact that solid evidence for scale invariance in nature, outside tuned phase transitions, is quite limited.

The same review notes that many such models are highly idealized and do not try to capture the real forces in a natural system. A grid of counters that pass tokens to their neighbours is not a beach. Nothing in what follows depends on pretending that it is.

Why the order of toppling does not matter

Three years after the first paper, Deepak Dhar noticed the property that gives the model its modern name. When several squares are too full at once, it makes no difference which one topples first. Any order ends in the same stable pile.

The reason is short. A toppling never takes grains from a neighbour, it only gives. So if two squares are both ready to topple, toppling one cannot make the other less ready. Swap two steps in a sequence and both are still legal. From that small fact a careful proof shows that every legal sequence of topplings has the same length and topples each square the same number of times, and so leaves the same pile.

A consequence follows at once. Adding a grain here and then a grain there gives the same result as adding them the other way round, because both are ways of stabilizing the pile that has both grains on it. Addition of grains commutes. Mathematicians call a commuting operation abelian, and Dhar named the model for it.

There is a sharper statement, which Dhar called a least action principle. The number of times each square topples in a legal sequence is the smallest number that could possibly stabilize the pile, square by square. Even if illegal moves were allowed, with squares going into debt along the way, no plan that ends stable could ask less of any square. The pile never does more work than it must.

This is the part you can test with your own hands. Take a small grid, load it with grains, and topple one square at a time in three ways: always the first unstable square in reading order, always the last, or one picked at random. The intermediate pictures differ completely. The final pile, the number of topplings and the number of grains lost over the edge are identical every time.

A pile you can add like a number

On a finite grid, grains that topple over the edge are gone, so every pile eventually settles. That allows a kind of sum. To add two stable piles, add them square by square and then let the result topple until it is stable again.

Not every stable pile behaves well under this sum. Some piles can be reached again and again as grains keep arriving; they are called recurrent. Others can only appear early and never return. The empty pile is one of those: once two neighbouring squares have held sand, they can never both be empty again, because the last of the two to topple receives a grain from the other.

Restricted to the recurrent piles, the sum is a genuine group, the sandpile group. Every recurrent pile has an inverse, and one recurrent pile acts as zero. The size of the group is a classical number, the count of spanning trees of a slightly larger grid; the link, due to Majumdar and Dhar, runs through the burning test described below. On a 2 by 2 grid there are 256 stable piles, and 192 of them are recurrent. On 3 by 3 the count is 100,352.

How do you tell whether a pile is recurrent? Dhar gave a test with a vivid name. Set fire to the border. A square burns when it holds at least as many grains as it has unburnt neighbours, and burning spreads until nothing more can catch. The pile is recurrent exactly when every square burns. The full pile of all threes passes at once. The empty pile fails at once.

The zero of the group is the strangest object in the subject. It is not the empty pile, which is not even in the group. A known recipe produces it: fill every square with six grains, stabilize, subtract the result from the all sixes pile, and stabilize again. On a 2 by 2 grid the answer is two grains on each square, 8 grains in all. On larger grids it is an intricate figure with nested squares and curved lace, and adding it to any recurrent pile leaves that pile exactly as it was. Add it to a pile that is not recurrent and the pile changes, which is a second way to run the test.

What the pictures prove, and what they do not

The most famous picture needs no border at all. Drop a large number of grains on one square of an endless grid and let them spread. Try it with 16 grains and you can check the result by hand: nine topplings, twelve squares left holding sand. With 65,536 grains the pile settles after 77,107,818 topplings into a rounded patch about 189 squares across, filled with triangles, stripes and curved bands in four colors.

Enlarge the count and the patch grows, but the design seems to stay the same. That impression is now a theorem. Wesley Pegden and Charles Smart proved that the pile, shrunk by the square root of the number of grains, converges to a single limit, and described that limit through an equation from the theory of obstacle problems. With Lionel Levine they then showed that this equation has solutions built like an Apollonian circle packing, which accounts for the fractal look.

What is proved is narrower than what the eye reports, though. The convergence is in an averaged sense, not square by square. When the first theorem appeared, its authors pointed out that nobody could yet prove the limit has regions of constant height three, or even that its outline is not a circle. The shape is trapped between bounds: for a pile of n grains, written as pi times r squared, every square within r divided by the square root of 3 is reached, and nothing beyond about r divided by the square root of 2 is.

The identity figure is in a weaker position still. Its pictures on larger and larger grids look alike, and a limit has been conjectured, but a survey by six authors observed that even its most obvious feature, the large square in the middle, had no proof. A picture is evidence. It is not an argument.

Measuring avalanches without fooling yourself

Return to the physicists’ experiment. Drop grains one at a time at random squares of a bordered grid and record each avalanche: how many topplings, how many distinct squares, how many rounds. Plot how often each size occurs on axes that are both logarithmic, and the middle of the plot is close to a straight line. A straight line on such axes is a power law.

The slope of that line is where care is needed. On a grid 65 squares wide, twenty thousand grains give a slope near 1.06 for avalanche size when the fit runs from 10 topplings to 422. Move the range and the number moves. The largest avalanches are cut short by the border, so the line bends down at the right, and how far the straight part extends depends on the grid.

Nor is there a settled value to compare against. Dhar’s review states that the avalanche exponents of this model in two dimensions are still unknown, that numerical estimates have covered a wide range depending on the method, and that the conjectured values are 6/5 and 5/4, for the number of topplings and the number of distinct squares. It adds that the simple scaling picture behind those values has itself been challenged, because avalanches that reach the border seem to behave differently from those that do not.

So a slope read from a simulation is a measurement on one grid over one stated range. It is not the exponent. Anyone who reports it without the grid size and the range has reported nothing.

The model cannot tell you whether earthquakes or forest fires organize themselves this way. It cannot yet tell you its own exponents. What it does give is rarer in a subject that began as physics: statements that are exactly true and can be checked on a screen in a second. Topple in any order. Add the identity. Burn the border. The answers never vary.

Sources

Every source consulted for this guide. Links checked October 10, 2026.

  1. Abelian sandpile model Wikipedia
  2. Self-organized criticality: An explanation of the 1/ f noise OpenAlex catalogue record W2075514521 (Per Bak, Chao Tang and Kurt Wiesenfeld, Physical Review Letters, vol. 59, no. 4, pages 381 to 384, 1987)
  3. Self-organized critical state of sandpile automaton models OpenAlex catalogue record W2037190943 (Deepak Dhar, Physical Review Letters, vol. 64, no. 14, pages 1613 to 1616, 1990)
  4. Studying Self-Organized Criticality with Exactly Solved Models arXiv cond-mat/9909009 (Deepak Dhar)
  5. Chip-Firing and Rotor-Routing on Directed Graphs arXiv 0801.3306 (Alexander E. Holroyd, Lionel Levine, Karola Meszaros, Yuval Peres, James Propp and David B. Wilson)
  6. Convergence of the Abelian sandpile arXiv 1105.0111 (Wesley Pegden and Charles K. Smart)
  7. Apollonian structure in the Abelian sandpile arXiv 1208.4839 (Lionel Levine, Wesley Pegden and Charles K. Smart)
  8. Strong Spherical Asymptotics for Rotor-Router Aggregation and the Divisible Sandpile arXiv 0704.0688 (Lionel Levine and Yuval Peres)
  9. Growth Rates and Explosions in Sandpiles arXiv 0901.3805 (Anne Fey, Lionel Levine and Yuval Peres)
  10. 25 Years of Self-Organized Criticality: Concepts and Controversies arXiv 1504.04991 (Nicholas Watkins, Gunnar Pruessner, Sandra Chapman, Norma Bock Crosby and Henrik Jensen)
  11. Sandpile models arXiv 1401.0354 (Antal A. Jarai)
  12. A007341: Number of spanning trees in n X n grid The On-Line Encyclopedia of Integer Sequences
  13. A307652: The number of grains of sand in the identity element for the sandpile group on an (n+1) X (n+1) square grid The On-Line Encyclopedia of Integer Sequences
  14. A349990: For any n >= 0, consider a sandpile model on the infinite square lattice starting with n grains at the origin, the other sites being empty; a(n) gives the number of nonempty sites after stabilization of this sandpile model The On-Line Encyclopedia of Integer Sequences