Application of Neural Network and Time-Domain Feature Extraction Techniques for Determining Volumetric Percentages and the Type of Two Phase Flow Regimes Independent of Scale Layer Thickness

One of the factors that significantly affects the efficiency of oil and gas industry equipment is the scales formed in the pipelines. In this innovative, non-invasive system, the inclusion of a dual-energy gamma source and two sodium iodide detectors was investigated with the help of artificial intelligence to determine the flow pattern and volume percentage in a two-phase flow by considering the thickness of the scale in the tested pipeline. In the proposed structure, a dual-energy gamma source consisting of barium-133 and cesium-137 isotopes emit photons, one detector recorded transmitted photons and a second detector recorded the scattered photons. After simulating the mentioned structure using Monte Carlo N-Particle (MCNP) code, time characteristics named 4th order moment, kurtosis and skewness were extracted from the recorded data of both the transmission detector (TD) and scattering detector (SD). These characteristics were considered as inputs of the multilayer perceptron (MLP) neural network. Two neural networks that were able to determine volume percentages with high accuracy, as well as classify all flow regimes correctly, were trained.


Introduction
In addition to the gamma radiation efficiency technique, which is the basis of this study, there are other techniques, such as hydrostatic, ultrasonic, and hydrometric techniques, that are used to distinguish the flow regime and volume fraction of multiphase flow. The answer to the fundamental question of what the benefit of is implementing a non-invasive method to determine the mentioned parameters can be explained in several parts.
(A) One of the requirements for optimizing the separation process in the oil and gas industry is to have quantitative and sufficient information about the volume fraction of the gas and oil phases. (B) Understanding the type of flow pattern along with determining the volume fraction of gas and oil phases is a requisite of transfer processes because it is straightforwardly related to a large part of the project economy. (C) The efficiency of the separation process is highly influenced by the type of flow regime. (D) Whether the drilling process should continue or stop at any time can only be determined by understanding the volume fraction of each component.
One of the studies conducted years ago to flow metering and determine volume percentage was a study published in 1999 by Abro et al. [1]. Determination of void fraction was done by Abro et al. using low-energy gamma-ray Americium-241 instead of the traditional Caesium-137 source. They tried to determine which detector positions best serve the purpose and placed three detectors at angles of 140-degree, 154-degree, and 180-degree to the source. The EGS4 software package has been chosen as a substrate for volumetric percentage determination with a 3% error for all flow regimes. In 2020, Sattari and his colleagues were able to simulate three common flow regimes in the volumetric percentage of 5-90% using a structure containing a detector and a cesium-137 source [2]. They performed two independent GMDH neural networks to detect volume percentages and flow regimes. In the beginning, they passed the photon spectrum extracted from the detector through a Savitzky-Golay filter to eliminate the existing high-frequency noise, then extracted 7 time-domain characteristics from this spectrum to give them as input of the neural network. This approach could eventually achieve the type of flow regimes and volume percentage prediction with a root mean square error of less than 1.11. Some studies in recent years have shown that gamma radiation can be used as a technique to detect these internal deposits in oil and gas pipelines. Oliviera et al. used a structure with a NaI detector and a source of cesium-137 to inspect the scale deposited pipe in 2015 [3]. In the discussed approach, the detector and the source move simultaneously in 0.5 cm increments. At each stop, the detector records the gamma spectrum passed through the pipe for one minute. The results showed that the presence and thickness of scale in the pipe could be predicted. In reference [4], the researchers simulated three flow regimes in different volumetric percentages and scale thickness inter the pipe; they were able to classify flow regimes with not very high accuracy using SVM neural network and predicted volumetric percentages with an RMSE of less than 3.67 using the MLP neural network. In addition, in a similar study [5], an attempt was made to predict the scale thickness in the pipe independent of the flow regime and volume percentage using the RBF neural network with an RMSE of less than 0.22. Radiation multiphase flowmeters and the applications of artificial intelligence in them can be found in other studies that are available in references [6][7][8][9][10][11][12][13][14][15]. Oil and gas pipelines may become internally fouled and have devastating effects. These deposits can reduce the internal diameter, reduce the equipment life cycle, reduce efficiency, and, ultimately, increase costs [16]. The scale deposited in a pipeline is depicted in Figure 1.

