Introduction

Water hammer is the formation of pressure wave due to sudden change in fluid velocity in pipes, for example, rapid closing of valves and pump power failure create water hammer [1, 2]. The first successful investigation of water hammer was made by an Italian engineer called Lorenzo Allievi. He analyzes the water hammer problem by two different approaches. The first approach is the rigid column theory which ignores elasticity of pipe walls and fluid compressibility, while the second approach takes into consideration full analysis including pipe elasticity [3].

The following equation was developed by Joukowsky in 1898 to estimate the rise or drop in pressure as a result of pump power failure.

$$\Delta {H}_{1}=\pm \frac{a}{g}\times \Delta V$$
(1)

where ΔH1 is the change in pressure, ΔV is the change of fluid velocity in pipeline, g is the gravitational acceleration, and a is the wave speed.

Estimation of water hammer has been performed graphically, but the graphical method is not accurate and extremely complex [4]. Eleven available water hammer software programs were investigated, and it is found that method of characteristics was applied in eight of them [5]. The effect of using air chambers to protect the pipelines against negative pressures due to water hammer was investigated. The results showed that air chambers guarantee a positive pressure in the pipeline at all stages after pump power failure [6]. Design charts to size air chambers for pump power failure were developed. It is recommended to use these charts only at the preliminary design stage. This is due to the simplifying assumptions, parameters range, and the limited solution accuracy [7]. A simplified analysis to calculate wave celerity, maximum head, minimum head, and critical time for water hammer was developed [8]. Three types of water hammer-protecting devices were investigated. The devices are one-way surge tank, two-phase control valve, and hydropneumatic tank (air vessel). The results showed that hydropneumatic tank is the best protecting device for water hammer [9].

Hoop strain and stress relations can be used to get formulas for the wave celerity in thin-walled pipes [10]. For a pipeline of wall thickness δ and diameter D, the pipe thickness is considered thin if as follows:

$$\frac{D}{\delta }>25$$
(2)

For a thin-walled pipe, the wave celerity can be calculated as follows:

$$\mathrm{a}=\sqrt{\frac{\raisebox{1ex}{$K$}\!\left/ \!\raisebox{-1ex}{$\rho $}\right.}{1+\left(\frac{K}{E}\right)\times \left(\frac{D}{\delta }\right)\times c}}$$
(3)

where ρ is the fluid density, K is the fluid bulk modulus of elasticity, and E is Young’s modulus of elasticity of pipe material, and c has three formulas as follows:

1st formula:

$$c=1-\frac{\upsilon }{2}$$
(4)

where ν is Poisson’s ratio for pipe material and is used if the pipe is anchored only at the upstream end.

2nd formula:

$$c=1-{\upsilon }^{2}$$
(5)

This formula is used if the pipe is anchored throughout its length.

3rd formula:

$$\mathrm{c}=1$$
(6)

This formula is used if the pipe has expansion joints throughout its length.

For transient flow in pipes, the equation of motion is as follows [10]:

$$\frac{1}{A}\frac{\partial Q}{\partial t}+g\frac{\partial H}{\partial x}+\frac{f}{2D{A}^{2}}Q\left|Q\right|=0$$
(7)

And the continuity equation is as follows:

$$\frac{\partial H}{\partial t}+\frac{{a}^{2}}{gA}\frac{\partial Q}{\partial x}=0$$
(8)

where the discharge Q and the pressure head H are the dependent variables. Moreover, f is the Darcy-Weisbach friction factor, A is the pipe cross-section area, and g is the gravitational acceleration. In addition, the distance along the pipeline x and time t is the independent variables.

For any pipeline with hydropneumatic tank, when positive wave is created in the system, water moves from the pipeline into the hydropneumatic tank, and the air is compressed, and when negative wave is created, water moves from the hydropneumatic tank to the pipeline to avoid very low pressure in the pipeline. According to the previous procedure, the mathematical model for hydropneumatic tank is developed (Fig. 1).

Fig. 1
figure 1

Mathematical model of the hydropneumatic tank

For a hydropneumatic tank, the gas follows the following relation [11]:

$${PV}^{k} = C$$
(9)

