When a valve at the end of a pipeline suddenly closes, a pressure surge hits the valve and travels along the pipeline. This is known as water hammer. This process is modeled by two partial differential equations (PDEs). The PDEs can be discretized along the spatial dimension to give a set of ordinary differential equations, ODEs. For a given set of parameters, this application solves the resulting ODEs numerically and plots the pressure dynamics at the valve.
Water hammering can be described by the following PDEs:
∂∂tVx,t+1ρ∂∂xPx,t+frictionVx,t Vx,t⁢V⁡x,t2 Dia=0
where V⁡x,t and P⁡x,t are the velocity and pressure at position x and time t, friction ( Vx,t ) is the friction factor at a given velocity, ρ is the liquid density, Dia is the pipe diameter, and Ks is the effective bulk modulus of the system.
Discretizing the PDEs by replacing the spatial derivatives with a central difference approximation gives these equations:
ⅆⅆ tVit+1ρPi+1t−Pi−1t2 Δx+frictionVit Vit Vi(t)2 Dia=0
Vi+1t−Vi−1t2 Δx+1Ksⅆⅆ t Pit=0
This application solves the discretized ODEs numerically.
Pressure at start of pipeline
Effective modulus of system
friction≔procVlocal Rey,fL,fT: option hfloat: if typeV,numeric then Rey≔Dia⋅V⋅ρμ: fL≔64Rey: fT≔11.8⁢log106.9Rey+e3.7⁢Dia1.112: if Rey>0 and Rey<2000 then return fL: elif Rey≥2000 and Rey<4000 then return fL+fT−fL⋅Rey−20004000−2000 elif Rey≥4000 then return fT else return 0 end if;else return 'friction'Vend ifend proc:
Steady State Flow Rate
Calculate the steady state pipeline velocity from the Darcy-Weisbach equation:
Discretize the PDEs into ODEs
Number of nodes:
Length of each node:
Spatially discretized form of each PDE:
eq1≔diffcatV,it,t+1ρ'cat'P,i+1t−catP,i−1t2 dx+friction⁡cat⁡V,i⁡t⁢cat⁡V,i⁡t⁢cat⁡V,i⁡t2 Dia=0:
Generate the entire set of ODEs:
Initial and Boundary Conditions
During the initial two seconds, the velocity at the valve is at a steady state. After that, the velocity decreases exponentially to zero as the valve closes.
Pressure at the start and end of the pipeline:
Initial pressure and velocity distribution along the pipeline:
The velocity at node 0 is equal to the velocity at node 1 (because there are no derivatives involving node 0):
Solve the ODEs and Plot Pressure at Valve
res≔dsolveeqs,ic,numeric,output=listprocedure,known=friction, 'range' = 0..3:
Plot pressure dynamics at the valve:
Download Help Document
What kind of issue would you like to report? (Optional)