Proposing an Intelligent Dual-Energy Radiation-Based System for Metering Scale Layer Thickness in Oil Pipelines Containing an Annular Regime of Three-Phase Flow

: Deposition of scale layers inside pipelines leads to many problems, e.g., reducing the internal diameter of pipelines, damage to drilling equipment because of corrosion, increasing energy consumption because of decreased efﬁciency of equipment, and shortened life, etc., in the petroleum industry. Gamma attenuation could be implemented as a non-invasive approach suitable for determining the mineral scale layer. In this paper, an intelligent system for metering the scale layer thickness independently of each phase’s volume fraction in an annular three-phase ﬂow is presented. The approach is based on the use of a combination of an RBF neural network and a dual-energy radiation detection system. Photo peaks of 241 Am and 133 Ba registered in the two transmitted detectors, and scale-layer thickness of the pipe were considered as the network’s input and output, respectively. The architecture of the presented network was optimized using a trial-and-error method. The regression diagrams for the testing set were plotted, which demonstrate the precision of the system as well as correction. The MAE and RMSE of the presented system were 0.07 and 0.09, respectively. This novel metering system in three-phase ﬂows could be a promising and practical tool in the oil, chemical, and petrochemical industries.


Introduction
Deposition of scale layers inside pipelines leads to many problems in the petroleum industry. As a part of such problems, it can include decreasing of the internal diameter, drilling equipment corrosion, increasing the energy consumption due to decreased equipment efficiency, short life, and so forth. Water flooding, which contains calcium, barium, and strontium sulfate scales, has caused many scale problems in several oil fields worldwide. Scale deposition limits and blocks petroleum production. Consequently, scale deposition causes critical challenges such as emergency shutdowns, equipment failures, and decreasing efficiency of equipment [1][2][3][4][5][6][7][8].
Gamma attenuation technique is a useful method for detecting mineral scale in petroleum pipelines. In 2015 [7], Oliviera et al. employed a NaI detector together with a 2 of 14 137 Cs radioisotope source to scan scale deposits in a pipe. They acquired a gamma spectrum for each 0.5 cm step. They finally concluded that the gamma transmission scanning could estimate the presence of scale in a pipe in which a single-phase fluid flows, but that it is impossible to predict the precise distribution of scale. In 2018 [8], Teixeira et al. presented an approach to investigate scale in a pipe. The proposed geometry consisted of a steel pipe, a 137 Cs radioisotope source with isotropic flux, and one NaI detector. The gamma spectra measured from the pipe's internal diameter were considered the input of the ANN, whereas the output was the thickness of the scale. This methodology estimated the scale thickness with deviations below 10% for 70% of the cases. The drawback of their proposed system was that they could only measure the scale thickness of pipelines in which a single fluid flowed, while in real oil pipelines there exists two or three-phase flow. Roshani et al. investigated the possibility of identifying the flow regime and determining gas void fraction in two-phase flow without any dependency on the scale layer of the oil pipeline by combining photon attenuation and artificial intelligence techniques [9]. Their study implemented ANN for regime identification and void fraction prediction. The results revealed that their proposed technique is unable to identify all three flow regimes. To the best of the author's knowledge, as mentioned in the literature review, no investigation has been done on the thickness measurement of scale layers in oil pipelines with an existing gas-oil-water three-phase flow with various volume fractions. In real situations, there are two or threephase flows with variating volume fractions inside the oil pipelines which affect drastically the performance of radiation-based scale thickness meters. The novelty of the present study is the proposal of a system with the capability to measure scale layer thickness in petroleum and oil pipelines without any dependency on the volume fractions of each phase in the annular regime of a three-phase flow. We employed a dual-energy gamma attenuation technique combined with a radial basis function neural network (RBFNN) to achieve this aim. The details of the proposed approach are explained in the following sections.

