Application of Wavelet Feature Extraction and Artificial Neural Networks for Improving the Performance of Gas–Liquid Two-Phase Flow Meters Used in Oil and Petrochemical Industries

Measuring fluid characteristics is of high importance in various industries such as the polymer, petroleum, and petrochemical industries, etc. Flow regime classification and void fraction measurement are essential for predicting the performance of many systems. The efficiency of multiphase flow meters strongly depends on the flow parameters. In this study, MCNP (Monte Carlo N-Particle) code was employed to simulate annular, stratified, and homogeneous regimes. In this approach, two detectors (NaI) were utilized to detect the emitted photons from a cesium-137 source. The registered signals of both detectors were decomposed using a discrete wavelet transform (DWT). Following this, the low-frequency (approximation) and high-frequency (detail) components of the signals were calculated. Finally, various features of the approximation signals were extracted, using the average value, kurtosis, standard deviation (STD), and root mean square (RMS). The extracted features were thoroughly analyzed to find those features which could classify the flow regimes and be utilized as the inputs to a network for improving the efficiency of flow meters. Two different networks were implemented for flow regime classification and void fraction prediction. In the current study, using the wavelet transform and feature extraction approach, the considered flow regimes were classified correctly, and the void fraction percentages were calculated with a mean relative error (MRE) of 0.4%. Although the system presented in this study is proposed for measuring the characteristics of petroleum fluids, it can be easily used for other types of fluids such as polymeric fluids.


Introduction
Information on flow regimes is used to increase the performance of flow meters [1]. Regime recognition and void fraction measurement are important issues in many industrial applications [2]. A wide variety of methods have been proposed for determining these parameters. The gamma-ray attenuation technique is the most accurate of these [3,4]. Over the past several years, many studies have been performed to enhance the accuracy of this method. Abro and co-authors [5] advanced a new methodology based on multibeam gamma-ray densitometry for flow regime classification and void fraction calculation. The dual modality densitometry technique was studied by Jiang et al. [6] for regime classification in a two-phase flow using a radial basis function (RBF) neural network. Abro et al. carried out a study investigating the efficiency of single-beam and multi-beam gammaray densitometry in predicting the void fraction in two-phase flow systems [7]. Based on the presented results, the multi-beam gamma-ray technique showed better performance than the single-beam technique. Nazemi and co-authors performed research into void fraction measurement that was independent of density changes in the liquid phase, by employing a dual modality densitometry technique [3].
Roshani et al. [1] studied flow regime identification in a two-phase flow structure utilizing the dual modality densitometry method. For regime identification and void fraction measurement, three features were extracted. The extracted features were considered as the inputs of an ANN. Nazemi et al. utilized a method to investigate the optimum position of the scattering detector involving two features for achieving greater accuracy [8]. In this study, an RBF neural network was used to accomplish the investigations. This strategy enabled them to calculate volumetric percentages autonomously of the density changes. A new approach was investigated by Peyvandi and co-workers that aimed to calculate the void fraction in some specific conditions where only one side of the pipe is accessible [9]. Nazemi et al. carried out research into two-phase flow regimes for volume fraction calculations autonomously of the various types of regimes in the pipe, using the gamma-ray attenuation technique [10]. In all the previously mentioned studies, three or more detectors were employed, but in the latter study, the gamma-ray attenuation technique made it possible to use two detectors in the structure. Subsequently, a new study was performed to identify three flow regimes in a specific condition. Roshani et al. used one source and one detector to classify three flow regimes in their system, but only two of them were identified correctly [11].
Roshani et al. studied void fraction measurements independently of the type of flow regimes using a dual-energy broad beam technique. In this context, several features were extracted from the signals from the detector to use in network inputs [12]. Hanus et al. studied time-domain feature extraction to recognize flow regimes by employing different types of neural networks [13]. Sattari and co-workers used time-domain feature extraction for estimating volumetric percentages and identifying flow regimes. In this study, void fraction percentages were calculated with an MRE of 5.32 [14].
In the current study, a system including one source (cesium-137) and two detectors (NaI) was used to register the emitted photons passing through a pipe. Three main regimes consisting of homogeneous, stratified, and annular regimes with void fractions in the range of 5-90% were considered and simulated using MCNP code. The signals from both detectors were decomposed using DWT into approximation and detail components. In order to achieve regime identification and void fraction measurement, two methods for extracting features to utilize as the inputs of ANNs were analyzed.
In this paper, by utilizing an optimized structure and taking advantage of the wavelet transform, the types of regimes and volume fraction percentages in a two-phase flow were obtained precisely. In this study, the features of the signals were extracted using a wavelet transform. Then, various feature extraction methods were applied to the signals and finally, using the defined SA parameter, the best features with the best separation ability were selected. Following this, the features were applied to the networks, and the results demonstrated the precision and correctness of the presented solution. This method reduced the rate of errors in terms of the void fraction.

