Application of Gamma Attenuation Technique and Artiﬁcial Intelligence to Detect Scale Thickness in Pipelines in Which Two-Phase Flows with Different Flow Regimes and Void Fractions Exist

: Scale deposits can reduce equipment efﬁciency in the oil and petrochemical industry. The gamma attenuation technique can be used as a non-invasive effective tool for detecting scale deposits in petroleum pipelines. The goal of this study is to propose a dual-energy gamma attenuation method with radial basis function neural network (RBFNN) to determine scale thickness in petroleum pipelines in which two-phase ﬂows with different symmetrical ﬂow regimes and void fractions exist. The detection system consists of a dual-energy gamma source, with Ba-133 and Cs-137 radioisotopes and two 2.54-cm × 2.54-cm sodium iodide (NaI) detectors to record photons. The ﬁrst detector related to transmitted photons, and the second one to scattered photons. The transmission detector recorded two signals, which were the counts under photopeak of Ba-133 and Cs-137 with the energy of 356 keV and 662 keV, respectively. The one signal recorded in the scattering detector, total counts, was applied to RBFNN as the inputs, and scale thickness was assigned as the output. novel approach for estimating the scale thickness in pipes in which two-phase ﬂows with different ﬂow patterns and void fraction exists. A dual-energy gamma attenuation method with RBFNN was used. The proposed RBFNN— with three inputs (photopeaks of Ba-133 and Cs-137 from the transmitted detector and total count from scattering detector) and one output (scale thickness)—was optimized. The optimized RBFNN consisted of 15 neurons in a hidden layer associated with a spread value of 2. The regression diagrams for both testing and training sets that showed the precision of the system were plotted. The MAE, MRE%, and RMSE of the proposed system were 0.18, 0.29, and 0.22, respectively. The results show the proposed system can be adopted in the petroleum industry for measuring Author Contributions: Conceptualization, M.A., M.B., E.N. and E.E.-Z.; Software, E.M.K., M.A.S.; Validation, O.T. and E.N.; Writing—Review and Editing, E.M.K., O.T., E.N. and E.E.-Z.; Visualization, M.B.; Supervision, M.A., E.N.; Funding acquisition, E.E.-Z.


Introduction
Scale deposits on the inside of surface production equipment can cause problems such as the reduction of the internal diameter of pipelines, perforation of equipment and pipelines due to corrosion, high energy consumption costs, reduced equipment life cycle, and decreased equipment efficiency in the petroleum industry. Scale problems occur in some of the oilfields around the world, caused by floods containing barium, strontium sulfate scales, and calcium. Scale deposits can hinder oil production by clogging the matrix of oil-producing formations. Moreover, scales can clog the production equipment and flowlines and hence block damage the fluid flow. The scale deposits may also occur in the down-hole pumps, heater treaters, blocking flow lines in tubes, tanks, and other production facilities. This can cause an emergency shutdown, production equipment failure, increased maintenance costs, and a reduction in overall production efficiency [1][2][3][4][5][6][7][8].
Previous studies have shown that the gamma attenuation technique can be used as an effective method for detecting mineral scales in petroleum pipelines. Oliviera et al.
(2015) used a 5.08-cm × 5.08-cm NaI detector and one Cs-137 radioactive source to scan a pipe with scale deposits [7]. To scan the pipe, both source and detector were moved simultaneously with steps of 0.5 cm. For each step, a transmission gamma spectrum was captured with the NaI detector, and the measurement duration was set to 60 s. The results showed that with gamma transmission scanning, it is possible to predict the presence of scale and measure scale as well as thickness in a pipe. However, it is not possible to estimate the exact distribution of scale on the pipe wall with the technique. Teixeira et al. (2018) proposed a gamma attenuation technique to inspect scale in a pipe. The researchers implemented the Monte Carlo simulation code (MCNP) and analytical method in the study [8]. Because of the complexity of the problem, they used Artificial Neural Networks (ANN) as their analytical method. ANNs are proven solutions for complex problems and accurate predictions using less statistical training compared to other techniques used in non-linear estimations [9]. The simulated geometry contained a steel pipe that had an external diameter of 28 cm, a Cs-137 radioactive source with a divergent beam, and one 5.08-cm × 5.08-cm NaI detector. The scale considered was made of barium sulfate scale (BaSO 4 ) with a thickness ranging between 0.5 and 6 cm, and a step of 0.4 cm as scale layer inside the pipe. First, the optimum opening size for the collimator was established before simulating the pipe with different diameters in the range of 15-27 cm. A single-phase fluid existed inside the pipe. The research team used the internal diameter of the pipe and acquired gamma spectrum with the detector as the inputs to an artificial neural network, and the thickness of scale was the output. With this method, scale thickness was estimated with deviations below 10% for 70% of the cases. Salgado et al. (2020) utilized the MCNP6 code to investigate the possibility of using gamma attenuation technique combined with ANN for predicting scale thickness in a pipe in which a gas-oil-water three-phase flow existed [10]. The proposed simulation geometry included an iron pipe with an outer diameter of 25 cm, a Cs-137 collimated source with a divergence angle of 8.84 • , and one 3.17-cm × 1.90-cm NaI detector. The study investigated an annular flow regime of threephase flow with a constant volume fraction (30 % water, 60 % oil, and 10% gas) inside the pipe. The scale considered was BaSO 4 with thicknesses ranging from 0 to12.4 cm and a step of 0.4 cm as a scale layer. The recorded gamma energy spectrum in the detector and scale thickness were the ANN input and output, respectively. This technique estimated the scale-thickness with a relative error of 0.6%.
Existing gamma attenuation techniques for detecting scale layers in pipelines are usually considered a single-phase flow. Even in cases where a multiphase flow was considered, a simple model of a multiphase flow with a constant flow regime and volume fraction was assumed. In a real situation, however, multiphase flows with varying flow regimes and volume fractions usually exist in oil pipelines. The present study will focus on determining scale thickness in pipelines in which two-phase flows with different flow regimes and void fractions exist. To achieve this goal, a dual-energy gamma attenuation method and RBFNN was proposed.

