Accurate Flow Regime Classiﬁcation and Void Fraction Measurement in Two-Phase Flowmeters Using Frequency-Domain Feature Extraction and Neural Networks

: Two-phase ﬂow is very important in many areas of science, engineering, and industry. Two-phase ﬂow comprising gas and liquid phases is a common occurrence in oil and gas related industries. This study considers three ﬂow regimes, including homogeneous, annular, and stratiﬁed regimes ranging from 5–90% of void fractions simulated via the Mont Carlo N-Particle (MCNP) Code. In the proposed model, two NaI detectors were used for recording the emitted photons of a cesium 137 source that pass through the pipe. Following that, fast Fourier transform (FFT), which aims to transfer recorded signals to frequency domain, was adopted. By analyzing signals in the frequency domain, it is possible to extract some hidden features that are not visible in the time domain analysis. Four distinctive features of registered signals, including average value, the amplitude of dominant frequency, standard deviation (STD), and skewness were extracted. These features were compared to each other to determine the best feature that can offer the best separation. Furthermore, artiﬁcial neural network (ANN) was utilized to increase the efﬁciency of two-phase ﬂowmeters. Additionally, two multi-layer perceptron (MLP) neural networks were adopted for classifying the considered regimes and estimating the volumetric percentages. Applying the proposed model, the outlined ﬂow regimes were accurately classiﬁed, resulting in volumetric percentages with a low root mean square error (RMSE) of 1.1%. writing—original draft preparation, S.H., A.M.I. and E.E.-Z.; writing—review and editing, S.H., K.H., A.M.I. and T.A.; investigation, S.H., K.H., A.M.I. and A.S.S.; visualization, S.H. and E.E.-Z.; supervision, T.A. and A.M.I.; resources, A.M.I. and E.E.-Z.; validation, A.S.S.;


Introduction
Nowadays, analyzing the flow regimes and volumetric percentages of multiphase flows is a significant and notable topic in many industries [1][2][3]. Liquids and gases are the most important elements in oil and gas storage. For better comprehension as to whether the drilling process is sensible or not, it is essential to measure each parameter [4]. Also, the separation procedure will be better developed, with adequate information about regime the separation procedure will be better developed, with adequate information about regime types and volumes of each phase. In this regard, different methods have been studied for determining the mentioned parameters. According to former studies, gamma-ray attenuation technique was the most accurate method [1]. Abro and his colleagues investigated the efficiency of single-and multi-beam gamma-ray densitometry to estimate the volumetric percentages in two-phase flows consisting of gases and liquids [5]. According to their acquired results, the multi-beam gamma ray method was more accurate than the single-beam technique. Jing and co-workers investigated dual modality densitometry to classify the flow regimes in a vertical pipe [6]. In 2014, three flow regimes (see in Figure 1) (homogeneous, annular, and stratified) were simulated via MCNP code [4]. One 137 Cs source, one transmitted, and scattered detector were utilized as the proposed structure. For classifying the flow regimes and predicting volumetric percentages, three attributes of signals were extracted and used as the ANN inputs. Faghihi et al. studied stratified, homogeneous, and annular regimes in a pipe with vertical position for 3 different flow regimes [7]. Nazemi et al. investigated the gamma-ray attenuation technique in annular, bubbly, and stratified flow regimes in a two-phase flow structure. In this article, volume fraction was determined independent of regime type [8]. Two transmitted detectors were applied for registering the transmitted photons. In this situation, void fraction percentages were calculated using the MLP neural network. Nazemi et al. improved the accuracy of estimation by applying two features of registered signals in a Radial Basis Function (RBF) neural network for determining void fraction. By using the proposed method, the percentages of volume fraction were determined to be autonomous of density alterations in the liquid phase of the stratified regime [9]. Utilizing fewer detectors in structure is a matter of key importance in industries; not only does it lessen expenditures, but it also makes it easier to work with these systems. Roshani and co-workers analyzed a simple setup with single NaI detector, as well as a Co 60 source, but they found that it was impossible to classify all the flow regimes using one detector in the structure, and only two of the regimes were identified [2]. Different features in the frequency domain were presented by Hanus and co-workers in order to identify the flow regimes in a dynamic condition [10]. In this work, three various structures of two-phase flows (air-water), including plug flow, bubble flow, and transitional plug-bubble flow were studied. Salgado et al. have several works which aimed to distinguish flow regimes and determine void fraction using ANNs [11][12][13][14]. Sattari et al. carried out research work by taking advantage of time-domain feature extraction for regime classification and void fraction prediction. By adopting timedomain techniques, volumetric percentages were estimated with an RMSE of 5.32 [15]. In recent years, many researchers have put a great deal of effort into oil and gas fields for flow regime identification and void fraction measurement by utilizing different methods such as GMDH and wavelet feature extraction [16][17][18].

Simulation Procedure
The data collection process in this work includes two separated stages. Firstly, three principal regimes, including homogeneous, annular, and stratified were simulated using MCNP code. Simulations were accomplished for 5-90% void fraction. Gasoil and air were considered as the liquid and gas phases, respectively. A 137 Cs source and two NaI detectors In recent years, many researchers have put a great deal of effort into oil and gas fields for flow regime identification and void fraction measurement by utilizing different methods such as GMDH and wavelet feature extraction [16][17][18].