Simulated Structure
MCNP code, which is a powerful tool for modeling radiation-based multiphase flow meters [15][16][17][18][19][20][21][22][23][24], was used in this study to model the measuring system. In the simulations, homogeneous, stratified, and annular regimes were considered in the structure. Simulations were accomplished for void fractions ranging from 5% to 90% for all the aforementioned regimes. Gas oil and air were defined as the liquid and gas phases, respectively. It is Polymers 2021, 13, 3647 3 of 16 worth noting that radiation-based multiphase flow meters are independent of the chemical characteristics of the materials inside the pipe that the radiation passes through. In other words, it makes no difference whether the radiation passes through a polymeric fluid, water, gas oil, or any other type of fluid. Therefore, instead of gas oil, which is used as an example liquid inside the pipe in this study, there could be a polymeric liquid, and the structure of the proposed measuring system would remain the same.
A 137Cs radioactive source (emitter energy: 0.662 MeV) and two 25.4 mm NaI transmitted photon detectors were used to detect emitted photons. The detectors were positioned at a distance of 250 mm from the source at angles of 0 and 13 degrees. It is worth mentioning that the simulated structure used in this study was validated in several experiments in our previous research [4,10].
The energy spectra of the registered photons for both detectors in three flow regimes are illustrated in Figure 1. homogeneous, stratified, and annular regimes were considered in the structure. Simulations were accomplished for void fractions ranging from 5% to 90% for all the aforementioned regimes. Gas oil and air were defined as the liquid and gas phases, respectively. It is worth noting that radiation-based multiphase flow meters are independent of the chemical characteristics of the materials inside the pipe that the radiation passes through. In other words, it makes no difference whether the radiation passes through a polymeric fluid, water, gas oil, or any other type of fluid. Therefore, instead of gas oil, which is used as an example liquid inside the pipe in this study, there could be a polymeric liquid, and the structure of the proposed measuring system would remain the same. A 137Cs radioactive source (emitter energy: 0.662 MeV) and two 25.4 mm NaI transmitted photon detectors were used to detect emitted photons. The detectors were positioned at a distance of 250 mm from the source at angles of 0 and 13 degrees. It is worth mentioning that the simulated structure used in this study was validated in several experiments in our previous research [4,10].
The energy spectra of the registered photons for both detectors in three flow regimes are illustrated in Figure 1.

Discrete Wavelet Transform
The wavelet decomposition tree is shown in Figure 2. The approximation signal in the initial stage was also divided into new approximation and detail components and the procedure was reiterated [25,26].

Discrete Wavelet Transform
The wavelet decomposition tree is shown in Figure 2. The approximation signal in the initial stage was also divided into new approximation and detail components and the procedure was reiterated [25,26].
There are many well-known wavelet families, such as Haar, Coiflet, Symmlet, and Daubechies wavelets [27], etc., which have a wide range of applications. There is no certain way to choose a specific wavelet family in research. The choice of wavelet functions depends on the application. One of the greatest advantages of the Haar wavelet algorithm is the fact that it is easy to compute and simple to understand [28]. There are many well-known wavelet families, such as Haar, Coiflet, Symmlet, and Daubechies wavelets [27], etc., which have a wide range of applications. There is no certain way to choose a specific wavelet family in research. The choice of wavelet functions depends on the application. One of the greatest advantages of the Haar wavelet algorithm is the fact that it is easy to compute and simple to understand [28].