where P is the absolute pressure head, V is the volume of gas, k is the polytropic exponent with an average value of 1.2, and C is a constant. The continuity equation at the vessel junction is as follows:

$${\mathrm{Q}}_{\mathrm{a}} ={\mathrm{Q}}_{\mathrm{b}}+ {\mathrm{Q}}_{\mathrm{v}}$$
(10)

where Q a is the flowing discharge into the junction, Q b is the flowing discharge out of the junction, and Q v is the flowing discharge through the orifice; it can be positive or negative according to flow direction. The air and water in the hydropneumatic tank follow the following relation:

$${{Q}_{v}=A}_{v}\frac{d{H}_{v}}{dt}=-\frac{dV}{dt}$$
(11)

where H v is the water level in the air vessel, A v is the horizontal sectional area of the air vessel, and t is the time. The water level and air pressure in the vessel are as follows:

$${H}_{P}=\left(\frac{P}{\gamma }-{H}_{atm}\right)+{H}_{v}+\sigma \frac{\left|{Q}_{v}\right|{Q}_{v}}{2g{A}_{o}^{2}}$$
(12)

where H P is the elevation of the hydraulic grade line at the junction, P is the air pressure, γ is the specific weight of water, H atm is the atmospheric pressure head, g is the gravitational acceleration, σ is the orifice resistance coefficient, and A 0 is the orifice sectional area.

A computer program based on the transient continuity and momentum equations is established to investigate the initial volume of air and throttling the orifice of the hydropneumatic tank [12]. Their results showed that the throttling has a great effect on the hydropneumatic tank size, and that the orifice diameter should not be less than 0.3 of the main pipe diameter. A computer model was developed using method of characteristics to study the effects of hydropneumatic tank on water hammer for a high head pumping station [13]. Their results showed that the system maximum pressure declines by increasing the volume of the hydropneumatic tank. Moreover, the shape of the hydropneumatic tank has little effect on the water hammer. Design guidelines for hydropneumatic tank in long pipeline systems were proposed [14]. An optimization model is performed to select the best volume of the hydropneumatic tank. A spherical hydropneumatic tank was proposed and compared with the traditional cylindrical one [15]. A computer program model of the spherical hydropneumatic tank was established using the characteristics method. The results showed that the spherical hydropneumatic tank had better protective performance against water hammer. The spherical hydropneumatic tank had a smaller total volume for identical protection requirements.

Artificial neural networks were used to predict the total volume of hydropneumatic tank and the air volume in it from pump static head, pipeline diameter, pipeline length, friction factor, wave celerity, steady-state velocity, and the desirable pressures at the upstream [16]. About 450 realizations were used during training, validation, and testing the network. The network was implemented in the software package DYAGATS. Artificial intelligence was used to design the protection from water hammer of water supply systems [17]. Hytran model was used to model water hammer. The results showed that adaptive neuro-fuzzy inference system had better determination of water hammer values in UPVC pipes. Optimization of the size of water hammer protection devices for a pipe system via particle swarm optimization and genetic algorithm was proposed [18]. The objective was to decrease the maximum head, increase the minimum head, or decrease the difference between the minimum and maximum heads in a pipeline system. Multiple case studies were evaluated. The results showed that simple water hammer protection devices were often better.

The process of trial and error for hydropneumatic tank sizing to protect pipeline system against water hammer is cumbersome and time-consuming for the designer engineer. The objective of this paper is to perform sensitivity analysis to show the effect of pump and pipeline parameters on the maximum and minimum heads just downstream the pump and to produce a computer program capable of estimating the gas volume of a hydropneumatic tank to protect the pipeline from water hammer effects. This can be done by performing a large number of runs using Bentley Hammer software for different lengths of pipeline, different pipe diameters, different wave celerity, water velocity, gas volume, static head, H s, and the head losses per unit length and get the corresponding maximum and minimum heads just downstream the pump after a pump power failure. Then, the results of the previous runs should be introduced to the artificial neural networks (ANNs) in order to map the relations between the inputs and outputs. After that, the produced network can be used to estimate the gas volume in a hydropneumatic tank that guarantees the pressure in the pipeline is within the allowable range.

Methods

