Simulation Study of Utilizing X-ray Tube in Monitoring Systems of Liquid Petroleum Products

: Radiation-based instruments have been widely used in petrochemical and oil industries to monitor liquid products transported through the same pipeline. Different radioactive gamma-ray emitter sources are typically used as radiation generators in the instruments mentioned above. The idea at the basis of this research is to investigate the use of an X-ray tube rather than a radioisotope source as an X-ray generator: This choice brings some advantages that will be discussed. The study is performed through a Monte Carlo simulation and artiﬁcial intelligence. Here, the system is composed of an X-ray tube, a pipe including ﬂuid, and a NaI detector. Two-by-two mixtures of four various oil products with different volume ratios were considered to model the pipe’s interface region. For each combination, the X-ray spectrum was recorded in the detector in all the simulations. The recorded spectra were used for training and testing the multilayer perceptron (MLP) models. After training, MLP neural networks could estimate each oil product’s volume ratio with a mean absolute error of 2.72 which is slightly even better than what was obtained in former studies using radioisotope sources.


Introduction
In the oil industry, it is common practice to transport large quantities of fluids from the refineries to distribution centers through an interconnected pipeline system. Oil pipelines are used efficiently to distribute oil and its derivatives (kerosene, gasoline, diesel, etc.). On the other hand, poly-pipeline is more economical for large-volume transfers thanks to high efficiency and the removal of storage needs. [1]. The economy of poly-pipelines 2 of 10 is counterbalanced because two or more different products are in contact and mixed (contamination). The mixed fluid is then directed to special tanks or separation units with an increase in the economic costs. This process highlights the necessity of developing nondestructive techniques to precisely identify the fluid interface region aiming at a better transportation and separation process in a poly-pipeline [1].
In recent years, many efforts have been attempted by different researchers to measure characteristics of petroleum liquid products using gamma emitter radioisotopes. In 2013, G. H. Roshani et al. described a methodology to evaluate the density of some petroleum derivatives independent of the pipe diameter [2]. The proposed technique included a combination of adaptive neuro-fuzzy inference system (ANFIS) and a single gammaray densitometer. The experimental setup was made of a polyethylene pipe with outer diameter of 10.16 cm, a cesium-137 radioisotope source and one 7.62 cm sodium iodide (NaI) scintillation detector. The ANFIS system was processing two inputs (i.e., pipe diameter and detector counts) and returning the density as output. The researchers managed to estimate the density for several values of pipe diameter with an error of less than 2.64%. The group of C. Salgado proposed, in 2016, a technique based on a broad beam detection system and artificial neural network (ANN) to determine the density of petroleum and its derivatives [1]. A cesium-137 source and one sodium iodide crystal detector were modeled using MCNPX code, and the system was tested on a range of petroleum products with densities varying from 0.55 to 1.26 g/cm 3 . The ANN was fed with the photon energy from the detector: the resulting density of petroleum products could be estimated independent of fluid composition. In 2020, W. L. Salgado et al. designed an experimental setup to validate the Monte Carlo simulation [3]. The equipment was composed of a cesium-137 radioisotope source, a glass pipe, and one NaI scintillation detector. Two liquids (i.e., oil and water) with different percentages were placed in the pipe in a way to reproduce a stratified flow regime. The researchers succeeded in determining the interface region with an accuracy of 1%. In 2020, M. Roshani et al. proposed a high-performance system based on a dual-energy gamma-peak detection coupled with ANN: this method allowed the recognition of four different petroleum byproducts and to measure the amount of each one [4]. The system was composed of a dual energy gamma source ( 241 Am and 133 Ba) and one NaI detector; the resulting maximum mean relative error (MRE) in the petroleum byproducts measurement fractions was just 1.72. Moreover, in recent years a variety of studies have been carried out on radiation-based instruments in the oil industry to measure different characteristics such as flow regime and void fraction of gas−oil two-phase flow [5][6][7][8][9][10][11][12][13], velocity of gas−oil two-phase flow [14][15][16], density of petroleum and derivatives [17][18][19][20], flow regime and volume fraction of water−gas−oil three-phase flow [21][22][23][24][25][26][27][28], scale layer thickness of oil pipelines [29,30], etc.
In former studies reported in the literature, one or two gamma emitter radioisotope sources were used for measuring characteristics of petroleum liquid products. This study aims to investigate the possibility of applying an X-ray tube instead of radioactive sources in high-performance radiation-based petroleum product monitoring systems using Monte Carlo simulation. An X-ray tube has several advantages compared to a radioactive source: (1) it is safer for operators if correctly handled, as it can be switched off when it is not in use and does not present stochastic effects; (2) it offers the capability of adjusting emitted photons' energy and flux in a specific range; (3) radioisotope sources activity, and hence emission, decreases with time (the time constant is the half-life of the radioisotope) while X-ray tubes have virtually constant emission over time; (4) transport and handling may not require difficult-to-obtain licenses or national regulatory approvals that are often needed for high-activity radioisotope sources.

