Governing model
dQ/dt = (gA/L) [h₀ − x − hf(Q)]
dx/dt = [Q − Qg(t)] / As
hf(Q) = [fL/D + K] · Q|Q| / (2gA²)
Qg(t) = Q₀ max(1 − t/tc, 0)
Qs = 1.84 b [max(x − Hc, 0)]3/2
Here Q is penstock flow, x is the surge-tank level change, A is pipe area, As is tank area, L is effective pipe length, and h₀ = hf(Q₀) is the initial Darcy–Weisbach head loss. The gate flow falls linearly to zero over the selected closure time. The spillway uses the textbook SI coefficient 1.84 and an illustrative width b = 0.8 m. The model uses g = 9.81 m/s² (textbook).
Numerical method
The coupled equations are integrated with fourth-order Runge–Kutta at a fixed 1/120 s step (illustrative numerical setting). The browser frame rate only controls how many fixed steps are drawn between frames.
What is simplified
This is a rigid-column surge model: it treats the water in the penstock as one uniform moving column. It does not resolve elastic pressure waves, pipe-wall compliance, distributed velocity profiles, turbine efficiency, air admission, or a detailed gate discharge curve. The tank has an illustrative lower drawdown boundary at −14.5 m and pauses there rather than simulating air entry. The linear gate-flow schedule and the illustrative spillway law are teaching assumptions. Real installations require a distributed transient analysis.
What is illustrative
Slider settings, readouts, presets and experiment results describe this example installation, not a real dam or a design recommendation. SI units are used throughout. The lossless period and peak checks are ideal textbook limits, not predictions for the frictional run.