Shallow Water Equations: 2D Height & Velocity Field Solver
2D companion to the 1D Shallow Water Equations simulator: a full coupled height h(x,y) and velocity (u,v) finite-difference solver over a 2D grid. Watch radial dam-break bores, basin sloshing, interfering circular wave sources, and shoaling waves that steepen into breaking fronts as they cross a shelf.
A 2D companion to the 1D Shallow Water Equations simulator: a coupled height and velocity finite-difference solver over a full grid, showing radial dam-break bores, basin sloshing, interfering wave sources, and shoaling waves that steepen into breaking fronts.
About this simulation
This is a full 2D companion to the 1D Shallow Water Equations simulator. Instead of a single cross-section h(x,t), it steps a coupled height field h(x,y,t) and depth-averaged velocity field (u,v)(x,y,t) forward on a 2D grid with a dimensionally-split Lax-Friedrichs finite-difference scheme, so waves can spread radially, interfere, and steepen into breaking fronts exactly as real shallow water does.
🔬 What it shows
Four scenarios reuse the same 2D solver: a radial dam-break that sends a circular bore outward, a tilted basin that sloshes back and forth, two point sources whose circular waves interfere constructively and destructively, and a shoaling scenario where a shallower bed on one side steepens and breaks an incoming pulse.
🎮 How to use
Pick a scenario, then tune the base depth and disturbance amplitude sliders, add bed friction to damp motion, and adjust the CFL number to trade stability for speed. Click or tap anywhere on the water to drop a stone and see its circular wave interact with the running scenario.
💡 Did you know?
The same nonlinear steepening that turns a smooth swell into a breaking wave on a beach — because faster, deeper water outruns slower, shallower water ahead of it — is exactly what the "breaking-front cells" readout is counting in real time.
Frequently asked questions
How is this different from the 1D Shallow Water Equations simulator?
The 1D version tracks a single cross-section h(x,t) and u(x,t) along one line. This 2D version solves the full coupled system over a grid — h(x,y,t), u(x,y,t) and v(x,y,t) — so waves can spread outward, curve, and interfere the way real water waves do, which a 1D solver cannot represent.
What causes a wave to "break" in this simulation?
Wave speed in shallow water is c = √(gh): taller, deeper regions of the wave travel faster than shorter, shallower regions ahead of them. As a wave's front steepens enough, the local surface gradient crosses a threshold and the cell is counted as a "breaking-front" cell — a numerical stand-in for a bore or a breaking wave.
Why does the Shoaling Bore scenario break so reliably?
Its bed depth decreases from left to right. As the initial pulse moves into shallower water, its speed c = √(gh) drops, and because momentum flux must still be conserved, the amplitude grows to compensate — the classic shoaling amplification that makes ocean swells rear up and break as they approach a beach.
What does the Interference scenario demonstrate?
Two fixed grid cells are driven with an oscillating height, each radiating circular waves like ripples from two stones dropped together. Where the two wave trains arrive in phase they add constructively into taller crests; where they arrive out of phase they cancel — the same principle behind double-slit interference, but for real nonlinear water waves.
Why is mass tracked as a live check?
The solver is written in conservative flux form, so the total water volume Σh·dx·dy over the whole grid should stay close to its initial value for a closed, wall-bounded domain like this one. Tracking it is a running check that the finite-difference scheme isn't numerically creating or destroying water.
A 2D companion to the 1D Shallow Water Equations simulator: a full coupled height h(x,y) and velocity (u,v) finite-difference solver over a 2D grid, using a dimensionally-split Lax-Friedrichs scheme with a CFL-limited timestep. Radial dam-break bores, basin sloshing, interfering circular wave sources, and a shoaling scenario where waves steepen and break as they cross a shallower bed.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install