Water surface height h(x,t) — blue fill, bed in brown
Velocity u(x,t) and Froude number Fr(x)

About this simulation

This simulation solves the 1D Saint-Venant (shallow water) equations — conservation of mass ∂h/∂t + ∂(hu)/∂t = 0 and momentum ∂(hu)/∂t + ∂(hu²+½gh²)/∂x = 0 — with a Lax-Friedrichs-style flux and a CFL-limited adaptive timestep so the scheme stays stable as wave speeds change. Four scenarios reuse the same solver: a classic dam-break (step in depth h), a sloshing tank (sinusoidal initial surface), a boundary-driven wave train, and a moving hydraulic step, letting you compare how the same shallow-water physics produces bores, sloshing oscillations, and steady wave trains.

🔬 What it shows

A 1D column of water height h(x) and depth-averaged momentum hu(x), stepped forward with a finite-volume scheme. The flux function computes hu and hu·u+½gh² at each cell face, and the CFL condition dt = CFL·dx/max(|u|+√(gh)) keeps the explicit update stable even as the dam-break bore accelerates.

🎮 How to use

Pick a scenario (Dam Break, Slosh, Wave, Step), then drag the Left Height and Right Height sliders to set the initial water depths either side of the dam, tune Manning's roughness coefficient for bed friction, and adjust the CFL number to trade stability for speed. Total mass is tracked against its initial value (mass0) so you can check conservation as the simulation runs.

💡 Did you know?

The dam-break problem has an exact analytical (Ritter) solution for a frictionless bed, which is why it is the standard textbook test case for validating any new shallow-water numerical scheme before applying it to rivers, tsunamis, or flood plains.

Frequently asked questions

What are the shallow water (Saint-Venant) equations?

They are a depth-averaged simplification of the Navier-Stokes equations, valid when the horizontal length scale is much larger than the water depth. They track only height h(x,t) and depth-integrated momentum hu(x,t), which is why they can be solved cheaply in 1D while still capturing waves, bores, and sloshing.

What happens physically in the dam-break scenario?

Setting different left (hL) and right (hR) heights and releasing them models a dam suddenly failing: the taller column collapses into the shorter one, producing a shock-like bore that advances into the shallow side and a rarefaction (spreading) wave that retreats into the deep side, exactly as in a real flood surge.

Why does the simulation need a CFL-limited timestep?

Explicit finite-volume schemes are only stable if information cannot cross more than one grid cell per timestep. Since wave speed is u±√(gh), the code recomputes dt = CFL·dx/max_wave_speed every step so a fast bore in the Dam scenario or a fast Step scenario doesn't outrun the numerical scheme and blow up.

What does the Manning roughness slider control?

Manning's coefficient represents bed friction from the riverbed or channel surface. Raising it adds a drag term that removes momentum from the flow over time, damping oscillations in the Slosh scenario and slowing the bore in the Dam scenario, similar to how a rough riverbed slows real floodwater.

Why is total mass tracked during the simulation?

Because the discretised equations are written in conservative form (flux differences between neighbouring cells), the total water volume Σh·dx should stay equal to its initial value mass0 for any closed or periodic domain — tracking it is a live check that the numerical scheme isn't artificially creating or destroying water.