Introduction

Accurate rate estimation of two-phase flow wells is one of the crucial concerns of petroleum engineers. Mostly, direct rate measurement of every single well is not possible because the fluid content of several wells is often mixed at the manifolds or even well survey in this purpose is costly and time-consuming (Mahdiani and Khamehchi 2016).

Therefore, several approaches are developed to avoid well surveys to estimate wellbore conditions precisely. Some of them are rule-based like the study Kabir et al. (2008) and Izgec et al. (2010), which used wellhead pressure and wellhead temperature data, and Hasan and Kabir (2010) or Zolfagharroshan and Khamehchi (2020), which provided methods to model two-phase flow wells. In contrast, some developed models need special tools like Ouyang and Belanger (2004), which are out the scope of this study.

So, there are numerous studies on the ways to model pressure and temperature traverse in two-phase flow wells. Computer-based models have been extensively used over the past few years. For example, applying artificial intelligence tools like genetic programming, artificial neural network, etc., on big data sets led to strong models, which simulate production conditions like Wang et al. (2016), Pouryoussefi and Zhang (2015) or Alizadehdakhel et al. (2009).

There are also earlier methods which are usually the base of the recent studies, such as all the methods provided for pressure gradient calculations and flow pattern recognition in previous two-phase flow research. Duns and Ros (1963), Beggs and Brill (1973), Mukherjee and Brill (1985), Ansari et al. (1994), Petalas and Aziz (2000) introduced a variety of models in the description of different two-phase using different assumptions and based on experimental and mechanistic approaches. As an example, especially for temperature, Hasan et al. (2002) extensively explained temperature changes in two-phase flow in petroleum wellbores by solving the general equation of energy conservation. In the latter approaches, mostly the pressure or temperature was assumed to be available to compute another parameter; so, they may do not work when both pressure and temperature are unknown or in the two-phase flow cases. Another hypothesis or challenge in this study is the unknown oil and gas flow rates flowing in the wellbore.

In the present paper, the primary purpose is introducing a general model to forecast two-phase, oil and gas, flow rates in wells where the bottom hole conditions are unknown. In this way, an algorithm which is applicable in two-phase flow modeling in pipeline/wellbore proposed by Beggs and Brill (Shoham 2005) is combined with one of the most powerful artificial intelligence methods to solve the problem.

The novel proposed approach does not rely on just AI methods such as a major part of previous studies, and in the introduced methodology, a procedure is considered in which the flow parameters are considered such as flow pattern and liquid holdup, which probably were poorly discussed in the case of the simulations just based on the data points where the AI methods are used solely. Another feature of the proposed method is that the user will be needless to do a well survey, which is not desirable as the well has to shut in, so there will not be a need for specific tools or even experts to run wire-line tools. The validity of the model is examined by carrying out several analyses and using different data from other wells, except the presented case study, in which all the producing wells had established survey reports, previously. The proposed algorithm is flexible, and most parts of it can be replaced with other correlations, and equations or another AI solver, regarding the statement of the problem, which is explained in the following.

Two-phase flow and heat transfer in well/pipeline

When two-phase flow exists in a pipeline, due to the differences in density and shear stresses, the phases tend to move separately. Generally, as the pressure decreases, the flowing fluid expands, and light components are extracted from the liquid phase, and the flow velocity increases. This issue makes analyzing two-phase flow more complex.

Several factors appear in various flow patterns in wells like buoyancy force, inertia, interfacial tension, rate of fluids, diameter, and angle of the pipe and fluid properties.

Solving the mass and momentum conservation equations for a control volume provides the equation of pressure gradient of single-phase flow. The equation for two-phase flow is the same, and the total pressure gradient of two-phase streams is the summation of hydrostatic, frictional and kinetic terms as given in the following equation (Shoham 2005).

$$\left( {\frac{\partial P}{\partial L}} \right)_{\text{t}} = \left( {\frac{\partial P}{\partial L}} \right)_{\text{f}} + \left( {\frac{\partial P}{\partial L}} \right)_{\text{el}} + \left( {\frac{\partial P}{\partial L}} \right)_{\text{acc}}$$
(1)

where the kinetic term is usually small and is ignored (Watson 2016), and the hydrostatic term is proportional to the average mixture density; it is the dominated term in vertical flow.

