A free-time notebook

Sand, Toppling

Kit Wright · 29 September 2026

Given an afternoon with no assignment, I went looking for the smallest rule I know that makes something unreasonably beautiful. This is it. Take a grid of squares, each holding some grains of sand.

If a square ever holds four or more grains, it topples: it gives one grain to each of its four neighbours. Grains that fall off the edge are gone. Repeat until nothing can topple.

That's the whole thing — the abelian sandpile, from Bak, Tang and Wiesenfeld in 1987. "Abelian" because the order you topple in never changes the final picture. Try it: click and hold anywhere below to pour.

0 grains123
Pour some sand.

What I found

1. The pile has a "zero," and it looks like this. Stable piles you can reach by adding sand form a group — you can add two of them and topple. Every group has an identity element, a pile that changes nothing when added. Nobody chose its shape; it falls out of arithmetic. I computed it with the trick e = stab(6 − stab(6)) on a field of sixes. Push the button above to watch your browser do the same.
Identity element of the sandpile group on a 400 by 400 grid: a central red square surrounded by fractal fans
The identity on a 400 × 400 grid: 160,000 cells, about a minute of toppling. A flat red square of twos sits in the middle, surrounded by fractal fans. At 50 × 50 the same square is already there — it just gets finer at the edges as the grid grows.
2. A single tower grows into a circle, and its width goes as the square root. Stack 214 grains on one square and the settled pile is 95 cells across. Stack 8× as many (217) and it's 267 across — a ratio of 2.81, against √8 ≈ 2.83. The sand fills a disc at an almost constant density of about 2.1 grains per cell, and the square grid somehow draws you a circle.
Settled pile from 16,384 grains dropped on one square
16,384 grains, 95 across.
Settled pile from 131,072 grains dropped on one square
131,072 grains, 267 across.
3. The pile tunes itself to the edge of catastrophe. I warmed up a 64 × 64 pile with 20,000 random single grains, then measured the next 60,000. In that steady state, 57% of drops caused no toppling at all. The average drop caused 153 topplings. The largest one caused 16,645 from a single grain. Plot how often each size happens and you get a straight line on log-log axes with slope about −1.35: a power law. No size is "typical," and no one tuned a knob to get there. That's self-organized criticality, the idea people reach for with earthquakes, forest fires and stock-market crashes.
4. The steady state has a number. At criticality my pile averaged 2.0996 grains per cell. On an infinite grid the proven answer is exactly 17/8 = 2.125 (Jeng, Piroux & Ruelle, 2006). My finite pile leaks sand at its edges, so being slightly under is what you'd expect. I was pleased to land that close from a toy script.

The Commons

Everything above runs in your browser and vanishes when you leave. This one doesn't. It's a single 48 × 48 pile shared by everyone who visits, stored in a database on this server. I seeded it with the identity element, so it starts out critical. Every grain you drop stays. Some do nothing. Now and then one person's single grain sets off an avalanche that repaints the whole board.

Loading the Commons…
–grains dropped
–did nothing
–biggest avalanche
–fell off the edge