Gas-liquid two-phase flow measurement method and system based on machine learning and physical constraints
By introducing physical constraints of the basic equation of gas-liquid flow in the deep neural network model, the problem of insufficient robustness and extrapolated performance in gas-liquid flow measurement is solved, and more accurate flow prediction is achieved.
Patent Information
- Application Number
- CN202211004353.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-22
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2042-08-22
AI Technical Summary
Existing deep learning has insufficient robustness and extrapolated performance in gas-liquid two-phase flow measurement, making it difficult to effectively combine physical laws, resulting in inaccurate prediction results.
The physical constraint equation is established based on the basic equation of gas-liquid two-phase flow, and added it to the loss function of the deep neural network model to build an improved neural network model to improve prediction accuracy.
The interpretability and extrapolation capabilities of the deep learning model are enhanced, so that the prediction results are in line with basic physical laws, and the accuracy of gas-liquid flow measurement is improved.
Smart Images

Figure CN115355959B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of multiphase flow parameter measurement, and in particular to a gas-liquid two-phase flow measurement method and system based on the combination of machine learning and physical constraints. Background Art
[0002] Gas-liquid two-phase flow is widely present in fields such as petroleum, chemical engineering, geothermal energy, and nuclear energy. For example, in the oil and gas industry, as natural gas wells are mined, formation water seepage and hydrocarbon condensation result in the presence of liquid phases in the natural gas in the gathering and transportation pipelines. Therefore, developing low-cost online gas-liquid two-phase flow measurement technology is particularly important for mastering single-well data, scientifically managing gas reservoirs, and predicting gas well water yields. Gas-liquid two-phase flow is a very complex nonlinear system, and deep learning has excellent applications in processing complex nonlinear relationship mappings. Therefore, considering using deep learning to build models to predict gas-liquid two-phase flow. However, the black-box nature of deep learning results in uncertain prediction robustness and extrapolation performance, hindering its application in practical engineering. How to combine physical laws with deep learning to effectively learn the mapping relationship between data from small samples, ensure that the prediction results conform to general physical laws, and enhance the model's generalization and extrapolation capabilities has become a challenging problem. To this end, the present invention proposes a gas-liquid two-phase flow measurement method and system based on the combination of machine learning and physical constraints. Summary of the Invention
[0003] The purpose of the present invention is to provide a gas-liquid two-phase flow measurement method and system based on machine learning and physical constraints. A physical constraint equation is established based on the basic equation of gas-liquid two-phase flow, and the physical constraint equation is added to the loss function of the neural network model to obtain an improved neural network model. The accuracy of predicting gas-liquid two-phase flow based on the improved neural network model can be greatly improved.
[0004] To achieve the above object, the present invention provides the following solutions:
[0005] A gas-liquid two-phase flow measurement method based on machine learning and physical constraints, comprising:
[0006] A gas-liquid two-phase flow experiment was conducted based on a V-cone throttling device to obtain gas-liquid two-phase flow experimental data;
[0007] Establish physical constraint equations based on the basic equations of gas-liquid two-phase flow;
[0008] Introducing a physical constraint equation into the loss function of a deep neural network model to obtain an improved loss function; constructing an improved deep neural network model based on the improved loss function;
[0009] The improved deep neural network model is trained using the gas-liquid two-phase flow experimental data to obtain a gas-liquid two-phase flow measurement model, and the gas-liquid two-phase flow measurement model is used to measure the gas-liquid two-phase flow.
[0010] The present invention also provides a gas-liquid two-phase flow measurement system based on machine learning and physical constraints, comprising:
[0011] Experimental data acquisition module, used to conduct gas-liquid two-phase flow experiments based on the V-cone throttling device to obtain gas-liquid two-phase flow experimental data;
[0012] Physical constraint equation construction module, used to establish physical constraint equations based on the basic equations of gas-liquid two-phase flow;
[0013] A deep neural network model construction module is used to introduce physical constraint equations into the loss function of the deep neural network model to obtain an improved loss function; and to construct an improved deep neural network model based on the improved loss function;
[0014] The gas-liquid two-phase flow measurement module is used to train the improved deep neural network model using the gas-liquid two-phase flow experimental data to obtain a gas-liquid two-phase flow measurement model, and use the gas-liquid two-phase flow measurement model to measure the gas-liquid two-phase flow.
[0015] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0016] The present invention relates to a gas-liquid two-phase flow measurement method and system based on machine learning and physical constraints. A simplified physical constraint term is proposed based on the basic equation of gas-liquid two-phase flow. The physical constraint term is added to the loss function by customizing the loss function of the neural network. During the optimization process of the neural network, not only the gap between the predicted value and the target value is minimized, but also the residual term of the physical equation is minimized. That is, during the training process of the neural network model, there is guidance from the target value and constraints from the physical equation, thereby enhancing the interpretability and extrapolation ability of the deep learning network model, establishing a gas-liquid two-phase flow measurement model that conforms to basic physical laws, and thus improving the accuracy of the predicted gas-liquid two-phase flow measurement. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1A flow chart of a gas-liquid two-phase flow measurement method based on machine learning and physical constraints provided in Example 1 of the present invention;
[0019] Figure 2 A block diagram showing the principle of a gas-liquid two-phase flow measurement method based on machine learning and physical constraints provided in Example 1 of the present invention;
[0020] Figure 3 A schematic structural diagram of a V-cone throttling device provided in Example 1 of the present invention;
[0021] Figure 4 A schematic diagram of a fluid flowing through a throttling device provided in Example 1 of the present invention;
[0022] Figure 5 A comparison chart of the gas phase flow prediction effects of the physical constraint-integrated neural network model PGNN and the purely data-driven neural network model DNN provided in Example 1 of the present invention;
[0023] Figure 6 A comparison chart of the liquid phase flow prediction effects of the physical constraint-integrated neural network model PGNN and the purely data-driven neural network model DNN provided in Example 1 of the present invention. DETAILED DESCRIPTION
[0024] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0025] The purpose of the present invention is to provide a gas-liquid two-phase flow measurement method and system based on machine learning and physical constraints. A physical constraint equation is established based on the basic equation of gas-liquid two-phase flow, and the physical constraint equation is added to the loss function of the neural network model to obtain an improved neural network model. The accuracy of predicting gas-liquid two-phase flow based on the improved neural network model can be greatly improved.
[0026] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0027] Example 1
[0028] like Figure 1 As shown, this embodiment provides a gas-liquid two-phase flow measurement method based on machine learning and physical constraints, including:
[0029] S1: A gas-liquid two-phase flow experiment was conducted based on a V-cone throttling device to obtain gas-liquid two-phase flow experimental data.
[0030] Gas-liquid two-phase flow experiment based on V-cone differential pressure throttling device, Figure 3 The structure of the V-cone throttling device is shown. The gas and liquid mass flow rates m are measured using a single-phase flow meter. g , m l The gas and liquid are mixed and passed into the V-cone throttling device to measure the test section; the differential pressure ΔP between the upstream pressure point and the throat pressure point of the V-cone throttling device is collected. tp , the pressure drop ΔP between the upstream and downstream pressure points m , the gas-liquid two-phase flow pressure P and temperature T flowing through the V-cone throttling device. Multiple sets of working condition data under different throttling ratios of the V-cone throttling device are collected to obtain experimental data.
[0031] S2: Establish physical constraint equations based on the basic equations of gas-liquid two-phase flow;
[0032] like Figure 4 As shown in the figure, a schematic diagram of single-phase flow passing through a V-cone throttling device. For single-phase flow, its one-dimensional flow equation can be expressed as:
[0033]
[0034] Where β is the throttling ratio of the throttling device, which is defined as the ratio of the cross-sectional area of the throat of the throttling device to the cross-sectional area of the measuring pipe, A1 is the cross-sectional area of the pipe upstream of the throttling device, A2 is the cross-sectional area of the throat of the throttling device, P1 and P2 are the pressures upstream and at the throat of the throttling device, respectively, and u1 and u2 are the velocities of the fluid upstream and at the throat of the throttling device, respectively.
[0035] For high gas content (gas volume fraction GVF ≥ 95%) gas-liquid two-phase flow, it is assumed that the gas and liquid flow separately, and the shear force F between the gas and liquid phases is considered. s , then the flow equations for the gas and liquid phases are:
[0036]
[0037]
[0038] Among them, A g2 , A l2 They represent the cross-sectional area occupied by the gas phase at the throat of the throttling device and the cross-sectional area occupied by the liquid phase at the throat of the throttling device respectively;
[0039] The continuity equations for gas-liquid flow are:
[0040] m g =ρ g A g1 u g1 =ρ g A g2 ug2
[0041] m l =ρ l A l1 u l1 =ρ l A l2 u l2
[0042] The gas-liquid two-phase slip ratio is defined as:
[0043]
[0044] From the above equations, we can get:
[0045]
[0046] Solve for the differential pressure ΔP tp About m g and m l The partial derivative of can be obtained:
[0047]
[0048]
[0049] Combining the above two equations, we can get:
[0050]
[0051] in,
[0052] The expression of the physical constraint equation is defined as follows:
[0053]
[0054]
[0055] Where ΔP tp Indicates the differential pressure between the upstream pressure point and the throat pressure point of the V-cone throttling device; ρ g represents the gas phase density; ρ l Indicates liquid density; m g Indicates gas phase mass flow rate; m l represents the mass flow rate of the liquid phase; A2 represents the cross-sectional area of the throat of the throttling device; β represents the throttling ratio of the throttling device.
[0056] S3: Introducing a physical constraint equation into the loss function of the deep neural network model to obtain an improved loss function; constructing an improved deep neural network model based on the improved loss function;
[0057] The deep neural network structure is defined as M hidden layers, each layer has m neurons, 1 input layer, and 1 output layer. The input layer contains 4 neurons, which are the differential pressure ΔP tp , pressure loss ΔP m , gas-liquid density ratio DR, V cone throttling ratio β. The output layer contains 2 neurons, m g , m l are the gas phase mass flow rate and liquid phase mass flow rate, respectively. The gas-liquid phase density ratio is the ratio of the gas phase density to the liquid phase density. The gas phase density is calculated based on the pressure P and temperature T, while the liquid phase density is a constant.
[0058] The expression for defining the improved loss function is:
[0059] Loss=θ1MSE_m g +θ2MSE_m l +θ3MSE_f
[0060] Among them, θ1, θ2, θ3 represent weight coefficients; MSE_m g MSE_m represents the mean square error between the gas phase flow rate prediction value and the gas phase flow rate target value; l It represents the mean square error between the predicted value of liquid flow and the target value of liquid flow; MSE_f represents the residual function of the physical constraint equation.
[0061]
[0062]
[0063]
[0064] m g They are respectively the predicted value of gas phase flow rate and the target value of gas phase flow rate; m l are the predicted value of liquid flow rate and the target value of liquid flow rate respectively; n is the number of samples. Represents the predicted value of the physical constraint equation.
[0065] S4: Using the gas-liquid two-phase flow experimental data to train the improved deep neural network model to obtain a gas-liquid two-phase flow measurement model, and using the gas-liquid two-phase flow measurement model to measure the gas-liquid two-phase flow.
[0066] Step S4 specifically includes:
[0067] S41: Dividing the gas-liquid two-phase flow experimental data into a training data set and a first test data set according to a first preset ratio. In order to test the generalization ability of the model, the operating condition range included in the first test data set is larger than the operating condition range included in the training data set.
[0068] S42: Using a second preset proportion of data in the training data set as a second test data set.
[0069] Specifically, during the training process, 20% of the data in the training data set can be used as the second test data set to prevent the network from overfitting during the training process.
[0070] S43: Using the training data set to train the improved deep neural network model, and during the training process, using the second test data set to test the deep neural network model during the training process to obtain a trained deep neural network model;
[0071] S44: Using the second test data set to verify the prediction performance of the trained deep neural network model, and adjusting the model parameters of the trained deep neural network model to optimal parameters based on the verification results to obtain a gas-liquid two-phase flow measurement model.
[0072] After the model is trained, the first test data set is used to verify the generalization and extrapolation capabilities of the model.
[0073] In this embodiment, after obtaining the gas-liquid two-phase flow measurement model, the following steps are further included:
[0074] The root mean square error (RMSE) and mean absolute error (MAE) are used to evaluate the measurement performance of the gas-liquid two-phase flow measurement model.
[0075]
[0076]
[0077] in Represents the predicted value, y targ Represents the target value, N is the number of samples, and abs() represents the absolute value.
[0078] In order to facilitate those skilled in the art to understand the solution of the present invention, the measurement method in this embodiment is described below with reference to examples:
[0079] (1) This example uses five V-cone throttling devices with different throttling ratios (0.45, 0.48, 0.55, 0.65, and 0.75) to conduct experiments. A total of 774 sets of operating data are collected. The data set with a V-cone throttling ratio of 0.48 (327 sets) is used as the first test data set to test the effect of the neural network model, and the remaining data (447 sets) are used as the training data set for establishing the neural network model.
[0080] In order to test the generalization ability of the model, the operating range of the first test data set is larger than that of the training data set, where the gas phase mass flow rate range of the training data set is 0-0.14 kg·s -1 , the liquid mass flow rate range is 0-0.6kg·s -1 , Loma parameter X LM The Loma parameter X of the first test data set is 0-0.3. LM The gas phase mass flow rate range is 0-0.16 kg·s -1 , the liquid mass flow rate range is 0-1.0kg·s -1 .
[0081]
[0082] (2) The deep neural network model structure constructed in this example contains 7 hidden layers, 20 neurons in each layer, 1 input layer, and 1 output layer. The input layer contains 4 neurons, which are the differential pressure ΔP tp , pressure loss ΔP m , gas-liquid phase density ratio DR, V cone throttling ratio β. The output layer contains 2 neurons, which are the gas-liquid mass flow rate m g , m l .
[0083]
[0084]
[0085] Where P0, T0, and ρ0 are the pressure, temperature, and density at standard conditions. P0 is 101.325 kPa, and T0 is 0°C.
[0086] (3) In this example, the neural network activation function uses the hyperbolic tangent function tanh. The loss function is defined as:
[0087] Loss=5*MSE_m g +5*MSE_m l +0.01*MSE_f
[0088] (4) In order to evaluate the prediction performance of the method proposed in this paper, a deep neural network (PGNN) that integrates physics knowledge was trained and compared with a pure data-driven deep neural network (DNN). Figure 5 and Figure 6A comparison of the prediction performance of the PGNN and DNN for the gas and liquid phases on the first test dataset shows that the PGNN performs better across a wider range of test datasets, demonstrating that the proposed method effectively improves the extrapolation performance of the deep neural network model, enabling predictions to conform to certain physical laws. Furthermore, the RMSE and MAE of the prediction results from the two models were calculated to reflect their predictive performance. The comparative results are shown in Table 1, further demonstrating that the neural network combined with physical constraints exhibits superior generalization performance.
[0089] Table 1 Comparison of prediction indicators between PGNN and DNN on the first test dataset
[0090]
[0091] In this example, reasonable assumptions are made to simplify the flow equations for gas-liquid two-phase flow. Based on the automatic differentiation characteristics of neural network backpropagation, physical constraints suitable for deep learning are proposed. By customizing the neural network's loss function expression and incorporating the physical constraints into the loss function, the neural network training process is guided not only by the target value but also by the physical constraints. Compared to purely data-driven models, deep learning combined with physics improves the model's extrapolation capabilities and makes the neural network model somewhat interpretable.
[0092] Example 2
[0093] This embodiment provides a gas-liquid two-phase flow measurement system based on machine learning and physical constraints, including:
[0094] Experimental data acquisition module T1, used to conduct gas-liquid two-phase flow experiments based on the V-cone throttling device to obtain gas-liquid two-phase flow experimental data;
[0095] Physical constraint equation construction module T2, used to establish physical constraint equations based on the basic equations of gas-liquid two-phase flow;
[0096] The expression of the physical constraint equation in the physical constraint equation construction module T2 is:
[0097]
[0098] Where ΔP tp Indicates the differential pressure between the upstream pressure point and the throat pressure point of the V-cone throttling device; ρ g represents the gas phase density; ρ l Indicates liquid density; m g Indicates gas phase mass flow rate; m l Indicates the liquid mass flow rate.
[0099] A deep neural network model construction module T3 is used to introduce a physical constraint equation into the loss function of the deep neural network model to obtain an improved loss function; and to construct an improved deep neural network model based on the improved loss function;
[0100] Among them, the expression of the improved loss function in the deep neural network model construction module T3 is:
[0101] Loss=θ1MSE_m g +θ2MSE_m l +θ3MSE_f
[0102] Among them, θ1, θ2, θ3 represent weight coefficients; MSE_m g MSE_m represents the mean square error between the gas phase flow rate prediction value and the gas phase flow rate target value; l It represents the mean square error between the predicted value of liquid flow and the target value of liquid flow; MSE_f represents the residual function of the physical constraint equation.
[0103] The gas-liquid two-phase flow measurement module T4 is used to train the improved deep neural network model using the gas-liquid two-phase flow experimental data to obtain a gas-liquid two-phase flow measurement model, and use the gas-liquid two-phase flow measurement model to measure the gas-liquid two-phase flow.
[0104] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0105] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only intended to help understand the method and core concept of the present invention. At the same time, those skilled in the art will find that the specific implementation methods and application scopes may vary based on the concept of the present invention. In summary, the contents of this specification should not be construed as limiting the present invention.
Claims
1. A gas-liquid two-phase flow measurement method based on machine learning and physical constraints, characterized in that: include: A gas-liquid two-phase flow experiment was conducted based on a V-cone throttling device to obtain gas-liquid two-phase flow experimental data; Establish physical constraint equations based on the basic equations of gas-liquid two-phase flow; Introducing a physical constraint equation into the loss function of a deep neural network model to obtain an improved loss function; constructing an improved deep neural network model based on the improved loss function; Using the gas-liquid two-phase flow experimental data to train the improved deep neural network model to obtain a gas-liquid two-phase flow measurement model, and using the gas-liquid two-phase flow measurement model to measure the gas-liquid two-phase flow; The physical constraint equation is expressed as follows: Where ΔP tp Indicates the differential pressure between the upstream pressure point and the throat pressure point of the V-cone throttling device; ρ g represents the gas phase density; ρ l Indicates liquid density; m g Indicates gas phase mass flow rate; m l represents the mass flow rate of the liquid phase; A2 represents the cross-sectional area of the throat of the throttling device; β represents the throttling ratio of the throttling device; The improved loss function is expressed as follows: Loss=θ1MSE_m g +θ2MSE_m l +θ3MSE_f Among them, θ1, θ2, θ3 represent weight coefficients; MSE_m g MSE_m represents the mean square error between the gas phase flow rate prediction value and the gas phase flow rate target value; l It represents the mean square error between the predicted value of liquid flow and the target value of liquid flow; MSE_f represents the residual function of the physical constraint equation.
2. The method according to claim 1, characterized in that The method of using the gas-liquid two-phase flow experimental data to train the improved deep neural network model to obtain a gas-liquid two-phase flow measurement model specifically includes: Dividing the gas-liquid two-phase flow experimental data into a training data set and a first test data set according to a first preset ratio; using a second preset proportion of data in the training data set as a second test data set; Training the improved deep neural network model using the training data set, and during the training process, testing the deep neural network model in the training process using the second test data set to obtain a trained deep neural network model; The second test data set is used to verify the prediction performance of the trained deep neural network model, and based on the verification results, the model parameters of the trained deep neural network model are adjusted to the optimal parameters to obtain a gas-liquid two-phase flow measurement model.
3. The method according to claim 2, characterized in that The operating condition range included in the first test data set is larger than the operating condition range included in the training data set.
4. The method according to claim 1, wherein After obtaining the gas-liquid two-phase flow measurement model, the method further includes: The root mean square error (RMSE) and mean absolute error (MAE) are used to evaluate the measurement performance of the gas-liquid two-phase flow measurement model.
5. A system based on the method according to any one of claims 1 to 4, characterized in that: include: Experimental data acquisition module, used to conduct gas-liquid two-phase flow experiments based on the V-cone throttling device to obtain gas-liquid two-phase flow experimental data; Physical constraint equation construction module, used to establish physical constraint equations based on the basic equations of gas-liquid two-phase flow; The physical constraint equation is expressed as follows: Where ΔP tp Indicates the differential pressure between the upstream pressure point and the throat pressure point of the V-cone throttling device; ρ g represents the gas phase density; ρ l Indicates liquid density; m g Indicates gas phase mass flow rate; m l represents the mass flow rate of the liquid phase; A2 represents the cross-sectional area of the throat of the throttling device; β represents the throttling ratio of the throttling device; A deep neural network model construction module is used to introduce physical constraint equations into the loss function of the deep neural network model to obtain an improved loss function; and to construct an improved deep neural network model based on the improved loss function; The improved loss function is expressed as follows: Loss=θ1MSE_m g +θ2MSE_m l +θ3MSE_f Among them, θ1, θ2, θ3 represent weight coefficients; MSE_m g MSE_m represents the mean square error between the gas phase flow rate prediction value and the gas phase flow rate target value; l It represents the mean square error between the predicted value of liquid phase flow and the target value of liquid phase flow; MSE_f represents the residual function of the physical constraint equation; The gas-liquid two-phase flow measurement module is used to train the improved deep neural network model using the gas-liquid two-phase flow experimental data to obtain a gas-liquid two-phase flow measurement model, and use the gas-liquid two-phase flow measurement model to measure the gas-liquid two-phase flow.