There are lots of models to describe the pressure gradient of two-phase flow, as mentioned in the introduction. These models are usually classified into three groups; earlier methods such as Poettman and Carpenter (1952), Baxendell and Thomas (1961), and Fancher and Brown (1962); they used more straightforward assumptions as their models did not consider flow pattern and slippage. Second group considers just slippage, like Hagedorn and Brown (1965), and the last group regards both and usually are more complicated than first two groups, which nowadays have more applications due to more strong simulations. They are numerous, like the ones presented in the introduction.

As the third group acts more precisely, some more common methods in the petroleum industry are selected from this category depending on the assumptions. Finally, Mukherjee and Brill (1985) and Ansari et al.’s (1994) models are picked. The first one is highly used in deviated pipes, and the second one is a comprehensive model to determine the pressure gradient of vertical upward two-phase flow. The methods are mainly different in liquid holdup calculation and flow pattern determination (Shoham 2005).

Other methods are rejected in the first evaluation stage of this study, as some were suitable in horizontal flow modeling like Beggs and Brill (1973) and some developed for downward flows. Among the rest of the methods, by calculating pressure assuming constant temperature, the Mukherjee and Brill (1985) and Ansari et al.’s (1994) models had the closest results to the previous well survey, comparing relative errors. The first evaluation results are presented here. As it is said, if the case changed, for example, the flow is horizontal, the user can apply all the models in the algorithm, and also, there might not be a previous well survey data available.

Another process occurring during production in a well is the heat loss, which affects the fluid properties and phases ratios. The reasons for this issue are heat transfer between the fluid and surroundings, phase alteration, and changes in the acceleration of the flowing fluid. Flowing heat passes through the shown elements, as in Fig. 1 (Hasan et al. 2002).

Fig. 1
figure 1

Heat transfer path from producing fluid toward the earth in a typical petroleum well (Hasan et al. 2002)

Beggs and Brill presented an approach in which pressure and temperature profiles through a pipe segment can be computed. This approach is shown in Fig. 2 (Mokhatab and Vatani 2005).

Fig. 2
figure 2

Beggs and Brill flowchart in the pipeline for predicting thermodynamic properties of fluid flow (Mokhatab and Vatani 2005)

Pressure gradient model, flash calculations, and the changes in enthalpy are particular items. The selection of pressure drop methods is explained previously and the fluid properties used methods presented in Table 1. There are several developed equations for fluid properties, but selected methods are valid in the ranges of API, gas gravity, and temperature ranges. They may vary for different oils and gases with different properties.

Table 1 Physical properties correlations used in both models, suitable for producing oil and gas regarding operational conditions

By using the general equation of energy, changes in enthalpy are calculated as Eq. 2. The derivation of this equation is presented in “Appendix 1.”

$$\Delta H = \left( {\frac{{ - v_{\text{m}} \cdot v_{\text{sg}} }}{j}} \right)\frac{\Delta P}{P} - \left( {\frac{g}{j.}} \right)\Delta z - \frac{{U\left( {\pi D} \right)L}}{{\dot{m}}}\left( {\overline{T} - \overline{{T_{\text{s}} }} } \right)$$
(2)

where Vm and Vsg in (m/s) are mixture velocity and superficial gas velocity, j in (Nm/J) is the mechanical energy coefficient due to heat balance of the system, \(\Delta P\) in (Pa) the pressure changes for the length of L, \(\Delta z\) in (m) the elevation, U in (W/m2 K) the overall heat transfer coefficient, D in (m) the diameter, \(\dot{m}\) in (kg/s) the mass flow rate and \(\overline{T}\), \(\overline{{T_{\text{s}} }}\) in (K) are temperatures of the fluid and surrounding (Mokhatab and Vatani 2005).

Based on steady-state heat transfer, Hassan and Kabir derived the below expression for the overall heat transfer coefficient corresponding to Fig. 1:

$$\frac{1}{U} = \frac{{r_{\text{co}} }}{{r_{\text{ci}} h_{\text{c}} }} + \frac{{r_{\text{co}} \ln \left( {\frac{{r_{\text{co}} }}{{r_{\text{ci}} }}} \right)}}{{k_{\text{c}} }} + \frac{{r_{\text{to}} \ln \left( {\frac{{r_{\text{wb}} }}{{r_{\text{co}} }}} \right)}}{{k_{\text{cem}} }}$$
(3)

