Application of Artiﬁcial Intelligence for Determining the Volume Percentages of a Stratiﬁed Regime’s Three-Phase Flow, Independent of the Oil Pipeline’s Scale Thickness

: As time passes, scale builds up inside the pipelines that deliver the oil or gas product from the source to processing plants or storage tanks, reducing the inside diameter and ultimately wasting energy and reducing efﬁciency. A non-invasive system based on gamma-ray attenuation is one of the most accurate diagnostic methods to detect volumetric percentages in different conditions. A system including two NaI detectors and dual-energy gamma sources ( 241 Am and 133 Ba radioisotopes) is the recommended requirement for modeling a volume-percentage detection system using Monte Carlo N particle (MCNP) simulations. Oil, water, and gas form a three-phase ﬂow in a stratiﬁed-ﬂow regime in different volume percentages, which ﬂows inside a scaled pipe with different thicknesses. Gamma rays are emitted from one side, and photons are absorbed from the other side of the pipe by two scintillator detectors, and ﬁnally, three features with the names of the count under Photopeaks 241 Am and 133 Ba of the ﬁrst detector and the total count of the second detector were obtained. By designing two MLP neural networks with said inputs, the volumetric percentages can be predicted with an RMSE of less than 1.48 independent of scale thickness. This low error value guarantees the effectiveness of the intended method and the usefulness of using this approach in the petroleum and petrochemical industries.


Introduction
Scale deposits in oil pipelines have caused many problems in many oil fields around the world. Scale formation reduces the effective cross-sectional area of the pipeline and complicates the flow of petroleum products. This factor prevents pumps and various equipment from working properly. Increasing the amount of scale in the pipeline and not detecting it in time can lead to downtime accidents, damage to oil equipment, increased repair costs and reduced efficiency. It is for this reason that, in the presence of scale, using a control system that provides features such as detection of volume percentages is very useful for moving things forward. Researchers, when determining the various parameters of a polyphase flow, always allude to gamma-ray attenuation systems as the gold standard [1][2][3][4][5][6][7][8]. In [1], the researchers carried out a setup consisting of a cesium source, two detectors made of sodium iodide, and a test pipe. They implemented two-phase flow in three regions: stratified, bubbly, and annular, and were able to predict the volume percentages and classify the flow regimes using the counts recorded by two detectors fed as inputs to the RBF neural network. In [2], Roshni et al. used artificial neural networks of type GMDH trained on the imbalanced data to detect the type of flow regime and volume percentages. They justified the heavy computational load applied to the system with the resulting high accuracy. Years ago, Roshani et al. in [3], used the combination of a NaI detector and cobalt-60 source to design a system for detecting the flow regime and volume percentage, which had low accuracy in determining the parameters due to the extraction of inappropriate characteristics. The Jaya optimization algorithm was used by researchers in 2019 to predict the volume percentage of a three-phase flow in the stratified regime [4]. Two sodium iodide detectors, a cesium source, and a test pipe were the structures that led Sattari and his colleagues to introduce a system for accurate determination of volume percentages and classification of flow regimes. In a follow-up study [6], they investigated how to use GMDH neural networks to identify types of flow regimes and predict volume percentages. In this study, high accuracy was obtained in determining the volume percentage, but one of the disadvantages of this study was not considering the amount of scale in the pipe. In [7], the scale thickness in the oil pipe is detected by a dual-energy source including Ba-133 and Cs-137. After simulating the two-phase flow in different regimes, the Ba-133 and Cs-137 gamma peaks from the first transmission photon detector and the total number from the second scattered-photon detector were considered as inputs of the RBF neural network. Finally, their research led to the prediction of scale thickness with RMSE less than 0.22. In a recent investigation, the scale thickness in the oil pipe was detected by a dual-energy source including Ba-133 and Am-241. After simulating the three-phase flow in annular regimes, Photopeaks of Ba-133 and Am-241 of two transmission detectors were propounded as inputs of the RBF neural network. Eventually, their investigation resulted in the prediction of scale thickness with an RMSE of less than 0.09 [8]. The always-on energy sources based on radioisotopes lead to problems, including transportation problems and requiring employees to wear special protective clothing. Therefore, in recent years, the attention of researchers has been drawn to research the use of X-ray tubes to determine the parameters of multiphase flows [9][10][11][12]. Researchers in [9] determined the regime type and volumetric percentage of two-phase flows using an X-ray tube and a NaI detector. They extracted temporal features from the signals received by the detector and used these features to train two MLP neural networks. In the study of three-phase flows in [10], three regimes of homogeneous, annular, and stratified flow were simulated in different volume percentages. Three RBF neural networks were also trained with the frequency characteristics of the received signals, which were relatively accurate. Four petroleum products that are mixed two by two with different volumes were simulated in [11] with the MCNP code and centered on the X-ray tube. The inputs of three MLP neural networks were the recorded signals, which were used to predict the volume ratio of the three products. Considering that the volume ratio of three products was obtained, calculating the volume ratio of the fourth product was not difficult. The introduced method predicted the type and amount of products, but the lack of feature-extraction techniques prevented the obtaining of high precision. In order to develop research [11], wavelet transforms was investigated by Balubaid et al. [12] as a feature-extraction technique. Optimizing the computational load and improving the accuracy was one of the results of this action. With the help of the previous studies that have been undertaken in this field, in this study, an attempt has been made to provide a volume-percentage diagnostic system with high accuracy. For this purpose, a three-phase flow regime consisting of water, gas and oil in different volume percentages was simulated. A different value of scale thickness was considered in each simulation. By extracting the characteristics of the count under Photopeaks 241 Am and 133 Ba of the first detector and the total count of the second detector, and applying them to Processes 2022, 10, 1996 3 of 12 two MLP neural networks, we tried to predict volume percentages with high accuracy. The following are the contributions of the present research:
Measurements of volumetric fractions could be taken during the passage of a threephase flow via an oil pipe, despite the presence of scale; 3.
Examining the effectiveness of the photopeak characteristics of 241 Am and 133 Ba of the first detector and the total count of the second detector in identifying the volume percentages; 4.
Significantly reducing the computational burden by collecting useful features.

