Water Hammer - Maple Programming Help

Home : Support : Online Help : Applications and Example Worksheets : Applications : applications/WaterHammer

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:

$\frac{\partial }{\partial x}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}V\left(x,t\right)+\frac{1}{\mathrm{Ks}}\frac{\partial }{\partial t}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}P\left(x,t\right)=0$

where $V\left(x,t\right)$ and $P\left(x,t\right)$ are the velocity and pressure at position $x$ and time $t$, friction ( ) is the friction factor at a given velocity, $\mathrm{\rho }$ is the liquid density, $\mathrm{Dia}$ is the pipe diameter, and $\mathrm{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:

where $i=1..N$.

This application solves the discretized ODEs numerically.

 > $\mathrm{restart}$

Physical Parameters

Parameters

Liquid density

 > $\mathrm{ρ}≔1000:$

Bulk modulus

 > $K≔200{10}^{6}:$

Viscosity

 > $\mathrm{μ}≔0.001:$

Pipe diameter

 > $\mathrm{Dia}≔0.1:$

Wall thickness

 > $\mathrm{thick}≔0.001:$

Roughness

 > $e≔0.0001:$

Length

 > $L≔25:$

Young's modulus

 > $E≔70{10}^{9}:$

Cross-sectional area

 > $A≔\frac{1}{4}\mathrm{evalf}\left(\mathrm{\pi }\right){\mathrm{Dia}}^{2}:$

Pressure at start of pipeline

 > $\mathrm{Psource}≔0.5{10}^{6}:$

Effective modulus of system

 > $\mathrm{Ks}≔\frac{1}{\left(\frac{1}{K}+\frac{\mathrm{Dia}}{\left(E\mathrm{thick}\right)}\right)}:$

Friction Factor

 >

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

 >
 ${\mathrm{Vsteady}}{:=}{14.19058741}$ (4.1)
 > $\mathrm{Qsteady}≔\mathrm{Vsteady}A$
 ${\mathrm{Qsteady}}{:=}{0.1114526129}$ (4.2)

Discretize the PDEs into ODEs

Number of nodes:

 > $N≔30:$

Length of each node:

 > $\mathrm{dx}≔\frac{L}{N}:$

Spatially discretized form of each PDE:

 >
 >

Generate the entire set of ODEs:

 > $\mathrm{eqs}≔\mathrm{seq}\left({\left[\mathrm{eq1},\mathrm{eq2}\right]}_{\left[\right]},i=1..N\right):$

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:

 > $\mathrm{cat}\left(P,0\right)\left(t\right)≔\mathrm{Psource}:$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{cat}\left(P,N+1\right)\left(t\right)≔0:$

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):

 > $\mathrm{cat}\left(V,0\right)\left(t\right)≔\mathrm{V1}\left(t\right):$

Solve the ODEs and Plot Pressure at Valve

 >
 > $P‖N≔\mathrm{subs}\left(\mathrm{res},P‖N\left(t\right)\right):$

Plot pressure dynamics at the valve:

 > $\mathrm{plot}\left(P‖N\left(t\right),t=0..3\right)$