A robust method for estimating the two-phase flow rate of oil and gas using wellhead data

Flow rate prediction of multiphase flow in the oil and gas wellbores is more complicated than single-phase flow avoiding direct measurements such as using flowmeters or well logging. This study offers an approach to find the accurate two-phase flow rates, applicable in extensive cases of two-phase wells/pipelines. When in a production well, the wellhead data are accessible except for flow rate, and bottom hole conditions, computing the pressure and temperature profiles through the wellbore can be brought about by replacing different values for flow rates, and lead us to probable accurate answers. This aim can be achieved by hiring a heuristic solver to find the most accurate answers as quickly as possible. This approach is flexible and practical depending on the statement of the problem. So, in this study, it has been applied to some vertical two-phase flow wells, which their well survey data was available to avoid future loggings, the wells modeled. Two models were developed, where each one predicted the flow rate by an error of less than 2%. Considering the final results for vertical wells, in this study, the model in which a mechanistic method for predicting pressure gradient applied in proposed compared with experiment-based methods.


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).

3
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 twophase streams is the summation of hydrostatic, frictional and kinetic terms as given in the following equation (Shoham 2005).
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).
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).
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.
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." where V m and V sg 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, ΔP in (Pa) the pressure changes for the length of L, Δz in (m) the elevation, U in (W/m 2 K) the overall heat transfer coefficient, D in (m) the diameter, ṁ in (kg/s) the mass flow rate and T , T 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: 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). (2) Heat transfer path from producing fluid toward the earth in a typical petroleum well (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. This error is defined by Eq. 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 Fig. 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 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. 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.

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     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." 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 m 3 /day and 216,910 m 3 / 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 m 3 /day for oil and 2,168,900 m 3 /day for gas, by the defined error term of 0.8%. The real recorded rates were 708.0785 m 3 /day and 217,030 m 3 /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 Fig. 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 Second Model Generations 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. 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.
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 Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

Appendix 1: Derivation of enthalpy changes equation from conservation of energy in two-phase flow pipeline
Due to describing two-phase flow behavior, conservation equations have to be solved; so, to find out the quantity of energy loss or how temperature changes, the differential form of energy equation has to be considered for the fluid in the pipeline where the fluid does not do any work. Also, no work is done on the fluid, in the form of Eq. (5). The above equation has to be written in terms of the thermal balance equation; hence, the definition of fluid specific enthalpy (per unit of mass) is used, which is expressed in Eq. (6).
Combining Eqs. (5), (6), and considering the mechanical constant of mechanical energy, j, the differential equation of the thermal balance of the system would be as Eq. (7).
where L and θ are length and angle of the pipe about the horizon, respectively.
The first term in the right-hand side of Eq. (9) is the changes in fluid energy due to kinetic energy and is more important in the cases where the fluid is compressible, and

Appendix 2: The brief results of applying the algorithm on two other available wells
The properties of the productive reservoir of the wells listed in Table 7.  The results of generations versus error plotted in Figs. 13 and 14 for wells No.2 and No.3, using both models presented in this essay. Both figures illustrate the number of generations which took to achieve the best answer with the least error for two other wells. Where there was not a negligible change in error values, the searching process for oil and gas flow rates stopped.
In the final results, the outputs of the program for flow rates versus real flow rates are summarized in Table 8.