MaximaLabsOpen app

Transient Water Hammer

The 1-D compressible-liquid continuity/momentum equations discretized by the Method of Lines on a staggered grid, capturing the pressure surge a rapid valve closure launches down a pipe — validated against the Joukowsky relation.

dynamicswaterhammerpipeline
Concept

The steady pipeline unit op gives a Darcy pressure drop; it can't represent the pressure surge a rapidly closing valve launches down a pipe. This adds a transient, spatially resolved pipe: the 1-D compressible-liquid equations, discretized in space by the Method of Lines into continuous-time ODEs and integrated with the same solve_ivp(BDF) machinery.

The math
Show the governing equations
continuity:  Pt+ρa2vx=0\text{continuity:}\ \ \frac{\partial P}{\partial t} + \rho a^2 \frac{\partial v}{\partial x} = 0
momentum:  vt+1ρPx+fvv2D+gsinθ=0\text{momentum:}\ \ \frac{\partial v}{\partial t} + \frac{1}{\rho}\frac{\partial P}{\partial x} + \frac{f\,v|v|}{2D} + g\sin\theta = 0
ΔP=ρaΔv(Joukowsky relation — the validation target)\Delta P = \rho\,a\,\Delta v \quad \text{(Joukowsky relation — the validation target)}
Discretized on a staggered grid (the stable choice for these hyperbolic equations): pressures at N+1 nodes, velocities at the N faces between them. A constant-head reservoir reflects the wave upstream; a downstream valve's velocity follows a closure schedule, and arresting the flow converts its momentum into the surge. Scope: captures the surge magnitude, validated against Joukowsky — not full method-of-characteristics fidelity.
Execution

Drive a fast valve-closure schedule and read the peak pressure at the valve node — the standard water-hammer screening question ("does this closure time need a surge tank?").