A typical water transport system consists of a suction tank, delivery tank, pipeline, pump, and a hydropneumatic tank (Fig. 2). In this figure, the steady-state total energy line, maximum transient head envelop, and minimum transient head envelop are shown. The energy datum passes through the center of the pump, and the static head, H s, is the distance between the datum and the water level in the delivery tank.

Fig. 2
figure 2

Typical water transport system

The objectives of this paper are as follows: to perform sensitivity analysis to show the effects of pump and pipeline parameters on the maximum and minimum heads just downstream the pump, to create a network that can predict the maximum and minimum heads just downstream the pump from pump and pipeline parameters, to create another network that can predict the maximum and minimum heads just downstream the pump from only the most effective parameters, and to create models that use the previous networks in order to minimize the gas volume of an air vessel subject to the constrains that the maximum and minimum heads just downstream the pump do not go outside the allowable range.

Sensitivity analysis is performed using Bentley Hammer software to show the effects of pump and pipeline parameters on the maximum and minimum heads just downstream the pump. The effects of pipe diameter (d), pipeline length (L), wave celerity (a), air vessel gas volume, static head (H s), and pump inertia on water hammer are investigated (Table 1). Then, a large number of runs (760 runs) were performed using Bentley Hammer software for different lengths of pipeline (500, 2000, 5000, & 10,000 m), different pipe diameters (150, 300, 400, & 600 mm), different wave celerities (600, 900, 1200 m/s), different water velocities (1.7, 2, 2.3, 2.5, 3.4 m/s), different gas volumes (0, 5, 10, 20, 40 m3), different static heads (40, 60, 120 m), different head losses per unit length (0.00415, 0.00568, 0.00653, 0.007, 0.0084, 0.032, 0.096), and different pump inertias (2, 4, 8 kg.m2). The corresponding maximum and minimum transient heads just downstream the pump (H max, H min) after a pump power failure are extracted from Bentley Hammer results. The results of the previous runs are introduced to the artificial neural networks (ANNs) in order to map the relations between the inputs and outputs as shown in Fig. 3. The network estimates the output variables (H max/H o, H min/H o) when it receives the input variables (pipe diameter, pipeline length, wave celerity, water velocity, gas volume, H s, H f/L, and pump inertia). Another network is introduced (Fig. 4). It is simpler and depends only on the variables that have significant effects on maximum and minimum transient heads just downstream the pump. The second network estimates the output variables (H max/H o, H min/H o) when it receives the input variables (pipe diameter, pipeline length, water velocity, gas volume, H s, and H f/L).

Table 1 Ratio between friction losses and pipeline length (H f/L), water velocity (V), discharge (Q), operating head (H o), maximum head just downstream the pump (H max), and minimum head just downstream the pump (H min) for different values of pipe diameter (d), pipeline length (L), wave celerity (a), air vessel gas volume, static head (Hs), and pump inertia
Fig. 3
figure 3

Inputs and outputs for the 1st artificial neural network

Fig. 4
figure 4

Inputs and outputs for the 2nd artificial neural network

In order to design the 1st neural network, one should determine the number of hidden layers and the number of nodes in each hidden layer [19,20,21]. This is performed using trial and error. The input layer for this network has eight nodes that receive pipe diameter, pipeline length, wave celerity, water velocity, gas volume, static head, head losses per unit length, and pump inertia, while the output layer has two nodes for H max/H o and H min/Ho. The design of this network consists of four layers: input layer, output layer, and two hidden layers. Each of the hidden layers has ten nodes with tan-sigmoid transfer function. The output layer in this network has a linear transfer function as shown in Fig. 5. The design of the 2nd neural network is simpler (Fig. 6). The input layer for this network has eight nodes like the 1st network, but each of the hidden layers has eight nodes with tan-sigmoid transfer function.

Fig. 5
figure 5

Structure of the 1st neural network. The nodes of the hidden layers have a tan-sigmoid transfer function, while the nodes of the output layer have a linear transfer function

Fig. 6
figure 6

Structure of the 2nd neural network. The nodes of the hidden layers have a tan-sigmoid transfer function, while the nodes of the output layer have a linear transfer function

