Application Center - Maplesoft

App Preview:

Water Hammer

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application




Water Hammer

Introduction

 

When a valve at the end of a pipeline closes suddenly, a pressure surge hits the valve, and travels along the pipeline.  This is known as Water Hammer, and is described by the following PDEs

 

diff(V(x, t), t)+(diff(P(x, t), x))/rho+friction(abs(V(x, t)))*V(x, t)*abs(V(x, t))/(2*Dia) = 0

diff(V(x, t), x)+(diff(P(x, t), t))/Ks = 0

where V(x,t) and P(x,t) are the velocity and pressure at position x and time t, friction() is the friction factor at a given velocity, rho 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

 

diff(V[i](t), t)+(P[i+1](t)-P[i-1](t))/(rho*(2*`Δx`))+friction(abs(V[i](t)))*V[i](t)*abs(V[i](t))/(2*Dia) = 0

 

(V[i+1](t)-V[i-1](t))/(2*`Δx`)+(diff(P[i](t), t))/Ks = 0

 

where i = 1 ... N.

This application solves the discretized ODEs numerically.

Physical Parameters

 

restart

Liquid density, bulk modulus and viscosity

rho := 1000K := 200*10^6mu := 0.1e-2

Pipe diameter, wall thickness, roughness, length, Young's Modulus and cross-sectional area

Dia := .1thick := 0.1e-2e := 0.1e-3L := 25E := 70*10^9A := (1/4)*evalf(Pi)*Dia^2

Pressure at start of pipeline

Psource := .5*10^6

Effective modulus of system

Ks := 1/(1/K+Dia/(E*thick))

Friction Factor

 

friction := proc (V) local Rey, fL, fT; option hfloat; if type(V, numeric) then Rey := Dia*V*rho/mu; fL := 64/Rey; fT := 1/(HFloat(1.8)^2*log10(HFloat(6.9)/Rey+(e/(HFloat(3.7)*Dia))^HFloat(1.11))^2); if 0 < Rey and Rey < 2000 then return fL elif 2000 <= Rey and Rey < 4000 then return fL+(1/2000)*(fT-fL)*(Rey-2000) elif 4000 <= Rey then return fT else return 0 end if else return ('friction')(V) end if end proc

Steady State Flowrate

 

Calculate the steady-state pipeline velocity from the Darcy Weisbach Equation

Vsteady := fsolve(Psource = (1/2)*friction(V)*L*rho*V^2/Dia)

14.19058741

(4.1)

Qsteady := Vsteady*A

.1114526129

(4.2)

Discretize the PDEs into ODEs

 

Number of nodes

N := 30

Length of each node

dx := L/N

Spatially discretized form of each PDE

eq1 := diff((('cat')(V, i))(t), t)+((cat(P, i+1))(t)-(('cat')(P, i-1))(t))/(rho*(2*dx))+friction(abs((('cat')(V, i))(t)))*(('cat')(V, i))(t)*abs((('cat')(V, i))(t))/(2*Dia) = 0

eq2 := ((cat(V, i+1))(t)-(cat(V, i-1))(t))/(2*dx)+(diff((('cat')(P, i))(t), t))/Ks = 0

Generate the entire set of ODEs

eqs := seq([eq1, eq2][], i = 1 .. N)

Initial and Boundary Conditions

 

For the first 2 seconds, the velocity at the valve is the steady-state velocity. After that, the velocity decreases exponentially to zero as the valve closes.

(cat(V, N+1))(t) := piecewise(t < 2, Vsteady, Vsteady*exp(-70*(t-2)))

Pressure at start and end of pipeline

(cat(P, 0))(t) := Psource
(cat(P, N+1))(t) := 0

Initial pressure and velocity distribution along the pipeline

ic := seq([(cat(P, i))(0) = Psource-i*dx*Psource/L][], i = 1 .. N), seq([(cat(V, i))(0) = Vsteady][], i = 1 .. N)

Velocity at node 0 is equal to velocity at node 1 (because there are no derivatives involving node 0)

(cat(V, 0))(t) := V1(t)

Solve the ODEs and Plot Pressure at Valve

 

res := dsolve([eqs, ic], numeric, output = listprocedure, known = friction)

P || N := subs(res, (P || N)(t))

Plot pressure dynamics at valve

plot((P || N)(t), t = 0 .. 3)