Introduction

Gas viscosity is an essential physical property to predict future reservoir performance, the initial gas in place, optimal production schemes, and material balance calculations. Estimation of gas viscosity accurately is a great importance. The gas viscosity is a strong function of the pressure, temperature, gas gravity, gas composition, gas density and nonhydrocarbon components. It is commonly estimated by either experimental laboratory measurements or published gas models when the measured data are not available.

Most correlations of gas viscosity require additional tuning to provide acceptable predictions for a given reservoir fluid. Before recalibrating these correlations, data must be quality controlled to ensure suitable performance of regression procedures.

(Dempsey 1965) proposed a new gas viscosity correlation using (Carr et al. 1954) data points. (Lee et al. 1996) developed a gas viscosity model using these independent variables which comprise gas density, temperature, and gas molecular weight. He noticed that the correlation does not perform well in either sour gases or gas has higher specific gravity. (Vesovic 2001) used four models to evaluate the gas viscosity of natural gas using 111 experimental data points. (Schley et al. 2004) proposed model to estimate the gas viscosity using 448 data points with accuracy around 0.3 and 0.5%. (Londono et al. 2005) presented a new model for gas viscosity at 1 atmosphere using 4909 experimental data sets. He found that the average absolute error of this model is 4.91%. (Elsharkawy 2006) used 2400 experimental data points to modify the Lee correlation. This approach leads to increase accuracy the average relative error to 1.9 and standard deviation to 16.8. (Viswanathan 2007) adjusted Lee correlation coefficients and the results showed the new correlation has a good performance with the same data as to compare to the Lee correlation. (Sutton 2007) used around 588 to develop a new gas viscosity correlation at standard conditions by combining Lucas equation with LGE model. He found the absolute percent relative error of the model was 4.2%. (Ohirhian and Abu 2009) developed the gas viscosity correlation using experimental data from Nigeria. (Davani et al. 2009) evaluated some existing gas viscosity model and found that gas viscosity models are not reliable at high pressure and temperature condition. (Sanjari et al. 2011) established a new model to predict the gas viscosity at low temperature and pressure, using 4089 experimental data points. (Al-Nasser et al. 2012) proposed a new model to estimate gas viscosity with high accuracy using around of 5600 data points collected from the Saudi Arabia. (Heidaryan et al. 2013) proposed a new correlation to estimate gas viscosity in a wide range, using 3255 experimental data points for 25 different gas mixtures. He reported that the model achieved the average absolute error around 3.03%. (Anyiador et al. 2015) used 319 data from the Niger Delta to evaluated natural gas viscosity. He found that Dempsey correlation achieve the best one.

(Azad et al. 2015) presented a model to predict a gas viscosity in a wide range of temperatures, pressures and compositions. They found that their new proposed model performed well with the absolute relative error of 2.4%. (Xiaohong et al. 2017) presented a new gas viscosity model using 1539 measured data points from Chinese oil fields. The proposed model performed well with the relative error (Yang and Zhu 2021)was less than 1.9%. (Azubuike et al. 2019) proposed accurate model to estimate gas viscosity at high temperature and pressure. The authors collected 483 data points from the Niger Delta part in Nigeria. (Yang and Zhu 2021) collected 1669 experimental databases from Chinese oil fields to develop a new gas viscosity. (Seyedeh et al. 2020) applied machine learning to identify reservoir models from pressure derivative curves derived from horizontal wells. (Farshadet al. 2020) proposed ANN model to define the whole system by taking into account the effect of several parameters. (Saleh and Behzad 2020) used six intelligent connectionist approaches to determine the methanol loss during its recovery in a three-phase separator. (Menad et al. 2021a, b) used three types of neural network to estimate he solubility of N2O in various ionic Liquids. (Cuthbert et al. 2022) applied robust machine learning (ML) to predict interfacial tension. (Menad et al. 2021a, b, 2022) used intelligent paradigms to find the suitable design parameters of a water alternating gas project and to predict CO2 uptake in in metal–organic frameworks respectively. Tamer et al. 2023) used machine learning algorithms to determine the heat output and total weight values of panel radiators.