The next step is training the 1st network. Before doing this, the output and input vectors are normalized to have unit standard deviation and zero mean. The normalized data should be divided into three groups: training group, validation group, and testing group. The training group has 450 realizations, while each of the testing and validation groups has 155 realizations. It should be emphasized here that there is no firm rule to determine the number of realizations in each group. It is common that the training group contains 60% of the data, while each of the testing and validation groups contains 20%. The function of the training group is to adjust the weights of the network and extract the relation between the input and output data, while the validation group is used to prevent over fitting. This is achieved by stopping the training of the neural network when the error in the validation group begins to rise. This is a warning message that there is over fitting in the relation between the input and output data (Fig. 5). It should be declared here that the validation group does not have any effect on the network learning process that gets the relation between input and output data, but it has a very important task during the training process. The validation group controls the training process and prevents the network from over fitting. The network training stopped after twenty-two epochs when the curve of mean squared error for the validation group began to rise (Fig. 7).

Fig. 7
figure 7

A record for the errors of training and validation during the training process for the 1st network

The 1st model is developed by writing a MATLAB code to use the 1st network in order to determine the gas volume in a hydropneumatic tank that guarantees the maximum and minimum pressure heads just downstream the pump are within the allowable range (Fig. 8). The model estimates the gas volume in a hydropneumatic tank when it receives pipe diameter, pipeline length, wave celerity, water velocity, static head, head losses per unit length, pump inertia, maximum allowable transient head just downstream the pump, and minimum allowable transient head just downstream the pump.

Fig. 8
figure 8

The 1st model inputs and output

A flow chart describing how the model works is shown in Fig. 9. At the beginning, the model reads pipe diameter, pipeline length, wave celerity, water velocity, H s, H f/L, pump inertia, allowable H max, and allowable H min. Then, the model loads the 1st artificial neural network. After that, the model decides whether there is a need to a protection or not. The model uses this artificial neural network with the read pipeline parameters and a gas volume equal to zero. The output of the network is H max/H o and H min/H o. Then, it calculates H max and H min. If H max and H min are within the allowable range, then, there is not any need to a water hammer protection. If H max and H min are outside the allowable range, then, the model tries the case of a gas volume equal 40 m3. The model uses the artificial neural network with the read pipeline parameters and a gas volume equal 40 m3. The output of the network is H max/H o and H min/H o. Then, it calculates H max and H min. If H max or H min are outside the allowable range, then, there is a need of water hammer protection with gas volume greater than 40 m3. If H max and H min are within the allowable range, then, there is a need of water hammer protection with gas volume less than 40 m3. The model tries a large number of cases with gas volume between 0 and 40 m3 and chooses the case with minimum gas volume, and H max and H min are within the allowable range.

Fig. 9
figure 9

Flow chart for the 1st model

The 2nd model is developed by writing a MATLAB code to use the 2nd network in order to determine the gas volume in a hydropneumatic tank that guarantees the maximum and minimum pressure heads just downstream the pump are within the allowable range (Fig. 10). The model estimates the gas volume in a hydropneumatic tank when it receives pipe diameter, pipeline length, water velocity, static head, head losses per unit length, maximum allowable transient head just downstream the pump, and minimum allowable transient head just downstream the pump.

Fig. 10
figure 10

The 2nd model inputs and output

A flow chart describing how the model works is shown in Fig. 11. At the beginning, the model reads pipe diameter, pipeline length, water velocity, H s, H f/L, allowable H max, and allowable H min. Then, the model loads the 2nd artificial neural network. After that, the model decides whether there is a need to a protection or not. The model uses this artificial neural network with the read pipeline parameters and a gas volume equal to zero. The output of the network is H max/H o and H min/H o. Then, it calculates H max and H min. If H max and H min are within the allowable range, then, there is not any need to a water hammer protection. If H max and H min are outside the allowable range, then, the model tries the case of a gas volume equal 40 m3. The model uses the artificial neural network with the read pipeline parameters and a gas volume equal 40 m3. The output of the network is H max/H o and H min/H o. Then, it calculates H max and H min. If H max or H min are outside the allowable range, then, there is a need of water hammer protection with gas volume greater than 40 m3. If H max and H min are within the allowable range, then, there is a need of water hammer protection with gas volume less than 40 m3. The model tries a large number of cases with gas volume between 0 and 40 m3 and chooses the case with minimum gas volume, and H max and H min are within the allowable range.