Simulation Procedure
The data collection process in this work includes two separated stages. Firstly, three principal regimes, including homogeneous, annular, and stratified were simulated using MCNP code. Simulations were accomplished for 5-90% void fraction. Gasoil and air were considered as the liquid and gas phases, respectively. A 137 Cs source and two NaI detectors were utilized in order to register photons that passed through the pipe with an inner diameter of 95 mm and a thickness of 2.5 mm.
Secondly, for evaluating the accuracy of the simulated structure (see in Figure 2) in MCNP code, simulated geometry was assessed for validity with multiple experiments in previous work [1]. The comparison between experimental and simulated data in the annular regime for first and second transmission detectors is shown in Figure 3. The maximum Relative Difference (RD) between experimental data and simulation data is 2.9%, which shows the good agreement between experimental and simulation results. Different stages of this work can be found in Figure 4. were utilized in order to register photons that passed through the pipe with an inner diameter of 95 mm and a thickness of 2.5 mm. Secondly, for evaluating the accuracy of the simulated structure (see in Figure 2) in MCNP code, simulated geometry was assessed for validity with multiple experiments in previous work [1]. The comparison between experimental and simulated data in the annular regime for first and second transmission detectors is shown in Figure 3. The maximum Relative Difference (RD) between experimental data and simulation data is 2.9%, which shows the good agreement between experimental and simulation results. Different stages of this work can be found in Figure 4.       were utilized in order to register photons that passed through the pipe with an inner diameter of 95 mm and a thickness of 2.5 mm. Secondly, for evaluating the accuracy of the simulated structure (see in Figure 2) in MCNP code, simulated geometry was assessed for validity with multiple experiments in previous work [1]. The comparison between experimental and simulated data in the annular regime for first and second transmission detectors is shown in Figure 3. The maximum Relative Difference (RD) between experimental data and simulation data is 2.9%, which shows the good agreement between experimental and simulation results. Different stages of this work can be found in Figure 4.

Stage 1: Data Collection
Three different flow regimes including Annular ,Stratified and Homogeneous were simulated using MCNP code and also validated with experimental data sets.

Stage 2: Feature extraction
Fast Fourier transform was used to transfer registered data into frequency domain . Then , four features comprising the average value , the amplitude of dominant frequency , standard deviation and skewness were extracted from the registered signals.

Stage 3: Feature selection
Extracted features were compared to each other to find the best one with the best separation ability .In this case ,all of the features were analyzed .Finally ,standard deviation that has no overlap in its diagram was selected to accomplish feature selection task.

Stage 4: Training custom built neural
network Two exclusive networks were implemented for classification and regression. The classifier aims to classify three different classes of regimes , including Annular , Stratified and Homogeneous and the regressor is responsible for predicting the volumetric percentages.

Regression Classification
Void fraction

Feature Extraction
Registered photon energy spectra for the 3 flow regimes (void fraction = 5%) are shown in Figure 5.

Feature Extraction
Registered photon energy spectra for the 3 flow regimes (void fraction = 5%) are shown in Figure 5. Stage 1: Data Collection Three different flow regimes including Annular ,Stratified and Homogeneous were simulated using MCNP code and also validated with experimental data sets.

Stage 2: Feature extraction
Fast Fourier transform was used to transfer registered data into frequency domain . Then , four features comprising the average value , the amplitude of dominant frequency , standard deviation and skewness were extracted from the registered signals.

Stage 3: Feature selection
Extracted features were compared to each other to find the best one with the best separation ability .In this case ,all of the features were analyzed .Finally ,standard deviation that has no overlap in its diagram was selected to accomplish feature selection task.

Stage 4: Training custom built neural
network Two exclusive networks were implemented for classification and regression. The classifier aims to classify three different classes of regimes , including Annular , Stratified and Homogeneous and the regressor is responsible for predicting the volumetric percentages.

Regression Classification
Void fraction

