Introduction

The value of the production rates of the flowing oil and gas well in Middle Eastern counties is essential for economic revenue. However, there is not enough research being done to vindicate the validity of the current models. Numerical correlations impede the ability for predicting choke size accurately that controls the production rate. Artificial Intelligence (AI) can be used to address this problem.

In the wellhead assembly component, the wellhead choke that is used to control the flow of oil and gas can be either adjustable or positive. Because these two types of chokes are essential for controlling the flow in pipelines, we will be focusing on the adjustable choke as it can turn the flow on and off, whereas the positive choke is fixed and cannot, therefore, control the quantity of oil and gas being produced. Adjustable chokes can be used in the well completion process, which help to control the flow while cleaning or testing the oil and gas well. During this process, an optimum flow rate can be achieved, and so we can change from adjustable to a positive choke before production.

Since the estimation of multiphase flow is crucial to Middle East economic production, many numerical correlations were developed to optimize the choke size. There are two types of multiphase flow: critical and subcritical. Critical flow occurs when the fluid velocity is equal to or higher than the velocity of sound in that fluid, whereas subcritical is less than the sound velocity in that fluid. The focus of this study will be on subcritical flow as it has gotten less attention on research compared to sonic flow.

To have a vital rate, downstream pressure should be about 0.55 of the upstream pressure. In such a situation, the flow rate depends on the upstream pressure and gas oil ratio (GOR) only; therefore, the change in the downstream pressure does not influence the flow rate. Damage of surface facilities may occur if the choke breakdown or malfunctioning due to the prevention of the smooth transitions between downstream and upstream pressure. For this reason, the correct design of the production well will lead to the accurate prediction of the flow behavior of multiphase mixtures through chokes. Modern techniques, as well as AI, are also used in the design operations over the entire production system. This process demands accurate models that can describe the performance of each element in the system.

Many studies (Elhaj et al. 2015, 2017; AlAjmi et al. 2015) proved that the AI gave more accurate results compared to the numerical correlations when it comes to the choke size prediction.

Four techniques of AI will be used to increase the accuracy of the prediction of the choke size. These techniques are: artificial neural networks (ANN), fuzzy logic (FL), support vector machines (SVM), and functional networks (FN). Each technique will be discussed in detail in the following paragraphs to determine which technique has the best accuracy for optimizing choke size.

Literature review

As numerical correlations are usually used to examine choke size, the types of multiphase flow chokes will be outlined in this research. There are two types of two-phase flow: critical and subcritical. The developed model for critical flow has gotten most of the attention of researchers compared to subcritical flow, according to the literature. These models were created with inspiration from the Gilbert-type empirical relationship (Gilbert 1954). Several researchers revised and developed Gilbert’s model during the decades, such as Ros, Baxendell, Achong, Pilehvari, Secen, and Osman and Dokla (Sachdeva et al. 1986; Osman and Dokla 1990; Omana et al. 1969a, b; Ros 1960; Abdul-Majeed and Maha 1991; Pilehvari 1981). Most of these models have a linear relationship between the flow rate the upstream pressure.

Another type of correlations of a four-parameter equation was presented by other investigators (Surbey et al. 1989; Al-Attar 2008). These investigators considered a nonlinear relationship between the flow rate and the wellhead pressure (Al-Towailib and Al-Marhoun 1994; Al-Attar and Abdul-Majeed 1988; Al-Towailib and Al-Marhoun 1992; Hosmer et al. 2013; Salah and Rahman 2005). Surbey et al. (1989) developed a four-parameter equation for critical two-phase flow through multi-orifice-valve chokes. They stated that this equation is probably restricted to this type of chokes only. However, Al-Towailib and Al-Marhoun (1992, 1994) obtained consistent results when they applied this equation for Middle East data. Al-Attar and Abdul-Majeed (1988) proposed a similar correlation for East-Baghdad oil wells.