Monte Carlo Simulation
MCNP code [10] was implemented in the present investigation to model the radiationbased system. In the past few decades, it has been proved that MCNP code is a potential tool for modeling radiation-based measuring instruments [11][12][13][14][15][16][17][18][19][20][21][22]. As pointed out in the abstract section, our aim is to propose a gamma radiation-based system with the ability to determine scale thickness independently of volume fraction changes of an annular three-phase flow's components. In order to obtain more information from the different materials inside the pipe, a system consisting of a dual-energy source consisting of 241 Am and 133 Ba radioisotopes that emit photons with energies of 59 and 356 keV, respectively, and two NaI detectors for recording transmitted photons were used.
As shown in Figure 1, a steel pipe with an internal radius of 10 cm was simulated in this study. In order to model the scale layer, a cylindrical shell of barium sulfate (BaSO4) with a density of 4.5 g.cm −3 and different thicknesses in the range of 0-2 cm was considered on the internal wall of the steel pipe.
An annular regime of a three-phase flow, including gas, oil, and water components, was modeled inside the pipe. Air, gasoil, and water were utilized as gas, oil, and water phases, respectively. Various volume fractions (10-80 percent) were simulated for each component (5 different scale thickness × 36 different volume fractions = total of 180 simulations performed) for each scale thickness.
As mentioned earlier, in this investigation, two NaI detectors were applied. Tally F8 was utilized to register photon energy spectra in both detectors. The first detector was positioned diametrically in front of the radioactive source, and the second one was placed at an orientation of 7 • .
It is worth mentioning that the simulated configuration performance in this work was benchmarked in our earlier study using an experiment [23]. As shown in Figure 2, in that study, an experimental model was established. A two-phase flow annular regime with various amounts of gas and oil components was also modeled inside a pipe. A geometry the same as the experimental setup was simulated. The acquired results showed that the experimental and simulated data were in good agreement, which confirmed the simulated detection system performance. An annular regime of a three-phase flow, including gas, oil, and water components, was modeled inside the pipe. Air, gasoil, and water were utilized as gas, oil, and water phases, respectively. Various volume fractions (10-80 percent) were simulated for each component (5 different scale thickness × 36 different volume fractions = total of 180 simulations performed) for each scale thickness.
As mentioned earlier, in this investigation, two NaI detectors were applied. Tally F8 was utilized to register photon energy spectra in both detectors. The first detector was positioned diametrically in front of the radioactive source, and the second one was placed at an orientation of 7°.
It is worth mentioning that the simulated configuration performance in this work was benchmarked in our earlier study using an experiment [23]. As shown in Figure 2, in that study, an experimental model was established. A two-phase flow annular regime with various amounts of gas and oil components was also modeled inside a pipe. A geometry the same as the experimental setup was simulated. The acquired results showed that the experimental and simulated data were in good agreement, which confirmed the simulated detection system performance.
Although the presented system in the current study was developed for measuring the scale layer thickness independently of different volume fractions of each phase in an annular regime of a three-phase flow, it can be applied for the other types of flow regimes.
There are different numbers of computational units named neurons in each layer. RBF networks weigh and combine information through these neurons. Concerning process input data, RBF is used in the hidden layer of the RBF neural network. A typical architecture of an RBF neural network is shown in Figure 3. The hidden neurons, through "synaptic weights", connect and weigh the input signals. The neurons' responses represent neuron "activation" values. Nonlinear activation functions consider such values by adding up a bias to the weighted summation of their input [91]. The activation function of the hidden layer is "radbas". Therefore, Equation (2) refers to the hidden layer, and precisely to the mth node's output [91][92][93]: The default spread value (σ) in MATLAB software commands is 1, but this value was optimized in this study. The output prediction from the jth node of the output layer is The activation function of the hidden layer is "radbas". Therefore, Equation (2) refers to the hidden layer, and precisely to the mth node's output [91][92][93]: The default spread value (σ) in MATLAB software commands is 1, but this value was optimized in this study. The output prediction from the jth node of the output layer is [94]: Both "radbas" and "purelin" are neural transfer functions. These kinds of functions are the most well-known functions for the hidden layer and output layer of typical RBF neural networks, respectively, and have been used in a lot of previous research. In this study, 180 separate cases were simulated using the MCNPX code. 126 cases (70%) were implemented to train the network, and 54 cases (30%) were used to test the efficiency of the presented RBF neural network. In this problem, for measuring the scale layer thickness of pipe independently of different volume fractions in a three-phase flow, four features were extracted from two transmission detectors and applied to the RBF neural network. The counts under the photopeaks for 241 Am and 133 Ba from both transmission detectors were considered the RBF neural network inputs, and scale layer thickness of the pipe was considered the RBF neural network output. The reason for choosing these mentioned features as the inputs for the network is that counts under these two photopeaks are directly connected to the amount and type of materials between the radiation source and the detector, while other features in the recorded photon energy spectrum inside the detector are not directly connected. The procedure for scale layer thickness metering is illustrated in Figure 4.
Using a trial-and-error method, the best configuration of the network was obtained. As mentioned previously, the RBF neural network has only 3 layers. The obtained configuration was tabulated in Table 1, and the schematic of the network is shown in Figure 5.  Using a trial-and-error method, the best configuration of the network was obtained. As mentioned previously, the RBF neural network has only 3 layers. The obtained configuration was tabulated in Table 1, and the schematic of the network is shown in Figure 5.

Performance of the Modeled Detection System
Counts under photo peaks of 241 Am and 133 Ba radioisotopes were recorded in bo detectors for various scale layer thicknesses and volume fractions. As an example, terna surface plots of the recorded counts under the photopeak for the 133 Ba radioisotope in th first detector for various combinations of gas, oil, and water volume fractions when th scale thickness is 0 and 2 cm, are shown in Figure 6a,b. Comparing Figure 6a,b, it cou be observed that when the scale layer is 0 cm, the sensitivity relative to changes of gas, o and water components is much more than when the scale thickness is 2 cm. In oth words, by increasing the thickness of the scale layer, somehow, information about the flo inside the pipe starts fading. This exact occurrence has also been observed for the oth detector and radioisotope.