Simulation Setup
The passage of time has shown that researchers are interested in using MCNP code to simulate structures in which X-ray or gamma radiation is used [13][14][15][16]. The framework proposed in this study was modeled with the MCNP code-simulation platform [17]. 241 Am and 133 Ba radioisotopes form the centrality of the proposed framework of this research. The aforementioned dual-energy source has a photon energy of 59 kilo electron volts and 356 kilo electron volts, respectively, and emits its photons towards a steel test pipe and collects them at the end using two detectors. These two detectors, which are made of sodium iodide, are placed at an angle of 0 and 7 degrees to the hypothetical horizon line and have dimensions of 2.54 cm × 2.54 cm. However, the main event happens inside the test pipe, where a three-phase flow is simulated in a stratified flow regime. The said pipe is 0.5 cm thick and has an inner diameter of 10 cm. Inside this pipe, there is a scale made of BaSO 4 with different thicknesses. To be precise, there is a scale with a density of 4.5 g per cubic centimeter in thicknesses of 0, 0.5, 1, 1.5, 2, 2.5, and 3 cm inside the pipe, where water, oil, and gas pass through the scale. In this modeling, the density of water is 1, gas is 0.00125 and oil is 0.826 g per cubic centimeter. In this research, the structure was implemented in the MCNP code. It should be mentioned that the validation of the simulated structure in this study was undertaken with the experimental structure implemented in the study [1]. The recorded counts obtained from the detectors of the simulated structure and the experimental structure were compared. It was apperceived that there is an acceptable match between them. For every seven values of the scale thickness, there are 36 different volume percentages, which finally result in 252 simulations. From each simulation, three characteristics-named counts under Photopeaks 241 Am and 133 Ba of the first detector and the total count of the second detector were extracted, which were obtained in total for training the neural network of 3 × 252 matrix. There are two neural networks, each of which has three inputs and one output. One output gives the volume percentage of the gas phase and the other the volume percentage of the oil phase. It is obvious that in the meantime, the volume percentage of water can be calculated simply by subtracting these two values obtained from the initial total volume. The whole described structure is shown in Figure 1. The extracted features are illustrated in Figure 2.