Recently, AI has been successfully applied in many applications in oil businesses. A range of analysis has been disbursed on the utilization of varied computational intelligence (CI) schemes to estimate the two-phase flow through reservoirs and pipes. Many researchers used these schemes in oil and gas industry, such as logistic regression (LR), K-nearest neighbor (KNN), multilayer perceptrons (MLP), radial basis function (RBF), Bayesian belief networks (BBN), Naïve Bayes (NB), random forests (RF), functional networks (FunNets), support vector machines (SVM), artificial neural networks (ANN), probabilistic networks (PN), adaptive-neuro fuzzy systems (ANFIS) and decision trees (DT) (Hosmer et al. 2013; Salah and Rahman 2005; Duch et al. 1997; Guojie 2004; Lauría and Duchessi 2006).

Although both AI and CI seemed to be similar in trying to search for the same goal, CI deals with fixing issues in which effective computational algorithms are not available. In other words, CI is a branch of AI and every CI process is an AI process, but not the reverse. However, some areas and application can be done by both techniques, such as pattern recognition, image analysis, and operations research. CI is based only on soft computing techniques, while AI uses hard computing technique. The only problem when using the hard computing technique is that human language cannot always be translated to binary logic, which is based on only two values (0 and 1). Therefore, using techniques based on fuzzy logic is essential when dealing with this situation. CI relies on different logic algorithms such as fuzzy systems, neural networks, support vector machines, and evolutionary computation. In addition, CI also embraces techniques that use swarm intelligence, fractals and chaos theory, artificial immune systems, wavelets, etc.

For more than five decades, fuzzy sets (FS) are widely used in different sciences, especially in computer science, which is found to give more accurate estimation and simulation for a specific scenario compared to others. There are two types of these sets type 1 FS and type 2 FS, which is introduced by Zadeh (1965). The idea behind these sets is to represent uncertainty and vagueness mathematically in addition to give a tool for dealing with the imprecision. The FS consists of grades of membership; each member is a based on logic too (Karnik et al. 1999).

Support vector machines

SVMs are one of the AI techniques that can be used as a learning machine, and they applied for classification and regression. They can be classified under the linear classifiers. In addition, the use in the specific scenario of regression, such as the regularization of ill-posed problems (Tikhonov regularization), is also one of the usages of SVMs. SVM models can be represented by either data points or map. Each map constructs a hyperplane or a group of hyperplanes in a high or infinite dimension space. Two parallel hyperplanes are built on each side of the hyperplane that separates the data. The generalization error is directly proportional to the distance between those two parallel hyperplanes, which is assumed by Burges (1998).

Many applications of SVMs are applied in both engineering and science, such as defect prediction (Elish and Elish 2008), surface tension (Wang et al. 2007), geotechnical process (Goh and Goh 2007) and petroleum engineering (Hou and Wenfen 2006).

Functional networks

Functional networks are different than neural networks in many ways, for example, the functional networks do not have weights that related to neurons, and moreover, the neuron functions are adaptable, not steady like in neural networks. In these networks, a system of functional equations is obtained as a solution to a problem, in which this system has a smaller number of degrees of freedom compared to neural networks.

The concept behind the work of functional networks is by permitting the f functions learning, whereas weights are terminated. Moreover, these functions can be in multidimensional, even though these functions can be changed by the functions of single variables. The functional networks consist of four main elements (1) input units; (2) output units; (3) one or many layers of computing units; and (4) group of directed links.

A complete explanation of the applications of functional networks in both engineering and statistics are presented in the research done by Castillo et al. (2001). Unfortunately, it is scarce to find in the literature that functional networks have that much of application regarding petroleum engineering.

For two-phase flow through chokes prediction using AI, the only research was done by Al-Khalifa and Al-Marhoun (2013). He studied in his master thesis the application of neural network for two-phase flow through chokes. The study used 4031 data points collected from different wells in the Middle East. In his research, he developed an ANN model to predict the choke size utilizing a ratio of 80% for training and 10% for validation and 10% for testing for the data under study. A comparison was made between the results obtained by NN and the existing correlations. It was shown that the ANN gives better results among all the correlations and models.

Problem statement

Since the Multiphase flow prediction is highly crucial, as discussed in the introduction, the prediction should be accurate enough. The study of Al-Khalifa and Al-Marhoun (2013) used only a neural network (NN). In this investigation, several techniques of artificial intelligence will be used, and a comparison of the results obtained from the different procedure will be made.

Methodology