Modeling the Proposed System
In the present work, Monte Carlo N-Particle code version X (MCNP-X), which is used for neutron, photon, electron, or coupled neutron/photon/electron transport, was Processes 2021, 9, 828 3 of 10 implemented to model the system [31]. The experimental setup is shown in Figure 1, and the modeled system includes an X-ray tube as a radiation source and one NaI scintillation detector for detecting and recording the photons.

Modeling the Proposed System
In the present work, Monte Carlo N-Particle code version X (MCNP-X), which is used for neutron, photon, electron, or coupled neutron/photon/electron transport, was implemented to model the system [31]. The experimental setup is shown in Figure 1, and the modeled system includes an X-ray tube as a radiation source and one NaI scintillation detector for detecting and recording the photons. Moreover, instead of modeling a complete X-ray tube comprising an electron source as cathode and one tungsten/molybdenum target as anode, a photon source embedded in an X-ray tube's shield was defined in the input file of MCNP code. This saves a consistent amount of calculation time in generating X-ray photons. Report number 78 from the Institute of Physics and Engineering in Medicine (IPEM) [32] was implemented to generate the required X-ray energy spectrum for the adopted photon source. The electronic version of IPEM report 78 can generate different sets of radiology X-ray energy spectra for the tungsten anode with angles in the range of 6°-22°. In cases where the tube voltage ripple is not considered, the software can generate X-ray energy spectra for voltages in the range of 30-150 kV, while in cases where the voltage ripple is considered, it can generate voltages in the range of 55-90 kV. The mentioned software also can provide X-ray energy spectra for the molybdenum and rhodium anodes for mammography purposes. Additionally, the software defines some typical materials, such as beryllium, aluminum, copper, etc., with various thicknesses as filters. In this study, a tungsten anode with an angle of 12°, a tube voltage of 90 kV with a ripple voltage of 10%, and a filter made of aluminum foil 0.5 mm thick was selected in IPEM software. The generated spectrum generated by IPEM software used for photon source in this study is shown in Figure 2. Moreover, instead of modeling a complete X-ray tube comprising an electron source as cathode and one tungsten/molybdenum target as anode, a photon source embedded in an X-ray tube's shield was defined in the input file of MCNP code. This saves a consistent amount of calculation time in generating X-ray photons. Report number 78 from the Institute of Physics and Engineering in Medicine (IPEM) [32] was implemented to generate the required X-ray energy spectrum for the adopted photon source. The electronic version of IPEM report 78 can generate different sets of radiology X-ray energy spectra for the tungsten anode with angles in the range of 6 • -22 • . In cases where the tube voltage ripple is not considered, the software can generate X-ray energy spectra for voltages in the range of 30-150 kV, while in cases where the voltage ripple is considered, it can generate voltages in the range of 55-90 kV. The mentioned software also can provide X-ray energy spectra for the molybdenum and rhodium anodes for mammography purposes. Additionally, the software defines some typical materials, such as beryllium, aluminum, copper, etc., with various thicknesses as filters. In this study, a tungsten anode with an angle of 12 • , a tube voltage of 90 kV with a ripple voltage of 10%, and a filter made of aluminum foil 0.5 mm thick was selected in IPEM software. The generated spectrum generated by IPEM software used for photon source in this study is shown in Figure 2.
Poly-pipeline serves to transport two different fluids in contact and mixed with each other; this mixing defines the interface region.
Four oil products, namely ethylene glycol, crude oil (heavy, Mexican), gasoil, and gasoline with respective densities of 1.114, 0.975, 0.826, and 0.721 g.cm −3 , were considered for this study. Two-by-two mixtures of the four mentioned various oil products (six different combinations) with varying ratios of volume in the range of 0-100% with a step of 5% were taken into consideration in modeling the interface region inside the pipe. For each mixture, the X-ray energy spectrum in the detector was recorded using pulse height tally (tally type F8) in MCNPX code (a total of 118 simulations were done in this work). Poly-pipeline serves to transport two different fluids in contact and mixed with each other; this mixing defines the interface region.
Four oil products, namely ethylene glycol, crude oil (heavy, Mexican), gasoil, and gasoline with respective densities of 1.114, 0.975, 0.826, and 0.721 g.cm −3 , were considered for this study. Two-by-two mixtures of the four mentioned various oil products (six different combinations) with varying ratios of volume in the range of 0-100% with a step of 5% were taken into consideration in modeling the interface region inside the pipe. For each mixture, the X-ray energy spectrum in the detector was recorded using pulse height tally (tally type F8) in MCNPX code (a total of 118 simulations were done in this work).

