Multi-Objective Optimal Design of Water Distribution Networks Accounting For Transient Impacts
Multi-Objective Optimal Design of Water Distribution Networks Accounting For Transient Impacts
Article
Implementation and Validation of a Free Open Source
1D Water Hammer Code
Rune Kjerrumgaard Jensen 1,† , Jesper Kær Larsen 1 , Kasper Lindgren Lassen 1 , Matthias Mandø 2
and Anders Andreasen 3, * ID
1 Aalborg University Esbjerg, Niels Bohrs Vej 8, 6700 Esbjerg, Denmark; [email protected] (R.K.J.);
[email protected] (J.K.L.); [email protected] (K.L.L.)
2 Department of Energy Technology, Aalborg University Esbjerg, Niels Bohrs Vej 8, 6700 Esbjerg, Denmark;
[email protected]
3 Studies & FEED, Field Development, Rambøll Energy, Bavnehøjvej 5, 6700 Esbjerg, Denmark
* Correspondence: [email protected]
† Current address: Process Department, Field Development, Rambøll Energy, Bavnehøjvej 5,
6700 Esbjerg, Denmark.
Received: 9 August 2018; Accepted: 29 August 2018; Published: 3 September 2018
Abstract: This paper presents a free code for calculating 1D hydraulic transients in liquid-filled piping.
The transient of focus is the Water Hammer phenomenon which may arise due to e.g.,
sudden valve closure, pump start/stop etc. The method of solution of the system of partial differential
equations given by the continuity and momentum balance is the Method of Characteristics (MOC).
Various friction models ranging from steady-state and quasi steady-state to unsteady friction models
including Convolution Based models (CB) as well as an Instantaneous Acceleration Based (IAB) model
are implemented. Furthermore, two different models for modelling cavitation/column separation
are implemented. Column separation may occur during low pressure pulses if the pressure decreases
below the vapour pressure of the fluid. The code implementing the various models are compared to
experiments from the literature. All experiments consist of an upstream reservoir, a straight pipe and
a downstream valve.
Keywords: water hammer; unsteady friction; fluid transients; method of characteristics; column
separation; cavitation; numerical simulation
1. Introduction
Sudden changes to fluid flow in piping may result in the generation of a pressure surge
or a chock wave travelling at the speed of sound. The flow changes may be induced by e.g.,
pump starting/stopping, pipe rupture/leakage, valve opening/closing etc. The phenomenon is
referred to as Water Hammer and is most common for liquid flow, due to the low compressibility
of water. Probably the most common water hammer is when a downstream valve closes suddenly.
When the valve closes, the liquid column upstream is still moving and when the liquid column
is slowed down, the kinetic energy is converted to pressure head. The pressure pulse created is
noisy and the pressure pulse may have a magnitude which causes pipe rupture or resulting in other
equipment damage. Water hammer may be observed in a variety of applications e.g., in power
plant steam generation/cooling systems [1,2], district heating system [3], hydro-power [4], irrigation
systems [5,6], domestic plumbing [7], pipeline transport of oil and chemicals [8,9] etc. It is important
to be able to accurately model the physical phenomenon for correct dimensioning of pipes, adequate
choice of valve closing time etc. to prevent damages.
The water hammer phenomenon is fully described by the continuity and momentum equations.
Different methods for solving these equations exist, e.g., the Finite Volume Method (FVM) [10],
the Finite Difference Method (FDM) [11,12], the Finite Element Method (FEM) [13], and the Method of
Characteristics (MOC) [14]. The most popular method is the explicit MOC because it is relatively easy
to implement and it has a relatively high accuracy [15].
In this paper an implementation of the MOC proposed by [15] will be demonstrated. The MOC
is discretized and implemented in Octave [16]/MATLAB
R
(The MathWorks, Natick, MA, USA).
A number of different friction models are implemented, as well as two different methods for handling
column separation/cavitation. As a part of the present paper, the full source code is provided, in order
for anyone to explore the code and freely use it for their own studies and for further improvement.
Many commercial tools are available in the market, a vast amount already summarised by [14].
The authors find it important to have a tool which is easy to modify and extend in order to e.g.,
explore different solution schemes, grid types, friction models etc. Furthermore such code may find
potential usage in applications such as failure analysis [17], condition monitoring [18], and aid the
design of protective measures in order to avoid e.g., pipeline rupture [19]. By sharing the source code,
the authors hope, at least partially, to contribute to achieving this goal. The full verbatim code is
provided in the Appendix A of the present paper and further it is available for download [20]. In the
present paper the code and the implementation of the different friction and cavitation models are
validated against experimental data from the literature. The different implemented models will be
investigated and quantitatively compared.
∂H a2 ∂Q Q
g + − g sin(α) = 0 (1)
∂t A ∂x A
∂H 1 ∂Q
g + +J=0 (2)
∂x A ∂t
where g is the gravitational acceleration, H is the piezometric head, t is time, A is the cross-sectional
area of the pipe, Q is the volumetric flow rate, x is position in the axial direction, J is the friction term,
and α is the angle from horizontal. In the equations, it is assumed that the cross sectional area and the
wave speed, a, are constant, and that a >> v which means that the convective terms can be neglected.
It is also assumed that the flow is one dimensional and that the compressibility and flexibility of the
pipe is accounted for in the wave speed as seen in Equation (3).
K/ρ
a2 = (3)
1 + [(K/E)( D/e)] c1
where ρ is the density of the fluid, K is the bulk modulus of the fluid, E is Young’s modulus of the pipe,
D is the inner pipe diameter, e is the pipe wall thickness, and c1 is a coefficient describing the relation
to Poisson’s ratio, ν.
The method used to solve the set of Partial Differential Equations (PDEs) is the MOC.
The MOC transforms the set of PDEs into the four Ordinary Differential Equations (ODEs) seen
in Equations (4) and (5).
dQ gA dH g
± + AJ ∓ sin(θ ) Q = 0 (4)
dt a dt a
dx
= ±a (5)
dt
The equations in Equation (4) can be solved along the characteristic lines with the slope
determined by Equation (5), as is illustrated in Figure 1. By use of the characteristic lines, point P can
Fluids 2018, 3, 64 3 of 49
be found using point A and B. This is done by the positive characteristic line, C + , corresponding to
a positive a and the negative characteristic line, C − , corresponding to a negative a. In this case the
characteristic lines are linear, since it is assumed that a is constant.
Approximating Equation (4) with finite differences and integrating along the positive
characteristic line and along the negative characteristic line yield Equations (6) and (7), where C p and
a
Cm are described with Equations (8) and (9), respectively and B = gA .
C + : HP = C p − BQ P (6)
C − : HP = Cm + BQ P (7)
a ∆x
C p = H A + BQ A − J A ∆t + sin(θ ) Q A (8)
g aA
a ∆x
Cm = HB − BQ B + JB ∆t + sin(θ ) Q B (9)
g aA
Inserting Equation (6) into Equation (7) and solving for HP yields:
C p + Cm
HP = (10)
2
Q P can then be calculated with Equation (11).
HP − Cm
QP = (11)
B
Equations (6) to (9) are used in a rectangular grid to simulate the water hammer. The friction term
J is evaluated explicitly.
A rectangular grid is chosen over the less computationally intensive diamond grid to enhance the
plotting of the pressure distribution. Note that the rectangular grid, which consists of two independent
diamond grids, tends to generate small unphysical oscillations, which are visible on the plots.
1 sin(θ )
HP = H A − J∆x + Q0 ∆x (12)
g aA
Fluids 2018, 3, 64 4 of 49
2.3. Friction
The estimation of the water hammer pressure propagation is largely dependent on the
friction forces. Traditionally, the friction is modelled as steady or quasi-steady. The steady and
quasi-steady friction is able to predict the pressure at the first pressure peak, but as the wave propagates,
the dampening of the pressure is not sufficient [23]. For engineering design, the first and thereby largest
pressure peak, for single phase flows, is of primary interest. However, there are also specific situations
where the secondary pressure peaks are of interest [24]. An example of this is in the cooling system of
a nuclear power plant, where a quick restart of the cooling system is necessary. Another example can
be quick restart of (off-shore) oil and gas production facilities in order to reduce loss of production etc.
If there are sensitive components behind the closed valve, it is necessary to wait for the water hammer
to dissipate to a sufficiently low pressure, at which the sensitive components can survive without
damage [25].
A method to accurately describe the dampening of the pressure peak is by modelling the unsteady
friction. It is complex and more computationally heavy to model unsteady friction compared to
modelling steady friction, but unsteady friction modelling is essential for a more precise estimation of
the transient behavior [24]. Unsteady friction models fall into three main groups.
The CB friction models are dependent on the convolution of the history of accelerations with a
weighting function. This was first derived by Zielke [26] for laminar flow. Work has been carried out to
extend Zielke’s CB model to the turbulent regime by Vardy and Brown, assuming a bilinear turbulent
viscosity distribution for both smooth pipes [27] and fully rough pipes [28]. Zarzycki et al. [29]
derived a more advanced CB friction model for turbulent flow assuming a four-region turbulent
viscosity model.
The IAB model suggested by Brunone et al. [30] is dependent on the instantaneous acceleration,
the convective acceleration, and a damping coefficient. The damping coefficient can be found either
empirically as suggested by [30] or as will be used here, the theoretical values derived by Vardy and
Brown [27,28]. The determination of the damping coefficient can be done from the initial Reynolds
number as a constant or updated on the local Reynolds number, which has been shown to give better
results [31]. IAB models with two damping coefficients exist [32,33], but they are not covered herein
because there is no analytical way of determining these and therefore they have to be determined
empirically.
The EIT derived by Axworthy et al. [34] is a physically well described model, but it has a
relaxation time that is usually determined empirically. Storli and Nielsen [35] have derived values
based on position dependent coefficients from CB models.
The friction term J consists of a quasi-steady friction term and an unsteady friction term as in
Equation (13) [22].
J = Jqs + Jus (13)
The quasi-steady friction term is the skin friction of the pipe and it is modelled using Equation (14).
f qs Q| Q|
Jqs = (14)
2DA2
where f qs is the quasi-steady Darcy friction factor which is updated for the local flow.
The unsteady friction is modelled with both convolution based friction models, and an
instantaneous acceleration based friction model.
Fluids 2018, 3, 64 5 of 49
4ρt
τ= (16)
µD2
All the CB models are defined as in Equation (15) with different weighting functions. The CB
models are implemented in a rectangular grid with first order finite difference approximations as in
Equation (17) [36].
n −1
∆τ
16ρ
Jus =
µD2 A ∑ (Q(i, n − j + 1) − Q(i, n − j)) · W j∆τ −
2
(17)
j =2
where i is the spatial index, j is the time index, n ≥ 3 and is the number of time steps from the
beginning of the closure of the valve. It should also been noted that in the implementation of the
accelerations in the code, the acceleration vector is filled from the bottom of the vector for simplifying
the convolution with the weighting function. Equation (17) is evaluated at both the positive and
negative characteristics.
The weighting function suggested by Zielke is defined as in Equation (18).
6
∑ m j τ0.5j−1 ; τ ≤ 0.02
j =1
W (τ ) = 5 (18)
∑ e−n j τ
; τ > 0.02
j =1
where m j = {0.282095, −1.25, 1.057855, 0.9375, 0.396696, −0.351563} and n j = {26.3744, 70.8493,
135.0198, 218.9216, 322.5544}.
Vardy and Brown [27,28] extended the range of applicability to the turbulent flow regime for
Reynolds numbers up to 108 with a two-region turbulent viscosity model. In the two-region turbulent
viscosity model, it is assumed that the turbulent viscosity varies linearly from the wall to the core
region and is constant in the core region. It is also assumed that the viscosity distribution is constant
over time. The approximated weighting function derived for a smooth pipe has the form as seen in
Equation (19) [27].
∗
A∗ eτB
W (τ ) = √ (19)
τ
Reκ
where A∗ = 2√1 π , B∗ = 12.86 , κ = log Re15.29
0.0567 , and it is assumed that the eddy viscosity at the wall is
Ren
W (τ ) = C √ (20)
τ
where k is Brunone’s friction coefficient, which describes the damping of the head, ∂Q ∂t is the local
∂Q
instantaneous acceleration, and ∂x is the instantaneous convective acceleration. The implementation
of the IAB model has been done explicitly with first order finite differences as in Equation (22) for the
positive characteristic and as in Equation (23) for the negative characteristics.
Brunone’s friction coefficient, k, can either be determined empirically [30] or analytically via
Vardy’s shear decay coefficient, C ∗ , as in Equation (24) [37].
√
C∗
k= (24)
2
Vardy’s shear decay coefficient for laminar flow is defined as in Equation (25) and for turbulent
flow, in smooth pipes, as in Equation (26) [37].
C ∗ = 0.000476 (25)
7.41
C∗ = 0.05 (26)
Relog(14.3/Re )
The analytical solution is based on the CB model suggested by Vardy & Brown, where Vardy’s
shear coefficient is derived as a limiting value of the unsteady friction coefficient with the special case
of constant acceleration.
2.6.1. Reservoir
When using a reservoir, it is assumed that the reservoir is large enough, so that elevation changes
during operation can be neglected. The head at the reservoir is assumed to be constant, HP = HR ,
and the flow rate can be isolated from Equation (7).
2.6.2. Valve
When applying a valve, it is important to correctly describe the closure, since it affects both the
magnitude and the shape of the pressure peak. It is possible to approximate the valve behaviour using
Equation (27) [21].
Fluids 2018, 3, 64 7 of 49
m
t
τv = 1 − (27)
tc
where τv is the dimensionless valve closure time, tc is the actual closure time, t is the time, and m is an
adjustable constant. If m is set to zero, then the valve is assumed to close instantaneously which yields
the maximum pressure peak. The behaviour of τv is illustrated in Figure 2 for m > 0. When 0 < m < 1,
there will be a rapid decrease in flow rate at the beginning and a slow decrease at the end of the closure.
For m = 1 there will be a linear fall in flow rate during the closure. When m > 1, there will a slow
decrease in flow rate at the beginning and a rapid decrease at the end of the closure. The flow rate can
be calculated with Equation (28).
q
Q P = − BCv + ( BCv )2 + 2Cv C p (28)
( Q0 τv )2
where Cv = 2H0 and 0 denotes steady state values.
dVg
= Qout − Qin (29)
dt
where Qout is the volumetric flow rate exiting the node and Qin is the volumetric flow rate entering the
node. To determine the volume of the gas pocket, Equation (29) can be integrated from time t − 2∆t to
time t, and the result is given in Equation (30) [21].
where Vg is the volume of the gas pocket, Q is the volumetric flow rate, the subscript P indicate points
at time t, P0 indicate points at time t − 2∆t, u indicate volumetric flow rate entering the node, and ψ is
a weighting factor.
The volumetric flow rates are illustrated in Figure 3. It can be seen that there is a modification
to the negative characteristics equation, C − , since it goes from Qu,B and not Q B . Therefore the Q B in
Equation (9) is replaced with Qu,B and Qu,P is calculated by Equation (31).
C p − HP
Qu,P = (31)
B
The weighting factor ψ controls the weight of the values at t and at t − 2∆t. With ψ = 0 only
values at t − 2∆t are used and with ψ = 1 only values at t are used. It is generally recommended to
keep ψ above 0.5 as an over reliance of old values have shown to give excessive numerical oscillation.
A value close to 0.5 is expected to give the most accurate results, but at this low value some numerical
oscillations may still be present. The numerical oscillation is primarily present when gas cavity sizes
are small, i.e., in the high pressure zones of the water hammer event. To decrease the numerical
oscillations, the value of ψ can be increased towards unity. However, this will cause more spreading of
rarefaction waves which can result in increased attenuation. Setting ψ = 1 will remove all numerical
oscillations, but will introduce the largest amount of attenuation. Therefore it is recommended to
choose a value of ψ as close to 0.5 as possible while experiencing minimal oscillation [21].
HP = z P + Hv (32)
When the head in the node is known, it is possible to calculate the volumetric flow rates and the
vapour cavity size with Equation (11), (30) and (31) respectively, where Vg,P and Vg,P0 are replaced
with Vcav,P and Vcav,P0 .
DVCM—Steady State
As described earlier, DVCM assumes that flow at steady state can be treated as a single
phase system, with Vcav = 0, and it is therefore calculated as described in Section 2.2.
DVCM—Boundary Conditions
The upstream reservoir is calculated as in Section 2.6.1, with Vcav = 0, because it is assumed that
the pressure in the reservoir is always above the vaporization pressure.
For the downstream valve, the outlet volumetric flow rate, Q P , is described as in Section 2.6.2,
while the nodes are treated in a similar fashion as in Section 2.7.1. The difference between the
calculation method for the interior nodes, see Figure A2 in Appendix A.1, and the valve boundary,
is that Equation (10) is replaced with Qu,P = Q P and Equation (33) in the flowchart, while Equation (11)
is replaced with Equation (28) in the flowchart in Appendix A.1.
HP = C p − BQu,P (33)
Mg R g T = Pg |{z}
αV = Pg,0 α0 V (34)
Vg,P
R g is the gas constant, T is the temperature, Pg is the absolute partial pressure of the free gas,
and Pg,0 is the absolute partial pressure for the initial void fraction α0 (i.e., at steady state). Vg,P is
isolated from Equation (34) and a simplified form can be seen in Equation (35), where Pg is described
with Equation (36).
C3
Vg,P = (35)
HP − z P − Hv
Pg = ρl g( HP − z P − Hv ) (36)
Pg,0 α0 V
C3 = (37)
ρl g
Fluids 2018, 3, 64 10 of 49
With the expression for Vg,P in Equation (35), Equation (30) will have the form seen in
Equation (38), remembering that Qu,P and Q P are described with Equations (31) and (28) respectively.
C3
HP −z P − Hv = Vg,P0
h
C p − HP
i (38)
+ 2∆t ψ HP −
B
Cm
− B + (1 − ψ) ( Q P0 − Qu,P0 )
0.5
B2 = 2
B2 BC3
C4 = ψ∆t
Vg,P0
+(1−ψ)( Q − Q )
(40)
P0 u,P0
Bv = 2∆t ψ
z P + Hv
B1 = − B2 C p + Cm + B2 BBv + 2
Equation (39) can be solved as a quadratic equation, where x is the variable. The result can be seen
in Equation (41), where the two first expressions are isolated from the roots of the quadratic equation.
The third and fourth expressions are linearised versions of the two first expressions, which can produce
inaccurate results in extreme conditions of high pressure and very low void fraction, or at very low
pressure and high void fraction, where | BB | = |C4 /B12 | << 1. The fifth expression is for the case
when B1 = 0.
√
− B1 1 + 1 + BB + z P + Hv if B1 < 0 and BB > 0.001
√
− B1 1 − 1 + BB + z P + Hv if B1 > 0 and BB > 0.001
C4
HP = −2B1 − + z P + Hv
2B1 if B1 < 0 and BB < 0.001 (41)
C4
2B1 + z P + Hv if B1 > 0 and BB < 0.001
√
C4 + z P + Hv otherwise
With the head described as in Equation (41), the volumetric flow rates and the gas cavity size are
calculated with Equations (31), (11), and (30) respectively.
DGCM—Steady State
For the steady state conditions, DGCM uses the same calculation method as for single phase flow,
Section 2.2, with the addition of the calculation of the gas cavity size. At steady state Equation (34) can
be simplified to Equation (42) because Pg,0 = Pg .
Vg,P = α0 V (42)
DGCM—Boundary Conditions
For DGCM, the upstream reservoir uses the same calculation method as for single phase flow,
Section 2.6.1, with the addition of the calculation of the gas cavity size. The gas cavity size is calculated
with Equation (35), where HP is replaced with Hr .
For the downstream valve, the same method for calculating the outlet volumetric flow rate,
Q P , as in Section 2.6.2 is used. The expression for the head is derived in a similar fashion as
to Section 2.7.2, but this time an expression for Q P is not needed in Equation (30), as it is now
Fluids 2018, 3, 64 11 of 49
described with Equation (28). This gives the expression in Equation (43), which can be rearranged in
Equation (44).
C p − HP
C3
= Vg,P0 + 2∆t ψ Q P − + (1 − ψ) ( Q P0 − Qu,P0 ) (43)
HP − z P − Hv B
0 = ( HP − z P − Hv )2 + 2B1 ( HP − z P − Hv ) − C4 (44)
1
B2 = 2
B2 BC3
C4 = ψ∆t
Vg,P0
+(1−ψ)( Q − Q )
(45)
P0 u,P0
Bv = 2∆t ψ
z P + Hv
B1 = − B2 C p − BQ P + B2 BBv + 2
It can be seen that Equations (44) and (39) has the same form and therefore they are solved in the
same form, and give the same results, Equation (41). It is important to note that the expressions for the
coefficients in Equation (45) are different from the coefficients in Equation (40).
The volumetric flow rates and the gas cavity size are calculated with Equations (31),
(28) and (30), respectively.
3. Experimental
Previous articles have compared CB and IAB friction models to a single experiment, where a
friction model is recommended for a single experiment [40,41]. In this article, three CB friction models
and one IAB friction model will be compared to three different experiments to establish how the
different friction models behave under different experimental conditions. As for the implementation
of different friction models, the implemented cavitation models are compared to experiments from
the literature.
The experiments chosen consist of a single pipe between a reservoir/pressure tank at the upstream
end and a fast closing valve at the downstream end as seen in Figure 4.
The different friction models are compared with experimental results found in literature.
The pressure is evaluated at the valve position. The selected experiments vary in pipe material,
diameter, length, thickness as well as flow velocity in an attempt to see how these differences affect,
prediction of the water hammer phenomenon. An overview of the different parameters is found in
Table 1.
Fluids 2018, 3, 64 12 of 49
Experiment No. E [GPa] ε [µm] ν [−] D [mm] e [mm] L [m] α [−] ρ [kg/m3 ] µ [kg/m· s] K [GPa] u0 [m/s] a [m/s] Re [−]
1 200 2.0 0.28 19 1.5 7.671 1◦ 998.2 1.002 × 10−3 2.2 2.75 1386 52052
2 120 1.5 0.35 16 1 98.11 0◦ 1000 0.9493 × 10−3 2.1 0.94 1282 15843
3 120 1.5 0.35 20 1 15.22 0◦ 998.2 1.002 × 10−3 2.2 0.42 1275 8435
4 120 1.5 0.35 20 1 15.22 0◦ 998.2 1.002 × 10−3 2.2 0.5 1275 9894
5 120 1.5 0.35 22.1 1.63 37.23 3.12◦ 998.2 1.002 × 10−3 2.2 0.3 1319 6605
6 120 1.5 0.35 22.1 1.63 37.23 3.12◦ 998.2 1.002 × 10−3 2.2 1.4 1319 30823
It is attempted to cover a wide variety of flow conditions to test the implemented models. The three
chosen experiments for validating the different implemeted friction models have a Reynolds number
of 52052, 15843, and 8453, respectively. The experiments used for comparing the different cavitation
models have Reynolds number of 6605, 9894 and 30823, respectively.
3.1. Experiment 1
The experimental study conducted by Traudt et al. [42] consist of a 7.7 m stainless steel pipe
(grade 1.4541) with a diameter of 19 mm and a wall thickness of 1.5 mm. Young’s modulus is set to
200 GPa, the pipe roughness to ε = 2 × 10−6 m, and Poisson’s ratio to ν = 0.28. The test section has a
high-pressure tank at the upstream end and a fast acting valve, with a closure time of 18 ms, at the
downstream end. The piping also has a 1◦ upwards slope. The initial flow velocity is 2.75 m/s with a
head at the reservoir of 433 m. For the simulation, m is set to 3.8, which was the best fit for the valve
closure, as τv is not reported by Traudt et al. The fluid in the study is water at room temperature.
3.2. Experiment 2
The experimental study conducted by Adamkowski and Lewandowski [40] consists of a 98 m
copper pipe in a spiral coil with an inner pipe diameter of 16 mm and a wall thickness of 1.0 mm.
Young’s modulus and Poisson’s ratio are reported in the article at 120 GPa and 0.35 GPa, respectively.
The roughness was not stated by [40]. For the present investigation, a roughness of 1.5 × 10−6 m is used
corresponding to a typical value of copper. The test section has a high-pressure tank at the upstream
end and a quick-closing spring driven ball valve, with a closure time of 3 ms, at the downstream
end. The test section has a reported maximum inclination angle of less than 0.5◦ . Because of the
uncertainty of the inclination and its small size it is neglected in the simulations. The initial flow
velocity is 0.94 m/s with a head at the reservoir of 128 m. For the simulation, m is chosen as 0.1, which
was the best fit for the valve closure as τv is not reported by Adamkowski et al. The fluid in the study is
water where the density, viscosity, and bulk modulus was given at 1000 kg/m3 , 0.9493 × 10−3 kg/m· s,
and 2.1 GPa, respectively.
Table 2. Comparison of model and experimental results for experiment 1 conducted by [42].
R
The calculations were conducted on a laptop with an Intel CoreTM i7-4700MQ processor (Santa
Clara, CA, USA) and 8 GB of random access memory (RAM).
Parameter Experiment Steady Quasi-Steady Brunone Zielke Vardy & Brown Zarzycki
Oscillation frequency 43.14 45.14 45.14 44.78 44.67 44.67 44.67
Maximum head [m] 803.16 805.89 804, 79 805.10 807.07 807.04 807.10
Deviation from experiment [%] − 0.22 0.20 0.24 0.49 0.48 0.49
Third pressure peak [m] 762.28 795.78 795.13 779.57 766.08 765.52 765.74
Deviation from experiment [%] − 4.39 4.31 2.27 0.50 0.43 0.45
Tenth pressure peak [m] 616.16 767.99 765.47 710.64 680.98 680.95 679.78
Deviation from experiment [%] − 24.64 24.23 15.33 10.52 10.51 10.33
Calculation time [s] − 0.26 0.31 0.45 1.09 1.14 1.19
Normalized calculation time [-] − 1.00 1.19 1.73 4.19 4.38 4.58
Fluids 2018, 3, 64 14 of 49
Figure 5. Comparison of the experimental data (experiment 1 [42]) with the simulated results for each
friction model. Note that the steady and quasi-steady friction models gave similar results and all the
Convolution Based models (CB) friction models also gave similar results.
The experimental results [42] indicate some double peaks, which are not predicted by any of
the friction models. This is believed to be caused by harmonics of the experimental setup. As such
Traudt et al. [42] report that the second harmonic frequency of the experimental setup of 132 Hz
is interfering with the frequency of the water hammer which is 43 Hz. Since none of the models
accurately describe the experimental data, a sensitivity analysis on the parameters, Young’s modulus,
Poisson’s ratio and the temperature of the water were conducted to see, whether this could explain the
difference. Both Young’s modulus and Poisson’s ratio are varied ±20% and the temperature of the
water ±10 ◦ C. Decreasing the Young’s modulus and the temperature and increasing the Poisson’s ratio
individually improved the results slightly compared to the experiment, but not enough to explain the
difference. Investigating combined effects also showed an improvement compared to the experimental
data, but again it could not explain the difference. Therefore, there must be an effect in the experiment
that causes extra damping on the head and a slower oscillation frequency that is not taken into account
in the friction models.
In Table 2, an average calculation time, for five identical simulations, for each friction model
can be seen, together with a normalized calculation time, where the reference time is the average
calculation time for the steady friction model. It can be seen that as the complexity of the friction
model increases, so does the calculation time, where a significant increase is seen when going from
Brunone’s unsteady friction model to the CB models. The reason for this increase is because of the
convolution in the CB models, which uses all of the calculated volumetric flow rates in the used nodes,
while Brunone only uses the volumetric flow rate from the two previous time steps.
Figure 6 and Table 3 show the results of the different friction models for experiment 2.
The oscillation frequency for all the models is close to the experimental, see Table 3.
Looking overall on the first peak, the steady, quasi-steady and Brunone coincide best with the data,
and all three CB friction models seem to overestimate the head slightly, but it is close to the highest
peak in the experimental data with a difference of −0.01% for Vardy and Brown, 0.63% for Zielke and
0.91% for Zarzycki. The head at the valve in steady state is lower for the experiment compared to
the simulations, which could be because of an underestimation of the steady state friction. Initially,
the friction models suggested by Zielke and Zarzycki render the most accurate representation of the
dampening of the head and at the third pressure peak, only underestimating the head by 0.05% and
Fluids 2018, 3, 64 15 of 49
0.58%, respectively. This is followed by the friction model by Brunone with an overestimation of 1.01%,
the Quasi-Steady model with 1.83%, the Steady model with 2.15%, and the model by Vardy and Brown
with 2.35%. At the tenth pressure peak, the picture is different with the model by Vardy and Brown
giving the most accurate representation with an overestimation of the head by 1.17% followed by the
model by Brunone with an overestimation of 2.31%, the model by Zielke with an underestimation
of 3.86%, the model by Zarzycki with an underestimation of 5.31%, the Quasi-Steady model with an
overestimation of 7.64%, and the Steady model with an overestimation of 9.81%. The behaviour of the
steady, quasi-steady and Brunone models is not reminiscent of the experimental results. The CB based
models behaviour is reminiscent of the experimental data with the Vardy & Brown model being the
closest to the experimental. The difference in the CB friction models is attributed to the difference in
the weighting functions and their dependency on the Reynolds number. Overall, it is the model by
Vardy & Brown that provides the best representation.
Figure 6. Comparison of the experimental data (experiment 2 [40])with the simulated results for each
friction model. Note that Zielke and Zarzycki friction models gave similar results.
Parameter Experiment Steady Quasi-Steady Brunone Zielke Vardy & Brown Zarzycki
Oscillation frequency 3.19 3.32 3.32 3.31 3.31 3.31 3.31
Maximum head [m] 256.64 252.10 252.08 253.63 258.26 256.62 258.97
Deviation from experiment [%] − −1.77 −1.77 −1.17 0.63 −0.01 0.91
Third pressure peak [m] 223.92 228.73 228.01 226.19 223.82 229.18 222.63
Deviation from experiment [%] − 2.15 1.83 1.01 −0.05 2.35 −0.58
Tenth pressure peak [m] 171.77 188.62 184.90 175.74 165.15 173.78 162.65
Deviation from experiment [%] − 9.81 7.64 2.31 −3.86 1.17 −5.31
Calculation time [s] − 0.28 0.28 0.42 1.06 1.11 1.15
Normalized calculation time [-] − 1.00 1.00 1.50 3.79 3.96 4.11
In Table 3, the average calculation time is summarised. It can be seen, that as the complexity of
the friction model increases, the calculation time increases, which was also seen for experiment 1.
Figure 7 and Table 4 show the results of the different friction models for experiment 3.
The oscillation frequency of the models, ranging from 20.74 to 20.94 Hz, is close to the experimental
one, at 20.69 Hz, therefore no offset between the experimental data and the simulations is expected, and
it is also evident in Figure 7. The head at steady state is larger for the simulations than the experiment,
which could be due to an underestimation of the steady state friction.
Fluids 2018, 3, 64 16 of 49
Figure 7. Comparison of the experimental data (experiment 3 [41]) with the simulated results for each
friction model. Note that the steady and quasi-steady friction models gave similar results and all the
CB friction models also gave similar results.
Parameter Experiment Steady Quasi-Steady Brunone Zielke Vardy & Brown Zarzycki
Oscillation frequency 20.69 20.94 20.94 20.80 20.74 20.74 20.74
Maximum head [m] 98.70 100.96 100.95 100.98 101.53 101.53 101.55
Deviation from experiment [%] − 2.29 2.28 2.31 2.87 2.87 2.89
Third pressure peak [m] 94.9 100.20 100.17 96.49 96.97 96.88 96.84
Deviation from experiment [%] − 5.58 5.55 1.67 2.19 2.09 2.05
Tenth pressure peak [m] 83.3 97.70 97.57 83.79 85.20 85.02 84.71
Deviation from experiment [%] − 17.29 17.13 0.59 2.28 2.06 1.70
Calculation time [s] − 0.35 0.37 0.55 1.61 1.65 1.73
Normalized calculation time [-] − 1.00 1.06 1.57 4.60 4.71 4.94
All the friction models slightly overestimate the first pressure peak with steady and quasi-steady
giving the best estimation with an overestimation of 2.29% and 2.28%, respectively, Brunone being
comparable with an overestimation of 2.31% and the CB friction models with an overestimation ranging
from 2.87% to 2.89%. Part of the overestimation of the models is likely caused by the overestimation of
the steady state head. The model by Brunone represents the dampening of the head most accurately
by overestimating the head with 1.67% at the third pressure peak and with 0.59% at the tenth pressure
peak, followed by the CB friction models overestimating the third pressure peak in the range 2.05–2.19%
and for the tenth pressure peak 1.70–2.28%, the Steady and Quasi-Steady models overestimating the
third peak with 5.58% and 5.55%, and for the tenth peak with 17.29% and 17.13%.
In Table 4, the average calculation time is summarised. The same trend as for experiment 1 and 2
is observed.
For all the experiments, it can be seen that the steady and quasi-steady friction models accurately
estimate the first peak of the pressure wave, but do not accurately describe the damping of the
pressure wave. There is almost no difference in the head of steady and quasi-steady, which means that
there is little to no gain from calculating the friction factor for each node and time step which is done in
the quasi-steady model. If a precise estimation of the wave propagation is wanted, an unsteady friction
model shall be used. A general behaviour for the experiments with copper pipes (experiments 2 and 3)
is that the friction in the pipe in steady state is underestimated. This can be due to some of the material
properties chosen for the simulations not exactly matching the real properties.
Fluids 2018, 3, 64 17 of 49
Based on the four experiments, the Vardy & Brown friction model is recommended as a generic
choice. The friction model has a good estimation of the wave behaviour and propagation. The head
of the friction model is in neither of the experiments underestimated, as e.g., Zielke and Zarzycki in
experiment 2.
Figure 8. Comparison of the experimental data of experiment 4 [41] with the simulated results obtained
with the Discrete Vapour Cavity Model (DVCM) and the Discrete Gas Cavity Model (DGCM).
Table 5. Comparison of the Discrete Vapour Cavity Model (DVCM), the Discrete Gas Cavity Model
(DGCM), and experimental results for experiment 4 [41].
The oscillation frequency of both DVCM and DGCM are close to the one obtained from the
experimental data of 20.24 Hz. In the first high pressure zone it can be seen that DVCM and DGCM
Fluids 2018, 3, 64 18 of 49
give almost identical results both overestimating the pressure by 2.93%. In the second high pressure
zone the large pressure peak is caused by the implosion of bubbles. Both models give an overestimation
of the second high pressure peak with DVCM giving an error of 6.28%. In the third pressure zone
neither of the models are able to model the largest pressure peak with DVCM underestimating the
pressure peak by 30.07% and DGCM by 21.91%. However, both models have a maximum pressure
exceeding this pressure in the previous pressure peak, and is therefore still conservative although
slightly inaccurate. On the tenth peak DVCM gives the best results overestimating the head by 10.17%
compared to DGCM by 17.53%. Overall the DVCM is the best model for experiment 4.
In Table 5, it can be seen that the calculation time for DVCM and DGCM is very similar, and hence
the added complexity of DGCM does not extend the calculation time significantly. Figure 9 and Table 6
show the results obtained with DVCM and DGCM for experiment 5.
The oscillation frequency is larger for both DVCM, 8.70 Hz, and DGCM, 8.46 Hz, than the one
obtained by the experimental data, 8.15 Hz. Thus, the models are expected to oscillate faster than
the experiment, which is also clear for DVCM. For DGCM it seems that there is almost no difference
between the oscillation of the model and the experiment. This means that the oscillation of the pressure
wave is accurate but that the timing of the pressure peaks are off.
Figure 9. Comparison of the experimental data of experiment 5 [43] with the simulated results obtained
with DVCM and DGCM.
Table 6. Comparison of DVCM, DGCM, and experimental results for experiment 5 [43].
In the first high pressure zone both models give similar results overestimating the pressure by
4.83% or 4.84%. For the second pressure peak both models give a good approximation of the pressure
with DGCM giving the best approximation with an overestimation of 4.53%. In the third high pressure
zone there is two high pressure peaks; one in the beginning and one in the end. Neither of the models
are able to model the pressure peak in the beginning of the third pressure zone, but both are able
to model the pressure peak in the end. This pressure peak is most accurately modelled by DGCM
with an overestimation of 7.61% compared to an underestimation of 13.80% with DVCM. In the
seventh pressure zone DVCM gives the best results with an overestimation of the pressure by 11.96%
compared to 19.57% obtained with DGCM. Overall DGCM gives the best result as it accurately model
the oscillation of the pressure wave and provides the best results when cavitation is occurring.
In Table 6, it can be seen that the calculation time for DVCM and DGCM is very similar, as was
the case with experiment 5, and hence the complexity of DGCM does not extend the calculation
time significantly.
Figure 10 and Table 7 show the results obtained with DGCM for experiment 6.
Figure 10. Comparison of the experimental data of experiment 6 [43] with the simulated results
obtained with DGCM.
In this experiment only the DGCM gives satisfactory results. The DVCM model has a way too fast
oscillation and dampening of the pressure, giving unrealistic results. Therefore, the results obtained
Fluids 2018, 3, 64 20 of 49
from DVCM have been omitted. This failure to obtain realistic results is attributed to the large void
fractions obtained, which is known to cause problems for the DVCM.
Comparing the oscillation frequency of the DGCM with the experiment it is clear that they
are almost identical at 2.92 Hz and 2.90 Hz respectively. Therefore almost no offset between the
experimental data and the simulated data are expected, as is also evident in Figure 10. The DGCM
give accurate results for the first three pressure zones never overestimating the pressure by more than
5.83%. However, at the fourth pressure zone the simulated data starts to exhibit some oscillations
causing an overestimation of 20.09%.
In Table 7, the calculation time for DGCM is shown. The reason for the calculation time being
lower than experiment 5, while still with a higher flow time, is due to experiment 5 using 48 reaches,
while experiment six uses only 24 reaches.
The overall best model for cavitation/column separation is considered to be the DGCM. It is
more robust and provides accurate results of the pressure while never underestimating the maximum
pressure. DGCM is recommended as a generic choice.
5. Conclusions
In this paper an implementation of a code for simulation of pressure transients in liquid-filled
piping both with and without cavitation/column separation has been presented. The solution scheme
implemented for simulating water hammer is the MOC.
For single phase/ liquid-filled pipe water hammer, six friction models are implemented and
tested against three different experiments found in literature. The friction models consist of a steady,
quasi-steady, and four unsteady models. The unsteady friction models consist of three CB models
(Zielke, Vardy and Brown, and Zarzycki) and one IAB model (Brunone). For the experiments included
in the present study the Vardy and Brown model seems to provide the best results.
Two models for taking the effects of cavitation/column separation into account have been
implemented, the DVCM and DGCM models. The two models are compared to three different
experiments. For all experimental comparisons the Vardy and Brown CB friction model has been
applied. For the included experiments the DGCM gives the best results overall, although the DVCM
provides a slightly better fit for a single experiment.
Generally, it is found that employing unsteady friction models the presented code is adequately
able to simulate the chosen experiments.
The authors provide the full verbatim source code to the presented MOC implementation along
with the present paper. In doing so, the authors hope that the code can find good use for others.
Author Contributions: Conceptualization, A.A. and M.M.; Data curation, R.K.J., J.K.L. and K.L.L.; Methodology,
R.K.J., J.K.L. and K.L.L.; Software, R.K.J., J.K.L. and K.L.L.; Validation, R.K.J., J.K.L., K.L.L., A.A. and M.M.; Formal
Analysis, R.K.J., J.K.L. and K.L.L.; Investigation, R.K.J., J.K.L. and K.L.L.; Writing—Original Draft Preparation,
R.K.J., J.K.L., K.L.L. and A.A.; Writing—Review and Editing, A.A. and M.M.; Supervision, A.A and M.M.
Funding: This research received no external funding.
Acknowledgments: Language secretary Susanne Tolstrup, Field Development, Ramboll Energy, has kindly
provided her assistance for proofreading this manuscript.
Conflicts of Interest: The authors declare no conflict of interest.
Fluids 2018, 3, 64 21 of 49
Abbreviations
The following common symbols are used in this manuscript:
α Void fraction, −
∆ Difference, −
e Pipe roughness, µm
µ Dynamic viscosity, kg/m· s
ν Kinematic viscosity, m2 /s
νp Poisson’s ratio, −
ρ Density, kg/m3
τ Dimensionless time, −
τv Dimensionless closing time, −
θ Pipe inclination, ◦
ψ Weighting factor, −
∗ Convolution operator, −
A Cross sectional area, m2
a Single phase wave speed, m/s
a0 Two phase wave speed, m/s
B Pipe constant, s/m2
c1 Poisson’s ratio dependent constant, −
C∗ Vardy shear decay coefficient, −
D Inner pipe diameter, m
E Young’s modulus, Pa
e Thickness of the pipe wall, m
f Darcy’s friction factor, −
g Gravitational acceleration, 9.81 m/s2
H Piezometric head, m
Hr Piezometric head at the reservoir, m
i&j Index notation, −
J Friction term, m/s2
K Bulk modulus, Pa
k Brunone’s friction coefficient or turbulent kinetic energy, − or m2 /s2
L Length of the pipe, m
n Number of reaches (divisions of the pipes), −
P Pressure, Pa
Q Volumetric flow rate, m3 /s
R&r Radius, m
Re Reynolds number, −
S Surface tension, N/m
T Temperature, K
t Time, s
u Velocity, m/s
V Volume, m3
W Weighting function, −
x Spatial coordinate, m
z Elevation of the pipe from datum, m
The program starts with importing user defined parameters and settings. The steady state
conditions is calculated before the closure of the valve. Then the spatial index, i, and the time index,
j, are set to 2. All the interior nodes are calculated, i.e., from i = 2 to i = n − 1 for time j = 2.
When i = n − 1 the boundary conditions, i.e., the flow conditions at the reservoir and the valve.
Then the accelerations are calculated if an unsteady friction model is used. If the time step j < nt ,
the time step is updated to j = j + 1 and i = 2 or if j = nt the simulation is finished and the data can
be outputted.
A flow chart of the calculation method for the interior nodes for the DVCM can be seen in
Figure A2, where the block with Vcav (i, j − 1) > 0 investigates the presence of a vapour cavity in
the previous time step. If a vapour cavity was present, it is assumed that the current time step
should be treated as a pressure boundary. If the node is calculated as a pressure boundary, the
calculations are followed by a check for whether the vapour cavity is less than or equal to zero. If this
is true, it is assumed that the vapour cavity has condensed, but the pressure has not risen above the
vapourization pressure.
Fluids 2018, 3, 64 23 of 49
| FrictionTerm.m
| PipeConst.m
| ResistanceCoeff.m
| WaveSpeed.m
| WeightFuncVardyBrown.m
| WeightFuncZarzycki.m
| WeightFuncZielke.m
|
+---Input
| Input.m
| Input_OnePhase_Adamkowski.m
| Input_OnePhase_Covas.m
| Input_OnePhase_Soares.m
| Input_OnePhase_Traudt.m
| Input_TwoPhase_Bergant_High_DGCM.m
| Input_TwoPhase_Bergant_High_DVCM.m
| Input_TwoPhase_Bergant_Low_DGCM.m
| Input_TwoPhase_Bergant_Low_DVCM.m
| Input_TwoPhase_Soares_DGCM.m
| Input_TwoPhase_Soares_DVCM.m
|
+---Output
| | Output.m
| |
| +---Mat_Files
| | Flow_Rate.mat
| | Head.mat
| | t.mat
| | Volume_Cavities.mat
| | Volume_Gas.mat
| |
| +---Text_Files
| | Flow_Rate.txt
| | Head.txt
| | t.txt
| | Volume_Cavities.txt
| | Volume_Gas.txt
| |
| \---Plot
| Head_and_Flow_Node_X.png
|
\---Solver
| Solver_DGCM.m
| Solver_DVCM.m
| Solver_SinglePhase.m
|
+---Boundary
| Reservoir_Upstream.m
| Reservoir_Upstream_DGCM.m
| Valve_Closure.m
| Valve_Closure_DGCM.m
| Valve_Closure_DVCM.m
|
+---InteriorNodes
| InteriorNodes_DGCM.m
| InteriorNodes_DVCM.m
| InteriorNodes_SinglePhase.m
|
\---SteadyState
SteadyState.m
SteadyState_DGCM.m
Fluids 2018, 3, 64 25 of 49
Master
5 %% S t a r t i n g t i m e r
6 tic
7
8 %% Adding f o l d e r s t o d i r e c t o r y
9 addpath ( ’ F u n c t i o n s ’ , ’ Output ’ , ’ S o l v e r ’ , ’ S o l v e r \Boundary ’ , . . .
10 ’ S o l v e r \ I n t e r i o r N o d e s ’ , ’ S o l v e r \ S t e a d y S t a t e ’ , ’ Output\ P l o t ’ , ’ Input ’ )
11
12 %% S p e c i f y Input F i l e
13 %Input
14 %Input_OnePhase_Traudt
15 %Input_OnePhase_Covas
16 %Input_OnePhase_Adamkowski
17 %Input_OnePhase_Soares
18 %Input_TwoPhase_Soares_DVCM
19 Input_TwoPhase_Soares_DGCM
20 %Input_TwoPhase_Bergant_Low_DVCM
21 %Input_TwoPhase_Bergant_Low_DGCM
22 %Input_TwoPhase_Bergant_High_DVCM
23 %Input_TwoPhase_Bergant_High_DGCM
24
39 %% C a l c u l a t i n g t h e weighting f u n c t i o n f o r unsteady f r i c t i o n
40 W = 0;
41 s w i tc h F r i c t i o n _ T y p e
42 case ’ Unsteady_Friction_Zielke ’
43 W = WeightFuncZielke ( v i s c o s i t y , dt , D, rho , n_t ) ;
44 c a s e ’ Unsteady_Friction_VardyBrown ’
45 W = WeightFuncVardyBrown ( v i s c o s i t y , dt , D, rho , Re_0 , n_t ) ;
46 case ’ Unsteady_Friction_Zarzycki ’
47 W = WeightFuncZarzycki ( v i s c o s i t y , dt , D, rho , Re_0 , n_t ) ;
48 end
49
50 %% S o l v e r
51 s w i tc h S o l v e r
52 c a s e ’ 1 D_SinglePhase ’
53 Solver_SinglePhase
54 c a s e ’ 1D_TwoPhase_DVCM ’
55 Solver_DVCM
56 c a s e ’ 1D_TwoPhase_DGCM ’
57 Solver_DGCM
58 end
59
Fluids 2018, 3, 64 26 of 49
60 %% D i s p l a y i n g and s t o r i n g t h e c a l c u l a t i o n time
61 toc
62 % C a l c u l a t i o n time [ s ]
63 t_cal = toc ;
64
65 %% Output
66 Output
Input
22 % Choose f r i c t i o n type :
23 % 1) P r e s c r i b e d _ S t e a d y _ S t a t e _ F r i c t i o n ( i n s e r t value i n f _ p r e )
24 % 2) Steady_State_Friction
25 % 3) Quasi_Steady_Friction
26 % 4) Unsteady_Friction_Brunone
27 % 5) Unsteady_Friction_Zielke
28 % 6) Unsteady_Friction_VardyBrown
29 % 7) Unsteady_Friction_Zarzycki
30 F r i c t i o n _ T y p e = ’ Unsteady_Friction_VardyBrown ’ ;
31
32 %% Mesh
33 % Number o f d i v i s i o n s o f t h e pipe [ − ]
34 Reaches = 4 8 ;
35 % One o s c i l l a t i o n i s f o u r ti me s t h e t r a v e l i n g time o f t h e p r e s s u r e wave [ − ]
36 Oscillations = 20;
37
38 %% U n i v e r s a l Constants
39 % G r a v i t a t i o n a l a c c e l e r a t i o n [m/s ^2]
40 g = 9.8;
41
54 roughness = 0 . 0 0 1 5 E − 3;
55 % Poisson ’ s r a t i o [ − ]
56 nu_p = 0 . 3 5 ;
57 % Angle o f i n c l i n a t i o n [ deg ]
58 theta = 0;
59
60 %% F l u i d P r o p e r t i e s
61 % Density o f water [ kg/m^3]
62 rho = 9 9 8 . 2 ;
63 % Bulk modulus o f water [ Pa ]
64 K = 2 . 2 E9 ;
65 % Dynamic v i s c o s i t y [ kg/m∗ s ]
66 v i s c o s i t y = 1 . 0 0 2 E − 3;
67
68 s w i tc h S o l v e r
69 c a s e ’ 1D_TwoPhase_DVCM ’
70 % Vapour p r e s s u r e i n p i e z o m e t r i c head [m]
71 H_vap = 0 . 1 0 7 9 3 ;
72 % B a r o m e t r i c p r e s s u r e head [m]
73 H_b = 101325/( rho ∗g ) ;
74 % Vapour p r e s s u r e i n gauge p i e z o m e t r i c head [m]
75 H_v = H_vap − H_b ;
76 c a s e ’ 1D_TwoPhase_DGCM ’
77 % S a t u r a t i o n p r e s s u r e i n p i e z o m e t r i c head [m]
78 H_sat = 0 . 1 0 7 9 3 ;
79 % B a r o m e t r i c p r e s s u r e head [m]
80 H_b = 101325/( rho ∗g ) ;
81 % S a t u r a t i o n p r e s s u r e i n gauge p i e z o m e t r i c head [m]
82 H_v = H_sat − H_b ;
83 % Void f r a c t i o n a t r e f e r e n c e p r e s s u r e [ − ]
84 alpha_0 = 1e − 7;
85 end
86
91 %% Flow I n p u t s
92 % I n i t i a l flow v e l o c i t y [m/s ]
93 u_0 = 0 . 1 5 6 e −3/A;
94 % I n i t i a l v o l u m e t r i c flow r a t e [m^3/ s ]
95 Q_0 = u_0∗A;
96 % I n i t i a l Reynolds number [ − ]
97 Re_0 = rho ∗u_0∗D/ v i s c o s i t y ;
98
99 %% Upstream r e s e r v o i r / I n i t i a l head
100 % Height/ p r e s s u r e o f t h e r e s e r v o i r [m]
101 H_r = 4 6 ;
102
103 %% Downstream v a l v e
104 % C l o s i n g time o f v a l v e [ s ]
105 t_c = 18/1000;
106
107 s w i t ch Downstream_boundary
108 case ’ Valve_Instantaneous_Closure ’
109 % Valve c l o s u r e c o e f f i c i e n t [ − ]
110 m = 0;
111 case ’ Valve_Transient_Closure ’
112 % Valve c l o s u r e c o e f f i c i e n t [ − ]
113 m = 5;
114 end
115
117 s w i tc h WaveSpeed_Type
118 c a s e ’ WaveSpeed_Calculate ’
119 % Speed o f t h e p r e s s u r e wave [m/s ]
120 a = WaveSpeed ( e , D, K, rho , E , nu_p ) ;
121 c a s e ’ WaveSpeed_Known ’
122 % Speed o f t h e p r e s s u r e wave [m/s ]
123 a = 1200;
124 end
125
WaveSpeed
12 %% C a l c u l a t i o n o f t h e wave speed
13 % Wave speed [m/s ]
14 a = s q r t (K/rho ) / s q r t ( 1 + (K∗D/(E∗e ) ) ∗ c_1 ) ;
15
16 end
WeightingFuncVardyBrown
12 f o r j = 1 : n_t −2
13 % Dimensionless time [ − ]
14 tau ( j ) = j ∗ dtau − 0 . 5 ∗ dtau ;
15 % Weighting f u n c t i o n [ − ]
16 W( j ) = A_star ∗ exp(− B _ s t a r ∗ tau ( j ) ) / s q r t ( tau ( j ) ) ;
17 end
18 end
Solver SinglePhase
1 %% I n i t i a l i z e m a t r i c e s t o reduce c a l c u l a t i o n time
2 % Volumetric flow r a t e [m^3/ s ]
3 Q( 1 : n , 1 : n_t ) = 0 ;
4 % P i e z o m e t r i c head [m]
5 H( 1 : n , 1 : n_t ) = 0 ;
6 % Time [ s ]
Fluids 2018, 3, 64 29 of 49
7 t ( 1 : n_t ) = 0 ;
8 % Height from datum [m]
9 z (1: n) = 0;
10 % Volumetric flow r a t e a c c e l e r a t i o n [m^3/ s ^2]
11 dQ( n , n_t − 2) = 0 ;
12
20 %% Steady S t a t e
21 [Q, H] = S t e a d y S t a t e ( Q_0 , H_r , rho , D, v i s c o s i t y , a , A, roughness , g , . . .
22 dx , Q, H, n , t h e t a , F r i c t i o n _ T y p e , f _ p r e ) ;
23
24 %% T r a n s i e n t flow
25 % j i n d i c a t e time s t e p number [ − ]
26 f o r j = 2 : n_t
27 % Time [ s ]
28 t ( j ) = t ( j − 1) + dt ;
29
30 %% I n t e r i o r Nodes
31 f o r i = 2 : n−1
32 [Q( i , j ) , H( i , j ) ] = I n t e r i o r N o d e s _ S i n g l e P h a s e ( a , g , A, rho , D , . . .
33 v i s c o s i t y , roughness , dx , t h e t a , Q( i − 1, j − 1) , H( i − 1, j − 1) , . . .
34 Q( i +1 , j − 1) , H( i +1 , j − 1) , Q, Re_0 , i , j , dt , F r i c t i o n _ T y p e , . . .
35 Q_0 , f_pre , W, dQ, n_t ) ;
36 end
37
38 %% Upstream Boundary
39 s w i tc h Upstream_boundary
40 case ’ Reservoir ’
41 [Q( 1 , j ) , H( 1 , j ) ] = Reservoir_Upstream ( a , g , A, rho , D, dx , . . .
42 v i s c o s i t y , roughness , t h e t a , Q( 2 , j − 1) , H( 2 , j − 1) , H_r , . . . .
43 Q, Re_0 , i , j , dt , F r i c t i o n _ T y p e , Q_0 , f_pre , W, dQ, n_t ) ;
44 end
45
46 %% Downstream Boundary
47 s w i tc h Downstream_boundary
48 case ’ Valve_Instantaneous_Closure ’
49 [Q( n , j ) , H( n , j ) ] = Valve_Closure ( a , g , A, D, dx , roughness , . . .
50 rho , v i s c o s i t y , t ( j ) , t _ c , m, t h e t a , Q( n , 1 ) , H( n , 1 ) , . . .
51 Q( n − 1, j − 1) , H( n − 1, j − 1) , Q, Re_0 , i , j , dt , . . .
52 F r i c t i o n _ T y p e , f_pre , W, dQ, n_t ) ;
53 case ’ Valve_Transient_Closure ’
54 [Q( n , j ) , H( n , j ) ] = Valve_Closure ( a , g , A, D, dx , roughness , . . .
55 rho , v i s c o s i t y , t ( j ) , t _ c , m, t h e t a , Q( n , 1 ) , H( n , 1 ) , . . .
56 Q( n − 1, j − 1) , H( n − 1, j − 1) , Q, Re_0 , i , j , dt , . . .
57 F r i c t i o n _ T y p e , f_pre , W, dQ, n_t ) ;
58 end
59
70 case ’ Unsteady_Friction_Zarzycki ’
71 i f j <n_t
72 dQ ( : , n_t − j +1) = Q ( : , j )−Q ( : , j − 1) ;
73 end
74 end
75 end
Solver DVCM
1 %% I n i t i a l i z e m a t r i c e s t o reduce c a l c u l a t i o n time
2 % Volumetric flow r a t e [m^3/ s ]
3 Q_u ( 1 : n , 1 : n_t ) = 0 ;
4 % Volumetric flow r a t e [m^3/ s ]
5 Q( 1 : n , 1 : n_t ) = 0 ;
6 % P i e z o m e t r i c head [m]
7 H( 1 : n , 1 : n_t ) = 0 ;
8 % Time [ s ]
9 t ( 1 : n_t ) = 0 ;
10 % Height from datum [m]
11 z (1: n) = 0;
12 % Volumetric flow r a t e a c c e l e r a t i o n [m^3/ s ^2]
13 dQ( n , n_t − 2) = 0 ;
14 % Vapour c a v i t y volume [m^3]
15 V_cav ( 1 : n , 1 : n_t ) = 0 ;
16
24 %% Steady S t a t e
25 [Q, H] = S t e a d y S t a t e ( Q_0 , H_r , rho , D, v i s c o s i t y , a , A, roughness , g , . . .
26 dx , Q, H, n , t h e t a , F r i c t i o n _ T y p e , f _ p r e ) ;
27 Q_u ( : , 1 ) = Q( : , 1 ) ;
28
29 %% T r a n s i e n t
30 % j i n d i c a t e time s t e p number [ − ]
31 f o r j = 2 : n_t
32 % Time [ s ]
33 t ( j ) = t ( j − 1) + dt ;
34
35 %% I n t e r i o r Nodes
36 % The d i f f e r e n t formulaton f o r j = 2 and j > 2 i s because Equation 7 . 9
37 % r e q u i r e s a vapour c a v i t y volume from two time s t e p s back . However as
38 % t h e r e i s no j = − 1, t h e s t e a d y s t a t e v a l u e s ( j = 1 ) w i l l be used f o r
39 % V_cav , Q, and Q_u i n Equation 7 . 9 .
40 i f j == 2
41 f o r i = 2 : n−1
42 [ Q_u ( i , j ) , Q( i , j ) , H( i , j ) , V_cav ( i , j ) ] = InteriorNodes_DVCM ( . . .
43 a , g , A, rho , D, v i s c o s i t y , roughness , dx , t h e t a , . . .
44 Q( i − 1, j − 1) , H( i − 1, j − 1) , Q_u ( i +1 , j − 1) , H( i +1 , j − 1) , Q , . . .
45 Q_u , Re_0 , i , j , dt , F r i c t i o n _ T y p e , Q_0 , f_pre , W, dQ , . . .
46 n_t , V_cav ( i , j − 1) , V_cav ( i , j − 1) , Q( i , j − 1) , Q_u ( i , j − 1) , . . .
47 psi , z ( i ) , H_v ) ;
48 end
49 else
50 f o r i = 2 : n−1
51 [ Q_u ( i , j ) , Q( i , j ) , H( i , j ) , V_cav ( i , j ) ] = InteriorNodes_DVCM ( . . .
52 a , g , A, rho , D, v i s c o s i t y , roughness , dx , t h e t a , . . .
53 Q( i − 1, j − 1) , H( i − 1, j − 1) , Q_u ( i +1 , j − 1) , H( i +1 , j − 1) , Q , . . .
54 Q_u , Re_0 , i , j , dt , F r i c t i o n _ T y p e , Q_0 , f_pre , W, dQ , . . .
Fluids 2018, 3, 64 31 of 49
60 %% Upstream Boundary
61 s w i tc h Upstream_boundary
62 case ’ Reservoir ’
63 [Q( 1 , j ) , H( 1 , j ) ] = Reservoir_Upstream ( a , g , A, rho , D, dx , . . .
64 v i s c o s i t y , roughness , t h e t a , Q_u ( 2 , j − 1) , H( 2 , j − 1) , H_r , . . .
65 Q_u , Re_0 , 1 , j , dt , F r i c t i o n _ T y p e , Q_0 , f_pre , W, dQ, n_t ) ;
66 end
67 Q_u ( 1 , j ) = Q( 1 , j ) ;
68
69 %% Downstream Boundary
70 % Again , because t h e r e i s no j = − 1, t h e s t e a d y s t a t e v a l u e s a r e used
71 % f o r V_cav , Q, and Q_u i n Equation 7 . 9 .
72 i f j == 2
73 s w i tc h Downstream_boundary
74 case ’ Valve_Instantaneous_Closure ’
75 [ Q_u ( n , j ) , Q( n , j ) , H( n , j ) , V_cav ( n , j ) ] = Valve_Closure_DVCM ( . . .
76 a , g , A, D, dx , roughness , rho , v i s c o s i t y , . . .
77 t ( j ) , t _ c , m, t h e t a , Q( n , 1 ) , H( n , 1 ) , Q( n − 1, j − 1) , . . .
78 H( n − 1, j − 1) , Q, Re_0 , n , j , dt , F r i c t i o n _ T y p e , f_pre , . . .
79 W, dQ, n_t , V_cav ( n , j − 1) , V_cav ( n , j − 1) , Q( n , j − 1) , . . .
80 Q_u ( n , j − 1) , psi , z ( n ) , H_v ) ;
81 case ’ Valve_Transient_Closure ’
82 [ Q_u ( n , j ) , Q( n , j ) , H( n , j ) , V_cav ( n , j ) ] = Valve_Closure_DVCM ( . . .
83 a , g , A, D, dx , roughness , rho , v i s c o s i t y , . . .
84 t ( j ) , t _ c , m, t h e t a , Q( n , 1 ) , H( n , 1 ) , Q( n − 1, j − 1) , . . .
85 H( n − 1, j − 1) , Q, Re_0 , n , j , dt , F r i c t i o n _ T y p e , f_pre , . . .
86 W, dQ, n_t , V_cav ( n , j − 1) , V_cav ( n , j − 1) , Q( n , j − 1) , . . .
87 Q_u ( n , j − 1) , psi , z ( n ) , H_v ) ;
88 end
89 else
90 s w i t ch Downstream_boundary
91 case ’ Valve_Instantaneous_Closure ’
92 [ Q_u ( n , j ) , Q( n , j ) , H( n , j ) , V_cav ( n , j ) ] = Valve_Closure_DVCM ( . . .
93 a , g , A, D, dx , roughness , rho , v i s c o s i t y , . . .
94 t ( j ) , t _ c , m, t h e t a , Q( n , 1 ) , H( n , 1 ) , Q( n − 1, j − 1) , . . .
95 H( n − 1, j − 1) , Q, Re_0 , n , j , dt , F r i c t i o n _ T y p e , f_pre , . . .
96 W, dQ, n_t , V_cav ( n , j − 1) , V_cav ( n , j − 2) , Q( n , j − 2) , . . .
97 Q_u ( n , j − 2) , psi , z ( n ) , H_v ) ;
98 case ’ Valve_Transient_Closure ’
99 [ Q_u ( n , j ) , Q( n , j ) , H( n , j ) , V_cav ( n , j ) ] = Valve_Closure_DVCM ( . . .
100 a , g , A, D, dx , roughness , rho , v i s c o s i t y , . . .
101 t ( j ) , t _ c , m, t h e t a , Q( n , 1 ) , H( n , 1 ) , Q( n − 1, j − 1) , . . .
102 H( n − 1, j − 1) , Q, Re_0 , n , j , dt , F r i c t i o n _ T y p e , f_pre , . . .
103 W, dQ, n_t , V_cav ( n , j − 1) , V_cav ( n , j − 2) , Q( n , j − 2) , . . .
104 Q_u ( n , j − 2) , psi , z ( n ) , H_v ) ;
105 end
106 end
107
Solver DGCM
1 %% I n i t i a l i z e m a t r i c e s t o reduce c a l c u l a t i o n time
2 % Volumetric flow r a t e [m^3/ s ]
3 Q_u ( 1 : n , 1 : n_t ) = 0 ;
4 % Volumetric flow r a t e [m^3/ s ]
5 Q( 1 : n , 1 : n_t ) = 0 ;
6 % P i e z o m e t r i c head [m]
7 H( 1 : n , 1 : n_t ) = 0 ;
8 % Time [ s ]
9 t ( 1 : n_t ) = 0 ;
10 % Height from datum [m]
11 z (1: n) = 0;
12 % Volumetric flow r a t e a c c e l e r a t i o n [m^3/ s ^2]
13 dQ( n , n_t − 2) = 0 ;
14 % Gas c a v i t y volume [m^3]
15 V_g ( 1 : n , 1 : n_t ) = 0 ;
16
31 %% Steady S t a t e
32 [Q, H, V_g ] = SteadyState_DGCM ( Q_0 , H_r , rho , D, v i s c o s i t y , a , A , . . .
33 roughness , g , dx , Q, H, n , t h e t a , F r i c t i o n _ T y p e , f_pre , alpha_0 , . . .
34 V _ t o t a l , V_g , z , H_v ) ;
35 Q_u ( : , 1 ) = Q( : , 1 ) ;
36
37 %% T r a n s i e n t
Fluids 2018, 3, 64 33 of 49
38 % j i n d i c a t e time s t e p number [ − ]
39 f o r j = 2 : n_t
40 % Time [ s ]
41 t ( j ) = t ( j − 1) + dt ;
42
43 %% I n t e r i o r Nodes
44 % The d i f f e r e n t formulaton f o r j = 2 and j > 2 i s because Equation 7 . 9
45 % r e q u i r e s a vapour c a v i t y volume from two time s t e p s back . However as
46 % t h e r e i s no j = − 1, t h e s t e a d y s t a t e v a l u e s ( j = 1 ) w i l l be used f o r
47 % V_g , Q, and Q_u i n Equation 7 . 9 .
48 i f j == 2
49 f o r i = 2 : n−1
50 [ Q_u ( i , j ) , Q( i , j ) , H( i , j ) , V_g ( i , j ) ] = InteriorNodes_DGCM ( . . .
51 a , g , A, rho , D, v i s c o s i t y , roughness , dx , t h e t a , . . .
52 Q( i − 1, j − 1) , H( i − 1, j − 1) , Q_u ( i +1 , j − 1) , H( i +1 , j − 1) , Q , . . .
53 Q_u , Re_0 , i , j , dt , F r i c t i o n _ T y p e , Q_0 , f_pre , W, dQ , . . .
54 n_t , H( i , 1 ) , alpha_0 , V _ t o t a l ( i , 1 ) , V_g ( i , j − 1) , Q( i , j − 1) , . . .
55 Q_u ( i , j − 1) , psi , z ( i ) , H_v ) ;
56 end
57 else
58 f o r i = 2 : n−1
59 [ Q_u ( i , j ) , Q( i , j ) , H( i , j ) , V_g ( i , j ) ] = InteriorNodes_DGCM ( . . .
60 a , g , A, rho , D, v i s c o s i t y , roughness , dx , t h e t a , . . .
61 Q( i − 1, j − 1) , H( i − 1, j − 1) , Q_u ( i +1 , j − 1) , H( i +1 , j − 1) , Q , . . .
62 Q_u , Re_0 , i , j , dt , F r i c t i o n _ T y p e , Q_0 , f_pre , W, dQ , . . .
63 n_t , H( i , 1 ) , alpha_0 , V _ t o t a l ( i , 1 ) , V_g ( i , j − 2) , Q( i , j − 2) , . . .
64 Q_u ( i , j − 2) , psi , z ( i ) , H_v ) ;
65 end
66 end
67
68 %% Upstream Boundary
69 s w i tc h Upstream_boundary
70 case ’ Reservoir ’
71 [ Q_u ( 1 , j ) , Q( 1 , j ) , H( 1 , j ) , V_g ( 1 , j ) ] = Reservoir_Upstream_DGCM ( . . .
72 a , g , A, rho , D, dx , v i s c o s i t y , roughness , t h e t a , . . .
73 Q_u ( 2 , j − 1) , H( 2 , j − 1) , H_r , Q_u , Re_0 , 1 , j , dt , . . .
74 F r i c t i o n _ T y p e , Q_0 , f_pre , W, dQ, n_t , H( 1 , 1 ) , alpha_0 , . . .
75 V _ t o t a l ( 1 , 1 ) , z ( 1 ) , H_v ) ;
76 end
77
78 %% Downstream Boundary
79 % Again , because t h e r e i s no j = − 1, t h e s t e a d y s t a t e v a l u e s a r e used
80 % f o r V_g , Q, and Q_u i n Equation 7 . 9 .
81 i f j == 2
82 s w i tc h Downstream_boundary
83 case ’ Valve_Instantaneous_Closure ’
84 [ Q_u ( n , j ) , Q( n , j ) , H( n , j ) , V_g ( n , j ) ] = Valve_Closure_DGCM ( . . .
85 a , g , A, D, dx , roughness , rho , v i s c o s i t y , . . .
86 t ( j ) , t _ c , m, t h e t a , Q( n , 1 ) , H( n , 1 ) , Q( n − 1, j − 1) , . . .
87 H( n − 1, j − 1) , Q, Re_0 , n , j , dt , F r i c t i o n _ T y p e , f_pre , . . .
88 W, dQ, n_t , alpha_0 , V _ t o t a l ( n , 1 ) , V_g ( n , j − 1) , . . .
89 Q( n , j − 1) , Q_u ( n , j − 1) , psi , z ( n ) , H_v ) ;
90 case ’ Valve_Transient_Closure ’
91 [ Q_u ( n , j ) , Q( n , j ) , H( n , j ) , V_g ( n , j ) ] = Valve_Closure_DGCM ( . . .
92 a , g , A, D, dx , roughness , rho , v i s c o s i t y , . . .
93 t ( j ) , t _ c , m, t h e t a , Q( n , 1 ) , H( n , 1 ) , Q( n − 1, j − 1) , . . .
94 H( n − 1, j − 1) , Q, Re_0 , n , j , dt , F r i c t i o n _ T y p e , f_pre , . . .
95 W, dQ, n_t , alpha_0 , V _ t o t a l ( n , 1 ) , V_g ( n , j − 1) , . . .
96 Q( n , j − 1) , Q_u ( n , j − 1) , psi , z ( n ) , H_v ) ;
97 end
98 else
99 s w i tc h Downstream_boundary
100 case ’ Valve_Instantaneous_Closure ’
Fluids 2018, 3, 64 34 of 49
SteadyState
9 % R i s a r e s i s t a n c e c o e f f i c i e n t , which d e s c r i b e s t h e f r i c t i o n a t s t e a d y
10 % s t a t e where unsteady f r i c t i o n i s zero .
11 s w i tc h F r i c t i o n _ T y p e
12 case ’ Prescribed_Steady_State_Friction ’
13 % R e s i s t a n c e c o e f f i c i e n t [ s ^2/m^5]
14 R = f _ p r e ∗dx /(2∗ g∗D∗A^2) ;
15 otherwise
16 % R e s i s t a n c e c o e f f i c i e n t [ s ^2/m^5]
17 R = R e s i s t a n c e C o e f f ( g , D, A, dx , roughness , rho , Q_0 , v i s c o s i t y ) ;
18 end
19
20 for i = 2:n
21 % P i e z o m e t r i c head , d i s r e g a r d i n g f r i c t i o n [m]
22 H_0 = H( i − 1 ,1) − dx ∗ sind ( t h e t a ) ;
23 % P i e z o m e t r i c head [m]
24 H( i , 1 ) = H_0 − R∗Q_0∗ abs ( Q_0 ) + dx /( a∗A) ∗ sind ( t h e t a ) ∗Q_0 ;
25 end
26
27 end
Fluids 2018, 3, 64 35 of 49
SteadyState DGCM
10 % R i s a r e s i s t a n c e c o e f f i c i e n t , which d e s c r i b e s t h e f r i c t i o n a t s t e a d y
11 % s t a t e where unsteady f r i c t i o n i s zero .
12 s w i tc h F r i c t i o n _ T y p e
13 case ’ Prescribed_Steady_State_Friction ’
14 % R e s i s t a n c e c o e f f i c i e n t [ s ^2/m^5]
15 R = f _ p r e ∗dx /(2∗ g∗D∗A^2) ;
16 otherwise
17 % R e s i s t a n c e c o e f f i c i e n t [ s ^2/m^5]
18 R = R e s i s t a n c e C o e f f ( g , D, A, dx , roughness , rho , Q_0 , v i s c o s i t y ) ;
19 end
20
21 for i = 2:n
22 % P i e z o m e t r i c head , d i s r e g a r d i n g f r i c t i o n [m]
23 H_0 = H( i − 1 ,1) − dx ∗ sind ( t h e t a ) ;
24 % P i e z o m e t r i c head [m]
25 H( i , 1 ) = H_0 − R∗Q_0∗ abs ( Q_0 ) + dx /( a∗A) ∗ sind ( t h e t a ) ∗Q_0 ;
26 end
27
28 for i = 1:n
29 % Gas c a v i t y volume [m^3]
30 V_g ( i , 1 ) = alpha_0 ∗ V _ t o t a l ( i , 1 ) ;
31 end
32
33 end
InteriorNodes SinglePhase
InteriorNodes DVCM
29 % Checking i f t h e vapour c a v i t y d i s a p p e a r s .
30 i f V_cav_P <= 0
31 %% Vapour c a v i t y d i s a p p e a r s because o f a r i s e i n head .
32 % Vapour c a v i t y volume [m^3]
33 V_cav_P = 0 ;
34 % P i e z o m e t r i c head [m]
35 H_P = ( C_p + C_m) / 2 ;
36
47 end
48 else
49 %% No vapour c a v i t y was p r e s e n t i n t h e pr ev i ou s time s t e p .
50 % P i e z o m e t r i c head [m]
51 H_P = ( C_p + C_m) / 2 ;
52
65 % Checking i f a vapour c a v i t y i s c r e a t e d .
Fluids 2018, 3, 64 37 of 49
66 i f V_cav_P <= 0
67 %% No vapour c a v i t y i s c r e a t e d .
68 % Vapour c a v i t y volume [m^3]
69 V_cav_P = 0 ;
70 % P i e z o m e t r i c head [m]
71 H_P = ( C_p + C_m) / 2 ;
72
83 end
84 else
85 %% Head i s above v a p o u r i z a t i o n l e v e l .
86 % Vapour c a v i t y volume [m^3]
87 V_cav_P = 0 ;
88 % Volumetric flow r a t e [m^3/ s ]
89 Q_u_P = ( C_p − H_P ) /B ;
90 % Volumetric flow r a t e [m^3/ s ]
91 Q_P = Q_u_P ;
92 end
93 end
94
95 end
InteriorNodes DGCM
17 %% C a l c u l a t i o n o f head − F l u i d T r a n s i e n t s i n Systems
18 % P r e s s u r e a t s t e a d y s t a t e [ Pa ]
19 P_0 = rho ∗g ∗ ( H_0 − z_P − H_v ) ;
20 % Constant [m^4]
21 C_3 = P_0∗ alpha_0 ∗ V _ t o t a l /( rho ∗g ) ;
22 % Constant [ − ]
23 B_2 = 0 . 5 / 2 ;
24 % Constant [m^2]
25 C_4 = B_2∗B∗C_3 /( p s i ∗ dt ) ;
26 % Constant [m^3/ s ]
27 B_v = ( V_g_P0 /(2∗ dt ) + ( 1 − p s i ) ∗ ( Q_P0 − Q_u_P0 ) ) / p s i ;
28
29 i f B_v <= 0
30 % Constant [m^3/ s ]
Fluids 2018, 3, 64 38 of 49
31 B_v = 0 ;
32 end
33
34 % Constant [m/s ]
35 B_1 = −B_2 ∗ (C_m + C_p ) + B_2∗B∗B_v + ( z_P + H_v ) / 2 ;
36
37 i f B_1 == 0
38 % P i e z o m e t r i c head [m]
39 H_P = s q r t ( C_4 ) + z_P + H_v ;
40 else
41 % Constant [ − ]
42 B_B = C_4/B_1 ^ 2 ;
43
72 i f V_g_P < 0
73 % Gas c a v i t y volume [m^3]
74 V_g_P = C_3 /(H_P − z_P − H_v ) ;
75 end
76
77 end
Reservoir Upstream
Valve Closure
13 %% C a l c u l a t i n g t h e v o l u m e t r i c flow r a t e a t t h e v a l v e
14 % Pipe c o n s t a n t [ s/m^2]
15 B = PipeConst ( a , g , A) ;
16 % P o s i t i v e c h a r a c t e r i s t i c s e q u a t i o n [m]
17 C_p = C h a r a c t e r i s t i c _ P l u s ( a , g , A, D, dx , roughness , rho , . . .
18 v i s c o s i t y , t h e t a , Q_A, H_A, Q, Re_0 , i , j , dt , . . .
19 F r i c t i o n _ T y p e , Q_0 , f_pre , W, dQ, n_t ) ;
20 % V a r i a b l e [m^5/ s ^2]
21 C_v = ( Q_0∗ tau_v ) ^2/(2∗H_0 ) ;
22 % Volumetric flow r a t e [m^3/ s ]
23 Q_P = − B∗C_v + s q r t ( ( B∗C_v ) ^2 + 2∗C_v∗C_p ) ;
24
25 %% C a l c u l a t i o n o f t h e head
26 % P i e z o m e t r i c head [m]
27 H_P = C_p − B∗Q_P ;
28
29 end
Fluids 2018, 3, 64 40 of 49
14 %% C a l c u l a t i n g t h e v o l u m e t r i c flow r a t e a t t h e v a l v e
15 % Pipe c o n s t a n t [ s/m^2]
16 B = PipeConst ( a , g , A) ;
17 % P o s i t i v e c h a r a c t e r i s t i c s e q u a t i o n [m]
18 C_p = C h a r a c t e r i s t i c _ P l u s ( a , g , A, D, dx , roughness , rho , v i s c o s i t y , . . .
19 t h e t a , Q_A, H_A, Q, Re_0 , i , j , dt , F r i c t i o n _ T y p e , Q_0 , f_pre , W, . . .
20 dQ, n_t ) ;
21 % V a r i a b l e [m^5/ s ^2]
22 C_v = ( Q_0∗ tau_v ) ^2/(2∗H_0 ) ;
23 % Volumetric flow r a t e [m^3/ s ]
24 Q_P = − B∗C_v + s q r t ( ( B∗C_v ) ^2 + 2∗C_v∗C_p ) ;
25
26 %% C a l c u l a t i o n o f t h e head
27 % Checking i f a vapour c a v i t y was p r e s e n t a t t h e pr e vi ou s time s t e p .
28 i f V_cav_t > 0
29 %% Vapour c a v i t y was p r e s e n t a t t h e pr e vi ou s time s t e p .
30 % P i e z o m e t r i c head [m]
31 H_P = z_P + H_v ;
32 % Volumetric flow r a t e [m^3/ s ]
33 Q_u_P = ( C_p − H_P) /B ;
34 % Vapour c a v i t y volume [m^3]
35 V_cav_P = V_cav_P0 + 2∗ dt ∗ ( p s i ∗ (Q_P − Q_u_P ) + ( 1 − p s i ) ∗ ( Q_P0 − Q_u_P0 ) ) ;
36
37 % Checking i f t h e vapour c a v i t y d i s a p p e a r s .
38 i f V_cav_P <= 0
39 %% Vapour c a v i t y d i s a p p e a r s because o f a r i s e i n head
40 % Vapour c a v i t y volume [m^3]
41 V_cav_P = 0 ;
42 % Volumetric flow r a t e [m^3/ s ]
43 Q_u_P = Q_P ;
44 % P i e z o m e t r i c head [m]
45 H_P = C_p − B∗Q_P ;
46
52 end
53 else
54 %% No vapour c a v i t y was p r e s e n t i n t h e pr ev i ou s time s t e p
55 % Volumetric flow r a t e [m^3/ s ]
56 Q_u_P = Q_P ;
57 % P i e z o m e t r i c head [m]
58 H_P = C_p − B∗Q_u_P ;
59
62 %% Head f e l l below v a p o u r i z a t i o n l e v e l .
63 % P i e z o m e t r i c head [m]
64 H_P = z_P + H_v ;
65 % Volumetric flow r a t e [m^3/ s ]
66 Q_u_P = ( C_p − H_P ) /B ;
67 % Vapour c a v i t y volume [m^3]
68 V_cav_P = V_cav_P0 + 2∗ dt ∗ ( p s i ∗ (Q_P − Q_u_P ) + ( 1 − p s i ) ∗ ( Q_P0 − Q_u_P0 ) ) ;
69
70 % Checking i f a vapour c a v i t y i s c r e a t e d .
71 i f V_cav_P <= 0
72 %% No vapour c a v i t y i s c r e a t e d
73 % Vapour c a v i t y volume [m^3]
74 V_cav_P = 0 ;
75 % P i e z o m e t r i c head [m]
76 H_P = C_p − B∗Q_P ;
77
93 end
14 %% C a l c u l a t i n g t h e v o l u m e t r i c flow r a t e a t t h e v a l v e
15 % Pipe c o n s t a n t [ s/m^2]
16 B = PipeConst ( a , g , A) ;
17 % P o s i t i v e c h a r a c t e r i s t i c s e q u a t i o n [m]
18 C_p = C h a r a c t e r i s t i c _ P l u s ( a , g , A, D, dx , roughness , rho , v i s c o s i t y , . . .
19 t h e t a , Q_A, H_A, Q, Re_0 , n , j , dt , F r i c t i o n _ T y p e , Q_0 , f_pre , W, . . .
20 dQ, n_t ) ;
21 % V a r i a b l e [m^5/ s ^2]
22 C_v = ( Q_0∗ tau ) ^2/(2∗H_0 ) ;
23 % Volumetric flow r a t e [m^3/ s ]
24 Q_P = − B∗C_v + s q r t ( ( B∗C_v ) ^2 + 2∗C_v∗C_p ) ;
25
26 %% C a l c u l a t i o n o f t h e head
27 % P r e s s u r e a t s t e a d y s t a t e [ Pa ]
28 P_0 = rho ∗g ∗ ( H_0 − z_P − H_v ) ;
Fluids 2018, 3, 64 42 of 49
29 % Constant [m^4]
30 C_3 = P_0∗ alpha_0 ∗ V _ t o t a l /( rho ∗g ) ;
31 % Constant [ − ]
32 B_2 = 1 / 2 ;
33 % Constant [m^2]
34 C_4 = B_2∗B∗C_3 /( p s i ∗ dt ) ;
35 % Constant [m^3/ s ]
36 B_v = ( V_g_P0 /(2∗ dt ) + ( 1 − p s i ) ∗ ( Q_P0 − Q_u_P0 ) ) / p s i ;
37
38 i f B_v <= 0
39 % Constant [m^3/ s ]
40 B_v = 0 ;
41 end
42
43 % Constant [m/s ]
44 B_1 = −B_2 ∗ ( C_p − B∗Q_P ) + B_2∗B∗B_v + ( z_P + H_v ) / 2 ;
45
46 i f B_1 == 0
47 % P i e z o m e t r i c head [m]
48 H_P = s q r t ( C_4 ) + z_P + H_v ;
49 else
50 % Constant [ − ]
51 B_B = C_4/B_1 ^ 2 ;
52 i f B_1 < 0 && B_B >= 0 . 0 0 1
53 % P i e z o m e t r i c head [m]
54 H_P = −B_1 ∗ ( 1 + s q r t ( 1 + B_B ) ) + z_P + H_v ;
55 e l s e i f B_1 > 0 && B_B >= 0 . 0 0 1
56 % P i e z o m e t r i c head [m]
57 H_P = −B_1 ∗ ( 1 − s q r t ( 1 + B_B ) ) + z_P + H_v ;
58 e l s e i f B_1 < 0 && B_B < 0 . 0 0 1
59 % P i e z o m e t r i c head [m]
60 H_P = −2∗B_1 − C_4 /(2∗ B_1 ) + z_P + H_v ;
61 e l s e i f B_1 > 0 && B_B < 0 . 0 0 1
62 % P i e z o m e t r i c head [m]
63 H_P = C_4 /(2∗ B_1 ) + z_P + H_v ;
64 end
65 end
66
78 i f V_g_P < 0
79 % Gas c a v i t y volume [m^3]
80 V_g_P = C_3 /(H_P − z_P − H_v ) ;
81 end
82
83 end
Characteristic Plus
6 % f o r t h e p o s i t i v e or t h e n e g a t i v e c h a r a c t e r i s t i c s l i n e .
7 Charact_Line = ’ Plus ’ ;
8
9 % Pipe c o n s t a n t [ s/m^2]
10 B = PipeConst ( a , g , A) ;
11
12 % F r i c t i o n term [m]
13 J = F r i c t i o n T e r m ( F r i c t i o n _ T y p e , D, roughness , rho , Re_0 , Q_0 , Q_p , Q , . . .
14 v i s c o s i t y , A, i , j , dx , dt , Charact_Line , g , a , f_pre , W, dQ, n_t ) ;
15
16 % P o s i t i v e c h a r a c t e r i s t i c s e q u a t i o n [m]
17 C_p = H_p + Q_p∗ ( B + dx /( a∗A) ∗ sind ( alpha ) ) − J ;
18 end
Characteristic Minus
9 % Pipe c o n s t a n t [ s/m^2]
10 B = PipeConst ( a , g , A) ;
11
12 % F r i c t i o n term [m]
13 J = F r i c t i o n T e r m ( F r i c t i o n _ T y p e , D, roughness , rho , Re_0 , Q_0 , Q_m, Q , . . .
14 v i s c o s i t y , A, i , j , dx , dt , Charact_Line , g , a , f_pre , W, dQ, n_t ) ;
15
16 % Negative c h a r a c t e r i s t i c s e q u a t i o n [m]
17 C_m = H_m + Q_m∗( −B + dx /( a∗A) ∗ sind ( alpha ) ) + J ;
18 end
FrictionTerm
89 end
90 end
91 % F r i c t i o n term [m]
92 J = J _ s + J _ q + J_u ;
93 end
FricFac
6 i f Re==0
7 % Darcy f r i c t i o n f a c t o r f o r zero flow [ − ]
8 f = 1;
9 e l s e i f Re>0 && Re<2100
10 %% Laminar flow
11 % Darcy f r i c t i o n f a c t o r f o r laminar flow [ − ]
12 f = 64/Re ;
13 else
14 %% Colebrook −White e q u a t i o n
15 % The f r i c t i o n f a c t o r , f , i s solved i t e r a t i v e l y with f f being t h e i n i t i a l
16 % value , and t h e a c c e p t e d e r r o r being 1E − 12. e r r i s t h e e r r o r compared
17 % with t h e allow e r r o r , and t h e f r i c t i o n f a c t o r i s only a c c e p t e d when
18 % e r r becomes lower than 1E − 12.
19 % I n i t i a l i z i n g f f [ −]
20 ff = 10;
21 % S e t t i n g lower e r r o r l i m i t [ − ]
22 err = 0.0001;
23 % I n i t i a l i z i n g Darcy f r i t i o n f a c t o r [ − ]
24 f_old = 0;
25
BrunoneFricp
14 % Brunone ’ s f r i c t i o n c o e f f i c i e n t [ − ]
Fluids 2018, 3, 64 46 of 49
15 k = s q r t (C) / 2 ;
16
BrunoneFricm
14 % Brunone ’ s f r i c t i o n c o e f f i c i e n t [ − ]
15 k = s q r t (C) / 2 ;
16
CBFricp
CBFricp
References
1. Algirdas, K.; Uspuras, E.; Vaišnoras, M. Benchmarking analysis of water hammer effects using RELAP5 code
and development of RBMK-1500 reactor main circulation circuit model. Ann. Nucl. Energy 2007, 34, 1–12.
[CrossRef]
2. Zuo, Q.; Qiu, S.; Lu, W.; Tian, W.; Su, G.; Xiao, Z. Water hammer characteristics of integral pressurized water
reactor primary loop. Nucl. Eng. Des. 2013, 261, 165–173. [CrossRef]
3. Kaliatka, A.; Vaišnoras, M.; Valinčius, M. Modelling of valve induced water hammer phenomena in a district
heating system. Comput. Fluids 2014, 94, 30–36. [CrossRef]
4. Bonin, C. Water-hammer damage to Oigawa Power Station. ASME J. Eng. Power 1960, 82. [CrossRef]
5. Tadić Ananić, M.; Gjetvaj, G. Water hammer in irrigation systems. GRAÐEVINAR 2017, 69, 633–638.
[CrossRef]
6. Kaya, B.; Güney, M.S. An Optimization Model and Waterhammer for Sprinkler Irrigation Systems. Turk. J.
Eng. Environ. Sci. 2000, 24, 203–215.
7. Ord, S.C. Water hammer—Do we need to protect against it? How to predict it and prevent it damaging
pipelines and equipment. IChemE Symp. Ser. 2006, 151, 20.
8. Zurigat, Y.; Jubran, B.; Khezzar, L. Surge Analysis of Multiphase Flow in a Gathering Manifold.
Pet. Sci. Technol. 2008, 26, 1741–1756. [CrossRef]
9. Li, C.; Liao, K.; Jia, W.; Wu, X. Waterhammer Analysis of Oil Transportation Pipeline Using
Brunone-Vitkovsky Unsteady Flow Friction Model. In Proceedings of the 2011 Asia-Pacific Power and
Energy Engineering Conference, Wuhan, China, 25–28 March 2011; pp. 1–5. [CrossRef]
10. Zhao, M.; Ghidaoui, M.S. Godunov-Type Solutions for Water Hammer Flows. J. Hydraul. Eng. 2004,
130, 341–348. [CrossRef]
11. Chaudhry, M.H.; Hussaini, M.Y. Second-Order Accurate Explicit Finite-Difference Schemes for Waterhammer
Analysis. J. Fluids Eng. 1985, 107, 523–539. [CrossRef]
12. Jiang, D.; Ren, C.; Zhao, T.; Cao, W. Pressure Transient Model of Water-Hydraulic Pipelines with Cavitation.
Appl. Sci. 2018, 8, 388. [CrossRef]
13. Keramat, A.; Tijsseling, A.S.; Hou, Q.; Ahmadi, A. Fluid-Structure Interaction with Pipe-Wall Viscoelasticity
During Water Hammer. J. Fluids Struct. 2012, 28, 434–455. [CrossRef]
14. Ghidaoui, M.S.; Zhao, M.; McInnis, D.A.; Axworthy, D.H. A Review of Water Hammer Theory and Practice.
Appl. Mech. Rev. 2005, 58, 49–75. [CrossRef]
15. Wylie, E.B.; Streeter, V.L. Fluid Transients, 1st ed.; Prentice-Hall: Englewood Cliffs, NJ, USA, 1983.
Fluids 2018, 3, 64 48 of 49
16. Eaton, J.W.; Bateman, D.; Hauberg, S.; Wehbring, R. GNU Octave Version 4.4.1 Manual: A High-Level
Interactive Language for Numerical Computations. Available online: https://www.gnu.org/software/
octave/doc/v4.4.1/ (accessed on 31 August 2018).
17. Pozos-Estrada, O.; Sánchez-Huerta, A.; Breña-Naranjo, J.A.; Pedrozo-Acuña, A. Failure Analysis of a Water
Supply Pumping Pipeline System. Water 2016, 8, 395. [CrossRef]
18. Tuck, J.; Lee, P. Inverse Transient Analysis for Classification of Wall Thickness Variations in Pipelines. Sensors
2013, 13, 17057–17066. [CrossRef]
19. Wan, W.; Zhang, B. Investigation of Water Hammer Protection in Water Supply Pipeline Systems Using an
Intelligent Self-Controlled Surge Tank. Energies 2018, 11, 1450. [CrossRef]
20. Code on Savannah Free Software Repository. Available online: https://savannah.nongnu.org/projects/
whammer/ (accessed on 31 August 2018).
21. Wylie, E.B.; Streeter, V.L. Fluid Transients in Systems, 1st ed.; Prentice-Hall: Upper Saddle River, NJ, USA, 1993.
22. Chaudry, M.H. Applied Hydraulic Transients, 3rd ed.; Springer: Berlin, Germany, 2014.
23. Kwon, H.J. Analysis of transient flow in a piping system. KSCE J. Civ. Eng. 2007, 11, 209–214. [CrossRef]
24. Pothof, I. A Turbulent Approach to Unsteady Fiction. J. Hydraul. Res. 2008, 46, 679–690. [CrossRef]
25. Carlsson, J. Water Hammer Phenomenon Analysis using the Method of Characteristics and Direct
Measurements Using a “Stripped” Electromagnetic Flow Meter. Master’s Thesis, KTH, Physics, Stockholm,
Sweden, 2016.
26. Zielke, W. Frequency-Dependent friction in transient pipe flow. J. Basic Eng. 1969, 91, 109–115. [CrossRef]
27. Vardy, A.E.; Brown, J.M.B. Transient turbulent friction in smooth pipe flows. J. Sound Vib. 2003, 259, 1011–1036.
[CrossRef]
28. Vardy, A.E.; Brown, J.M.B. Transient turbulent friction in fully rough pipe flows. J. Sound Vib. 2004,
270, 233–257. [CrossRef]
29. Zarzycki, Z.; Kudzma, S.; Urbanowicz, K. Improved method for simulating transients of turbulent pipe flow.
J. Theor. Appl. Mech. 2011, 49, 135–158.
30. Brunone, B.; Karney, B.W.; Mecarelli, M.; Ferrante, M. Velocity profiles and unsteady pipe friction in transient
flow. J. Water Resour. Plan. Manag. 2000, 126, 236–244. [CrossRef]
31. Vítkovský, J.P.; Lambert, M.F.;Lambert, A.R.; Bergant, A. Advances in unsteady friction modelling in
transient pipe flow. In Proceedings of the 8th International Conference on Pressure Surges–Safe Design and
Operation of Industrial Pipe System, Hague, The Netherlands, 12–14 April 2000.
32. Vítkovský, J.P.; Simpson, A.R.; Lambert, M.F.; Wang, X.J. An experimental verification of the inverse transient
technique. In Proceedings of the 6th Conference on Hydraulics in Civil 6th Conference on Hydraulics in
Civil Engineering: The State of Hydraulics, Hobart, Tasmania, 28–30 November 2001.
33. Ramos, H.M.; Covas, D.; Borga, A.; Loureiro, D. Surge damping analysis in pipe systems: Modelling and
experiments. J. Hydraul. Res. 2004, 42, 413–425. [CrossRef]
34. Axworthy, D.H.; Ghidaoui, M.S.; McInnis, D.A. Extended Thermodynamics Derivation of Energy Dissipation
in Unsteady Pipe Flow. J. Hydraul. Eng. 2000, 126, 276–287. [CrossRef]
35. Storli, P.T.; Nielsen, T.K. Transient friction in pressurized pipes. III: Investigation of the EIT model based on
position-dependent coefficient approach in MIAB model. J. Hydraul. Eng. 2011, 137, 1047–1053. [CrossRef]
36. Urbanowicz, K.; Zarzycki, Z. Convolution Integral in Transient Pipe Flow. In Proceedings of the XX Fluid
Mechanics Conference KKMP2012, Task Quarterly 16 no. 3-4, Gliwice, Poland, 17–20 September 2012.
37. Bergant, A.; Simpson, A.R.; Vítkovský, J. Developments in unsteady pipe flow friction modelling.
J. Hydraul. Res. 2001, 39, 249–257. [CrossRef]
38. Provoost, G.A.; Wylie, E.B. Discrete gas model to represent distributed free gas in liquids. In Proceedings of
the 5th International Symposium on Column Separation. International Association for Hydraulic Research,
Obernach, Germany, 28–30 September 1981; pp. 249–258.
39. Simpsons, A.R.; Bergant, A. Numerical Comparison of Pipe-Column-Seperation Models. J. Hydraul. Eng.
1994, 120, 361–377. [CrossRef]
40. Adamkowski, A.; Lewandowski, M. Experimental Examination of Unsteady Friction Models for Transient
Pipe Flow Simulation. J. Fluids Eng. 2006, 128, 1361–1363. [CrossRef]
41. Soares, A.K.; Martins, N.; Covas, D.I. Investigation of Transient Vaporous Cavitation: Experimental and
Numerical Analyses. Procedia Eng. 2015, 119, 235–242. [CrossRef]
Fluids 2018, 3, 64 49 of 49
42. Traudt, T.; Bombardieri, C.; Manfletti, C. Influences on Water-hammer Wave Shape: An Experimental Study.
CEAS Space J. 2016, 8, 215–227. [CrossRef]
43. Bergant, A.; Karadzic, U.; Vítkovský, J.; Vusanovic, I.; Simpson, A.R. A Discrete Gas-Cavity Model that
Considers the Friction Effects of Unsteady Pipe Flow. Stronjniski Vestn.-J. Mech. Eng. 2005, 5111, 692–710.
44. Jensen, R.K.; Larsen, J.K.; Lassen, K.L. Modelling of a Two Phase Water Hammer. Master’s Thesis, Aalborg
University Esbjerg, Esbjerg, Denmark, 2018.
c 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access
article distributed under the terms and conditions of the Creative Commons Attribution
(CC BY) license (http://creativecommons.org/licenses/by/4.0/).