Water Hammer - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


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&comma;fL&comma;fT&colon; option hfloat&colon;  if  typeV&comma;numeric then Rey≔Dia⋅V⋅ρμ&colon; fL≔64Rey&colon; fT≔11.8⁢log106.9Rey&plus;e3.7⁢Dia1.112&colon;    if Rey&gt;0 and  Rey<2000 then       return fL&colon;    elif Rey≥2000 and Rey<4000 then       return fL&plus;fT−fL⋅Rey−20004000−2000    elif Rey≥4000 then       return fT    else       return 0    end if&semi;else return &apos;friction&apos;Vend ifend proc&colon;

Steady State Flow Rate

Calculate the steady state pipeline velocity from the Darcy-Weisbach equation:

> 

Vsteady≔fsolvePsource=friction⁡V⁢LDia⁢&rho; V22

Vsteady:=14.19058741

(4.1)
> 

Qsteady≔Vsteady⁢A

Qsteady:=0.1114526129

(4.2)

Discretize the PDEs into ODEs

Number of nodes:

> 

N≔30&colon;

Length of each node:

> 

dx≔LN&colon;

Spatially discretized form of each PDE:

> 

eq1≔diffcatV&comma;it&comma;t+1&rho;&apos;cat&apos;P&comma;i+1t−catP&comma;i−1t2 dx+friction⁡cat⁡V&comma;i⁡t⁢cat⁡V&comma;i⁡t⁢cat⁡V&comma;i⁡t2 Dia=0&colon;

> 

eq2≔&apos;cat&apos;V&comma;i+1t−&apos;cat&apos;V&comma;i−1t2 dx+1Ks⁢diffcatP&comma;it&comma;t=0&colon;

Generate the entire set of ODEs:

> 

eqs≔seqeq1&comma;eq2&comma;i=1..N&colon;

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&comma;N&plus;1t≔Vsteadyt<2Vsteady⁢&ExponentialE;−70 t−2otherwise&colon;

Pressure at the start and end of the pipeline:

> 

catP&comma;0t≔Psource&colon;catP&comma;N+1t≔0&colon;

Initial pressure and velocity distribution along the pipeline:

> 

ic≔seqcat⁡P&comma;i⁡0=Psource−i⁢dxL⁢Psource&comma;i=1..N,         seqcat⁡V&comma;i⁡0=Vsteady&comma;i=1..N&colon;

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

> 

catV&comma;0t≔V1t&colon;

Solve the ODEs and Plot Pressure at Valve

> 

res≔dsolveeqs&comma;ic&comma;numeric&comma;output=listprocedure&comma;known=friction&comma; &apos;range&apos; &equals; 0..3&colon;

> 

P‖N≔subsres&comma;P‖N⁡t&colon;

Plot pressure dynamics at the valve:

> 

plotP‖N⁡t&comma;t=0..3