This simulation needs WebAssembly, and it could not start in this browser.
The image is a frame from a real run. Check that JavaScript is on, or try another browser.
Adhémar Barré de Saint-Venant wrote down the shallow-water equations in 1871 to describe floods in rivers. They hold whenever the water is much shallower than the waves are long: the pressure is then hydrostatic, the flow is the same at every depth, and a 3D fluid reduces to a 2D sheet described by its surface height and one horizontal velocity. Tsunami forecasts and tide models still run on them. Their waves all travel at the same speed, , set only by gravity and the depth.
What you see
The surface of a square basin, 200 by 200 cells, seen from above: bright cyan is a crest, dark blue a trough, and the middle blue the still level. The colors scale with the highest wave on screen, so a ring keeps its contrast as it spreads and flattens. The basin’s edges wrap around, so a wave leaving on one side comes back on the other.
The waves move at cell per time unit, which is 84 cells per second on screen. A ring from a bump at the center reaches the edge in about 1.2 seconds. Its crest falls as , the energy of the ring being spread over a growing circumference: measured 0.185 at radius 12 and 0.077 at radius 61, against 0.082 from that law.
Equation
For a small surface displacement on a mean depth with depth-averaged velocity ,
with . The heights sit at the cell centers and the velocities on the cell faces (an Arakawa C grid), which keeps neighboring cells from decoupling into a checkerboard. Each time step first updates the heights from the old velocities and then the velocities from the new heights. This forward-backward order is stable up to ; the simulation runs at 0.35, four steps per frame. Updating both from the old state instead would amplify every wave a little on each step. Without damping the scheme conserves the volume exactly and a discrete wave energy to within over 1000 steps (measured).
Linear shallow-water waves do not disperse: all wavelengths travel at the same speed, so a pulse keeps its shape along the ring.
Presets
Ring wave: a Gaussian bump in the middle, released at rest. It splits into an outgoing ring and settles back; after about 1.2 seconds the ring meets its own copies across the wrapped edges and a lattice of interference begins.
Dam break: the left half starts 1 above the still level, the right half 0.5 below. Each step in the surface splits into two fronts of half its height, one running each way at , with a flat level of +0.25 left between them. The edges wrap, so there are two steps (in the middle and at the edge) and four fronts.
Two bumps: two sources a third of the basin apart. Their rings cross and form an interference pattern, bright where crests meet crests.
Parameters
Damping γ: a linear drag on the flow, like friction with the bottom, from 0 to 0.02 per time unit. The wave energy decays as : at the default 0.003 it halves in about 2.8 seconds on screen.
Resolution: cells per side; changing it restarts the current preset on the new grid.
Velocity arrows and isolines draw the flow and lines of equal height over the surface.