Thus, to achieve the best description of the two-phase flow behavior in a well/pipeline, there have to be some exact predictions of thermodynamic characteristics of the flowing fluid. In this manner, lots of studies provided the models to determine pressure and temperature in some cases separately, and in others when they are simultaneously unknown (Hasan et al. 2002).

Genetic algorithm (GA)

The genetic algorithm (GA) is developed by John Holland (1970) and based on biological evolution. The main application of this approach is in discrete optimization. One of the most important benefits of this approach compared with others like artificial neural networks is that GA models are meaningful and can be interpreted (Weise 2009).

The GA can be used for solving problems that require significant investigations or ones with complicated assumptions. It can also be hired when the components suffer ambiguous effects. Other applications of GA include optimization, automatic programming, machine learning, economics, operations research, and ecology, studies of evolution and learning, and social systems (Stoisits et al. 2001; Khamehchi and Mahdiani 2017).

As we needed a tool to couple with the algorithm shown in Fig. 2, we used GA to substitute different flow rates as possible answers and minimize the error, which is introduced in Sect. 4. The characteristics of GA is attained by analyzing several runs of the program, which satisfied the condition of minimum error and also the less run-time.

Theory/calculation

The algorithm presented in Fig. 2 is applicable even in the case pressure, and temperatures are unknowns. Other parameters are given like flow rates and pipe geometry by a trial and error approach. As explained before, the flow rates in this study are considered unknown, which can take place in the production phases, so the GA is added to the algorithm to estimate them by working on oil and gas rates, which follows a smart and trainable trend toward the answers. In this way, it uses the wellhead pressure and temperature to validate the accuracy of the flow rates.

After finding the probable answers with the least value of error, pressure, and temperature profiles computed from bottom hole to surface, and compared to recorded wellhead data plotted. The main algorithm, combining all explanations and Eq. 4, presented in Fig. 3.

Fig. 3
figure 3

The proposed algorithm to find oil and gas flow rates, using the genetic algorithm, based on the presented flowchart is given in Fig. 2

This error is defined by Eq. 4:

$${\text{Error}} = \frac{{\left| {P_{\text{est}} - P_{\text{wh}} } \right|}}{{P_{\text{wh}} }} + \frac{{\left| {T_{\text{est}} - T_{\text{wh}} } \right|}}{{T_{\text{wh}} }}$$
(4)

In the above formula, “wh” and “est” indices refer to the wellhead and estimated values of pressure and temperature, respectively.

GA tests a wide range of answers for flow rates; then, the calculations will improve in the entire well, until the error minimized. There has to be the first approximate pressure and temperature gradients to start the whole calculations. The properties of simulated well, well DQ11, and producing reservoir characteristics are listed in Tables 2 and 3.

Table 2 Properties of producing fluids of the well DQ11, recorded in the wellhead
Table 3 Reservoir data of the well DQ11

The downhole equipment and completion data of this well is presented in Tables 4 and 5, and lastly, Table 6 expresses the properties of GA required for training a model.

Table 4 Downhole equipment of well DQ11
Table 5 completion data of the well DQ11
Table 6 Properties of the GA in MATLAB toolbox for the well DQ11

Results and discussion

Firstly, fluids and well geometry properties and two approximations of pressure and temperature gradient are read by program as inputs, and the program starts searching flow rates. Pressure–temperature calculations to surface starts, and when the value of error becomes minimized, the program will stop.

Before running the model, two separate ranges for flow rates are considered as the searching areas of answers. The latest action is because of less time spent to find the results, and also to avoid inappropriate and false answers which satisfy the stopping criteria when you have a sense about the range of answers. At the end, when estimated flow rates are reported, all physical and thermodynamic properties of the flow are plotted.

There are two different pressure gradient methods applied in this study, and as pressure gradient calculation approaches are usually different in determining liquid holdup, they have different outputs. The validation of methods is carried out by comparing previous well surveys in this case. Still, as it is said before, the main aim of this study is to avoid a well survey, so this evaluation is for future applications of this model. There has to be emphasis that several analyses have been carried out on the introduced well in this study, to find the appropriate parameters of GA like population, and then, to ensure that the algorithm works properly, at least three series of runs is applied on the DQ11, and the profiles presented in Figs. 4 and 5 are plotted as the outputs of generations versus error. The trends in the two figures, as mentioned earlier, move toward the stopping criteria or accurate answers. This analysis is done also on two other wells in a different field. Still, almost the same fluids properties, which their well surveys were also available, and the results reported briefly in “Appendix 2.”