Artificial Intelligence
The multilayer perceptron (MLP) neural network is known as the most widely used tool to solve various prediction and classification problems [33]. To estimate the weights and biases of MLP networks, a variety of optimization techniques can be used, such as gradient descent, conjugate gradient, Levenberg−Marquardt, Gauss−Newton, or any Newton-type method. Owing to its high performance in terms of convergence speed, the Levenberg−Marquardt (LM) algorithm was employed to train the networks of this study. By combining the speed of Gauss−Newton with the stability of gradient descent, the LM algorithm is known to be among the most efficient training algorithms for small-and medium-sized applications. Any appealing property of this algorithm is that it requires only function and gradient evaluations as the Hessian matrix can be estimated through the sum of outer products of the gradient vectors.
In this research, 118 different cases were simulated, and consequently 118 different spectra were obtained. Each spectrum was divided into 90 sections, and consequently 90 features (each 1 keV was considered as 1 feature) were obtained from each spectrum. Therefore, 118 spectra with 90 features for every spectrum were used to train and test ANN models. The input matrix of ANNs has 118 rows and 90 columns. A total of 83 spectra were used for training each ANN, while 35 spectra were used for testing each ANN. MATLAB 7.0.4 software was used for training the ANN models.

Artificial Intelligence
The multilayer perceptron (MLP) neural network is known as the most widely used tool to solve various prediction and classification problems [33]. To estimate the weights and biases of MLP networks, a variety of optimization techniques can be used, such as gradient descent, conjugate gradient, Levenberg-Marquardt, Gauss-Newton, or any Newton-type method. Owing to its high performance in terms of convergence speed, the Levenberg-Marquardt (LM) algorithm was employed to train the networks of this study. By combining the speed of Gauss-Newton with the stability of gradient descent, the LM algorithm is known to be among the most efficient training algorithms for small-and medium-sized applications. Any appealing property of this algorithm is that it requires only function and gradient evaluations as the Hessian matrix can be estimated through the sum of outer products of the gradient vectors.
In this research, 118 different cases were simulated, and consequently 118 different spectra were obtained. Each spectrum was divided into 90 sections, and consequently 90 features (each 1 keV was considered as 1 feature) were obtained from each spectrum. Therefore, 118 spectra with 90 features for every spectrum were used to train and test ANN models. The input matrix of ANNs has 118 rows and 90 columns. A total of 83 spectra were used for training each ANN, while 35 spectra were used for testing each ANN. MATLAB 7.0.4 software was used for training the ANN models.
Three optimized ANN models were obtained in order to measure ratios of ethylene glycol, crude oil, and gasoline, respectively. The gas to oil ratio could then be obtained as a difference by the previous percentages. The optimized ANN model for measuring ethylene glycol percentage has one hidden layer with six neurons and 850 epochs. The optimized ANN model for measuring crude oil percentage has one hidden layer with five neurons and 550 epochs. The optimized ANN model for measuring gasoline percentage has one hidden layer with nine neurons and 800 epochs. "Logsig" was the activation function of hidden layer neurons of the first and second models, and "Tansig" for the third model. Figure 3 illustrates the proposed procedure in order to measure the volume percentage of petroleum products. mized ANN model for measuring crude oil percentage has one hidden layer with five neurons and 550 epochs. The optimized ANN model for measuring gasoline percentage has one hidden layer with nine neurons and 800 epochs. "Logsig" was the activation function of hidden layer neurons of the first and second models, and "Tansig" for the third model. Figure 3 illustrates the proposed procedure in order to measure the volume percentage of petroleum products.

Result and Discussion
The photon energy spectra recorded in the detector for the six various mixtures ((a) ethylene glycol and gasoline, (b) ethylene glycol and gasoil, (c) ethylene glycol and crude oil, (d) crude oil and gasoline, (e) crude oil and gasoil, and (d) gasoil and gasoline) in different volume ratios in the range of 0-100%, with a step of 10%, are shown in Figure 4. It is evident from this figure that by increasing the volume ratio of the fluid with higher density, e.g., ethylene glycol in the mixture of ethylene glycol and gasoline, the recorded counts in all the energy bins are regularly reduced. Moreover, by comparing Figure 4a with Figure 4b,c, it can be observed that discrepancy between the recorded spectra for different volume ratios of ethylene glycol−gasoline mixture is more than those for the ethylene glycol−gasoil and ethylene glycol−crude oil mixtures. In other words, it can be said that the sensitivity of proposed detection system in distinguishing between the fluids having more density difference is higher than recognizing sensitivity between the fluids having less density difference. The reason lies in the fact that the photon attenuation coefficients of the fluids with less density difference are closer to each other.