Simulation Setup
The modeling of the detection system in this study was performed through version X of Monte Carlo N-Particle Code (MCNPX) [17]. The schematic view of the mentioned detection system is shown in Figure 2. As is apparent, the two-phase flow and the scale formed inside the steel pipe are in the middle, and the dual-energy source and two NaI detectors at a 45-degree angle to each other are on the other side. In this schematic, the stratified flow is considered as an example. In the source part, a dual-energy gamma source, including radioisotopes of Cesium-137 and Barium-133 was used, which radiate 0.662 MeV and 0.356 MeV, respectively. In the proposed structure, scattered and transmitted photons are received by two 25.4 mm × 25.4 mm NaI detectors. The detector, which is responsible for recording transmitted photons, was located on the other side of the pipe just opposite the photon transmitter source. The other detector, which is responsible for receiving the scattered photons, was located at a 45-degree angle with the hypothetical line connecting the center of the pipe to the transmission detector. The pipe was considered in this simulation is made of steel with an inner diameter of 20 cm. The scale on the inner wall of the pipe was intended as a circular symmetrical layer of BaSO 4 with different thicknesses. Three types of flow regimes with annular, stratified, and homogeneous names were simulated in volume percentages between 10% to 85% with steps of 15% and in seven different scale thicknesses. In our previous work [18], the structure discussed in this article had been validated by several experiments. The obtained detector responses were compared in experimental and simulation. The results showed a good agreement between the simulated results and the experimental data. The uttermost relative difference between the experimental data and simulated data for the detector response was 2.2%. The actual working conditions were dynamic; however, the reference points for flowmeter training were fixed and can be considered static, so experiments and simulations were performed in static conditions. These fixed points were used for flowmeter training to determine the volume fraction and to detect flow regimes in multiphase flowmeters in real conditions. Swift gamma-ray neutron active analysis was considered for quantitative analysis for swift, non-intrusive and online measurements of multiphasic seawater/gas/oil flows in [19]. In this research, all simulations have been considered in static conditions but have been used in real conditions. In [20], conceivable use of transmitted and scattered gamma radiation detection for the characterization of produced water from offshore oil wells has been evaluated. The simulated flow regimes are illustrated in Figure 3. Figure 4 depicts the spectra recorded for three flow regimes with a scale thickness of 2 cm and a void fraction of 55% in both detectors.

Feature Extraction
Feature extraction is a process of defining a set of features that aims to reduce the signal size, but this size reduction should preserve the properties of the signal and make it even more suitable for interpretation. There are several methods for extracting the features of signals. For instance, extraction of characteristics in the frequency domain, extraction of characteristics in the time domain, combined mode of extraction of characteristics in the time-frequency domain, and even other creative methods. Sattari et al. Examined time characteristics that used a creative method to select the characteristics of skewness, kurtosis, and 4th order moment as efficient characteristics [21]. The same creative method was used in the research of Hosseini et al. to select the appropriate frequency characteristics [22]. There are several methods to determine the effective and appropriate properties of the signal, for example, in [2], researchers used the GMDH neural network to determine the effective signal properties. They used the network's self-organizing feature as a tool for feature selection. Feature extraction method using wavelet transform has also been considered by many researchers [23,24]. By extracting the approximate and the details of the received signals, they extract the characteristic features of the signal. Correlation analysis methods have also been studied to determine suitable characteristics in other studies [25]. Nevertheless, the gap in their research was that they did not consider the scale thickness of the inner pipe. In this study, inspired by previous research [21], three time features of skewness, kurtosis, and 4th order moment were extracted as follows: • 4th order moment: • skewness: • kurtosis:
Perceptron is a kind of neural network in terms of computational unit. In fact, perceptron is a single-layer neural network; a multilayer perceptron is called a neural network. Taking of real values of input vectors and calculating a linear composition of these inputs are perceptron's duties. If the result value is less than the threshold value, the perceptron output will be −1 and, otherwise, will be 1. The following equation determines the perceptron output [108,109]: The page is divided into two parts if the perceptron has two inputs x 1 and x 2 and the equation of the dividing line is defined as follows: In the n-dimensional space of instances, perceptron is thought-outed as a hyperplane. Perceptron only learns instances that are linearly separable so that it can completely divide the instances into two parts by a hyperplane and apply the values of −1 to one side and 1 to the other side. Obtaining the values of perceptron weights is the goal of training it so that perceptron produces the real value of training instances. Perceptron is taught according to the following algorithm:
For each training instance, perceptron is applied. If the samples are misjudged, the perceptron weight values are corrected.
Yes, the end of the algorithm.
When the network is single-neuron, it loses the ability to implement nonlinear functions. Multilayer perceptron networks (MLP) are very useful and can be offered as a solution because they perform nonlinear mapping with high accuracy, which is considered as the main solution in many engineering problems. MLP is a type of feed-forward network; the output is calculated directly from the input without any feedback. In the MLP network, the neuron model consists of a nonlinear activation function. Nonlinearity, continuity, and derivability at all points are some of the features that an activation function should have. If the activation function is not nonlinear, the network performance will be reduced to the level of monolayer perceptron.