Performance of the Modeled Detection System
Counts under photo peaks of 241 Am and 133 Ba radioisotopes were recorded in both detectors for various scale layer thicknesses and volume fractions. As an example, ternary surface plots of the recorded counts under the photopeak for the 133 Ba radioisotope in the first detector for various combinations of gas, oil, and water volume fractions when the scale thickness is 0 and 2 cm, are shown in Figure 6a,b. Comparing Figure 6a,b, it could be observed that when the scale layer is 0 cm, the sensitivity relative to changes of gas, oil, and water components is much more than when the scale thickness is 2 cm. In other words, Counts under photo peaks of 241 Am and 133 Ba radioisotopes were recorded in both detectors for various scale layer thicknesses and volume fractions. As an example, ternary surface plots of the recorded counts under the photopeak for the 133 Ba radioisotope in the first detector for various combinations of gas, oil, and water volume fractions when the scale thickness is 0 and 2 cm, are shown in Figure 6a,b. Comparing Figure 6a,b, it could be observed that when the scale layer is 0 cm, the sensitivity relative to changes of gas, oil, and water components is much more than when the scale thickness is 2 cm. In other words, by increasing the thickness of the scale layer, somehow, information about the flow inside the pipe starts fading. This exact occurrence has also been observed for the other detector and radioisotope.  For example, registered counts in both detectors versus the changes in scale thickness for the state in which the volume fractions of components are fixed (50% gas, 30% oil, and 20% water) are shown in Figure 7. As expected, the registered counts in both detectors decrease by increasing the scale thickness. As can be seen from Figure 7, the sensitivity of registered counts under the photopeak for the 133 Ba radioisotope in both detectors relative to the scale thickness changes is more than those for 241 Am. For example, registered counts in both detectors versus the changes in scale thickness for the state in which the volume fractions of components are fixed (50% gas, 30% oil, and 20% water) are shown in Figure 7. As expected, the registered counts in both detectors decrease by increasing the scale thickness. As can be seen from Figure 7, the sensitivity of registered counts under the photopeak for the 133 Ba radioisotope in both detectors relative to the scale thickness changes is more than those for 241 Am. For example, registered counts in both detectors versus the changes in scale thickness for the state in which the volume fractions of components are fixed (50% gas, 30% oil, and 20% water) are shown in Figure 7. As expected, the registered counts in both detectors decrease by increasing the scale thickness. As can be seen from Figure 7, the sensitivity of registered counts under the photopeak for the 133 Ba radioisotope in both detectors relative to the scale thickness changes is more than those for 241 Am.

Scale Thickness Prediction by RBF Neural Networks
The input matrix, output matrix (network target), and measured data (network output) for the testing set (54 cases) were tabulated in Table 2. An Intel Core i7 CPU computer was used for running the MCNPX simulations and MATLAB 8.1.0.604 software. The acquired results are shown as regression diagrams for training and testing sets in Figure 8a  For one output of the proposed RBF neural network model, the defined errors are shown in Table 3. Those defined errors contain MAE and RMSE, which have been calculated as: where the number of data points is referred to by N, 'X (real)' and 'X (measured)' applies for actual values and RBF predicted values, respectively. put) for the testing set (54 cases) were tabulated in Table 2. An Intel Core i7 CPU computer was used for running the MCNPX simulations and MATLAB 8.1.0.604 software. The acquired results are shown as regression diagrams for training and testing sets in Figure  8a,b. In this figure, measured scale values versus real scale values have been plotted for both training and testing sets.    Network performance testing using training and test data sets will give the reassurance of avoiding under-fitting and over-fitting of problems. For evaluating the precision and accuracy of the proposed network, the MAE and RMSE were calculated in Table 3. By investigating the errors ratio, it is clear that the errors are lower-proving the validity of the ANN model, which is well-trained and doesn't encounter under-fitting or over-fitting of the problem. The low errors for the training set show that the under-fitting problem has not occurred and that the network is precise. A performance-comparative evaluation of the RBF neural network with other ANN types for use in the presented metering system is proposed for future works.

Conclusions
In the present investigation, an intelligent system for metering the scale layer thickness independently of each phase's volume fractions in an annular three-phase flow was presented. In this regard, a combination of an RBF neural network and a Monte Carlo-based radiation transport calculation method was used. Photo peaks of 241 Am and 133 Ba from two transmitted detectors and the scale layer thickness of the pipe were considered the inputs and output of the network. The architecture of the presented network was optimized using a trial-and-error method. The regression diagrams showed the precision of the system as well as correction. The MAE and RMSE of the presented system were 0.07 and 0.09, respectively. The reasonable obtained results demonstrate the robustness of the proposed system. As mentioned earlier, to the best knowledge of the authors, it is the first time that a radiation-based system with the ability to measure the thickness of scale layer in oil pipelines with an existing gas-oil-water three-phase flow with different volume fractions is presented. The proposed new metering system can be applied as a promising tool in the different industries for measuring the scale layer thickness of pipelines.