Shaft paraffin removal period prediction method
Optimizing the hyperparameters of the random forest model through Bayesian algorithm, the problems of slow convergence speed and low learning efficiency of the wax deposition rate prediction model in the prior art are solved, and high-precision prediction of wax deposition rate and accurate prediction of wax clean period are achieved.
Patent Information
- Application Number
- CN202411889498.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-11
AI Technical Summary
The neural network model used for wax deposition rate prediction in the prior art has the problems of slow convergence speed, low learning efficiency and easy to fall into the local optimal state. The prediction results of the SVM model are very sensitive to the combination of the penalty factor C and the kernel function parameter g.
Bayesian algorithm is used to optimize the hyperparameters of the random forest model to improve the prediction accuracy of wax deposition rate. This method collects wax shaving experimental data under the simulation conditions of carbon dioxide flooding wells, preprocesses sample data, constructs an initial random forest prediction model, and uses Bayesian algorithm to optimize the hyperparameters in the model. Finally, the optimized model is used to predict real-time wax deposition rate and wax cleaning cycle prediction.
It effectively improves the prediction accuracy of wax deposition rate, reduces the overfitting problem, improves the accuracy of the overall model by integrating the prediction results of multiple decision trees, and realizes real-time prediction of wax deposition rate and accurate prediction of wax clean cycle.
Smart Images