Monte Carlo Simulation
The present study aims to estimate scale thickness in pipelines in which a gas-liquid two-phase flow exists. According to Beer-Lambert's law, gamma radiation-based instruments are sensitive to the amount and type of materials that are positioned between detector and radiation source. A simple gamma radiation-based instrument comprising a detector and a radiation source that follows Beer-Lambert's law can detect changes in one material. In the system, one known factor is the recorded signal in the detector, and one unknown factor is the change in a material amount.
The present study will consider three unknowns: scale thickness, flow patterns, and void fraction in a gas-liquid two-phase flow. In this case, a minimum of three known signals is needed. To investigate the idea of using dual energy gamma sources and two detectors for solving the aforementioned problem, MCNP-X [11] was implemented. The system includes two radioisotopes of Ba-133 and Cs-137 as the source and two NaI detectors to record the transmitted and scattered photons.
The transmission detector was positioned 5 cm away from the pipe. Moreover, the scattering detector was located at an orientation of 45 o with respect to the axial line connecting the transmission detector and the radiation source. The dual-energy source was collimated with VEC and DIR cards in MCNPX code to have a narrow beam emitting gamma radiation toward the transmission detector. In simulations, a steel pipe with a diameter and thickness of 21 cm and 0.5 cm was specified. The scale considered was a symmetric annular layer made of BaSO 4 inside the pipe wall. Scale layers with thicknesses ranging from 0 to 4 cm and a step of 0.5 cm were simulated. The liquid and gas phases in all simulation trials were investigated, and oil and air with respective densities of 0.826 g/cm 3 and 0.00125 g/cm 3 were considered. The simulations modeled the three typical flow patterns called stratified, homogenous, and annular flows. The percentages of the void fraction for each flow pattern ranges from 10% to 85%, with an increment of 15%. In this study, 162 simulations (3 flow patterns × 9 scale layers × 6 void fractions) were performed. It is important to mention that many studies were conducted on the measurements of multiphase flows in recent years . Figure 1 shows the modeled three flow patterns with a void fraction percentage around 25% and a scale thickness of 1.5 cm.