Recently, there are many artificial neural networks (ANN) techniques were proposed to predict gas viscosity presented in literature (Alquraishi 2011; Baniasadi and Khamehchi 2014; Lay et al. 2012; Sanaei et al. 2015). In additional, (Deumah et al. 2021; Fayazi et al. 2014; Liu et al. 2021; Rostami and Shamshirband 2018; Yousefi et al. 2014) and Yingxian et al. 2021) applied a machine learning model to estimate the gas viscosity.

According to the previous literature, there are a lot of empirical correlations to predict gas viscosity but artificial intelligent techniques are few. Also, the most empirical models require additional tuning to provide suitable estimations for gas viscosity. Therefore, this research is focused on developing the most accurate technique to predict gas viscosity either by using both the ANN algorithm and applying the hybrid PSONN model. Consequently, the large data were collected from Yemeni gas fields and the others were chosen carefully from published papers in order to extend the data range and to achieve this work.

Methodology

Particle swarm optimization

Particle swarm optimization (PSO) is an optimization technique based on the movement and intelligence of swarms was developed by (Eberhart and Kennedy 1995). Figure 1 describes the particle flying model. Each bird called as particle. PSO uses to search for the optimal solution by simulate the bird's movement. For more details about particle swarm optimization model, see (Al-Gathe et al. 2019; Eberhart and Kennedy 1995).

Fig. 1
figure 1

Particle flying model

Hybrid PSONN model development

ANN has outstanding features in handling nonlinear problem and achieves a high degree of prediction accuracy. Despite the improvement in ANN and a wide range of applications, but the algorithm itself has also an unavoidable weakness. The main difficulties of ANN are the local minimum point, slow convergence and the difficulty to determine hidden layer nodes and number of hidden layers.

According to these difficulties, the PSO is a global searching that has the fast convergence and ability to avoid the local minimum point. In additional, the PSO algorithm was also used to optimize the weights of ANN algorithm in order to avoid the determination of the hidden layer nodes and the number of hidden layers.

So, in this work, it is essentially to merge the PSOwith ANNalgorithm to achieve faster convergent speed around a global search. Therefore, combined PSOand ANN can achieve higher convergent accuracy. Moreover, merging ANN with PSO can overcome the weakness of each algorithm. This combining called PSONN algorithm.

The PSONN model works into two ways. First, the PSO algorithm is used to find the optimal weights of the network and then the ANN algorithm is applied for learning rule and adjusts the final weights. Finally, the iterative method of the PSONN model is represented in Fig. 2. For more details about PSONN model and their description is discussed in (Abedelrigeeb et al. 2021)

Fig. 2
figure 2

The iterative method of the PSONN model

Data gathering

In order to succeed this work, a large number of experimental measurements data of natural gases has been used to predict gas viscosity. The data include around 580 data points that collected from different Yemeni gas fields. In order to develop an appropriate model in a wide data range, 288 published data points were chosen carefully from three main sources (Carr et al. 1954; Lee et al. 1996; Vesovic 2001). Therefore, the proposed model can be run for a wider input data range in more reliable and efficient.

For each gas composition, the data comprise experimentally measured gas viscosity, specific gas gravity, temperature, pressure, molecular weight, pseudo-critical temperature and pressure. It also includes the amount of non-hydrocarbon components (H2S, CO2, and N2). Table 1 shows the complete description of input/output data ranges.

Table 1 Summary of the data ranges of each parameter

The criteria used in this study were average percent relative error, average absolute percent relative error the correlation coefficient (R2), (APRE) and absolute percent relative error, and the root mean square error (RMSE) as the following:

$${R}^{2}=\sqrt{\left(1-\frac{\sum_{i=1}^{{n}_{d}}{{\left({x}_{\mathrm{exp}}-{x}_{est}\right)}_{i}}^{2}}{\sum_{i=1}^{{n}_{d}}{{\left({x}_{\mathrm{exp}}-\overline{x }\right)}_{i}}^{2}}\right)}$$
(1)

where