This section discusses how models were developed, the methodology, selecting the independent variable, model architecture, and optimization. Models developed based on these techniques used about 10,440 data points and a ratio of 70% for training, 15% for validation, and 15% for testing.

The artificial intelligence techniques used for prediction are:

  1. 1.

    Artificial neural networks (ANN) (Al-Khalifa and Al-Marhoun 2013)

  2. 2.

    Fuzzy logic (FL) (Castillo, et al. 2001)

    • Genetic algorithm (GA) as an optimization tool.

  3. 3.

    Support vector machines (SVM) (Hou and Wenfen 2006)

  4. 4.

    Functional networks (FN) (Hosmer et al. 2013)

The models built using the above techniques will be implemented using Matlab software. Statistical analysis will be carried out to compare between results obtained by the different techniques and methods.

Correlation coefficient

It measures the statistical correlation between the predicted and actual values. This method is unique in the sense that it does not change with a scale in values. A higher number means a better model, with a one indicating perfect statistical correlation and a zero meaning there is no correlation at all. This performance measure is only used for numerical input and output (Karnik et al. 1999).

$$\frac{{\sum \left( {x - x^{\prime}} \right)\left( {y - y^{\prime}} \right)}}{{\sqrt {\sum \left( {x - x^{\prime}} \right)^{2} \sum \left( {y - y^{\prime}} \right)^{2} } }}$$
(1)

Data collection

Data from several fields in the Middle East were collected to develop artificial intelligent models. A wide range of choke sizes and flow rates were covered in this study. The reported production test data includes: oil and gas flow rates, choke sizes, downstream and upstream wellhead tubing pressures, gas relative density and oil API. Mixture density, ɤm, was calculated as shown below and used as an input parameter. (AlAjmi et al. 2015).

$$\gamma_{m} = \gamma_{o} + 2.18 x 10^{ - 4} x \gamma_{g}$$
(2)

As the parameters setting play a vital role in the outcomes of the results, the same AI techniques were used in the gas reservoir using different setting with almost the same parameters to emphasize the effect on the findings. For more details, see (Elhaj et al. 2015, 2017).

Table 1 summarizes some statistical parameters for the input and output data (6960 data points).

Table 1 Input and output data statistical analysis

Relations between the input parameters and the output were studied to develop the AI models. Figure 1 shows a clear relationship between the choke size and the total flow rate and upstream pressure. On the other hand, there is no significant correlation between choke size, gas oil ratio and mixture relative density. Table 2 shows the correlation between the input parameters, the output, and the relationship between the parameters themselves, which can help in designing the models. Therefore, the dominant factor affecting the choke size is the flow rate rather than the upstream pressure. In Table 2, the negative sign indicates that the parameter is inversely proportional to the output. Table 3 Column (1) shows that taking the log value for all the parameters did not show any significant difference compared to the raw data. Similarly, the same conclusion was noticed when normalizing the data, as shown in Table 3 Column (2). A visual check of the relation between the choke size and the input parameters was performed by plotting the choke size versus flow rate (Fig. 1), gas oil ratio (Fig. 2), wellhead pressure (Fig. 3), and mixture relative density (Fig. 4).

Fig. 1
figure 1

Total flow rate versus choke size of the raw data

Table 2 Correlation between the input and the output parameters
Table 3 Correlation between the log and typical values of the input and the output parameters
Fig. 2
figure 2

Gas oil ratio versus choke size of the raw data

Fig. 3
figure 3

Wellhead pressure versus choke size of the raw data

Fig. 4
figure 4

Mixture relative density versus choke size of the raw data

Data screening

The primary purpose of this study is to develop different artificial intelligent models to be used in choke design; therefore, this research deals primarily with data under the critical flow pattern. Subcritical flow data were not included. The critical flow pattern occurs when the downstream tubing pressure is less than 55% of the upstream tubing pressure. The Bernoulli principals and gas law equations were used to select the independent variables for the critical flow. Outlier data were removed, and the raw data was used in this study.

Because the research covers wide data ranges and each input parameter has a different scale than the others, the data were normalized before feeding it into the network. Two methods of normalization were done.

The first method uses the following formula:

