This simulation models 2D shallow-water wave propagation using a finite-difference cellular automaton. Each grid cell stores a water height value; at every time step the cell's new height is computed from the average of its four neighbours minus its previous height, multiplied by a damping factor. The result closely reproduces the behaviour of real ripples in a shallow tray or bath — circular wavefronts that travel outward, reflect off rigid walls, and produce interference patterns where they overlap.
Click or drag anywhere on the water surface to create disturbances. Use the Wave Size slider to control the initial amplitude of each splash and the Damping slider to set how quickly energy dissipates — lower damping lets ripples persist and interfere for longer, whilst higher damping produces the calmer look of a deep ocean surface.
Why do ripples spread out in circles?
In a uniform medium, wave energy travels at the same speed in every direction from the source. This means the wavefront — the set of points that the disturbance has just reached — forms a perfect circle centred on the impact point. The same principle governs sound waves from a loudspeaker and light pulses from a point source.
What happens when two sets of ripples meet?
Waves obey the superposition principle: their heights simply add together at each point. Where two crests coincide you get constructive interference (a taller peak); where a crest meets a trough you get destructive interference (the surface temporarily flattens). After passing through each other, both wave trains continue unchanged — a remarkable property of linear waves.
Why do waves bounce off the walls?
The rigid boundary condition forces the water height at the wall to remain fixed. When a wave crest reaches the wall, the restoring force sends it back in the opposite direction — just like a ball bouncing off a solid surface. In a closed container such as a bath, multiple reflections quickly build up a complex standing-wave pattern.
Each time step the computed wave height is multiplied by the damping factor (expressed as a percentage, e.g. 97%). A value of 97% means 3% of energy is lost per frame. At 60 fps this corresponds to a decay time of roughly 1.5 seconds, similar to ripples dying away in a real shallow tray. Setting it to 99% gives very persistent, almost lossless ripples.
In the shallow-water approximation, wave speed c = √(g·h), where g ≈ 9.81 m/s² is gravitational acceleration and h is water depth. For a typical bath with 10 cm of water, c ≈ 1 m/s. The simulation grid spacing and time step are chosen so the numerical wave speed matches this relationship without violating the Courant stability condition.
In deep water, each wavelength travels at a different speed (dispersion), so a sharp splash disperses into a spreading ring of ripples of gradually increasing wavelength — the "pebble in a pond" effect. Shallow-water waves are non-dispersive: all wavelengths travel at the same speed c = √(gh), which keeps wavefronts sharp. That is why this simple grid model reproduces bath ripples so faithfully.
Yes — click rapidly in the same spot or drag a line across the centre. If you excite the water at one of the tank's natural resonant frequencies (fn = c·n / 2L for mode n in a tank of length L), you will see a standing wave with fixed nodes and antinodes rather than travelling ripples. This is the same phenomenon responsible for the sloshing resonance in earthquake-affected storage tanks.
Running a full pixel-resolution wave equation would require millions of cells and exceed the browser's real-time budget. By grouping pixels into 4×4 blocks the grid size drops to roughly 480×270 cells, allowing 60 fps updates in JavaScript. The visual effect is almost identical since ripples span many cells — the slight pixelation at close range is the only trade-off.
Meteorologists use shallow-water equations to model large-scale atmospheric circulation. Civil engineers apply them to flood-routing in river valleys and tidal estuary simulations. Oceanographers use them to predict tsunami propagation — because a tsunami in the open ocean has a wavelength of hundreds of kilometres but a depth of only a few kilometres, the shallow-water limit applies perfectly even in the deep ocean.
Without energy dissipation (damping = 100%) the simulation is conservative: waves would bounce around the tank indefinitely, continuously adding to interference patterns until every grid cell was oscillating at maximum amplitude and the display became a visual noise field. Real water always has some viscosity and surface tension that dissipate energy; the damping slider mimics this physical loss.
Yes — click two spots at the same time (or in quick succession) at equal distances from the centre. If the two sources oscillate in phase, you will see regions of calm (destructive interference) radiating outward between the sources, and bright crests along the lines where path lengths differ by whole wavelengths. This is the classic double-slit interference pattern reproduced in water.