MLP Neural Network
The human brain is a collection of millions of interconnected computing units called neurons, which have branches called dendrites, which are the means of sending information. After performing the processing steps, information is transferred outside the neuron by the axon. The mentioned processes happen in physiological and biochemical fields, but the mathematical modeling undertaken by the researchers has made the matter different. The use of intelligent mathematical methods and artificial neural networks in many different fields of science has attracted the attention of many researchers [18][19][20][21][22][23][24][25][26][27][28][29][30][31][32]. One of the most-used modeling is the MLP neural network. The structure of this network consists of three different parts: the output layer part, the hidden layer part and the input layer part. Hidden layers can be more than one layer. In the hidden layers, mathematical processes are performed, which are called activation functions. The number of these layers, the number of hidden layer neurons and the type of activation function depends on the nature and degree of non-linearity of the available data. In the mathematical implementation of neurons, the output of neurons is as follows [18,19]:

MLP Neural Network
The human brain is a collection of millions of interconnected computing units called neurons, which have branches called dendrites, which are the means of sending information. After performing the processing steps, information is transferred outside the neuron by the axon. The mentioned processes happen in physiological and biochemical fields, but the mathematical modeling undertaken by the researchers has made the matter different. The use of intelligent mathematical methods and artificial neural networks in many different fields of science has attracted the attention of many researchers [18][19][20][21][22][23][24][25][26][27][28][29][30][31][32]. One of the mostused modeling is the MLP neural network. The structure of this network consists of three different parts: the output layer part, the hidden layer part and the input layer part. Hidden layers can be more than one layer. In the hidden layers, mathematical processes are performed, which are called activation functions. The number of these layers, the number of hidden layer neurons and the type of activation function depends on the nature and degree of non-linearity of the available data. In the mathematical implementation of neurons, the output of neurons is as follows [18,19]: where x represents the input parameters. W represents the weighting factor; b represents the bias term and f represents the activation function. i is the input number and j is the neuron number in each hidden layer. In order to solve the problem of over-training and under-training, the available data are divided into three categories: training, validation and testing. The training data contains most of the data and this data is used for the neural network to see and fit them. Generally, the term "validation data" refers to a sample of the dataset that is used to ensure the correct training process. During the training process, these data are used for network testing. The test data are applied to the neural network at the end of the neural-network training process in order to ensure the accuracy of the performance. When a neural network can work properly under operational conditions, it performs well against all three introduced data types. The number of training, validation and test data in this research are 176, 38 and 38, respectively.

Result and Discussion
Three features introduced in the previous sections were applied as inputs of two MLP neural networks, which consisted of a 3 × 252 matrix. The output of each neural network was the volume percentage of the gas phase or oil phase, which is 1 × 252 matrix. Several neural networks with a variant number of hidden layers and a different number of neurons in hidden layers were implemented, and the optimal structure for determining the volumetric percentage of gas and oil can be seen in Figures 3 and 4, respectively. The specifications of these networks are tabulated in detail in Table 1. To calculate the error value of the implemented network, two criteria MRE and RMSE are propounded. These criteria equations are as follows: where N represents the number of data, "X(Exp)" and "X(Pred)" represent the experimental and predicted values of ANN, respectively.

ANN Gas Volume Percentage Predictor Oil Volume Percentage Predictor
Neurons of the input layer 3 3 Neurons of the first hidden layer 18 8 Neurons of the second hidden layer 8 3 Neurons In order to combat over-fitting and under-fitting, the accessible data are separated into three categories: training data, validation data, and test data. The training data includes the information seen by the neural network and used to create the model. Validation refers to the process of introducing the test data that is utilized during training. The correct answer to these data shows that the training steps have been conducted correctly. After the neural network has been trained, its performance may be assessed using test data. As long as the neural network responds appropriately to these three data sets, the proposed network will be safe from over-fitting and under-fitting problems. The response of neural networks to these three categories can be seen by the fit diagram and error diagram in Figures 5 and 6. The fitting diagram shows both the target output and the network output in one graph so that the accuracy of the network can be seen. The regression diagram displays both the anticipated outcome (represented by a black line) and the neural network's outputs (represented by green circle). The difference between the two target outputs and the neural network output can be seen in the error diagram.     The calculation load may be decreased, while accuracy is improved by training MLP neural networks with extracted features that are useful in estimating percentages of volumes. The presented high-accuracy system eliminates the need of oil and petrochemical industries to use an accurate and reliable detection system. The issue that can be limiting in this research is the use of a radioisotope source, which leads to harmful effects on the human body, and it is necessary to use protective equipment and clothing when working with the device. There is no option to turn off the source either. The low error obtained in this research is the result of the correct processing of the obtained signals and the training of the neural network with the effective characteristics of the signal, and can cover the defects. Future studies in this area are highly encouraged to examine many features, such as time, frequency, and wavelet-transform characteristics, and the performance of various neural networks in order to increase productivity.