$$x_{\text{norm}} = \frac{{x_{i} - {\text{mean}}\left( {x_{i} } \right)}}{{{\text{STD}}\left( {x_{i} } \right)}}$$
(3)

The second method is the same as method one except that the mean was not deducted

$$x_{\text{norm}} = \frac{{x_{i} }}{{{\text{STD}}\left( {x_{i} } \right)}}$$
(4)

Tables 4 and 5 show a statistical analysis of both the input and output data after normalization and taking the logarithm, respectively.

Table 4 Statistical analysis of the data after normalization
Table 5 Statistical analysis of the log data (except mixture relative density, ɤm)

Results and discussion

Artificial neural network

The trial and error technique was used to estimate the number of neurons, layers, and type of function, which proves to be a successful technique when it comes to ANN modeling. Several functions were examined during the process of developing the model, and the log-sigmoid gave the best result among other functions. In contrast, cascade-forward was the best learning algorithm for the training data. During the process of running the model, some problems occurred due to the local minimum, which caused the training running to stop. To avoid this kind of issue from happening, the validation failure was increased to 300.

Two types of general layer feed were used in the ANN model: feed-forward (type 1) and cascade-forward (type 2). The main feature of these types is the internal feedback of information; one type shall not permit the internal feedback of information (type 1), while the other (type 2) enable this feedback. When it comes to dynamic models, type 2 is preferred. In this model, both types were tested and examined, but type 2 gave the best results and was recommended for this model. The following command and Fig. 5 illustrate the structure of the cascade-forward NN.

Fig. 5
figure 5

ANN structure

net=newcf (IPdata,TRGdata,[5,10,5],{‘logsig’,’purelin’},’trainlm’,’learngd’);

command (1)

In this study, more than one transfer functions were used for both the input and output data like log-sigmoid and purelin. Table 6 summarizes some of the results obtained from the different NN types and the learning techniques. Generally, cascade-forward NN type shows the best results achieved, so it is recommended.

Table 6 Results of type 1 and type 2 NN with different learning and transfer functions (newcf = cascade-forward)

Table 7 proves that three layers with different neurons (5, 10, 5) for cascade-forward NN type gave the best output.

Table 7 The effect of the neurons number combination for type 2 NN

Figures 6 and 7 show some of the results obtained from the ANN. The correlation coefficient (R) was 0.92, 0.79 and 0.82 for training, validation and testing, respectively. It was found to be 0.87 for the whole set of data, as shown in Fig. 6.

Fig. 6
figure 6

Correlation coefficient for the trained, the validated, the tested and all data

Fig. 7
figure 7

Correlation between the actual and the predicted choke size for both training and testing data

Fuzzy logic

Along with ANN, fuzzy logic (FL) is also used in this research. As it is known, FL has two types: grid partition and sub-clustering. The difference between these two types is that the grid partition takes a much longer time to accomplish a specific task compared to sub-clustering. Because of time constraints, sub-clustering was chosen to be used in this study. The range of influence (radii) was changed in the developing model to achieve a quicker and better result. Different radius ranges were used, and the range was between 0.01 and 0.2. Table 8 displays the influence of different radii. It was noticed while running the code for the training stage that the smaller the radii, the better the prediction was. For the testing stage, as the radius decreased, the error increased. Therefore, to avoid this kind of awkwardness, two techniques of optimization were used: trial and error and genetic algorithm. The optimum values for both mean square error (MSE) and the correlation coefficient were 0.145 and 0.01, respectively.

Table 8 Correlation coefficient for trained and tested data of FL model

Figures 8, 9 and 10 show the results obtained for both training and testing data for a radius of 0.1. Results illustrated that this radius of influence is good enough for training and testing. Results were estimated using a radius of 0.01. These results confirmed that the smaller the radius was, the better the results, as shown in Figs. 11, 12 and 13. A comparison of the results acquired with different radius values is organized in Table 8, and it is clear that the results that corresponded to a radius of 0.01 were the best.

Fig. 8
figure 8

Actual versus predicted choke size for FL model training (Radii = 0.1)

Fig. 9
figure 9

Actual versus predicted choke size for FL model testing (Radii = 0.1)

Fig. 10
figure 10