Fig. 4
figure 4

The number of generations versus error, based on the developed algorithm in Fig. 3, for the first model which uses Mukherjee and Brill models for pressure gradient calculations to find the flow rates for the well DQ11. The results of other runs are also plotted

Fig. 5
figure 5

The number of generations versus error, based on the developed algorithm in Fig. 3, for the second model, which uses Ansari et al.’s models for pressure gradient calculations to find the flow rates for the well DQ11. The results of other runs are also plotted

In the best fit on the well DQ11, for the first model in which Mukherjee and Brill pressure gradient method is used, the oil and gas rates were 713.0045 m3/day and 216,910 m3/day, respectively. The defined error as Eq. 4, for this model, was 1.5%. In the second model in which the Ansari et al.’s approach is used in predicting pressure, the results were 706.9661 m3/day for oil and 2,168,900 m3/day for gas, by the defined error term of 0.8%. The real recorded rates were 708.0785 m3/day and 217,030 m3/day for oil and gas, respectively. The stopping criteria is defined in Eq. 4. The above analysis is based on the more repetitive value of error attained form several programs run.

In an investigation, another analysis was done on some adjustable input parameters. The length of segments is changed in predicting flow rate to monitor the effect of segment length on the prediction of liquid holdup and was compared to the actual liquid holdup. As expected from the previous analysis, the second model had a more precise estimation, as it directly affects the pressure gradient, as most of the pressure drop is due to elevation and mixture density. So, the main origin of the difference in the predicted flow rates is the difference in predicting liquid holdups. By increasing segment length in calculations of PVT, more errors appear, as expected. The results are presented in Fig. 6.

Fig. 6
figure 6

Estimated liquid holdup by presented models and also, the holdup calculated based on real quantities of the oil and gas flow rate in well DQ11

Plotted pressure and temperature graphs in Figs. 7, 8, 9, 10, 11, and 12 are based on the estimated flow rates by the two models mentioned above by negligible differences regarding operational conditions. The variation is more obvious in estimated pressures, as formerly discussed, but the differences in predicted temperatures are less compared with pressure; this can be because of the smaller values of a thermal gradient, which made the changes minor.

Fig. 7
figure 7

The estimated and real pressure profiles of the well DQ1 during production condition, by the first model in bottom hole and toward the surface

Fig. 8
figure 8

The estimated and real pressure profiles of the well during production condition, by the second model in the bottom hole and toward the surface

Fig. 9
figure 9

The estimated and real pressure profiles of the well during production condition, by the first model in the upper part of the well

Fig. 10
figure 10

The estimated and real pressure profiles of the well during production condition, by the second model in the upper part of the well

Fig. 11
figure 11

The predicted temperature profile of the well DQ11 by the first model and the real temperature of the well reported from the well survey

Fig. 12
figure 12

The predicted temperature profile of the well DQ11 by second model and the real temperature of the well reported from the well survey

Overall, the first model overestimated the pressure points. In contrast, the second one underestimated it, but considering the error value, the second model is a more reliable model, which predicts a more exact flow rate. However, the trends show that the prediction becomes less accurate in the latest segments toward wellhead, which is most obvious in pressure curves. As an optimization operator is already hired in this algorithm, dedicating more time to run further might be near at hand solution, but giving too much time to the heuristic solvers usually does not return significantly better answers.

Conclusions

In this paper, a novel manner is applicable in estimating the flow rate of each single vertical petroleum well producing two-phase oil and gas where the downhole conditions are unspecified, which is the most important feature of the recommended approach compared with previous studies.

Generally, most of the simulators require more operational parameters to run, which might not be available in operational conditions, so the introduced method works with the least available parameters, consisting wellhead pressure and temperature, well geometry, and specific gravities of fluids.

All the adjustable elements of the algorithm were selected for simulating a vertical two-phase flow well, and from two applied models on modeling the wellbore, the one in which pressure gradient method developed based on mechanistic approach predicted the flow rates and then the thermodynamic characteristics of the producing well better than the one whose approach in forecasting flow patterns and pressure gradient was by the experimental investigations. Regarding the statement of the problem, the user can develop a variety of models, and after validating the aid of previously reported data or whether it were possible by experimental work, it would be reliable to use in operational cases.