Feature Extraction
Feature extraction is utilized for highlighting specific patterns, with the purpose of decreasing the substantial data loss. Classification and prediction can be carried out more accurately when the pattern is represented by the principal features of the signal. Feature engineering methods can be considered as a key element in classification and prediction problems [26].
In this study, at first the registered signals of both detectors were decomposed using a discrete wavelet transform (DWT). Following this, the approximation and detail components of the signals were calculated using the Haar wavelet family. Finally, the statistical features of the approximation signal were extracted [26] utilizing the average value (m), kurtosis (g), standard deviation ( σ ), and RMS. Formulations relating to these features are shown in Equations (1)-(4), respectively: The wavelet transform of the first detector's signal (annular) is shown in Figure 3.

Feature Extraction
Feature extraction is utilized for highlighting specific patterns, with the purpose of decreasing the substantial data loss. Classification and prediction can be carried out more accurately when the pattern is represented by the principal features of the signal. Feature engineering methods can be considered as a key element in classification and prediction problems [26].
In this study, at first the registered signals of both detectors were decomposed using a discrete wavelet transform (DWT). Following this, the approximation and detail components of the signals were calculated using the Haar wavelet family. Finally, the statistical features of the approximation signal were extracted [26] utilizing the average value (m), kurtosis (g), standard deviation (σ), and RMS. Formulations relating to these features are shown in Equations (1)-(4), respectively: The wavelet transform of the first detector's signal (annular) is shown in Figure 3.

Extracting Same Features from Both Detectors
In the first case, the same features were extracted from the approximation signals of both detectors. In Figure 4, the diagram of the extracted features from the first detector versus the second detector is shown, illustrating the separation ability of each feature.
As a result of the overlap of the illustrated features in Figure 4, the flow regimes could not be classified using these features.

Extracting Same Features from Both Detectors
In the first case, the same features were extracted from the approximation signals of both detectors. In Figure 4, the diagram of the extracted features from the first detector versus the second detector is shown, illustrating the separation ability of each feature. As a result of the overlap of the illustrated features in Figure 4, the flow regimes could not be classified using these features.
It should be noted that the points illustrated in each graph are related to different void fraction percentages. It should be noted that the points illustrated in each graph are related to different void fraction percentages.

Extracting Different Features from Both Detectors
In this section, different features of the approximation signal were extracted from each detector. The diagram of the extracted features from the first detector versus the second detector is shown in Figure 5, illustrating the separation ability of each feature.