Correlation between the actual and the predicted choke size for both training and testing data (FL model for Radii = 0.1)

Fig. 11
figure 11

Actual versus predicted choke size for FL model training (Radii = 0.01)

Fig. 12
figure 12

Actual versus predicted choke size for FL model testing (Radii = 0.01)

Fig. 13
figure 13

Correlation between the actual and the predicted choke size for both training and testing data (FL model for Radii = 0.01)

Radial basis function

Another type of neural network used here is the radial basis function (RBF). Generalized regression neural network function (GRNN) with different spread values ranging from 0.01 to 0.1 was used. The optimum spread value was found to be 0.1, as illustrated in Figs. 14, 15 and 16. For the spread value of 0.01, the training prediction was perfect; however, when comparing the testing data, results were inaccurate, as shown in Figs. 17, 18 and 19. Table 9 concludes the results for various spread values. The two points that deviated from the trend line in Fig. 17 related to the actual data that were used in this study. In other words, the focus of this study was the prediction of choke size that can be estimated from the actual data, not the error that occurred in the actual data as in such case.

Fig. 14
figure 14

Actual versus predicted choke size for RBF model training (spread = 0.1)

Fig. 15
figure 15

Actual versus predicted choke size for RBF model testing (spread = 0.1)

Fig. 16
figure 16

Correlation between the actual and the predicted choke size for both training and testing data (RBF model for spread = 0.1)

Fig. 17
figure 17

Actual versus predicted choke size for RBF model training (spread = 0.01)

Fig. 18
figure 18

Actual versus predicted choke size for RBF model testing (spread = 0.01)

Fig. 19
figure 19

Correlation between the actual and the predicted choke size for both training and testing data (RBF model for spread = 0.01)

Table 9 Correlation coefficient for trained and tested data of RBF model

Support vector machines

Many different kernel functions are available in a support vector machine (SVM). In this study, a few of these functions were used, such as

kernel=‘poly’; %’gaussian’; ‘polyhomog’;’htrbf’;’rbf’;

command (2)

During the buildup of the SVM model, Poly and Gaussian predicted the best results among the others. Figures 20 and 21 show results achieved using a Poly function for both training and testing data with correlation coefficient 0.82 for training and 0.998 for testing. The Gaussian function results were not as good as the Poly function, as illustrated in Figs. 22 and 23.

Fig. 20
figure 20

Correlation between the actual and the predicted choke size for training data (Poly function) (R = 0.82)

Fig. 21
figure 21

Correlation between the actual and the predicted choke size for testing data (Poly function) (R = 0.998)

Fig. 22
figure 22

Correlation between the actual and the predicted choke size for training data (Gaussian function) (R = 0.75)

Fig. 23
figure 23

Correlation between the actual and the predicted choke size for testing data (Gaussian function) (R = 0.998)

Table 10 summarizes the results from the two techniques.

Table 10 Correlation coefficient for trained and tested data of SVM model

Functional network

Different percentages for training and testing were used in the functional network model, but the best results were 70% for the training and 30%. Both results for training and testing gave the same values of R-square when using this percentage combination as can be seen in Figs. 24 and 25.

Fig. 24
figure 24

Correlation between the actual and the predicted choke size for training data (FN) (R = 0.81)

Fig. 25
figure 25

Correlation between the actual and the predicted choke size for testing data (FN) (R = 0.81)

Concluding remarks

Four main models for multiphase flow rate through chokes were developed, which are artificial neural network (ANN), fuzzy logic (FL), support vector machine (SVM), and functional network (FN). Several statistical and graphical techniques were made to check the accuracy of the new models.

The artificial intelligent (AI) was successfully applied to solve this problem using the different techniques proposed. The input and output data were preprocessed using normalization and log. It was observed that normalization of the input data was not as good as taking the log for the prediction.

Table 11 compares the five methods using the correlation coefficient as a comparison criterion for the data of testing and training. Fuzzy logic (FL) gives the best results for the training data while support vector machines (SVM) provide the best results for the testing data. Since the analysis of the data indicated that the data were clustered for most of the input parameters and as the fuzzy logic is best in its prediction for clustered data, it gives the best results in this study.

Table 11 Correlation coefficient summary for the different tools