Fig. 11
figure 11

Flow chart for the 2nd model

Results and discussion

The effects of pipe diameter (d), pipeline length (L), wave celerity (a), air vessel gas volume, static head (Hs), and pump inertia on the maximum and minimum heads just downstream the pump after pump power failure are presented in Table 1. It can be noticed that increasing pipe diameter leads to a decrease in both the maximum and minimum heads just downstream the pump. The operating discharge and water velocity increase, while the operating head and friction loss per unit length decrease. In addition, decreasing pipeline length leads to an increase in the maximum head just downstream the pump and decrease in the minimum head just downstream the pump. This is due to the increase in both water velocity and friction loss per unit length. Moreover, increasing wave celerity has a very small effect on both the maximum and minimum heads just downstream the pump. Operating discharge, operating head, water velocity, and friction loss per unit length are kept constants. Besides, increasing air vessel gas volume leads to a very small change in the maximum head just downstream the pump and a significant increase in the minimum head just downstream the pump. Operating discharge, operating head, water velocity, and friction loss per unit length are kept constants. In addition, increasing the static head leads to a small increase in the maximum head just downstream the pump and a significant increase in the minimum head just downstream the pump. Operating discharge, water velocity, and friction loss per unit length decrease, while operating head increases. Finally, increasing pump inertia leads to a very small decrease in the maximum head just downstream the pump and a very small increase in the minimum head just downstream the pump. Operating discharge, operating head, water velocity, and friction loss per unit length are kept constants.

After network training, it must be tested to estimate H max/H o and H min/H o by a new group (testing group). The estimated (Outputs) H max/H o and H min/H o are compared with the actual values (Targets) from the testing group. Each output of the 1st network (H max/H o and H min/H o) is plotted against the actual values of the testing group (Figs. 12 and 13). The best line which fits the relation between the output of the network and the actual values (Targets) is determined. Its equation and the correlation coefficient between the network output and the actual values (Targets) are also determined. One can notice from Figs. 12 and 13 that the correlation coefficients for H max/H o and H min/H o are close to 1, and this indicates an excellent agreement between the actual (Targets) and values of the network output. In addition, the slopes of these best lines are close to 1. This has a mean that the 1st neural network is capable of estimating H max/H o and H min/H o easily, in a very short time. The 2nd network is also tested to estimate H max/H o and Hmin/Ho by the testing group. Each output of the 2nd network (H max/H o and H min/H o) is plotted against the actual values of the testing group (Figs. 14 and 15). The best line which fits the relation between the output of the network and the actual values (Targets) is determined. Its equation and the correlation coefficient between the network output and the actual values (Targets) are also determined. One can notice from Figs. 14 and 15 that the correlation coefficients for H max/H o and H min/H o are close to 1, and this indicates an excellent agreement between the actual (Targets) and values of the network output. In addition, the slopes of these best lines are close to 1. It is clear that the 2nd network is simpler than the 1st one and has the same accuracy of the 1st network.

Fig. 12
figure 12

Predicted (Outputs) maximum transient head just downstream the pump versus actual values (Targets) for the 1st network

Fig. 13
figure 13

Predicted (Outputs) minimum transient head just downstream the pump versus actual values (Targets) for the 1st network

Fig. 14
figure 14

Predicted (Outputs) maximum transient head just downstream the pump versus actual values (Targets) for the 2nd network

Fig. 15
figure 15

Predicted (Outputs) minimum transient head just downstream the pump versus actual values (Targets) for the 2nd network

Example 1

Use the 1st and 2nd models to find the volume of gas in a hydropneumatic tank required to protect a pipeline from water hammer effect. The data of the water transport system is as follows: pipe diameter = 600 mm, pipeline length = 10,000 m, wave celerity = 1200 m/s, water velocity = 1.7 m/s, static head = 60 m, head losses per unit length = 0.00415, pump inertia = 8 kg.m2, the allowable H max = 140 m, and allowable H min = 12 m. Repeat the solution for allowable H min = 55 and 2 m.