Figure CN119807928A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method for predicting a wellbore wax removal cycle, and belongs to the field of petroleum and natural gas industry. Background Art
[0002] Most of the crude oil produced in my country has the characteristics of high viscosity, easy coagulation and high wax content. During pipeline transportation, when the pipe wall temperature is lower than the oil temperature and lower than the wax precipitation point, wax deposition will form on the pipe wall, which will lead to a series of problems such as increased friction loss, reduced flow area, and condensed pipe. Waxing on the pipe wall will reduce the effective flow area of the pipeline, increase the flow resistance, and reduce the transportation capacity. In severe cases, it may cause pipe blockage accidents, thereby increasing the risk of pipeline operation. Therefore, it is necessary to monitor the wax deposition generated during wellbore transportation, analyze the law of wax deposition, and accurately predict the wax deposition rate of crude oil in the wellbore, so as to provide more accurate guidance for the determination of the wax removal cycle, which is also conducive to pipeline maintenance and reducing operating costs.
[0003] With the continuous development of computer science, the research on wax deposition rate prediction model tends to be more inclined to computer intelligent algorithms. The research and application of pipeline wax deposition thickness prediction based on intelligent algorithms such as neural network and particle swarm algorithm are becoming more and more extensive. Zhou Shikui et al. first used neural network to predict the wax deposition rate of crude oil pipelines. They used artificial neural network (ANN) and BP neural network (BPNN) models to predict the wax deposition rate based on four influencing factors, and proved the feasibility of these two models for wax deposition rate prediction. Wang Lei et al. established a support vector machine model (SVM) to predict the wax deposition rate of pipelines.
[0004] By studying and summarizing the research results of previous scholars, it can be learned that the currently used neural network prediction models generally have problems such as slow convergence speed, low learning efficiency and easy to fall into local optimal state; when the SVM model uses (radial basis function, RBF) neural network as the kernel function, different penalty factors C and kernel function parameter g combinations have a greater impact on the prediction results. To solve the above problems, the researchers considered the CO2 flooding production conditions data, including: crude oil temperature (℃), CO2 pressure (MPa), flow rate (m / s), crude oil dynamic viscosity (Pa·s), oil-water ratio and wax content (%), and proposed a Bayesian algorithm-based optimization random forest model to predict the wax deposition rate of the wellbore. This method can effectively reduce the overfitting problem, improve the accuracy of the overall model by integrating the prediction results of multiple decision trees, and speed up the training speed through parallel computing. Summary of the invention
[0005] In view of the shortcomings of the methods for obtaining wax deposition rate in the prior art, the purpose of the present invention is to propose a method for predicting the wellbore wax cleaning cycle. The invention optimizes hyperparameters through a Bayesian algorithm to improve the prediction accuracy of the wax deposition rate, providing a convenient and accurate method that can realize real-time prediction of the wax deposition rate and prediction of the wax cleaning cycle.
[0006] The present invention provides a method for predicting a wellbore wax cleaning cycle, comprising the following steps:
[0007] 1) Collect wax deposition experimental data under simulated working conditions of CO2 flooding production wells and calculate the wax deposition rate experimental value;
[0008] 2) Preprocessing sample data, including crude oil temperature (°C), carbon dioxide pressure (MPa), wax content (%), flow rate (m / s), crude oil dynamic viscosity (Pa·s) and oil-water ratio;
[0009] 3) Build an initial random forest prediction model and use the Bayesian algorithm to optimize the hyperparameters in the model;
[0010] 4) Using the processed sample data under the simulated working conditions of the CO2 flooding production well to train the optimized random forest model;
[0011] 5) Obtaining real-time wax deposition data of CO2 flooding production well conditions;
[0012] 6) Input the real-time wax deposition data into the trained random forest model to predict the real-time wax deposition rate;
[0013] 7) Predicting the wax removal cycle according to the wax deposition rate, as shown in formula (1);
[0014]
[0015] Where: T is the wax cleaning cycle, h; β is the wax deposition rate correction coefficient; l is the wax density, kg / m 3 ; d is the inner diameter of the oil pipe, m; h is the critical wax deposition thickness, m; e is the roughness of the oil pipe, m; v is the predicted value of the optimized wax deposition rate, g / (㎡·h). Further, the step 3) constructs an initial random forest prediction model and uses the Bayesian algorithm to optimize the hyperparameters in the model. The specific steps of the optimization are as follows:
[0016] (1) Construct an initial random forest prediction model, including:
[0017] (1-1) The sample size of the training set is N. The Bootstrap sampling method is used to randomly select multiple training samples from the training set as the input training set of each decision tree;
[0018] (1-2) When generating each decision tree from the sample set, a part of the variables (the number of selected variables is m, m < M) is randomly selected from all the optional variables (data dimension M). Among them, the optional variables include: crude oil temperature (°C), carbon dioxide pressure (MPa), oil-water ratio, crude oil dynamic viscosity (Pa·s), flow rate (m / s), wax content (%). Then, according to the optimal partitioning algorithm (Classification and Regression Tree algorithm), variables are selected from the m variables to split the leaf nodes, and multiple decision tree models are respectively established for multiple samples;
[0019] (1-3) The multiple generated decision trees are integrated through majority voting to obtain the final output of the random forest model. For regression problems, the averaging method is used as shown in Equation (20);
[0020]
[0021] Among them, H(x) represents the combined model, h(x,θ i ), i = 1, 2..., N represents the decision tree model sequence, x is the input vector, including: crude oil temperature (°C), carbon dioxide pressure (MPa), oil-water ratio, crude oil dynamic viscosity (Pa·s), flow rate (m / s), wax content (%); θ i represents the random vector on which a single decision tree depends, referring to the randomly selected input vector. Different vectors determine different structures of the decision tree;
[0022] (2) Define the objective function. Take the standard error RMSE as the objective function, and use the Bayesian optimization algorithm to establish the relationship between the hyperparameters and the objective function. Bayesian optimization estimates the posterior probability distribution of the objective function f(x) based on Bayes' theorem, samples the hyperparameter combinations based on the posterior distribution, and continuously improves the shape of the posterior distribution according to the sampling results, so as to find the global optimal solution of the objective function, as shown in Equation (3);
[0023]
[0024] Among them, x * is the hyperparameter combination, χ is the parameter space, and f(x) is the objective function;
[0025] (3) Define the Gaussian process. If the objective function f(x) follows a Gaussian distribution, then any number of hyperparameter combinations will also follow a joint Gaussian distribution, which is represented by the mean function m(x) as shown in Equation (6) and the covariance function k(x, x') as shown in Equation (7);
[0026] m(x) = E[f(x)] (6)
[0027] k(x,x')=E[(f(x)-m(x))(f(x')-m(x'))] (7)
[0028] Among them, the mean function m(x) represents the expectation of any variable, and the mean function is usually set to 0; E represents mathematical expectation, which is used to describe the average value of a random variable; x and x' represent different hyperparameter combinations, and the covariance function k(x,x') uses the Matern kernel function;
[0029] (4) Initialize the hyperparameter space, select max_features (the maximum number of features considered when building the optimal decision tree model), min_samples_leaf (this parameter controls the minimum number of samples for internal node re-division), and n_estimators (this parameter controls the number of decision trees) as the hyperparameters for optimizing the random forest regression prediction model and define their value ranges;
[0030] (5) Collect initial observation points, randomly select some hyperparameter combinations, calculate the objective function value and obtain the sampling set:
[0031] D 1:i =[x 1:i ,f(x 1:i )] (twenty one)
[0032] The initial observation point refers to the specific value of the hyperparameter combination selected at the beginning of the optimization process. The performance of the decision tree model depends on the setting of the hyperparameters. In this embodiment, the default hyperparameter values of the random forest model are selected; 1:i represents the data set consisting of the 1st to the i-th observation points; x 1:i represents the hyperparameter combination corresponding to the i observation points; f(x 1:i ) represents a series of observation points x1 to x i The objective function value RMSE on
[0033] (6) Construct a proxy model and use Gaussian process regression to fit the initial observation points:
[0034] f(x 1:i )~N(m(x 1:i ),K(x,x')) (8)
[0035]
[0036] Among them, m(x 1:i ) represents the mean function, which describes the iThe average trend of the RMSE of the objective function above; N represents normal distribution; k(x,x') represents the kernel function (covariance function), which is used to measure the similarity or correlation between two observation points x and x'. In Gaussian process regression, the kernel function determines the smoothness and predictive ability of the model; K(x,x') represents the covariance matrix;
[0037] (7) Select the acquisition function. The acquisition function can directly determine the performance of model optimization, affect the convergence speed of the optimization process and the fitting effect of the posterior distribution. Commonly used acquisition functions include the expected lift function, the confidence limit criterion, the probability lift function, etc., as follows:
[0038] (7-1) The expected lifting acquisition function takes the point with the maximum expectation of the posterior distribution as the new sampling point, as shown in formula (12);
[0039] EI(x)=E Q (max(0,μ Q (x best )-mf(x))) (12)
[0040] Where EI(x) is the expected improvement acquisition function, E Q is the expected operation of the random variable, μ Q (x) is the expectation of the posterior distribution, x best is the point where the posterior distribution expectation reaches the optimal point, and m is the trade-off coefficient;
[0041] (7-2) The confidence limit criterion acquisition function directly searches for new samples in the upper and lower confidence limits of the posterior distribution. It can be divided into an upper confidence limit function such as formula (13) and a lower confidence limit function (14). The minimum or maximum value of the objective function is solved by minimizing the lower confidence limit or maximizing the upper confidence limit.
[0042] UCB(x)=μ Q (x)+kσ Q (x) (13)
[0043] LCB(x)=μ Q (x)-kσ Q (x) (14)
[0044] Among them, μ Q (x) is the mean of the posterior distribution, σ Q (x) is the standard deviation of the posterior distribution, k is the uncertainty coefficient, whose size affects the area explored;
[0045] (7-3) The probability enhancement acquisition function takes the point with the largest standard normal cumulative distribution as the new sampling point, as shown in formula (15);
[0046]
[0047] Where PI(x) is the probability boost acquisition function, Φ(·) is the standard normal cumulative distribution function;
[0048] (8) Optimize the acquisition function and maximize the acquisition function in the hyperparameter space to find the next sampling point x i+1 According to the properties of Gaussian process, we can get f(x i+1 ) and f(x 1:i ) obeys the joint Gaussian distribution as shown in formula (22);
[0049]
[0050] Among them, f(x i+1 ) represents the sampling point x i+1 The objective function value RMSE, represents the mean vector;
[0051] Then f(x i+1 ) is:
[0052] f(x i+1 |D 1:i ,x i+1 )~N(μ(x i+1 ),σ 2 (x i+1 )), μ(x i+1 )=(K(x,x'),x i+1 ,x 1:i ) T K(x,x') -1 f(x 1:i ),
[0053] k(x i+1 ,x 1:i ) T K(x,x') -1 f(x 1:i ),σ 2 (x i+1 )=k(x i+1 ,x 1:i )-(K(x,x'),x i+1 ,x 1:i ) T K(x,x') -1 (K(x,x'),x i+1 ,x 1:i ) (twenty three)
[0054] Among them, f(x i+1 |D 1:i ,x i+1 ) means that in a given data set D 1:iand a specific variable x i+1 Under the condition that f(x i+1 ) distribution; μ(x i+1 ) is f(x i+1 )’s conditional mean; σ 2 (x i+1 ) is f(x i+1 ) conditional variance;
[0055] x i+1 It is obtained by sampling the acquisition function, as shown in formula (24);
[0056]
[0057] Among them, Acq(x i+1 ) represents the acquisition function;
[0058] (9) Calculate the new point x i+1 The result f(x i+1 ) and update the objective function f' 1:i+1 ;
[0059] (10) Iteration: repeat steps (8) to (9) until the number of iterations is reached or the convergence condition is met;
[0060] (11) Output the optimal hyperparameter combination: objective function f' 1:i+1 The minimum value f min (x best ) and the corresponding optimal hyperparameter combination x best The present invention optimizes the hyperparameters of the random forest prediction model through the Bayesian algorithm to improve the prediction accuracy of the wax deposition rate, avoiding the situation where the model prediction accuracy is low due to random adjustment of the hyperparameters and the model hyperparameters cannot be effectively controlled. By continuously monitoring and optimizing the model, the model prediction accuracy is improved, providing more accurate guidance for determining the wellbore wax cleaning cycle. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0062] Figure 1 It is a flow chart of a wellbore wax cleaning cycle prediction method provided by the present invention;
[0063] Figure 2 This is a schematic diagram of a specific process of optimizing hyperparameters based on a Bayesian algorithm provided by an embodiment of the present invention;
[0064] Figure 3 It is a principle diagram of a wax deposition rate prediction method based on Bayesian optimization random forest provided by an embodiment of the present invention; DETAILED DESCRIPTION
[0065] In order to enable those skilled in the art to better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application. It should also be further understood that the term "and / or" used in the specification of the present invention and the attached claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0066] Figure 1 The present invention provides a method for predicting the period of wax removal in a wellbore. Figure 1 It can be seen that the method includes: collecting wax deposition experimental data under the simulated working conditions of the carbon dioxide drive production well and calculating the experimental value of the wax deposition rate; preprocessing the sample data; constructing an initial random forest regression model and optimizing the hyperparameters in the model using the Bayesian algorithm; training the optimized random forest model using the processed sample data under the simulated working conditions of the carbon dioxide drive production well; obtaining the real-time wax deposition data of the carbon dioxide drive production well working conditions; inputting the real-time wax deposition data into the trained random forest model to predict the real-time wax deposition rate; and predicting the wax removal cycle according to the wax deposition rate.
[0067] Figure 2 is a schematic diagram of a specific process of optimizing hyperparameters based on a Bayesian algorithm provided by an embodiment of the present invention, comprising Figure 2It can be seen that the specific steps of the Bayesian algorithm to optimize the hyperparameters in the random forest prediction model include: building an initial random forest prediction model; defining the objective function, and taking the standard error RMSE as the objective function; defining the Gaussian process, and using the Bayesian optimization algorithm to establish the relationship between the hyperparameters and the objective function; initializing the hyperparameter space, selecting max_features (the maximum number of features considered when building the optimal decision tree model), min_samples_leaf (this parameter controls the minimum number of samples for re-dividing internal nodes), and n_estimators (this parameter controls the number of decision trees) as the hyperparameters for optimizing the random forest regression prediction model and defining their value ranges; collecting initial observation points, randomly selecting some hyperparameter combinations, calculating the objective function value and obtaining the sampling set; building a proxy model, and using Gaussian process regression to fit the initial observation points; selecting the acquisition function; optimizing the acquisition function, maximizing the acquisition function in the hyperparameter space to find the next sampling point; calculating the results of the new point and updating the objective function; iterating until the number of iterations is reached or the convergence condition is met; outputting the optimal hyperparameter combination to obtain the optimal prediction model.
[0068] Figure 3 is a schematic diagram of a wax deposition rate prediction method based on Bayesian optimization random forest provided by an embodiment of the present invention, comprising Figure 3 It can be seen that the prediction model first uses the Bayesian algorithm to optimize the hyperparameters in the random forest model, and then establishes multiple parallel decision trees, and then outputs the final prediction results through majority voting of the results of each decision tree.
[0069] Example 1: Random forest, as an advanced algorithmic tool, is particularly suitable for processing imprecise and fuzzy information processing problems that require consideration of many factors and conditions at the same time. In order to solve the problem of overfitting that may occur when random forest performs regression prediction, the Bayesian algorithm is used to optimize the hyperparameters in the random forest prediction model, and the prediction results of the optimized model are compared with the prediction results of the initial random forest model, providing a more accurate wax removal cycle prediction method for monitoring the wax deposition rate of carbon dioxide drive production well conditions.
[0070] The specific implementation process is as follows:
[0071] 1) Collect wax deposition experimental data under simulated working conditions of CO2 flooding production wells and calculate the experimental value of wax deposition rate.
[0072] Furthermore, the step 1) comprises the following steps:
[0073] 1-1) Collecting wax deposition experimental data under simulated working conditions of carbon dioxide flooding production wells, including: at least 5 groups of data under different crude oil temperatures (°C), at least 5 groups of data under different carbon dioxide pressures (MPa), at least 5 groups of data under different wax contents (%), and at least 13 data groups, wherein the temperature gradient is 30, 35, 40, 45, 50°C, the carbon dioxide pressurization pressure gradient is 0, 1, 2, 3, 4MPa, and the wax content gradient is 6%, 8%, 10%, 12%, 14%. At the same time, the flow rate (m / s), crude oil dynamic viscosity (Pa·s) and oil-water ratio of each group are collected, as shown in Table 1;
[0074] 1-2) Collect the data of the experimental wax deposition mass (g), deposition time (h), and wax deposition area (㎡) of each group, substitute them into formula (2), and obtain the experimental value of the wax deposition rate of each data group. The wax deposition rate values corresponding to different experimental data groups are shown in Table 1;
[0075]
[0076] Where: v 实验 is the experimental value of wax deposition rate, g / (㎡·h); m 实验 is the mass of experimental wax deposit, g; t is the deposition time, h, which is 24 h in this embodiment; s is the wax deposition area, m2, which is 0.0017 m2 in this embodiment;
[0077] Table 1 Different experimental data groups and their corresponding wax deposition rate experimental values
[0078]
[0079] 2) Preprocessing sample data, including crude oil temperature (°C), carbon dioxide pressure (MPa), wax content (%), flow rate (m / s), crude oil dynamic viscosity (Pa·s) and oil-water ratio.
[0080] Furthermore, the step 2) comprises the following steps:
[0081] 2-1) Data integration: All data in various formats are stored in a data platform warehouse that includes data acquisition, data statistics, data mapping, hierarchical extraction, error recovery and security conversion functions;
[0082] 2-2) Data cleaning: Missing values can be filled with the mean, median or mode, and outliers can be identified by drawing box plots, scatter plots, etc. You can choose to delete outliers, perform data transformation, or treat them as a separate category.
[0083] 3) Build an initial random forest regression model using the model’s default parameter settings.
[0084] Furthermore, the step 3) comprises the following steps:
[0085] 3-1) Divide the data set, randomly select 80% of the data samples as the training set, and the remaining 20% of the data samples as the test set; 3-2) Train the random forest model, initialize a random forest regression model with 88 trees and train it on the training set to obtain the predicted value of the training set before Bayesian optimization, and the corresponding experimental value of wax deposition rate is shown in Table 2;
[0086] Table 2 Predicted values of wax deposition rate in the training set before optimization and their corresponding experimental values of wax deposition rate
[0087]
[0088] 4) Use the initial random forest model to predict the wax deposition rate and evaluate the results.
[0089] Furthermore, the step 4) comprises the following steps:
[0090] 4-1) Calculate and output the standard error (RMSE) of the model on the training set and test set as formula (4) and the coefficient of determination (R 2 ) As shown in formula (5), we can get the R of the random forest model on the training set 2 and RMSE were 0.931 and 2.899 respectively, while the R 2 and RMSE were 0.861 and 3.177, respectively;
[0091]
[0092] Among them, y i is the model measured value, is the model prediction value, is the mean of the measured values, R 2 The value range is [0,1]. The closer the value is to 1, the better the model prediction effect is. Generally, a value greater than 0.8 indicates that the model has high prediction accuracy. The value of RMSE is ≥ 0. When the predicted value is completely consistent with the true value, the value is 0, that is, a perfect model. The smaller the error, the smaller the value.
[0093] 4-2) Print out the predicted values of the test set before Bayesian optimization and the corresponding experimental values of wax deposition rate, and the results are shown in Table 3;
[0094] Table 3 Predicted values of wax deposition rate of the test set before optimization and their corresponding experimental values of wax deposition rate
[0095]
[0096] 5) Build an initial random forest regression model and use the Bayesian algorithm to optimize the hyperparameters in the model.
[0097] Furthermore, the step 5) comprises the following steps:
[0098] 5-1) Construct an initial random forest regression model;
[0099] 5-2) Define the objective function and use the Bayesian optimization algorithm to establish the relationship between the hyperparameters and the objective function, where the standard error RMSE is used as the objective function;
[0100] 5-3) Define Gaussian process. If the objective function f(x) obeys Gaussian distribution, then any number of hyperparameter combinations will also obey joint Gaussian distribution, expressed by mean function m(x) as formula (6) and covariance function k(x,x') as formula (7);
[0101] m(x)=E[f(x)] (6)
[0102] k(x,x')=E[(f(x)-m(x))(f(x')-m(x'))] (7)
[0103] Among them, the mean function m(x) represents the expectation of any variable, and the mean function is usually set to 0; E represents mathematical expectation, which is used to describe the average value of a random variable; x and x' represent different hyperparameter combinations, and the covariance function k(x,x') uses the Matern kernel function;
[0104] 5-4) Initialize the hyperparameter space, select max_features (the maximum number of features considered when building the optimal decision tree model), min_samples_leaf (this parameter controls the minimum number of samples for re-dividing internal nodes), and n_estimators (this parameter controls the number of decision trees) as the hyperparameters for optimizing the random forest regression prediction model and define their value ranges, as shown in Table 4;
[0105] Table 4 Hyperparameter setting range
[0106]
[0107] 5-5) Collect initial observation points, set the initial point to 250, randomly select some hyperparameter combinations, calculate the objective function value and obtain the sampling set;
[0108] 5-6) Construct a proxy model and use Gaussian process regression to fit the initial observation points;
[0109] 5-7) Select the acquisition function;
[0110] 5-8) Optimize the acquisition function and maximize the acquisition function in the hyperparameter space to find the next sampling point;
[0111] 5-9) Calculate the results of the new point and update the objective function;
[0112] 5-10) Iteration, set the number of iterations to 50, that is, N = 300, and repeat steps 5-8) to 5-9) until the number of iterations is reached or the convergence condition is met;
[0113] 5-11) Output the optimal hyperparameter combination, that is, the minimum value of the objective function and the corresponding hyperparameter combination.
[0114] 6) The optimized random forest model is trained using the processed sample data of the CO2 flooding production well conditions.
[0115] Furthermore, the step 6) comprises the following steps:
[0116] 6-1) Divide the data set, randomly select 80% of the data samples as the training set, and the remaining 20% of the data samples as the test set; 6-2) Train the random forest model after Bayesian optimization to obtain the predicted value of the optimized training set, and the corresponding actual value of the wax deposition rate is shown in Table 5;
[0117] Table 5 Predicted values of wax deposition rate of the optimized training set and their corresponding experimental values of wax deposition rate
[0118]
[0119] 7) Use the optimized and trained random forest model to predict the wax deposition rate and evaluate the results.
[0120] Furthermore, the step 7) comprises the following steps:
[0121] 7-1) Calculate and output the standard error (RMSE) and coefficient of determination (R) of the model on the training set and test set 2 ), we can get the R of the Bayesian optimization random forest model in the training set 2 and RMSE were 0.974 and 1.761 respectively, and the R 2 and RMSE were 0.906 and 2.615, respectively;
[0122] 7-2) Print out the predicted value of the test set after Bayesian optimization and its corresponding experimental value of wax deposition rate, the results are shown in Table 6;
[0123] Table 6 Predicted values of wax deposition rate of the optimized test set and their corresponding experimental values of wax deposition rate
[0124]
[0125] 8) Predict the wax cleaning cycle based on the wax deposition rate.
[0126] Furthermore, the step 8) predicts the wax removal cycle according to the wax deposition rate, and the prediction results are shown in Table 7, which specifically includes the following steps:
[0127] 7-1) Calculate the Reynolds number Re of crude oil flow in the oil pipe as shown in formula (16);
[0128]
[0129] Where: Re is the Reynolds number of crude oil flow in the oil pipe, dimensionless; l0 is the density of crude oil, kg / m 3 In this embodiment, 865 kg / m 3 ; v0 is the crude oil flow rate, m / s; d is the inner diameter of the oil pipe, m, which is 0.072m in this embodiment; γ is the dynamic viscosity of the crude oil, Pa·s; 7-2) Determine the flow state. When Re≤2000, the flow state of the crude oil in the oil pipe is laminar flow. The critical wax deposition thickness is calculated as shown in formula (17);
[0130]
[0131] Where: h is the critical wax deposition thickness, m; Q is the initial volume flow rate, m 3 / s, in this embodiment, 8.14×10 -4 m 3 / s;
[0132] When Re>2000, the crude oil flow in the oil pipe is turbulent, and the critical wax deposition thickness is calculated as shown in formula (18);
[0133]
[0134] Where: h is the critical wax deposition thickness, m; α is the multiple of the head loss along the way after wax deposition, usually 1.5 to 2, and 2 in this embodiment;
[0135] 7-3) Calculate the wax deposition rate correction factor as shown in formula (19);
[0136]
[0137] Where: k is the wax deposition correction factor, dimensionless; m1 is the actual wax deposition mass, g; m 实验 is the mass of experimental wax sediment, g;
[0138] 7-4) Predict the wax cleaning cycle as shown in formula (1);
[0139]
[0140] Where: T is the wax cleaning cycle, h; β is the wax deposition rate correction coefficient, which is calculated by formula (19) in this embodiment to be β = 0.3; l is the wax density, kg / m 3In this embodiment, 920 kg / m 3 ; d is the inner diameter of the oil pipe, m; h is the critical wax deposition thickness, m; e is the roughness of the oil pipe, m, which is 1.52×10 -6 m; v is the predicted value of wax deposition rate after optimization, g / (㎡·h).
[0141] Table 7 Wax removal cycle of a wellbore
[0142]
[0143] In summary, the initial random forest model of the embodiment has a very good model fitting effect on the training set, but poor performance on the test set, indicating that the random forest model has a certain degree of overfitting, further illustrating that the use of the model default parameter settings does not obtain good performance. Compared with the random forest model with default parameter settings, the random forest model after Bayesian optimization has greatly improved accuracy on both the training set and the test set, indicating that the Bayesian optimized random forest model has good generalization ability and better prediction accuracy in predicting wax deposition rate, and can provide more accurate guidance for determining the wellbore wax cleaning cycle of a carbon dioxide flooding oil well in a certain oil field.
[0144] The specific implementation modes of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.
Claims
1. A method for predicting a wellbore wax cleaning cycle, characterized in that: The following steps are involved: 1) Collect wax deposition experimental data under simulated working conditions of CO2 flooding production wells and calculate the wax deposition rate experimental value; 2) Preprocessing sample data, including crude oil temperature (°C), carbon dioxide pressure (MPa), wax content (%), flow rate (m / s), crude oil dynamic viscosity (Pa·s) and oil-water ratio; 3) Build an initial random forest regression model and use the Bayesian algorithm to optimize the hyperparameters in the model; 4) Using the processed sample data under the simulated working conditions of the CO2 flooding production well to train the optimized random forest model; 5) Obtaining real-time wax deposition data of CO2 flooding production well conditions; 6) Input the real-time wax deposition data into the trained random forest model to predict the real-time wax deposition rate; 7) Predicting the wax removal cycle according to the wax deposition rate, as shown in formula (1); Where: T is the wax cleaning cycle, h; β is the wax deposition rate correction coefficient; l is the wax density, kg / m 3 ; d is the inner diameter of the oil pipe, m; h is the critical wax deposition thickness, m; e is the roughness of the oil pipe, m; v is the predicted value of the optimized wax deposition rate, g / (㎡·h).
2. A method for predicting a wellbore paraffin removal cycle according to claim 1, characterized in that: The step 1) specifically includes: 1-1) collecting wax deposition experimental data under simulated working conditions of carbon dioxide flooding production wells, including: at least 5 groups of data under different crude oil temperatures (°C), at least 5 groups of data under different carbon dioxide pressures (MPa), at least 5 groups of data under different wax contents (%), and at least 13 data groups, and simultaneously collecting the flow rate (m / s), crude oil dynamic viscosity (Pa·s) and oil-water ratio of each group; 1-2) Collect the data of the experimental wax deposition mass (g), deposition time (h), and wax deposition area (㎡) of each group, substitute them into formula (2), and obtain the experimental value of wax deposition rate of each data group; Where: v 实验 is the experimental value of wax deposition rate, g / (㎡·h); m 实验 is the mass of experimental wax deposit, g; t is the deposition time, h; s is the wax deposition area, ㎡.
3. A method for predicting a wellbore wax removal cycle according to claim 1, characterized in that: The step 2) specifically includes: 2-1) data integration: storing all data in various formats into a data platform warehouse that includes data acquisition, data statistics, data mapping, hierarchical extraction, error recovery and security conversion functions; 2-2) Data cleaning: Missing values can be filled with the mean, median or mode, and outliers can be identified by drawing box plots, scatter plots, etc. You can choose to delete outliers, perform data transformation, or treat them as a separate category.
4. A method for predicting a wellbore paraffin removal cycle according to claim 1, characterized in that: The step 3) constructs an initial random forest regression model and optimizes the hyperparameters in the model using a Bayesian algorithm, specifically comprising: 3-1) constructing an initial random forest prediction model; 3-2) Define the objective function, take the standard error RMSE as the objective function, and use the Bayesian optimization algorithm to establish the relationship between the hyperparameters and the objective function, specifically including: Bayesian optimization estimates the posterior probability distribution of the objective function f(x) based on the Bayesian theorem, samples the hyperparameter combination based on the posterior distribution, and continuously improves the shape of the posterior distribution according to the objective function value, so as to find the global optimal solution of the objective function, as shown in formula (3); Among them, x * is a hyperparameter combination, χ is the parameter space, and f(x) is the objective function. 3-3) Define Gaussian process; 3-4) Initialize the hyperparameter space, select max_features (the maximum number of features considered when building the optimal decision tree model), min_samples_leaf (this parameter controls the minimum number of samples for re-dividing internal nodes), and n_estimators (this parameter controls the number of decision trees) as the hyperparameters for optimizing the random forest regression prediction model and define their value ranges; 3-5) Collect initial observation points, randomly select some hyperparameter combinations, calculate the objective function value and obtain the sampling set; 3-6) Construct a proxy model and use Gaussian process regression to fit the initial observation points; 3-7) Select the acquisition function; 3-8) Optimize the acquisition function and maximize the acquisition function in the hyperparameter space to find the next sampling point; 3-9) Calculate the results of the new point and update the objective function; 3-10) Iteration, repeat steps 3-8) to 3-9) until the number of iterations is reached or the convergence condition is met; 3-11) Output the optimal hyperparameter combination to obtain the optimal prediction model.
5. A method for predicting a wellbore paraffin removal cycle according to claim 1, characterized in that: The step 4) uses the processed sample data under the simulated working conditions of the carbon dioxide flooding production well to train the optimized random forest model, specifically comprising: 4-1) randomly extracting samples with replacement from the processed sample data under the simulated working conditions of the carbon dioxide flooding production well to form a training set; 4-2) Input the training set into the optimized random forest prediction model, and after iterative calculation, obtain the trained random forest prediction model.
6. A method for predicting a wellbore paraffin removal cycle according to claim 1, characterized in that: The step 5) obtains real-time wax deposition data of the carbon dioxide flooding production well working conditions, specifically including: crude oil temperature (°C), carbon dioxide pressure (MPa), flow rate (m / s), oil-water ratio, crude oil dynamic viscosity (Pa·s), and wax content (%).
7. A method for predicting a wellbore paraffin removal cycle according to claim 1, characterized in that: The step 6) inputs the real-time wax deposition data into the trained random forest model to predict the real-time wax deposition rate, specifically comprising: 6-1) Visualize the prediction results of the random forest model on the training set and test set 2, show the relationship between the true value and the predicted value through a scatter plot, and draw a diagonal line (perfect fit line) to intuitively show the performance of the model; 6-2) Use the coefficient of determination R 2 The prediction performance of the model is evaluated as shown in formula (4) and the standard error RMSE is shown in formula (5) to obtain the evaluation results; Among them, y i is the model measured value, is the model prediction value, is the mean of the measured values, R 2 The value range is [0,1]. The closer the value is to 1, the better the model prediction effect is. Generally, a value greater than 0.8 indicates that the model has high prediction accuracy. The value of RMSE is ≥ 0. When the predicted value is completely consistent with the true value, the value is 0, that is, a perfect model. The smaller the error, the smaller the value.
8. The method of constructing an initial random forest regression model and optimizing hyperparameters in the model using a Bayesian algorithm according to claim 4, characterized in that: The step 3-3) specifically includes: If the objective function f(x) obeys the Gaussian distribution, then any number of hyperparameter combinations will also obey the joint Gaussian distribution, expressed by the mean function m(x) as in equation (6) and the covariance function k(x,x') as in equation (7); m(x)=E[f(x)] (6) k(x,x')=E[(f(x)-m(x))(f(x')-m(x'))] (7) Among them, the mean function m(x) represents the expectation of any variable, and the mean function is usually set to 0; E represents mathematical expectation, which is used to describe the average value of a random variable; x and x' represent different hyperparameter combinations, and the covariance function k(x,x') uses the Matern kernel function; If there are i sampling points D1=[x 1:i ,f(x 1:i )] obeys the Gaussian process prior distribution, that is: f(x 1:i )~GP[m(x 1:i ),K(x,x')] (8) When a new sampling point x is obtained i+1 According to the properties of Gaussian process, f(x i+1 ) and f(x 1:i ) obeys the joint Gaussian distribution as shown in formula (10); Then, f(x i+1 The posterior distribution of ) is as shown in formula (11); f(x i+1 )~N(k(x i+1 ,x 1:i ) T K(x,x') -1 f(x 1:i ),k(x i+1 ,x 1:i )-k(x i+1 ,x i+1 ) T K(x,x') -1 k(x i+1 ,x 1:i )) (11) By continuously adding new sampling points and repeating the above Gaussian process, the true target function f(x) can be approached.
9. The method of constructing an initial random forest regression model and optimizing hyperparameters in the model using a Bayesian algorithm according to claim 4, characterized in that: The commonly used acquisition functions in step 3-7) include expected improvement function, confidence limit criterion, probability improvement function, etc., which are as follows: 3-7-1) The expected boosting acquisition function takes the point with the maximum expected posterior distribution as the new sampling point, as shown in formula (12); EI(x)=E Q (max(0,μ Q (x best )-mf(x))) (12) Among them, μ Q (x) is the expectation of the posterior distribution, x best is the point where the posterior distribution expectation reaches the optimal point, and m is the trade-off coefficient; 3-7-2) The confidence limit criterion acquisition function directly searches for new samples in the upper and lower confidence limits of the posterior distribution. It can be divided into an upper confidence limit function such as formula (13) and a lower confidence limit function such as formula (14). The minimum or maximum value of the objective function is solved by minimizing the lower confidence limit or maximizing the upper confidence limit. UCB(x)=μ Q (x)+kσ Q (x) (13) LCB(x)=μ Q (x)-kσ(x) (14) Among them, σ Q (x) is the standard deviation of the posterior distribution, k is the uncertainty coefficient, whose size affects the area explored; 3-7-3) The probability enhancement acquisition function takes the point with the largest standard normal cumulative distribution as the new sampling point, as shown in formula (15); where Φ(·) is the standard normal cumulative distribution function.
10. A method for predicting a wellbore paraffin removal cycle according to claim 1, characterized in that: The step 7) predicting the wax removal cycle according to the wax deposition rate specifically includes: 7-1) Calculate the Reynolds number Re of crude oil flow in the oil pipe as shown in formula (16); Where: Re is the Reynolds number of crude oil flow in the oil pipe, dimensionless; l0 is the density of crude oil, kg / m 3 ; v0 is the crude oil flow rate, m / s; d is the inner diameter of the oil pipe, m; γ is the dynamic viscosity of the crude oil, Pa·s; 7-2) Determine the flow state. When Re≤2000, the flow state of crude oil in the oil pipe is laminar flow. The critical wax deposition thickness is calculated as shown in formula (17); Where: h is the critical wax deposition thickness, m; Q is the initial volume flow rate, m 3 / s; When Re>2000, the crude oil flow in the oil pipe is turbulent, and the critical wax deposition thickness is calculated as shown in formula (18); Where: h is the critical wax deposition thickness, m; α is the multiple of the head loss along the way after wax deposition, usually 1.5 to 2; 7-3) Calculate the wax deposition rate correction factor as shown in formula (19); Where: k is the wax deposition correction factor, dimensionless; m1 is the actual wax deposition mass, g; m 实验 is the mass of experimental wax sediment, g; 7-4) Predict the wax cleaning cycle as shown in formula (1).
Citation Information
Cited By
Method and device for constructing digital real-time simulation model of generator stator
CN120068668A
New energy power generation multi-disaster impact analysis method and system in extreme weather
CN120387557A