Result and Discussion
In this paper, two separate artificial multilayer perceptron neural networks are designed to classify the type of flow regimes and predict the volume percentages independent of the thickness of the scale in the pipe. The inputs of both networks are the characteristics introduced in the previous section-extracted from the recorded signals from both the TD and the SD. In total, 126 simulations were performed in this study, of which about 70% (88 samples), 15% (19 samples), and 15% (19 samples) were used for training, validation, and testing data, respectively. The structure of the classifier network to identify the type of flow regimes is shown in Figure 5. To show the performance of this network, the confusion matrix is plotted for train, validation, and test data in Figure 6. It is very important to say that the output of this network consists of three numbers, 1, 2, and 3, which represent the annular, stratified, and homogeneous regimes, respectively. In addition, the thresholds for the output of this network are defined in such a way that if the output was between 0.5 to 1.5, the output number would be equal to 1, if the output number was between 1.5 to 2.5, the output would return to 2 and if the output was between 2.5 to 3.5, the network declares a homogeneous regime in the output.  Another network has been implemented with the aim of predicting volume percentages; the structure of this network is shown in Figure 7. To obtain the optimal network structure, various networks with one, two, three, and four hidden layers and with the different number of neurons in each layer and different activating functions including linear, log-sigmoid (Logsig), Heaviside, and hyperbolic tangent sigmoid (Tansig) were examined; which is the most optimal structure for both classifier and predictor networks is shown in Table 1. This table includes the number of input neurons, the number of hidden layers, and the number of neurons in each hidden layer, as well as the type of activation function and the number of the epoch. To show the performance of the predictor network, a fitting diagram and the error diagram were used for the three data sets of training, validation, and testing ( Figure 8). The fitting diagram shows both the desired output and the output of the designed network on a graph. The more the two diagrams match, the higher the accuracy of the designed network. The error diagram also shows the difference between the desired output and the network output for each of the data. One of the most important parameters in determining the accuracy of predictor networks is determining the accuracy measurement criteria. In this research, criteria named root mean square error (RMSE) and mean relative error (MRE), with the following equations, have been applied. The calculated values for these criteria are listed in Table 2.
where N is the amount of data and 'X (Exp)' and 'X (Pred)' stands for the experimental and predicted (ANN) values, respectively.

Classifier Predictor
No. of neurons in input layer 6 6 No. of neurons in the 1st hidden layer 15 22 No. of neurons in the 2nd hidden layer 11 16 No. of neurons in the 3rd hidden layer -10 No. of neurons in the output layer 1 1 No. of epoch 680 530 Activation function used for each hidden neuron Tansig Tansig

Conclusions
The present paper, through a creative structure based on radiation, offers an approach for flow pattern and volumetric percentage detection in scale-laden petroleum pipelines. For this purpose, a structure consisting of a dual-energy gamma source, two NaI detectors, and a pipe, to simulate different flow regimes at different volume percentages, as well as to model the scale thickness inside the pipe, was simulated using the Monte Carlo code. After completing all simulations and data collection, to better interpret the collected data, the feature extraction technique in the time-domain was used. The extracted features, which include 4th order moment, skewness, and kurtosis, were considered as neural network inputs. Two designed MLP neural networks were able to fully classify flow regimes and predict volume percentages with an RMSE of less than 1.84, respectively.