Water Hammer
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.
Model
Water hammering can be described by the following PDEs:
∂∂tVx,t+1ρ∂∂xPx,t+frictionVx,t Vx,t⁢V⁡x,t2 Dia=0
∂∂xVx,t+1Ks∂∂tPx,t=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
where i=1..N. This application solves the discretized ODEs numerically.
restart
Physical Parameters
Parameters
Liquid density
ρ≔1000:
Bulk modulus
K≔200⁢106:
Viscosity
μ≔0.001:
Pipe diameter
Dia≔0.1:
Wall thickness
thick≔0.001:
Roughness
e≔0.0001:
Length
L≔25:
Young's modulus
E≔70⁢109:
Cross-sectional area
A≔14⁢evalf⁡π⁢Dia2:
Pressure at start of pipeline
Psource≔0.5⁢106:
Effective modulus of system
Ks≔11K+DiaE⁢thick:
Friction Factor
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:
Vsteady≔fsolvePsource=friction⁡V⁢LDia⁢ρ V22
Vsteady:=14.19058741
Qsteady≔Vsteady⁢A
Qsteady:=0.1114526129
Discretize the PDEs into ODEs
Number of nodes:
N≔30:
Length of each node:
dx≔LN:
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:
eq2≔'cat'V,i+1t−'cat'V,i−1t2 dx+1Ks⁢diffcatP,it,t=0:
Generate the entire set of ODEs:
eqs≔seqeq1,eq2,i=1..N:
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.
catV,N+1t≔Vsteadyt<2Vsteady⁢ⅇ−70 t−2otherwise:
Pressure at the start and end of the pipeline:
catP,0t≔Psource:catP,N+1t≔0:
Initial pressure and velocity distribution along the pipeline:
ic≔seqcat⁡P,i⁡0=Psource−i⁢dxL⁢Psource,i=1..N, seqcat⁡V,i⁡0=Vsteady,i=1..N:
The velocity at node 0 is equal to the velocity at node 1 (because there are no derivatives involving node 0):
catV,0t≔V1t:
Solve the ODEs and Plot Pressure at Valve
res≔dsolveeqs,ic,numeric,output=listprocedure,known=friction, 'range' = 0..3:
P‖N≔subsres,P‖N⁡t:
Plot pressure dynamics at the valve:
plotP‖N⁡t,t=0..3
Download Help Document