RMSE
Train data Validation data Test data Train data Validation data Test data In order to combat over-fitting and under-fitting, the accessible data are separated into three categories: training data, validation data, and test data. The training data includes the information seen by the neural network and used to create the model. Validation refers to the process of introducing the test data that is utilized during training. The correct answer to these data shows that the training steps have been conducted correctly. After the neural network has been trained, its performance may be assessed using test data. As long as the neural network responds appropriately to these three data sets, the proposed network will be safe from over-fitting and under-fitting problems. The response of neural networks to these three categories can be seen by the fit diagram and error diagram in Figures 5 and 6. The fitting diagram shows both the target output and the network output in one graph so that the accuracy of the network can be seen. The regression diagram displays both the anticipated outcome (represented by a black line) and the neural network's outputs (represented by green circle). The difference between the two target outputs and the neural network output can be seen in the error diagram. The calculation load may be decreased, while accuracy is improved by training MLP neural networks with extracted features that are useful in estimating percentages of volumes. The presented high-accuracy system eliminates the need of oil and petrochemica industries to use an accurate and reliable detection system. The issue that can be limiting in this research is the use of a radioisotope source, which leads to harmful effects on the human body, and it is necessary to use protective equipment and clothing when working with the device. There is no option to turn off the source either. The low error obtained in this research is the result of the correct processing of the obtained signals and the training of the neural network with the effective characteristics of the signal, and can cover the defects. Future studies in this area are highly encouraged to examine many features, such as time, frequency, and wavelet-transform characteristics, and the performance of various neural networks in order to increase productivity.

Conclusions
Determining the volume percentage of each passing phase of condensate inside the oil pipe will optimize the system and improve the performance of the oil industry. Therefore, engineering and implementing a system to detect volume percentage can be an effective help in solving the challenges in the oil industry. In this research, to provide an accurate system to detect the volumetric percentage of three-phase condensates passing in a stratified flow regime, the gamma-ray attenuation technique was used and the optimal system was provided. The detection system includes a gamma source with dual energy and two NaI detectors placed on both sides of the pipe, where the volume percentage of each phase is measured. All this procedure is simulated using MCNP code. A threephase flow was simulated at different volume percentages, in the range of 10% to 80%

Conclusions
Determining the volume percentage of each passing phase of condensate inside the oil pipe will optimize the system and improve the performance of the oil industry. Therefore, engineering and implementing a system to detect volume percentage can be an effective help in solving the challenges in the oil industry. In this research, to provide an accurate system to detect the volumetric percentage of three-phase condensates passing in a stratified flow regime, the gamma-ray attenuation technique was used and the optimal system was provided. The detection system includes a gamma source with dual energy and two NaI detectors placed on both sides of the pipe, where the volume percentage of each phase is measured. All this procedure is simulated using MCNP code. A three-phase flow was simulated at different volume percentages, in the range of 10% to 80%, while different scale values, with thicknesses of 0 cm to 3 cm, were investigated. From the signals received from all simulations, three features-named counts under Photopeaks 241 Am and 133 Ba of the first detector and the total count of the second detector were extracted and used in the neural network design. Two MLP neural networks were trained in the condition that the mentioned features were considered as inputs and volume percentage of gas and oil as the output of each neural network. The volume percentage of the water phase will be easily obtained by subtracting the amount of gas and oil from the total volume of the pipe. These neural networks were able to predict the volume percentage with RMSE less than 1.48, which is a minor error compared to previous researches. The great precision of the provided method is a direct result of the effective extraction of features and their usage in training neural networks to create optimum networks. The detection system introduced in this research is very beneficial and its use is recommended for the oil and petroleum industry.