Feature Extraction
Registered photon energy spectra for the 3 flow regimes (void fraction = 5%) are shown in Figure 5.  Registered photons(per source particle) Registered photons(per source particle) Registered photons(per source particle) In this study, after transforming recorded signals into frequency domain via fast Fourier transform, several features were extracted. Adopted features are as follows: average, the amplitude of dominant frequency, standard deviation (STD), and skewness. These are the foremost features in the feature extraction field, which have been used in dozens of studies [19].
The average value, standard deviation, and skewness are shown in Equations (1)-(3), respectively: The signal output of the first detector in the frequency domain for annular regime (void = 5%) is shown in Figure 6. In this study, after transforming recorded signals into frequency domain via fast Fourier transform, several features were extracted. Adopted features are as follows: average, the amplitude of dominant frequency, standard deviation (STD), and skewness. These are the foremost features in the feature extraction field, which have been used in dozens of studies [19].
The average value, standard deviation, and skewness are shown in Equations (1) The signal output of the first detector in the frequency domain for annular regime (void = 5%) is shown in Figure 6. As observed in Figure 7, in all the three flow regimes there is a definite link between the air percentages in the pipe and the amplitude of dominant frequency. As observed in Figure 7, in all the three flow regimes there is a definite link between the air percentages in the pipe and the amplitude of dominant frequency.
The diagram of extracted features in the first detector versus the second detector are shown in Figure 8, which shows the ability of separation for every feature.
As shown in Figure 8, the classification procedure of flow regimes is possible only with one feature (standard deviation), and the three other extracted features are not capable of classifying the mentioned flow regimes due to overlap in their diagrams. According to the obtained results, it can be concluded that the standard deviation is the best feature. Also, the indicated points in each graph show the different void fraction percentages. Separations 2022, 9, x FOR PEER REVIEW 6 of 15   The diagram of extracted features in the first detector versus the second detector are shown in Figure 8, which shows the ability of separation for every feature.
As shown in Figure 8, the classification procedure of flow regimes is possible only with one feature (standard deviation), and the three other extracted features are not capable of classifying the mentioned flow regimes due to overlap in their diagrams. According to the obtained results, it can be concluded that the standard deviation is the best feature. Also, the indicated points in each graph show the different void fraction percentages.
In this research, two exclusive networks were adopted for classifying the considered flow regimes and predicting volumetric percentages. Standard deviation of both detectors' frequency spectra was utilized as the implemented ANN inputs, and the output was selected as the flow regime. Numerous ANNs with multiple numbers of neurons and hidden layers were tested and, ultimately, the optimal network was obtained. Figure 9 shows the flowchart of the proposed network to achieve an optimum network with the minimum error ratio.  Figure 9. A flowchart for implementing the proposed model.
The parameters and architecture of the obtained network for regime classification are indicated in Table 1 and Figure 10, respectively.  The parameters and architecture of the obtained network for regime classification are indicated in Table 1 and Figure 10, respectively. The performance of the employed network for the training and testing processes for regime classification are illustrated in Figure 11. The performance of the employed network for the training and testing processes for regime classification are illustrated in Figure 11. As indicated in Figure 11, in terms of the presented technique, the three flow regimes were classified accurately. The dataset was divided into 70% (39 data samples) and 30% (15 data samples) for model training and testing, respectively.  Figure 11. The performance of implemented ANN for regime classification (training and testing data samples). Figure 11, in terms of the presented technique, the three flow regimes were classified accurately. The dataset was divided into 70% (39 data samples) and 30% (15 data samples) for model training and testing, respectively.

As indicated in
The optimum network characteristics and architecture which were employed for void fraction measurement are demonstrated in Table 2 and Figure 12.  Figure 12. The architecture of the adopted network for void fraction prediction.
The network performances for void fraction measurement for training and testing data samples are indicated in Figures 13 and 14, respectively. The optimum network characteristics and architecture which were employed for void fraction measurement are demonstrated in Table 2 and Figure 12.  Figure 11. The performance of implemented ANN for regime classification (training and testing data samples). Figure 11, in terms of the presented technique, the three flow regimes were classified accurately. The dataset was divided into 70% (39 data samples) and 30% (15 data samples) for model training and testing, respectively.

As indicated in
The optimum network characteristics and architecture which were employed for void fraction measurement are demonstrated in Table 2 and Figure 12.  Figure 12. The architecture of the adopted network for void fraction prediction.
The network performances for void fraction measurement for training and testing data samples are indicated in Figures 13 and 14, respectively.  The network performances for void fraction measurement for training and testing data samples are indicated in Figures 13 and 14, respectively.  To evaluate the Adopted ANN, the root mean square error percentage (RMSE %) and coefficient of determination (R-squared) were computed by Equations (4) and (5), respectively. The errors achieved are indicated in Table 3.  To evaluate the Adopted ANN, the root mean square error percentage (RMSE %) and coefficient of determination (R-squared) were computed by Equations (4) and (5), respectively. The errors achieved are indicated in Table 3. To evaluate the Adopted ANN, the root mean square error percentage (RMSE %) and coefficient of determination (R-squared) were computed by Equations (4) and (5), respectively. The errors achieved are indicated in Table 3. where N is the number of data, X (sim) and X (pred) stands for simulated and predicted values by neural network, respectively. A comparison between this study and several research items in this field can be found in Table 4. Comparisons of simulated and estimated volumetric percentages by ANN for training and testing data sets are indicated in Tables 5 and 6, respectively.

Conclusions
This study proposed the use of fast Fourier transform (FFT) to transform and analyze the frequency domain signals of three flow regimes simulated using MCNP code. The same attributes were extracted in the frequency domain and the standard deviation was recognized as the best feature for determining the flow regimes. Furthermore, two specific neural networks were employed for regime classification and void fraction measurement. Moreover, by using the feature extraction technique and applying neural networks, flow regimes were accurately classified, leading to void fraction percentages with a low root mean square error of 1.1%, which is indicative of the utility of the proposed model.