This example is solved through the following steps. Enter the nine input parameters of the water transport system to the 1st model. Then, run the model. The output of this model is “The required gas volume is 3.2 m3.” For the case of allowable H min = 55 m, the output of this model is “There is a need of water hammer protection with gas volume greater than 40 m3.” For the case of allowable H min = 2 m, the output of this model is “There is no need to any protection.”

For the 2nd model, enter only the seven input parameters of the water transport system to the 2nd model. Then, run the model. The output of this model is “The required gas volume is 3.1 m3.” For the case of allowable H min = 55 m, the output of this model is “There is a need of water hammer protection with gas volume greater than 40 m3.” For the case of allowable H min = 2 m, the output of this model is “There is no need to any protection.” It is clear that the two models give the same results, while the 2nd one requires less parameters and is simpler.

Example 2

Use the 1st model to show the effect of various possible parameters on the size of air vessel gas volume.

The solution of this example is presented in Table 2. It can be noticed from this table that large diameter pipes, long pipelines, and pipelines with high steady-state velocity require more of gas volume. Moreover, increasing the static head and increasing the friction loss per unit length require less of gas volume. In addition, the variation of wave celerity and pump inertia has a very small effect on the required gas volume.

Table 2 Gas volume of air vessel for different pipe diameters (d), pipeline length (L), water velocity (V), static head (Hs), ratio between friction losses and pipeline length (H f/L), wave celerity (a), and pump inertia

Conclusions

Water hammer is the unsteady flow in conduits due to sudden change of velocities in the pipelines. It causes strong negative and positive pressures in pipelines and poses it to danger. Hydropneumatic tank is the most common protection device against water hammer and is often located after the pump station. Sensitivity analysis is performed using Bentley Hammer software to show the effects of pump and pipeline parameters on the maximum and minimum heads just downstream the pump. Increasing pipe diameter leads to a decrease in both the maximum and minimum heads just downstream the pump. Decreasing pipeline length leads to an increase in the maximum head just downstream the pump and decrease in the minimum head just downstream the pump. Increasing wave celerity has a very small effect on both the maximum and minimum heads just downstream the pump. Increasing air vessel gas volume leads to a very small change in the maximum head just downstream the pump and a significant increase in the minimum head just downstream the pump. Increasing the static head leads to a small increase in the maximum head just downstream the pump and a significant increase in the minimum head just downstream the pump. Finally, increasing pump inertia leads to a very small decrease in the maximum head just downstream the pump and a very small increase in the minimum head just downstream the pump.

A new approach to find the required gas volume in a hydropneumatic tank to protect the pipeline using artificial neural networks (ANNs) is introduced. A large number of runs (760 runs) were performed using Bentley Hammer software for different lengths of pipeline, different pipe diameters, different wave celerities, different water velocities, different gas volumes, different static heads, different head losses per unit length, and different pump inertias. The corresponding maximum and minimum transient heads just downstream the pump (H max, H min) after a pump power failure are extracted from Bentley Hammer results. The results of the previous runs are introduced to two ANNs in order to map the relations between the inputs and outputs. Each network estimates the output variables (H max/H o, H min/H o). The input parameters to the 1st network are as follows: pipe diameter, pipeline length, wave celerity, water velocity, gas volume, H s, H f/L, and pump inertia, while the inputs of the 2nd network are as follows: pipe diameter, pipeline length, water velocity, gas volume, H s, and H f/L. Testing the two networks showed the good ability of the two networks to predict the output variables (H max/H o, H min/H o) just downstream the pump after a pump power failure.

Two MATLAB codes are written to use the previous networks for finding the best design that guarantee the pressure in the pipeline is within the allowable range. The solved example shows the capability of the two models in determining the gas volume in a hydropneumatic tank easily and in a very short time. The second model is simpler and requires less input variables.

The effects of various parameters on air vessel sizing are discussed in example 2. It can be noticed that large diameter pipes, long pipelines, and pipelines with high steady-state velocity require more of gas volume. Moreover, increasing the static head and increasing the friction loss per unit length require less of gas volume. In addition, the variation of wave celerity and pump inertia has a very small effect on the required gas volume.