Result and Discussion
The photon energy spectra recorded in the detector for the six various mixtures ((a) ethylene glycol and gasoline, (b) ethylene glycol and gasoil, (c) ethylene glycol and crude oil, (d) crude oil and gasoline, (e) crude oil and gasoil, and (d) gasoil and gasoline) in different volume ratios in the range of 0-100%, with a step of 10%, are shown in Figure 4. It is evident from this figure that by increasing the volume ratio of the fluid with higher density, e.g., ethylene glycol in the mixture of ethylene glycol and gasoline, the recorded counts in all the energy bins are regularly reduced. Moreover, by comparing Figure 4a with Figure 4b,c, it can be observed that discrepancy between the recorded spectra for different volume ratios of ethylene glycol−gasoline mixture is more than those for the ethylene glycol−gasoil and ethylene glycol−crude oil mixtures. In other words, it can be said that the sensitivity of proposed detection system in distinguishing between the fluids having more density difference is higher than recognizing sensitivity between the fluids having less density difference. The reason lies in the fact that the photon attenuation coefficients of the fluids with less density difference are closer to each other.
The comparison between the desired network outputs and those predicted from the implemented networks is presented in Table 1.
Mean relative error (MRE) and mean absolute error (MAE) of proposed ANNs were calculated using Equations (1) and (2) and are tabulated in Table 2.
where N is the number of cases.     By investigating the error ratio obtained by presented networks for testing and training, it is obvious that the values of errors are significantly low, and this fact proves the validity of the ANN models. The low errors in the testing set show that the overfitting problem did not occur, and the presented models are precise and accurate. In fact, the small obtained errors confirm the precision and correctness of the presented metering system. Besides, the novel proposed metering system is safer, simpler, and more precise than previous systems, making it very convenient for use in oil, chemical, and petrochemical industries. Unlike a system with X-ray tube, the system with radioisotope sources cannot be switched off; therefore, there is continuous radiation emission, and this creates reluctance in various industries that limit its use. Hence, by replacing the radioisotope source with an X-ray tube some safety and regulatory concerns are removed, and this should benefit the acceptance of these meters. Tunable energy for emitted photons, much higher photon flux, constant photon intensity over time, more sensitivity (especially for low densities), etc., are some of the other benefits of the presented system. Usage of X-ray with energies lower than gamma rays emitted from cesium-137 or cobalt-60 is very applicable in measuring mixtures of low densities due to the increased sensitivity of the method. In low-density mediums, high-energy photons have low interactions and do not see the medium. Low Compton interactions probability is the reason for this fact. Therefore, substituting radioisotope sources with X-ray tubes can improve the sensitivity of metering in low-density cases. Moreover, in order to recognize materials with similar densities, X-ray with low energies is an appropriate choice due to the dominance of photoelectric interactions in this range of energy and relation of these interactions to atomic number of materials.
For future works, optimization of presented measurement geometry for increasing the precision is suggested. Additionally, optimizing the distance between the X-ray tube and the detector, usage of different collimator geometries, usage of different filters or monochromatizers, and optimization of X-ray tube voltage are interesting topics for future studies.

Conclusions
The volume ratio of different petroleum products in a standard pipe has been obtained with radioisotope sources in previous studies. In this paper, a novel metering system with an X-ray tube instead of radioisotope sources is proposed that is safer, simpler, and even more precise. Furthermore, usage of X-ray with energies lower than gamma rays emitted from radioisotope sources such as Co-60 or Cs-137 is very useful in measuring mixtures of low densities due to the increased sensitivity of the method. In this regard, two software programs were used: MCNPX code and MATLAB. The Monte Carlo simulations were used to create the phantoms of pipe, fluids, detector, and shields and to transport the X-ray in these phantoms. On the other hand, MATLAB was used to create the appropriate models for measuring different petroleum products. A total of 118 spectra with 90 features for every spectrum were used in order to train and test the models. Three optimized MLP-LMs were obtained with a maximum MRE of 1.7. The low errors of testing data show the correctness of presented models and support the fact that overfitting did not occur. We can conclude that the given measuring system is accurate and precise. For future works, testing the proposed system experimentally and optimizing presented geometry in order to increase the precision of metering system are proposed. Optimizing distance between the detector and the X-ray tube, optimizing collimator geometry, usage of different filters, and optimizing X-ray tube voltage are interesting subjects for future studies.