Artículo Científico / Scientific Paper https://doi.org/10.17163/ings.n20.2018.02 pISSN: 1390-650X / eISSN: 1390-860X DESIGN OF A NEURAL NETWORK FOR THE PREDICTION OF THE COEFFICIENT OF PRIMARY LOSSES IN TURBULENT FLOW REGIME DISEÑO DE UNA RED NEURONAL PARA LA PREDICCIÓN DEL COEFICIENTE DE PÉRDIDAS PRIMARIAS EN RÉGIMEN DE FLUJO TURBULENTO Jairo Castillo-Calderón1,*, Byron Solórzano-Castillo1, José Moreno-Moreno2

1. Introduction

The most widely used method to transport fluids from one place to another is to drive them through a pipe system, with circular sections being the most common for this purpose, providing greater structural strength and a greater cross section for the same outer perimeter than any another way [1].

The flow of a fluid in a pipeline is accompanied by a load loss that is accounted for in terms of energy per weight unit of the fluid that flows through it [2].

The primary losses or load losses in a rectilinear conduit of constant section are due to the friction of the fluid against itself and against the walls of the pipe that contains it. On the other hand, secondary losses are load losses caused by elements that modify the direction and speed of the fluid. For both types of loss, part of the energy of the system is converted into thermal energy (heat), which is dissipated through the walls of the pipeline and of devices such as valves and couplings [2, 3].

The estimation of the losses of load due to the friction in pipes is an important task in the solution of many practical problems in the different branches of the engineering; hydraulic design and the analysis of water distribution systems are two clear examples.

In the calculation of the pressure losses in pipes, whether the current regime is laminar or turbulent plays a discriminating role [3]. The flow regime depends mainly on the ratio of inertial forces to viscous forces in the fluid, known as Reynolds number (NR) [4]. Thus, if the is less than 2000 the flow will be laminar and if it is greater than 4000 it will be turbulent [2]. The majority of flows that are found in practice are turbulent [2–4], for this reason the present investigation is developed with this type of flow regime.

Equation 1 proposed by Darcy-Weisbach is valid for the calculation of frictional losses in laminar and turbulent regime in circular and non-circular pipes [2–4].

 (1)

Where:

hL : loss of energy due to friction (N.m/N).

f : friction factor.

L : length of the flow stream (m).

D : diameter of the pipe (m).

v : average flow speed (m/s).

g : gravitational acceleration (m/s2).

Equation 2, the implicit relationship known as the Colebrook equation, is universally used to calculate the friction factor in turbulent flow [3, 4]. Note that it has an iterative approach.

 (2)

Where:

/D: relative roughness. It represents the ratio of the average roughness height of the pipe to the diameter of the pipe.

An option for the direct calculation of the turbulent flow friction factor is Equation 3 developed by K. Swamee and K. Jain [2].

 (3)

Equations (2) and (3), and others such as that of Nikuradse, Karman and Prandtl, Rouse, Haaland, are obtained experimentally and their use can be cumbersome. Thus, the Moody diagram is one of the most used means to determine the friction factor in turbulent flow [2–4]. This shows the friction factor as a function of the Reynolds number and the relative roughness. The use of the Moody diagram or the aforementioned equations is a traditional means of determining the value of the friction factor when solving problems with manual calculations. However, this can be inefficient. For the automation of the calculations it is necessary to incorporate the equations in a program or spreadsheet to obtain the solution.

This investigation presents an alternative proposal for the prediction of the friction factor using artificial intelligence, specifically an ANN that allows the calculation to be automatic and reliable, thus reducing time and avoiding errors that may occur when using the previously mentioned alternatives.

2. Materials and methods

2.1. ANN design

The multilayer network to be developed has forward connections (feedforward) and employs the backpropagation algorithm which is a generalization of the least squares algorithm. It works through supervised Learning and, therefore, it needs a set of training instructions that describe the response that the network should generate from a given input [5].

2.1.1. ANN database

