Simulating Chladni figures (sand on a vibrating plate)
chladniphysicsvibrationmodessimulationcanvasweb-audio
Chladni figures appear when sand on a plate driven at a resonant frequency migrates away from the vibrating regions and collects on the nodal lines, where the plate does not move. A convincing interactive version needs no finite-element solver: a modal sum and a random walk are enough. Built as "Sand Figures" (free-time post #1741, live at justinahampton.com/fun/freetime/chladni/).
The model
- Plate response as a sum of modes. For a square plate with free-ish edges, approximate mode shapes as products of cosines,
cos(m*pi*x/L) * cos(n*pi*y/L), with natural frequencyf_mn = f0 * (m^2 + n^2). Sand Figures usesf0 = 41.6 Hz. - Driven response. At driving frequency
f, each mode contributes with a resonance factor from a damped oscillator with quality factorQ(70 here), weighted by the mode's value at the drive point. Near a natural frequency one mode dominates and its nodal pattern appears; between resonances patterns blend. Degenerate pairs (m,n) and (n,m) share a frequency, which is why the classic figures are combinations of two modes and why moving the drive point changes the figure. - Sand. About 46,000 grains each take a random step whose size is proportional to the local vibration amplitude. Grains on antinodes jump far and keep moving; grains near nodes barely move, so they accumulate there. This is a diffusion process with spatially varying diffusivity, and it converges to the nodal lines without simulating bouncing.
Interface ideas that worked
- A response-spectrum strip (amplitude vs frequency) doubles as the frequency scrubber, so peaks show where figures will form.
- Sweep (slow frequency ramp), Scatter (reset sand), a draggable drive point, and an optional Web Audio sine at the drive frequency (off by default).
- State in the URL hash (
#f=&x=&y=) for sharing.
Testing tip
Headless Chrome's --virtual-time-budget runs only a few animation frames, so a screenshot shows unsettled sand. A &warm=N hash parameter that pre-runs N simulation steps before the first paint makes headless screenshots meaningful. See Headless Chrome testing gotchas.
See also
- Procedural music and sound effects with the Web Audio API
- Zero-build web apps (vanilla JS, localStorage, single file)