RBFNN
In the last few years, a lot of researchers implemented ANN for different engineering applications . An ANN employs computational units in the network to weigh and combines data from input, hidden, and output layers. There is only one hidden layer in the RBFNN and the neurons that use RBF to process the input data. The architecture of a standard RBFNN is shown in Figure 2. Input signals (x 0 , x 1 , x 2 , . . . , x n ) are weighted by and connected to hidden neurons using "synaptic weights". The neurons' "activation" values are neuron responses. These values are considered through the activation of nonlinear functions for calculating the weighted sum of their input with the addition of a bias [63]: Equation (1) gives the weighted sum of the input and bias.
The average distance between the data points of a vector x is calculated with RBF consisting of an N-dimensional feature and a center location v related to a template vector extracted from the training data [64]. The activation function of the hidden layer is "radbas". Equation (2) expresses the output from the hidden layer's m th node as given in [65].
The default of σ value (spread) in MATLAB software is 1, but this value was optimized in this study. The activation function of the output layer is "purelin".
Equation (3) gives the prediction of output from the jth node of the output layer [64,65].
Training the RBFNN output weights is a mathematical procedure. Provided that the centers of RBF and the scaling parameters are determined, the weights of the output layer can be calculated. The matrix of the output layer weights (W) is the result of a minimization of the error function [66]: where H and Y are the outcome of radial basis functions and desired output, respectively. The solution is given in the form W = H + Y, where H + denotes the pseudo-inverse matrix of H. The solution W is unique and can also be found by gradient descent optimization of the error function defined in Equation (4). Despite the similarities of RBFNN with other neural network architectures such as MLPNN, RBFNN behave differently. The proposed RBF model in this paper was developed with the MATLAB 8.1.0.604 software.
The net = newrb(P, T, goal, spread, MN, DF) takes two of these arguments and returns a new radial basis network. P, T, Goal, Spread, MN, and DF are R-by-Q matrix of Q input vectors, S-by-Q matrix of Q target class vectors, Mean squared error goal, Spread of radial basis functions, Maximum number of neurons, and number of neurons to add between displays, respectively [67].

Monte Carlo Simulation
As shown in Figure 3, the transmission detector recorded two signals: the count under photopeak of Ba-133 associated with 356 keV energy and the count under photopeak of Cs-133 combined with 662 keV energy. The two signals and one signal recorded in the scattering detector, total count, were used to generate an adequate dataset for testing and training artificial neural networks.  In the scattering detector, a small difference in trend is observed compared with the results predicted by the transmission detector. When the scale thickness is zero, total counts slightly decrease as the void fraction increases, while for the scale thicknesses more than zero, total counts increase for the scale thicknesses greater than zero.

RBFNN
To predict the scale thickness deposited on the inner pipe wall, three different signals were extracted from both detectors and applied to the RBFNN. Gamma peak counts of Ba-133 and Cs-137 from the first transmission photons detector and total counts from the second scattered photons detector were considered as RBFNN inputs, and the scale thickness of the pipe was the RBFNN output. Figure 7 presents the flowchart of the specified RBFNN.
The best configuration of the network was obtained with the trial-and-error method. Table 1 shows the configuration, and the schematic of the network is presented in Figure 8. In Figure 9, the error value versus the number of hidden layer neurons was plotted.          In developing the optimal RBF model, several structures were constructed and tested. The errors changed significantly until the number was increased to 15 neurons, and the error change was negligible. This behavior was shown in Figure 10, which is a performance graph. The number of neurons exceeding 15 did not improve the performance of the network but increase the complexity of the network, and hence 15 neurons were selected.        (8).
where N is the number of data and 'X i (actual)' and 'X i (Predicted)' denote actual values and RBF predicted values, respectively. The results presented in Figures 11 and 12 and Table 2 indicate a good performance of the trained RBF neural network for estimating the scale layer thickness regardless of the type of flow regime and variations in void fraction.
It is important to mention that the coefficient of determination (R-squared) is employed as the goodness of fit index, which is defined as the proportion of variation explained by the best line model.

Conclusions
The present study proposed a novel approach for estimating the scale thickness in pipes in which two-phase flows with different flow patterns and void fraction exists. A dual-energy gamma attenuation method with RBFNN was used. The proposed RBFNNwith three inputs (photopeaks of Ba-133 and Cs-137 from the transmitted detector and total count from scattering detector) and one output (scale thickness)-was optimized. The optimized RBFNN consisted of 15 neurons in a hidden layer associated with a spread value of 2. The regression diagrams for both testing and training sets that showed the precision of the system were plotted. The MAE, MRE%, and RMSE of the proposed system were 0.18, 0.29, and 0.22, respectively. The results show the proposed system can be adopted in the petroleum industry for measuring scale thickness in pipes.
It is worth mentioning that the advantage of the presented system in this study is that no prior knowledge about the type of flow regime and volume fraction of multiphase components inside the pipe is required for predicting the scale thickness in case the RBF neural network is trained well. A comparative evaluation of the performance of RBFNN with other machine learning approaches is proposed for future research. Moreover, for the investigation of different pre-processing methods, different feature extraction methods, such as time domain, frequency domain, or time-frequency domain and correlation analysis, to improve the performance of the presented model are suggested.

Conflicts of Interest:
The authors declare no conflict of interest.