Feature Selection
Considering Figure 4, it is possible to recognize type of flow regime using three features (the standard deviation of the approximation signal of the first detector versus the kurtosis of the approximation signal of the second detector, the RMS of the approximation

Feature Selection
Considering Figure 4, it is possible to recognize type of flow regime using three features (the standard deviation of the approximation signal of the first detector versus the kurtosis of the approximation signal of the second detector, the RMS of the approximation signal of the first detector versus the kurtosis of the approximation signal of the second detector, and the average value of the approximation signal of the first detector versus the kurtosis of the approximation signal of the second detector). For investigating the separation ability of these three features, a novel parameter called the SA parameter, where SA stands for separation ability, was calculated as shown below. One of the three mentioned features is shown in Figure 6 for analyzing the operation of the SA parameter. The calculation methods for the SA parameter are shown in Figure 7 and Equations (5) to (8).
where D1, D2, and D3 in the equations are the average distances between the annularhomogeneous, annular-stratified, and homogeneous-stratified regimes, respectively. stands for separation ability, was calculated as shown below. One of the three mentioned features is shown in Figure 6 for analyzing the operation of the SA parameter. The calculation methods for the SA parameter are shown in Figure 7 and Equations (5) to (8).   Average value of 1 st Detector Figure 6. One of the features with separated graphs.  Figure 7. The calculation method for the SA parameter.
Where D1, D2, and D3 in the equations are the average distances between the annularhomogeneous, annular-stratified, and homogeneous-stratified regimes, respectively. SA stands for separation ability. By calculating the SA parameter for all three separated cases, the average value of the approximation signal of the first detector and the kurtosis of the approximation signal of the second detector can be recognized as the features that are able to classify the three flow regimes, and can be applied as inputs to the ANN, aiming to enable flow regime classification and void fraction measurement.
In this study, two different networks were utilized for recognizing the three flow regimes and measuring the void fraction percentages. The average value of the approximation signal of the first detector and the kurtosis of the approximation signal of the second detector were used as the inputs for both networks. A total of 54 different cases in three different regimes were simulated using MCNPX code. A dataset containing 39 cases (about 70%) was used for training the network and a dataset of 15 cases (about 30%) was used for evaluating the network.
Several networks with different parameters were analyzed, which led to finding the optimized network. The network characteristics and the diagram of the optimized network for regime classification are shown in Table 1 and Figure 8, respectively.  The performance of the obtained neural network for classifying the flow regimes is shown in Figure 9. The performance of the obtained neural network for classifying the flow regimes is shown in Figure 9.  According to the presented results ( Figure 9), with the aid of the proposed techniques, all the considered regimes were identified correctly.
In the second network, the same inputs were applied to the ANN, and the output of the network was the percentage void fraction. The characteristics of the neural network utilized to predict the void fraction are shown in Table 2 and Figure 10.  According to the presented results ( Figure 9), with the aid of the proposed techniques, all the considered regimes were identified correctly.
In the second network, the same inputs were applied to the ANN, and the output of the network was the percentage void fraction. The characteristics of the neural network utilized to predict the void fraction are shown in Table 2 and Figure 10.  The performance of the implemented network for determining the void fractions of the training and testing datasets is illustrated in Figures 11 and 12, respectively.   The performance of the implemented network for determining the void fractions of the training and testing datasets is illustrated in Figures 11 and 12, respectively.  The performance of the implemented network for determining the void fractions of the training and testing datasets is illustrated in Figures 11 and 12, respectively.     The performance of the implemented network for determining the void fractions of the training and testing datasets is illustrated in Figures 11 and 12, respectively.   The obtained errors of the proposed artificial neural network model are shown in Table 3, where the MRE% and RMSE values were calculated using Equations (9) and (10), respectively.
Polymers 2021, 13, 3647 (10) where N, X (Sim) and X (Pred) stand for the number of data points and the simulated and predicted values of the neural network, respectively. The low error for the testing set validates the presented model and also shows that overfitting has not occurred.  Table 4 shows a comparison between this study and other relevant studies in this field. Table 4. Comparison between current study and previous research.

Refs Predicted Volume Fractions (RMSE)
[10] 2.12 [14] 5.32 [101] 6.12 Current study 1.92 Measuring volumetric percentages is a matter of key importance in many industries. Dozens of investigations have been carried out in this field to accomplish this task more accurately and decrease the rate of errors. According to the information shown in Table 4, the current study shows better performance and a lower rate of errors. The three studies mentioned adopted time-domain as well as statistical features to calculate volumetric percentages. In this study, by utilizing wavelet feature extraction, all the flow regimes were classified correctly, and the calculated void fraction percentages had notably lower error rates in comparison with the previous studies.
The simulated and predicted values of the implemented network for void fraction percentages can be found in Table 5.

Conclusions
To conclude, three conventional flow regimes were simulated using MCNP code. The output signals of both transmitted photon detectors were decomposed using a discrete wavelet transform. Several statistical features were extracted from the approximation signals of both detectors. All these features were analyzed in order to find the best features with the highest ability to classify the relevant flow regimes, for use as the inputs to the networks. The average value of the approximation signal of the first detector and the kurtosis of the approximation signal of the second detector were found to be the features with the best separation ability. One ANN was used for classifying the three flow regimes and another ANN was employed for predicting the void fraction percentages. The low error rates of the presented ANNs demonstrate the precision and correctness of the presented models.
It should be noted that in the current research, using the described methods, all the flow regimes were identified correctly, and the volume fraction percentages were determined with an RMSE of less than 1.93, which is about three times better than in previous work [4].