Method for checking wellbore temperature field during cementing based on random forest algorithm
By optimizing the wellbore temperature field verification method using the random forest algorithm, the problems of deviation and low parameter adjustment efficiency in wellbore temperature field prediction are solved, achieving more efficient and accurate temperature field simulation and improving the reliability of cementing design and construction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SOUTHWEST PETROLEUM UNIV
- Filing Date
- 2026-01-14
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies rely on empirical formulas for predicting wellbore temperature fields, leading to discrepancies between calculated values and actual heat exchange efficiency. Furthermore, the efficiency of parameter adjustment is low, making it difficult to adapt to complex well conditions and affecting the optimization of cement slurry performance and the safety of cementing operations.
A method for verifying the temperature field of a wellbore is constructed using the random forest algorithm. By establishing a multi-region coupled transient heat transfer model, parameter optimization is performed using measured data, and the convective heat transfer coefficient is automatically calibrated to achieve intelligent parameter optimization.
It improves the accuracy and adaptability of wellbore temperature field simulation, reduces reliance on human experience, and provides a more reliable basis for cementing design and construction.
Smart Images

Figure CN121960155A_ABST
Abstract
Description
A method for verifying the temperature field of the wellbore during cementing based on the random forest algorithm Technical Field
[0001] This invention relates to the field of cementing engineering for oil and gas wells, and more specifically to a method for verifying the wellbore temperature field during cementing based on a random forest algorithm. Background Technology
[0002] In oil and gas well cementing operations, accurate prediction of wellbore temperature is crucial for ensuring cement slurry performance, optimizing thickening time design, and ensuring cementing construction safety.
[0003] Currently, obtaining the temperature field in wellbore mainly relies on numerical simulation methods, which involve establishing a multi-region coupled transient heat transfer model that includes the fluid inside the tubing, the tubing wall, the annulus, and the formation. Although such physical models can describe complex heat transfer processes, their solutions depend on numerous input parameters. Among these, the convective heat transfer coefficient, calculated by empirical formulas, is a key and significantly influential variable. Existing techniques typically use classical formulas based on Reynolds number and Prandtl number to estimate this coefficient. However, these formulas originate from specific experimental conditions and fail to fully consider the complex geometry, multiphase fluid characteristics, and dynamically changing flow states in actual wellbores, resulting in a non-negligible deviation between the calculated values and the actual heat exchange efficiency.
[0004] Furthermore, in order to compensate for the inherent biases of classical formulas, empirical correction coefficients are often introduced in practice to manually adjust the convective heat transfer formulas. This parameter adjustment process is highly dependent on the personal experience of engineers and lacks objective and unified standards. Since the heat transfer model itself is highly nonlinear, manually adjusting parameters is not only time-consuming and laborious, but also difficult to find the global optimal solution in the vast parameter space, which severely restricts the calibration efficiency and final accuracy of the model.
[0005] Furthermore, even when attempting to improve parameters through optimization algorithms, the challenge of computational efficiency remains. If global parameter optimization is performed directly based on a high-fidelity transient heat transfer model of the wellbore, a complete numerical simulation needs to be run for each parameter evaluation, resulting in extremely high computational costs. For optimization processes that require a large number of iterations, this traditional simulation-evaluation model is often impractical in practical engineering applications due to its excessive time consumption, thus limiting the application of advanced optimization algorithms in solving such inverse engineering problems.
[0006] Therefore, how to design a wellbore temperature field verification method based on the random forest algorithm during cementing, so as to overcome the limitations of empirical formulas, improve the reliability of temperature field prediction models and their adaptability to different well conditions, is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0007] In view of this, the present invention provides a method for verifying the wellbore temperature field during cementing based on the random forest algorithm. It aims to solve the problems of insufficient temperature prediction accuracy caused by the difficulty in accurately determining the convective heat transfer coefficient of the wellbore heat transfer model, and the low efficiency of parameter adjustment relying on manual trial and error. By constructing a data-driven intelligent optimization process, the model parameters can be automatically and quickly verified to obtain a temperature field that is more consistent with the actual working conditions, and ultimately serve the optimization design of cement slurry formulation and cementing construction process.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: a method for verifying the wellbore temperature field during cementing based on a random forest algorithm, comprising the following steps: S1, establishing a transient heat transfer model of the wellbore during the cementing process, and setting the value range of correction parameters for the convective heat transfer coefficients of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall respectively; S2, randomly generating multiple sets of initial parameter combinations within the value range of each correction parameter, inputting each set of initial parameter combinations into the transient heat transfer model of the wellbore for temperature field simulation, and obtaining the corresponding simulated temperature distribution; S3, comparing the simulated temperature distribution with the measured temperature data, calculating the temperature error corresponding to each set of parameter combinations, and constructing a model based on the initial parameter combinations and their corresponding temperature errors. S4. Establish an initial training sample set; S5. Train a random forest model using the initial training sample set to establish a nonlinear mapping relationship between parameter combinations and temperature error; S6. Randomly generate multiple candidate parameter combinations again within the range of the corrected parameter values, use the trained random forest model to predict the error of each candidate parameter combination, and select the top K parameter combinations with the smallest prediction error as the preferred parameter set; S7. Based on the preferred parameter set, verify and compare it with the wellbore transient heat transfer model to determine the optimal convection heat transfer coefficient correction parameter combination; S8. Apply the optimal convection heat transfer coefficient correction parameter combination to the wellbore transient heat transfer model to obtain the verified wellbore temperature field during the cementing process.
[0009] Preferably, in S1, the transient heat transfer model of the wellbore includes: a fluid heat transfer model inside the tubing, a tubing wall heat transfer model, an annular fluid heat transfer model, a wellbore heat transfer model, and a near-wellbore formation heat transfer model, and the model is discretized and solved using the finite difference method.
[0010] Preferably, in S1, the correction parameters for the convective heat transfer coefficients of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall are respectively... , , The range of values is .
[0011] Preferably, in S1, the convective heat transfer coefficients of the inner wall of the tubing, the outer wall of the tubing, and the well wall are... , , They are represented as follows:
[0012]
[0013]
[0014] in, For fluid thermal conductivity, Let Reynolds number be 1. For Prandtl numbers, , , These are the inner wall radius of the tubing string, the outer wall radius of the tubing string, and the wellbore radius, respectively. Preferably, in step S3, the temperature error corresponding to each parameter combination is calculated as follows:
[0015] in, This represents the u-th parameter combination. This represents the simulated temperature at depth index j and time index t under this set of parameters. This indicates the measured temperature at the corresponding location and time.
[0016] Preferably, step S4 includes: using each parameter combination in the initial training sample set as an input feature vector and the corresponding temperature error value as a target label; randomly sampling multiple training subsets with replacement from the initial training sample set using a bootstrap sampling method; training a decision tree for each training subset; when splitting at each node of each decision tree, randomly selecting a feature subset from all parameter features, and selecting the optimal splitting feature and splitting threshold from the feature subset to minimize the prediction error; integrating all trained decision trees to form a random forest model, and for a new parameter combination, using the average of the prediction results of all decision trees as the temperature error predicted by the random forest model.
[0017] Preferably, step S6 includes: inputting each parameter combination from the preferred parameter set into the wellbore transient heat transfer model, calculating the simulated temperature value of each parameter combination under specified time and depth conditions; comparing the simulated temperature value with the corresponding measured temperature data, and selecting the parameter combination with the smallest verification error as the current optimal parameter combination; if the verification error of the current optimal parameter combination is less than a preset error threshold, then the current optimal parameter combination is determined as the optimal convective heat transfer coefficient correction parameter combination; otherwise, returning to step S5 for iterative optimization.
[0018] Preferably, step S7 includes: substituting the optimal combination of convective heat transfer coefficient correction parameters into the convective heat transfer coefficient correction formula to calculate the verified convective heat transfer coefficients of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall; using the verified convective heat transfer coefficients as key input parameters, initializing and running the wellbore transient heat transfer model to simulate the entire process from the start of cementing operations to the end of setting time, and calculating the temperature field inside the wellbore that varies with time t and well depth z. From the temperature field Extract temperature information to guide engineering design.
[0019] As can be seen from the above technical solution, compared with the prior art, the technical solution of the present invention has the following beneficial effects: 1. The method constructs a transient wellbore heat transfer physical model containing multiple heat transfer sub-processes, and uses the random forest algorithm to perform data-driven intelligent optimization of the key and difficult-to-determine convective heat transfer coefficient in the model, so that the model parameters can be automatically calibrated based on the measured temperature data of a specific well, thereby reducing the systematic deviation between the model prediction results and the actual working conditions, and providing a more reliable basis for cementing design and construction.
[0020] 2. By introducing the random forest algorithm from machine learning into the parameter optimization process of traditional engineering models, and establishing a nonlinear mapping relationship between parameter combinations and model errors, it is possible to quickly pre-screen and evaluate massive candidate parameter combinations. This changes the inefficient parameter tuning mode that relies on manual experience and trial and error, realizes the intelligent optimization process of the key parameter convective heat transfer coefficient, and improves optimization efficiency.
[0021] 3. This method does not rely on a single fixed empirical formula. Its core lies in using the measured data of specific wells to perform targeted calibration of the general heat transfer model. This data-based calibration mechanism enables the same method framework to flexibly adapt to complex well conditions with different well structures, different fluid properties and different operating conditions, thereby improving the generalization ability of well temperature field simulation. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0023] Figure 1 is a flowchart of a wellbore temperature field verification method based on random forest algorithm provided by an embodiment of the present invention; Figure 2 is a comparison diagram of simulated and measured drilling fluid circulation outlet temperature under unverified conditions provided by an embodiment of the present invention; Figure 3 is a comparison diagram of simulated and measured outlet temperature of the cementing process under unverified conditions provided by an embodiment of the present invention; Figure 4 is a comparison diagram of simulated and measured drilling fluid circulation outlet temperature after verification provided by an embodiment of the present invention; Figure 5 is a comparison diagram of simulated and measured outlet temperature of the cementing process after verification provided by an embodiment of the present invention. Detailed Implementation
[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] As shown in Figure 1, this embodiment provides a method for verifying the wellbore temperature field during cementing based on the random forest algorithm, including the following steps: S1, establishing a transient heat transfer model of the wellbore during the cementing process, and setting the value range of the correction parameters for the convective heat transfer coefficients of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall respectively; S2, randomly generating multiple sets of initial parameter combinations within each correction parameter value range, inputting each set of initial parameter combinations into the transient heat transfer model of the wellbore for temperature field simulation, and obtaining the corresponding simulated temperature distribution; S3, comparing the simulated temperature distribution with the measured temperature data, calculating the temperature error corresponding to each set of parameter combinations, and constructing an initial training model based on the initial parameter combinations and their corresponding temperature errors. S4. Using the initial training sample set, train a random forest model to establish a nonlinear mapping relationship between parameter combinations and temperature error; S5. Within the range of the corrected parameter values, randomly generate multiple sets of candidate parameter combinations again, use the trained random forest model to predict the error of each candidate parameter combination, and select the top K sets of parameter combinations with the smallest prediction error as the preferred parameter set; S6. Based on the preferred parameter set, verify and compare it with the wellbore transient heat transfer model to determine the optimal convection heat transfer coefficient correction parameter combination; S7. Apply the optimal convection heat transfer coefficient correction parameter combination to the wellbore transient heat transfer model to obtain the verified wellbore temperature field during the cementing process.
[0026] By combining the random forest algorithm with the transient heat transfer model of the wellbore, it realizes an intelligent parameter verification method. Driven by measured data, it can efficiently and automatically optimize the key parameter of convective heat transfer coefficient in the heat transfer model, thereby improving the accuracy of wellbore temperature field simulation. This not only reduces the dependence on human experience, but also enhances the model's adaptability to different well conditions, providing a more reliable theoretical calculation basis for cementing design and construction.
[0027] The following provides a further detailed description of each step in the above method; In this embodiment, S1, a transient heat transfer model of the wellbore during the cementing process is established, and the range of values for the correction parameters of the convective heat transfer coefficient of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall is set respectively; wherein, the transient heat transfer model of the wellbore includes: (1) a heat transfer model inside the tubing string; during the downward flow of drilling fluid, the heat transfer and radial heat convection that occur cause the temperature of the fluid inside the pipe to change, and the heat transfer model can be expressed as:
[0028] In the formula , These represent the fluid temperature inside the tubing and the tubing wall temperature, respectively, in °C; The fluid density is expressed in kg / m³. Specific heat capacity of the fluid; J / (kg·℃); The displacement of the fluid is expressed in m³ / s. This represents the convective heat transfer coefficient of the inner wall of the tube column, in W / (m2·℃). Let be the inner radius of the tubular column, in meters (m). The heat generated by friction during fluid circulation within the pipe, J; For time, s; The axial direction.
[0029] (2) Heat transfer model of the tube wall; the factors affecting the temperature of the tube wall are the convective heat transfer between its inner and outer wall surfaces and the fluid. The model can be expressed as:
[0030] In the formula Let be the outer radius of the tubular column, in meters (m). is the convective heat transfer coefficient of the outer wall of the tube column, W / (m2·℃); The annular fluid temperature is ℃; The density of the tubular column is kg / m³. is the specific heat capacity of the tube column, J / (kg·℃); is the thermal conductivity of the tubular column, W / (m·℃).
[0031] (3) Annular fluid heat transfer model; During the upward flow of the annular fluid, convective heat transfer occurs with the outer wall of the tubing and the well wall. Ignoring the radial velocity gradient of the fluid and the axial heat conduction of the tubing, the annular temperature model can be expressed as:
[0032] In the formula The temperature of the well wall surface, in °C; Where is the radius of the well wall, in meters; The convective heat transfer coefficient of the well wall is expressed in W / (m²·℃). The heat generated by the frictional resistance of the circulating fluid in the annular space is expressed in J.
[0033] (4) Wellbore heat transfer model: Formation heat diffuses to the wellbore via thermal conduction, and then the annular fluid transfers heat from the wellbore to the annulus via thermal convection. Therefore, the heat transfer model can be expressed as:
[0034] In the formula Temperature of the cement sheath or stratum adjacent to the wall, in °C; Thermal conductivity of the cement ring or stratum adjacent to the wall, W / (m·℃); The outer radius of the well casing is in meters (m). The density of the well casing is kg / m³. is the specific heat capacity of the well casing, J / (kg·℃).
[0035] (5) Near-wellbore heat transfer model; considering the formation heat exchange near the wellbore as radial and axial heat conduction, the heat transfer model can be expressed as:
[0036] In the formula The temperature of the formation near the wellbore, in °C; The thermal conductivity of the formation near the wellbore is expressed in W / (m·℃). The density of the formation near the wellbore is kg / m³. is the specific heat capacity of the formation near the wellbore, J / (kg·℃).
[0037] The above partial differential equations are difficult to solve. In this embodiment, the two-dimensional Crank-Nicholson finite difference method is used to discretize the mathematical model in space and time before solving it. Taking the heat transfer model of fluid inside the pipe, pipe wall and annulus fluid as an example: The heat transfer model of fluid inside the pipe is discretized as follows:
[0038] In the formula For spatial grid nodes along the axis; This refers to a time point.
[0039] The heat transfer model of the tube wall is discretized as follows:
[0040] The annular fluid heat transfer model is discretized as follows:
[0041] Furthermore, the formula for the convective heat transfer coefficient is:
[0042] In the formula The convective heat transfer coefficient is expressed in W / (m²·℃). The Reynolds number is dimensionless. R is the radius of the cross-section through which the fluid flows, in meters; Prandtl coefficient:
[0043] In the formula It is the Prandtl number, which is dimensionless; The viscosity of the fluid is its plastic viscosity, Pa·s; The fluid thermal conductivity is W / (m·℃); the corrected convective heat transfer coefficients of the outer wall of the tubing, the outer wall of the tubing, and the well wall are respectively:
[0044]
[0045]
[0046] In the formula , , These are the correction parameters for the convective heat transfer coefficients of the outer wall of the tubing, the outer wall of the tubing, and the well wall, respectively. They are dimensionless and their values range from [0.1, 4].
[0047] It constructs a multi-region coupled transient heat transfer model covering the tubing, tubing wall, annulus, wellbore and near-wellbore formation, and uses the Crank-Nicolson finite difference method for numerical solution. By introducing correction parameters into the classical convection heat transfer formula and defining their value range, it establishes a physical calculation foundation and a clear parameter search space for the subsequent intelligent optimization process.
[0048] In this embodiment S2, multiple sets of initial parameter combinations are randomly generated within the range of values for each correction parameter. Each set of initial parameter combinations is input into the transient heat transfer model of the wellbore to simulate the temperature field and obtain the corresponding simulated temperature distribution. Specifically, parameter combinations are randomly generated within the range of values for a, b, and c. , For parameter combinations, This represents the number of parameter combinations; for each parameter combination, the heat transfer model is invoked to obtain the temperature at each depth and time.
[0049] In the formula For wellbore temperature distribution, The transient heat transfer model was constructed.
[0050] In this embodiment, S3, the simulated temperature distribution is compared with the measured temperature data, and the temperature error corresponding to each parameter combination is calculated. An initial training sample set is constructed based on the initial parameter combination and its corresponding temperature error. The measured temperature at a specified time and depth is input, the simulated temperature is compared with the measured temperature, the error is calculated, and then the parameter combination is used as input and the error is used as output to finally construct the initial training sample set.
[0051]
[0052] In the formula For the error set; The measured temperature is in °C. The training set is constructed.
[0053] In this embodiment S4, a random forest model is trained using the initial training sample set to establish a nonlinear mapping relationship between parameter combinations and temperature error. This includes: using each parameter combination in the initial training sample set as an input feature vector and the corresponding temperature error value as a target label; randomly selecting multiple training subsets with replacement from the initial training sample set using a bootstrap sampling method; training a decision tree for each training subset; when splitting at each node of each decision tree, randomly selecting a feature subset from all parameter features, and selecting the optimal splitting feature and splitting threshold from this feature subset to minimize the prediction error; integrating all trained decision trees to form a random forest model, and for a new parameter combination, using the average of the prediction results of all decision trees as the temperature error predicted by the random forest model.
[0054] Furthermore, when training each decision tree, its maximum depth is set to not exceed a preset depth threshold. And the total number of decision trees in the random forest model satisfy When selecting the optimal splitting feature and splitting threshold at each node, the splitting criterion used is to minimize the mean square error of the target value of the samples within the node.
[0055] It uses an initial sample set to train a random forest model, constructs multiple decision trees through bootstrapping, and introduces random feature selection when splitting nodes to establish a complex nonlinear mapping relationship between three-dimensional parameter combinations and one-dimensional temperature error. This model can replace computationally complex physical models and achieve fast and low-cost prediction of the error corresponding to any new parameter combination.
[0056] In embodiment S5, multiple candidate parameter combinations are randomly generated again within the range of the corrected parameter values. The error of each candidate parameter combination is predicted using the trained random forest model, and the top K parameter combinations with the smallest prediction error are selected as the preferred parameter set. In this embodiment, the error of each candidate point is predicted using the trained random forest model, and the top 10 parameter combinations with the smallest prediction error are selected. Randomly generated candidate combinations:
[0057] In the formula For parameter combinations; This represents the number of parameter combinations.
[0058] Predict the error values for each combination:
[0059] In the formula To determine the prediction error, select several groups with the smallest prediction errors:
[0060] In the formula The number of groups selected.
[0061] In this embodiment, S6, based on the preferred parameter set, verification and comparison are performed using a wellbore transient heat transfer model to determine the optimal combination of convective heat transfer coefficient correction parameters. This includes: substituting the candidate combinations into the temperature model to obtain a new simulated temperature and updating the optimal error; if the optimal error is less than a preset threshold, the optimal convective heat transfer coefficient parameter combination is output; and calculations are performed on the selected candidate combinations.
[0062] Determine whether the error of the candidate combination meets the set error threshold:
[0063] In the formula The set error threshold is dimensionless; if the above formula is satisfied, the optimal parameter combination is output; otherwise, the optimal parameter combination is updated until the error threshold is satisfied:
[0064] In the formula Optimal parameter combination.
[0065] The above-mentioned S5 uses a trained random forest model to quickly pre-screen the massive number of newly generated candidate parameter combinations to lock in potential optimal regions; while S6 calls a precise heat transfer model to perform small-scale precise verification and comparison of the preferred parameter set, and judges whether it has converged based on the error threshold. If it has not converged, new data is fed back to the training set to update the model, thus realizing an efficient optimization mechanism that combines intelligent coarse screening and precise verification.
[0066] In this embodiment, S7, the optimal convective heat transfer coefficient correction parameter combination is applied to the wellbore transient heat transfer model to obtain the verified wellbore temperature field during the cementing process. This includes: substituting the optimal convective heat transfer coefficient correction parameter combination into the convective heat transfer coefficient correction formula to calculate the verified convective heat transfer coefficients of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall; using the verified convective heat transfer coefficients as key input parameters, initializing and running the wellbore transient heat transfer model to simulate the entire process from the start of cementing operations to the end of the setting period, and calculating the temperature field inside the wellbore that varies with time t and well depth z. From the temperature field Extract temperature information to guide engineering design.
[0067] Furthermore, the extracted temperature information may specifically include: the temperature profile of the entire wellbore at any time, the temperature history curve of any well depth location during the entire operation, and the temperature values at key locations; the temperature values at key locations include the wellhead return temperature, the casing shoe temperature, and the target production zone temperature.
[0068] This step solidifies the optimized combination of correction parameters into the heat transfer model, which is used to perform the final wellbore temperature field prediction. By simulating the entire cement injection process, it outputs high-precision, spatiotemporally continuous wellbore temperature field data, providing direct and reliable quantitative basis for cement slurry formulation design, thickening time determination, and construction process optimization.
[0069] Furthermore, to verify the effectiveness of the wellbore temperature field verification method during cementing in this embodiment under actual well conditions, the implementation process is further explained below with reference to engineering data of a specific deep well. This deep well is a vertical well with a completed drilling depth of 6947 m. It adopts a four-section wellbore structure, and the wellbore structure data is shown in Table 1. The four-section tailpipe string combination is: φ149.2 mm × 10.54 mm (down to 1484.71 m) + φ149.2 mm × 9.65 mm (down to 6156.87 m) + φ196.85 mm × 12.7 mm (down to 6631.305 m) + φ206.38 mm × 17.25 mm (up to 6935 m).
[0070] Wellbore structure data are shown in Table 1 below: Table 1
[0071] The type and parameters of the slurry injected into the well are shown in Table 2 below: Table 2
[0072] Based on the above well structure and drilling fluid properties, the outlet temperature during the drilling fluid circulation process was numerically simulated and compared with the measured outlet temperature. The results are shown in Figure 2. Without verification, the minimum accuracy of the drilling fluid circulation outlet temperature calculated by the model was 86.38%, and the average accuracy was 88.53%.
[0073] Furthermore, based on the sequence and properties of the injected grout, the outlet temperature during the cement injection process was simulated, and the calculated results were compared with the measured outlet temperature. The results are shown in Figure 3. The minimum accuracy rate of the outlet temperature during cement injection was 91.14%, and the average accuracy rate was 92.69%.
[0074] As can be seen from Figures 2 and 3, without wellbore temperature verification, the accuracy of temperature calculations during both the drilling fluid circulation and cementing stages is low. To improve simulation accuracy, the temperature during drilling fluid circulation was verified based on measured temperature data, as shown in Table 3 below: Table 3
[0075] The total time to obtain the optimal parameter combination for this well was 1 minute and 42 seconds. The final determined parameter combination was (2.7, 3, 2). The comparison between the drilling fluid circulation temperature calculated using this parameter combination and the measured temperature is shown in Figure 4. After verification, the minimum accuracy of the outlet temperature during drilling fluid circulation calculated by the model increased to 95.16%, and the average accuracy increased to 97.84%, which are 8.78% and 9.31% higher than before verification, respectively.
[0076] The optimal parameter combination was then substituted into the model to calculate the outlet temperature during cement injection, and compared with the corresponding measured temperature. The results are shown in Figure 5. The comparison shows that after using the optimal convective heat transfer coefficient parameter combination, the minimum accuracy of the model's prediction of the outlet temperature during cement injection reached 95.31%, and the average accuracy reached 97.87%, which are 4.17% and 5.18% higher than before the verification, respectively.
[0077] The wellbore temperature field verification method based on the random forest algorithm provided in this embodiment establishes an accurate transient heat transfer model and uses the random forest algorithm to construct an error surrogate model, thereby achieving efficient, automated, and intelligent optimization of key heat transfer parameters. Finally, the optimized model can be used to obtain a high-precision wellbore temperature field during the cementing process, improving the reliability of temperature prediction and providing a reliable guarantee for cementing construction safety and optimized engineering design.
[0078] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0079] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for verifying the wellbore temperature field during cementing based on the random forest algorithm, characterized in that, Includes the following steps: S1. Establish a transient heat transfer model of the wellbore during the cementing process, and set the value range of the correction parameters for the convective heat transfer coefficients of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall, respectively; S2. Randomly generate multiple sets of initial parameter combinations within the value range of each correction parameter, input each set of initial parameter combinations into the transient heat transfer model of the wellbore for temperature field simulation, and obtain the corresponding simulated temperature distribution; S3. Compare the simulated temperature distribution with the measured temperature data, calculate the temperature error corresponding to each set of parameter combinations, and construct an initial training sample set based on the initial parameter combinations and their corresponding temperature errors; S4. Train a random forest model using the initial training sample set to establish a nonlinear mapping relationship between parameter combinations and temperature error; S5. Randomly generate multiple candidate parameter combinations again within the range of the corrected parameter values, use the trained random forest model to predict the error of each candidate parameter combination, and select the top K parameter combinations with the smallest prediction error as the preferred parameter set; S6. Based on the preferred parameter set, verify and compare it with the wellbore transient heat transfer model to determine the optimal convection heat transfer coefficient correction parameter combination; S7. Apply the optimal convection heat transfer coefficient correction parameter combination to the wellbore transient heat transfer model to obtain the verified wellbore temperature field during the cementing process.
2. The method for verifying the wellbore temperature field during cementing based on the random forest algorithm according to claim 1, characterized in that, In S1, the transient heat transfer model of the wellbore includes: the fluid heat transfer model inside the tubing, the tubing wall heat transfer model, the annular fluid heat transfer model, the well wall heat transfer model, and the formation heat transfer model near the well wall. The model is discretized and solved using the finite difference method.
3. The method for verifying the wellbore temperature field during cementing based on the random forest algorithm according to claim 1, characterized in that, In S1, the correction parameters for the convective heat transfer coefficients of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall are respectively... 、 、 The range of values is 。 4. The method for verifying the wellbore temperature field during cementing based on the random forest algorithm according to claim 1, characterized in that, In S1, the convective heat transfer coefficients of the inner wall of the tubing, the outer wall of the tubing, and the well wall are... 、 、 They are represented as follows: in, For fluid thermal conductivity, Let Reynolds number be 1. For Prandtl numbers, 、 、 These are the inner wall radius of the tubing string, the outer wall radius of the tubing string, and the well wall radius, respectively.
5. The method for verifying the wellbore temperature field during cementing based on the random forest algorithm according to claim 1, characterized in that, In step S3, the temperature error corresponding to each parameter combination is calculated as follows: in, This represents the u-th parameter combination. This represents the simulated temperature at depth index j and time index t under this set of parameters. This indicates the measured temperature at the corresponding location and time.
6. The method for verifying the wellbore temperature field during cementing based on the random forest algorithm according to claim 1, characterized in that, S4 includes: using each parameter combination in the initial training sample set as an input feature vector and the corresponding temperature error value as a target label; randomly sampling multiple training subsets with replacement from the initial training sample set using a bootstrap sampling method; training a decision tree for each training subset; when splitting at each node of each decision tree, randomly selecting a feature subset from all parameter features, and selecting the optimal splitting feature and splitting threshold from this feature subset to minimize the prediction error; integrating all trained decision trees to form a random forest model, and for a new parameter combination, using the average of the prediction results of all decision trees as the temperature error predicted by the random forest model.
7. The method for verifying the wellbore temperature field during cementing based on the random forest algorithm according to claim 1, characterized in that, S6 includes: inputting each parameter combination from the preferred parameter set into the wellbore transient heat transfer model, calculating the simulated temperature value of each parameter combination under specified time and depth conditions; comparing the simulated temperature value with the corresponding measured temperature data, and selecting the parameter combination with the smallest verification error as the current optimal parameter combination; if the verification error of the current optimal parameter combination is less than a preset error threshold, then the current optimal parameter combination is determined as the optimal convective heat transfer coefficient correction parameter combination; otherwise, returning to S5 for iterative optimization.
8. The method for verifying the wellbore temperature field during cementing based on the random forest algorithm according to claim 1, characterized in that, S7 includes: substituting the optimal combination of convective heat transfer coefficient correction parameters into the convective heat transfer coefficient correction formula to calculate the verified convective heat transfer coefficients of the inner wall of the tubing string, the outer wall of the tubing string, and the well wall; using the verified convective heat transfer coefficients as key input parameters, initializing and running the wellbore transient heat transfer model to simulate the entire process from the start of cementing operations to the end of setting time, and calculating the temperature field inside the wellbore that varies with time t and well depth z. From the temperature field Extract temperature information to guide engineering design.