$$\overline{x }=\frac{\sum_{i=1}^{{n}_{d}}{\left({x}_{\mathrm{exp}}\right)}_{i}}{{n}_{d}}$$
$$APRE=\frac{\sum abs\left[\frac{{X}_{\mathrm{exp}}-{X}_{est}}{{X}_{\mathrm{exp}}}\right]*100}{{n}_{d}}$$
(2)
$$RMSE=\sqrt{\frac{{\left({X}_{exp}-{X}_{est}\right)}^{2}}{{n}_{d}}}$$
(3)

where

x exp:

represent the experimental values.

x est:

represent the estimated values.

n d:

number of data.

Activation function

The selection of activation function depends on the research goals. Root Mean Squared Error (RMSE) is used here as a activation function. Optimization activation function is important to ensure that RMSE or learning error is getting lesser with the increase of number iterations. The feed-forward neural network with one hidden layer structure was developed.

Results and discussion

In this research, seven of existed empirical correlations of gas viscosity are applied. The results of these models are shown in Fig. 3 and Table 2. From these results, we found the Londono model achieved the best one with APRE and RMS equal to 10.74 and 21.11 respectively.

Fig. 3
figure 3

APRE and RMSE of empirical approaches

Table 2 Summary the statistical error analysis of all models

The ANN model was established in this research to improve the prediction of the gas viscosity. The data was classified into three groups: 70% for training, 15% for validating and 15% for testing. The neural network illustrates in Fig. 4. The Neural Network Regression results are shown in Fig. 5. Figure 6 shows the neural network training performance stopped at epochs 6 before overfitting was done.

Fig. 4
figure 4

Displays the neural network structure

Fig. 5
figure 5

Depicts the best global index of PSO algorithm

Fig. 6
figure 6

Shows APRE and RMS Error

Figure 5 shows the Neural Network Regression.

Figure 6 shows the Neural Network Training Performance.

The hybrid PSONN model was developed in this research to predict the gas viscosity by using 868 data sets. The Particle Swarm Optimization (PSO) algorithm has different control parameters as shown in Table 3. These parameters are tuned to find the optimal connection weighs and thresholds for the neural networks (NN). then the back-propagation learning rule and training algorithm is used to adjust the final weights. The best configuration for hybrid PSONN approach is described in Table 4.

Table 3 Depicts the control parameters of PSO model
Table 4 Shows optimal configuration for PSONN model

Number of dimension in above model is depending to number of weight and bias that obtained by the following equation (Al-Gathe et al. 2019):

$$\begin{array}{c}Dimension=(input\ast hidden\;input)+(hidden\ast\;output\;hidden)\\+{hidden}_{bias}+{output}_{bias}\end{array}$$

Figure 5 depicts the best global index performance of PSO algorithm for gas viscosity estimation.

The PSONN technique was evaluated together with ANN model and published correlations to check their performance and accuracy for determining the gas viscosity. The statistical results of the error analysis for all models are presented in Table 5. Table 5 and Fig. 6 show the hybrid approach achieved the best performance comparing with other empirical correlations and ANN approach as well. The result of proposed PSONN model predicted the gas viscosity in higher accuracy with APRE equal to 2.76 and correlation factor 0.997. Figure 7 also illustrates the cross-plot of PSONN approach that showing a good agreement between actual and predicted gas viscosity.

Table 5 Summary of the statistical error analysis for all models
Fig. 7
figure 7

Shows the cross-plot of PSONN model

Conclusions

From the results of ANN and hybrid approaches, the following conclusion points can be drawn.

  1. 1.

    The ANN approach improved the gas viscosity accuracy by decreasing the APRE error to 5.9.

  2. 2.

    The proposed hybrid PSONN model displayed the best performance with the lowest APRE errors (2.76) and the highest correlation Factor (0.997).

  3. 3.

    Error of gas viscosity models increases on going from the hybrid to ANN and empirical correlations.

  4. 4.

    Both approaches cover a wide data range of specific gas gravity from 0.55 to 2.1.

  5. 5.

    It is reported that the hybrid approach is powerful tools to overcome vagueness existent in estimation of gas viscosity.