The initialization parameters of the ANN are obtained from a set of 724 data tabulated in Microsoft Excel. These data were acquired using Moody’s diagram, that is, through the graphical method that contemplates a sequence of steps based on [2]. The data set considers 43 Reynolds Number values, (4000 "/D 1 × 108), 20 curves of relative roughness, (1×10−6 /D  0, 05), and the respective friction factors.

The Reynolds numbers used, shown in Table 1, correspond to those marked on the scale of the abscissas of Figure 1, with the purpose of achieving an exact calculation in the Moody diagram.

The Reynolds number and the relative roughness are the ANN’s input variables and the friction factor is the output variable or variable to be predicted. In order to establish an adequate database, only the friction factors that are the consequence of an obvious intersection of any of the 43 Reynolds Numbers in each of the relative roughness curves are considered.

 Table 1. Reynolds numbers used 2.2. ANN topology No concrete rules can be given to determine the number of hidden layers and the number of hidden neurons that a network must have to solve a specific problem; the size of the layers, both input and output, is usually determined by the nature of the application [7, 8]. Thus, the problems of the present investigation suggest that the Reynolds number and the relative roughness are the two inputs applied in the first layer and the friction factor, which is the output, is considered in the last layer of the network. The number of hidden neurons intervenes in the learning and generalization efficiency of the network; in addition, a single hidden layer is usually sufficient for the convergence of the solution. However, there are occasions when a problem is easier to solve with more than one hidden layer [7, 8]. Therefore, the optimal number of hidden layers and neurons is determined through experimentation. To be precise, the most appropriate topology of the ANN is selected by testing different configurations by varying the number of hidden layers from one to three and the number of neurons within each hidden layer from 5 to 40 with increments of 5. Figure 1. Moody’s diagram for the coefficient of friction in smooth and rough wall ducts [6]. 2.2.1. ANN Training The supervised learning of an ANN implies the existence of a training controlled by an external agent so that the inputs produce the desired outputs by strengthening the connections. One way to carry this out is the establishment of previously known synaptic weights [5]. For this reason, the set of input-output pairs is applied to the ANN, that is, examples of inputs and their corresponding outputs [5, 8, 9]. The network is trained with the Levenberg-Marquardt backpropagation algorithm, as it is stable, reliable and facilitates the training of standardized data sets [10–12]. The training is an iterative process and the software, by default, divides the

set of 724 data into 3 groups: 70% is comprised by training data, 15% by test data and the remaining 15% by validation data. In each iteration, when using new data from the training set, the backpropagation algorithm allows the output generated from the network to be compared with the desired output and an error is obtained for each of the outputs. As the error propagates backward, from the output layer to the input layer, the synaptic weights of each neuron are modified for each example, so that the network converges to a state that allows all training patterns to be successfully classified [9]. This is to say that the ANN training is carried out by error correction. As the network is trained, it learns to identify different characteristics of the set of inputs, so that when presented with an arbitrary pattern after training, it possesses the ability to generalize, understood as the ease of giving satisfactory outputs to entries not submitted in the training phase [13].

Due to the nature of the input and output data of the multilayer network, the activation or transfer functions must be continuous, and may even be different for each layer, as long as they are differentiable [9–13]. Thus, the tansig activation function is applied in the hidden layers and the purelin activation function in the output layer. These functions are commonly used when working with the backpropagation algorithm.

The ANN learning process stops when the error rate is acceptably small for each of the learned patterns or when the maximum number of iterations of the process has been reached [10], [14], [15]. The performance function used to train the ANN is the mean square error (MSE), denoted by Equation 4 [10–12]. The relative error, reflected arithmetically by Equation 5, is involved in the analysis [10–16].

 (1)

 (2)

Summarizing the above, Table 2 contains the design characteristics of the ANN applied to the different topologies tested.

Table 2. Design features of the ANN

3. Results and discussion

3.1. ANN architecture selection

According to the proposed methodology, a total of 24 architectures are trained, the results of which are shown in Table 3. It is observed that the topologies 2-30-30-1 and 2-25-25-25-1 present better results, since they have an average relative error of 0.1620% and 0.2282%, respectively, and a Pearson correlation coefficient of 0.9999 for both cases. However, the first one is selected because it shows a lower relative error of the predicted values compared to the desired ones and demands a lower computational expenditure. An outline of the structure of the selected ANN is shown in Figure 2. It shows the two external inputs, Reynolds number and relative roughness, applied to the first layer, the 2 hidden layers with 30 neurons each and in the last layer a neuron whose output is the friction factor. Entries are limited only to the flow of information while processing is carried out in the hidden and output layers [5].

Table 3. Results of the different architectures tested

Using the IBM SPSS Statistics 22® software, a descriptive analysis of the relative error variable is performed for the 724 data of the selected architecture. The histogram of Figure 3 represents the frequency distributions. The results show that the average is

0.1620%, the minimum relative error is 0% and the maximum is 4.2590%.

 Figure 2. Structure of the designed ANN. In addition, the standard deviation is 0.327, indicating that the dispersion of the data with respect to the mean is small. The distribution of data shows that there is a considerable predominance of relative error less than 1% in 97% of the total data analyzed. Supporting what is reflected in the histogram, Table 4 summarizes the values of the three quartiles obtained from the statistical analysis. Under Q1 there are relative errors between the desired output and the network output of less than 0.0313%. Q2, which is the median value, points out that half of the relative errors are below 0.0720%. Q3 states that three quarters of the data have a relative error of less than 0.1758%. From Q3, low relative errors are obtained, however, there are lagged values that are greater than 1%, but these represent only 3% of the total data analyzed. The above shows the quality of approximation of the predicted values of the ANN with respect to those of the Moody diagram. Figure 3. Relative error histogram. Table 4. Measures of non-central position of the relative error 3.2. Model performance The performance of training data sets, tests and validation compared to the desired output is shown in Figure 4. The sample intended for validation is used to measure the degree of generalization of the network, stopping training when it no longer improves, this prevents overfitting [12], understood as a poor performance of the model to predict new values. It is noted that the training process of the ANN with topology 2-30-30-1 is truncated in 91 iterations, because it is when the lowest MSE value of validation is obtained, which is 1, 7492 × 10−8. That is, the performance function has been minimized to the maximum and will no longer have a tendency to decrease after 91 iterations. Because the MSE value is very small, closest to zero, the ANN model is able to generalize with great precision. Figure 4. Performance of the ANN training process. Figure 5 shows the results of the Pearson R correlation coefficient for the designed ANN structure. The line indicates the expected values and the black circles represent the predicted values. The prediction is efficient, and a good performance of the network is observed, since a global index of 0.999999 is obtained indicating a strong and positive linear relationship between the friction factors of the Moody diagram and those granted by the ANN. Figure 5. Correlation between expected and predictedvalues