A Model-Based Intelligent Adjustment Method of Toolface for Bent-Housing Motor

The traditional toolface adjustment of a bent-housing motor is time-consuming and laborious. For the goal of rapid and accurate toolface adjustment, this paper presents an intelligent toolface adjustment method based on the drill string dynamics model and the BP (back propagation) neural network, optimized by a GA (genetic algorithm). Firstly, for the mode of rotating the drill string at the wellhead to change the downhole toolface, the drill string dynamics model is used to calculate the toolface change value. Then, the actual toolface change value is taken as the output data; the calculated toolface change value and the factors that have a significant impact on the change value of the toolface are taken as the input parameters; and the GA-BP neural network is adopted to fit the relationship between the input parameters and the output data. For the mode of changing the toolface by changing the WOB (weight on bit), the WOB change value and other parameters that cause the toolface to change were taken as the input data and the toolface change value was taken as the output data; the relationship between the WOB and the toolface was fitted with the GA-BP neural network. The results show that the prediction of absolute error under the mode of adjusting the toolface by rotating the drill string at the wellhead is within 10.9783◦, and the prediction of absolute error under the mode of adjusting the toolface by changing the WOB is within 18.8833◦. The intelligent models established under the two modes can meet the requirements of toolface control accuracy. Using the established intelligent prediction model, the toolface can be adjusted to the required value range at one time, which can improve drilling efficiency, and reduce labor intensity and the dependence on the experience of on-site personnel.


Introduction
In engineering practice, we often need to calculate or predict some parameters in advance, so as to formulate measures early, improve efficiency, and avoid adverse consequences. The toolface adjustment of the bent-housing motor is a typical representative of this kind of situation. At present, the bent-housing motor is still widely used in the construction of directional wells and horizontal wells due to its economy and adaptability to complex well conditions such as high temperature and high pressure [1]. In the process of controlling well trajectory with BHA (bottom hole assembly) containing a bent-housing motor, the orientation of the motor's bending angle needs to be adjusted frequently. The traditional toolface adjustment process is very time-consuming and laborious [2]. Whether the adjustment is in an on-bottom condition or off-bottom condition, the downhole toolface needs a certain response time to reach a stable state after the wellhead drill string rotates at an angle. Once the toolface is stable and recorded by MWD (measure while drilling), it will take several minutes to be uploaded to the drilling platform. If the toolface is not expected, it needs to be readjusted repeatedly until the toolface meets the expectation. Therefore, the traditional toolface adjustment not only increases the abnormal drilling time, but it also relies heavily on the experience of operators. It is very significant to adjust the toolface quickly and accurately to save the drilling cost and improve the drilling efficiency.
To some extent, the application of the automation system in drilling has improved the adjustment efficiency of the bent-housing motor toolface. In the directional steering control system proposed by Gillan [1,2], through the joint work of PLC (programmable logic controller), sensor package, HMI (human machine interface), and control package, the toolface of the bent-housing motor can be monitored in real time, and can be adjusted by inputting the rotation angle of the wellhead drill string through HMI, which reduces the labor intensity of manual adjustment and saves the adjustment time of the toolface to a certain extent. In China, Xu [3] also proposed a top-drive-based steering control system for sliding drilling similar to that proposed by Gillan. Wu [4,5] specially carried out the indoor experiment of the asynchronous machine toolface dynamic control system, which verified that the angle accuracy of its driving wellhead drill string rotation is less than 2 • , and the drive time is less than 5 s. However, the above-mentioned toolface automation adjustment methods rely on computer-based feedback control, and their effectiveness is largely affected by wellbore friction. Through experiments, Wang [6] found that when there is a large frictional force on the drill string, toolface hysteresis will ensue. When the toolface hysteresis exists, the purpose of rapid and accurate adjustment of the downhole toolface cannot be achieved only by relying on the wellhead automatic drill string torsion system. Without knowing the relationship between the wellhead rotation angle and the change value of the downhole toolface, the toolface still needs to be adjusted repeatedly, and the toolface hysteresis greatly extends the abnormal drilling time. Therefore, the most ideal state is when the downhole toolface can reach a predetermined angle after the wellhead drill string rotates one time.
In recent years, some researchers have tried to use dynamics models to describe the relationship between the rotation of the wellhead drill string and the change in the bottom hole toolface. Wang [7,8] proposed a model-based method for the rapid adjustment and control of the toolface of the bent-housing motor. The simulation example shows that this method can achieve the control goal in a short time, whether for toolface setting off-bottom or correction on-bottom. Zhong [9] established the dynamic equation of the drill pipe torsion process, carried out indoor experiments according to the model similarity theory, and obtained the parameter similarity conditions and scale corresponding relationship between the experimental model and the drilling prototype. On this basis, the expert PID method was used to realize the automatic control of the toolface. The principles of the drill string dynamics models related to toolface adjustment are clear and easy to understand. However, the models have made some idealized assumptions and simplifications, and have not yet been validated by on-site data. The actual situations of the drilling site are not completely consistent with the drill string dynamics models, which makes the calculated value of the models deviate from the actual value. For an 8000 m deep directional well, when the wellhead drill string rotates 360 • , the actual value of the downhole toolface differs by up to 50 • from the calculated value of the drill string dynamics model; when the wellhead drill string rotates 720 • , this difference can reach 150 • [10].
The artificial intelligence method can fit the relationship between the physical model results and the actual data in the drilling site well. A BP (back propagation) neural network, based on a GA (genetic algorithm), has a good fitting effect on nonlinear functions affected by multiple parameters, has been widely used in the drilling field, and has achieved satisfactory results in recent years, such as build-up rate prediction [11], crude oil output decline rate prediction [12], crude oil production prediction [13], overflow and leakage prediction [14][15][16], bottom hole pressure prediction [17], horizontal in situ stress and natural fracture property identification [18], oil saturation prediction [19], drilling tool structure optimization [20], optimal ROP calculation, and drilling parameter optimization [21]. The downhole toolface change value during the adjustment of the bent-housing motor toolface can be regarded as a nonlinear function affected by multiple parameters, and its influencing factors at least include well trajectory, wellbore structure, drilling assembly, drilling fluid property, bit performance, formation characteristics, the interaction between bit and formation, bent-housing motor performance, and drilling engineering parameters.
In this paper, the toolface change value during the toolface adjustment process of the bent-housing motor is the research object, and intelligent prediction models are established to predict the change value of the toolface, so as to provide adjustment parameters for field operators. Based on the drill string dynamics model, the downhole toolface change value of the bent-housing motor is calculated when the rotary parameters of the wellhead drill string are known. Then, the actual measured change value of the toolface is taken as the output parameter, the drill string dynamics model calculates the change value of the toolface, and where G is the shear modulus of the drill string element. I p is the cross-sectional moment of inertia of the drill string element. ρ is the density of the drill string element. c 1 is the viscous resistance coefficient in the torsional direction between the drilling fluid and the drill string element. µ t is the friction coefficient in the torsional direction between the drill string element and the wellbore. F is the lateral force received by the drill string element. D O is the outer diameter of the drill string element. The torsional equivalent damping coefficients of drilling mud can be expressed as follows where D i represents the inner diameter of the drill string. D w represents the well diameter. τ 0 represents the dynamic shear stress of drilling mud. µ pv represents the plastic viscosity of drilling mud. When the axial load of the wellhead is known, the axial tension and the normal contact force of the drill string element can be calculated from the wellhead to the bottom. The lateral force can be expressed as when the WOB is known, the axial tension and the normal contact force of the drill string element can be calculated from the bottom to the wellhead. The lateral force can be expressed as In Equations (8) and (9), T 1 and T 2 are the axial tension at the upper and lower ends of the unit, respectively. W t , W b , and W n are the components of gravity in a tangential direction, main normal direction, and sub-normal direction, respectively. γ is the dogleg degree of the drill string element. µ a is the component of the friction coefficient in the axial direction.
The components of gravity in each direction can be expressed as where W is the floating weight of the element. α 1 and α 2 are the well deviation angles at the upper and lower ends of the element, respectively. ∆ϕ represents the azimuth angle difference between the upper and lower ends of the element. The relationship between the axial friction coefficient, torsional friction coefficient, and overall friction coefficient can be expressed as The overall friction coefficient between the wellbore and the drill string is related to the movement speed, and this phenomenon can be described by the Stribeck friction curve.
where µ s represents the static friction coefficient; µ d represents the dynamic friction coefficient; v r represents the resultant velocity; v s is a characteristic velocity, which determines the speed at which µ approaches µ d as v r increases.

Initial Condition
For adjusting the downhole toolface by rotating the drill string at the wellhead, regardless of whether the drill bit is off-bottom or on-bottom, the initial displacement, velocity, and acceleration of each drill string element are zero in the torsion direction.

Boundary Condition
For the toolface adjustment in the off-bottom state, the bit has never contacted the bottom hole, so the WOB is always zero.
For the toolface adjustment in the on-bottom state, although the WOB will fluctuate during the adjustment process, the speed in the torsion direction is far greater than the axial speed during the adjustment process, which makes the axial component of the friction coefficient smaller, which can be approximately regarded as zero. Therefore, the WOB can be treated as always unchanged.
The drill string dynamics model described above can be programmed and operated in MATLAB to solve the change value of the downhole toolface. The specific modeling steps can be referred to in the appendix of reference [22].

Model-Based Intelligent Method
The principles of the drill string dynamics model are clear and easy to understand. However, it has made some idealized assumptions and simplifications, mainly including the following: (1) The dynamics model assumes that the drill string curve is completely consistent with the wellbore curve, but, in reality, there are some sinusoidal and spiral bucklings in the drill string that are not completely consistent with the wellbore curve. (2) The wellbore trajectory used in the calculation process is interpolated through MWD singlepoint measurement data, which has a certain error with the actual wellbore trajectory. (3) The friction coefficient used in the drill string dynamics model is derived from previous data inversion, and its value is the friction coefficient between the entire drill string and the wellbore. For the assembly of the lower drilling tool, the contact between the drill string and the wellbore is present at several points, such as the bit and stabilizer. However, due to the unique structure of the bit and stabilizer, their friction coefficient with the wellbore is not equal to the friction coefficient between the upper drill string and the wellbore.  The above reasons make the actual situation at the drilling site not completely consistent with the physical model, and there is a certain deviation between the calculated values of the drill string dynamics model and the actual values. If the drill string dynamics model calculation results are directly applied to guide drilling production, it will be misleading to some extent. Figure 1 shows the toolface deviation between the actual value and the drill string dynamics model calculated value of a two-dimensional horizontal well in the Sichuan Basin of China. Artificial intelligence methods can fit the relationship between physical model results and actual drilling site data well. The genetic-algorithm-based back propagation neural network (GA-BP) has a good fitting effect on nonlinear functions affected by multiple parameters. In recent years, it has been widely used in the field of drilling and has achieved satisfactory results.

BP Neural Network Algorithm
A BP neural network is a multilayer feedforward neural network trained according to the error back propagation algorithm. In terms of structure, a BP network has an input layer, hidden layer, and output layer. Figure 2 shows the structure of a three-layer BP neural network with l input neuron, m hidden neurons, and n output neurons. The number of hidden layer nodes of the neural network can be determined using the following formula. m l n a = + + (16) where a is a constant between 1 and 10. Artificial intelligence methods can fit the relationship between physical model results and actual drilling site data well. The genetic-algorithm-based back propagation neural network (GA-BP) has a good fitting effect on nonlinear functions affected by multiple parameters. In recent years, it has been widely used in the field of drilling and has achieved satisfactory results.

BP Neural Network Algorithm
A BP neural network is a multilayer feedforward neural network trained according to the error back propagation algorithm. In terms of structure, a BP network has an input layer, hidden layer, and output layer. Figure 2 shows the structure of a three-layer BP neural network with l input neuron, m hidden neurons, and n output neurons. The number of hidden layer nodes of the neural network can be determined using the following formula.
where a is a constant between 1 and 10.
In essence, the BP algorithm takes the MSE (mean square error) of the network as the objective function and uses the gradient descent method to calculate the minimum value of the MSE. Assuming that the output data after BP neural network training are Y P ( y 1 , y 2 , y 3 , . . . , y n ), and the actual data are Y R (y 1 , y 2 , y 3 , . . . , y n ), MSE is calculated according to the following formula.
The BP algorithm includes the forward propagation of a signal and back propagation of error. During forward propagation, the input value acts on the output node through the hidden layer, and generates the output value through nonlinear transformation. If the actual output value does not match the expected output value, the back propagation process of error will be started. The error back propagation is a process of transmitting the output error back to the input layer through the hidden layer and distributing the error to all units of each layer. The error value obtained from each layer is used as the basis for adjusting the weight of each unit. By adjusting the weights and thresholds of input nodes and hidden nodes, as well as hidden nodes and output nodes, the error can be reduced along the gradient direction. After repeated training, the weights and thresholds corresponding to the minimum error are finally determined, and the training is completed.
The advantage of a BP neural network is its strong nonlinear mapping ability. It has been proven that the three-layer BP neural network model can approximate any nonlinear problem [23]. However, the BP neural network also has some defects; the main defect is that it is easy to fall into the local optimal solution in the training process [11,14]. Artificial intelligence methods can fit the relationship between physical model results and actual drilling site data well. The genetic-algorithm-based back propagation neural network (GA-BP) has a good fitting effect on nonlinear functions affected by multiple parameters. In recent years, it has been widely used in the field of drilling and has achieved satisfactory results.

BP Neural Network Algorithm
A BP neural network is a multilayer feedforward neural network trained according to the error back propagation algorithm. In terms of structure, a BP network has an input layer, hidden layer, and output layer. Figure 2 shows the structure of a three-layer BP neural network with l input neuron, m hidden neurons, and n output neurons. The number of hidden layer nodes of the neural network can be determined using the following formula. m l n a = + + (16) where a is a constant between 1 and 10.

Genetic Algorithm
GA is a widely used global optimization algorithm, which is characterized by a strong global searching ability [11]. GA can solve the problem of BP converging slowly and easily falling into a local optimal solution. This paper mainly uses GA to optimize the threshold and weight of BP.
The operation steps of the genetic algorithm mainly include encoding, initial population generation, fitness evaluation, selection, crossover, mutation, and termination condition judgment. If the termination condition is not met, it needs to regenerate the initial population and continue to optimize. If the condition is satisfied, the individual with the largest fitness value will be output as the optimal solution.

Toolface Intelligent Adjustment Method Based on GA-BP
The framework of the BP neural network based on genetic algorithm optimization is shown in Figure 3. After determining the network structure, such as the number of layers and the number of elements in each layer of the BP neural network, the original data will be input and be preprocessed. Then, the initial weight and threshold of each input datum are set, and error evaluation is conducted. The training errors of the BP neural network are brought into the genetic algorithm as the fitness parameters, and the fitness value is finally calculated after the operations of selection, crossover, and mutation. If the fitness value meets the end conditions, then the weights and thresholds of the BP neural network are updated. If the updated weights and thresholds meet the end conditions of the BP neural network, the model training is completed and the predicted value is output.
x FOR PEER REVIEW 9 of 26 The frame of the intelligent adjustment method for the toolface angle of the benthousing motor proposed in this paper is shown in Figure 4. The toolface adjustment mode includes the wellhead drill string rotation adjustment mode and the WOB change adjustment mode. In the wellhead drill string rotation adjustment mode, firstly, the dynamics model of the drill string is used to calculate the toolface change value under the premise of knowing the rotation speed and displacement of the wellhead drill string, and the influencing factors of the toolface change value not considered in the dynamic model are summarized. Then, these data are initialized and divided into the training group and test group. After training and testing, a stable GA-BP prediction model is obtained. This model can represent the relationship between the rotation angle of the wellhead drill string and the downhole toolface change value. In the WOB change adjustment mode, the influencing factors between the toolface change value and WOB change value are summarized. Then, afterwards, the GA-BP method is used to initialize, train and test the data, and finally form a model for predicting the relationship between WOB change value and toolface change value. The frame of the intelligent adjustment method for the toolface angle of the benthousing motor proposed in this paper is shown in Figure 4. The toolface adjustment mode includes the wellhead drill string rotation adjustment mode and the WOB change adjustment mode. In the wellhead drill string rotation adjustment mode, firstly, the dynamics model of the drill string is used to calculate the toolface change value under the premise of knowing the rotation speed and displacement of the wellhead drill string, and the influencing factors of the toolface change value not considered in the dynamic model are summarized. Then, these data are initialized and divided into the training group and test group. After training and testing, a stable GA-BP prediction model is obtained. This model can represent the relationship between the rotation angle of the wellhead drill string and the downhole toolface change value. In the WOB change adjustment mode, the influencing factors between the toolface change value and WOB change value are summarized. Then, afterwards, the GA-BP method is used to initialize, train and test the data, and finally form a model for predicting the relationship between WOB change value and toolface change value.

Results and Discussions
The wells mentioned in Figure 1 are adopted to verify the accuracy of the established intelligent model. The wellbore structure of the example well is shown in Figure 5. Its drill assembly is as follows: Φ215.9 mm bit × 0.3 m + Φ172 mm bent-housing motor drill × 7.42 m + Φ172 mm directional joint × 0.5 m + Φ202 mm stabilizer × 0.64 m + Φ165.1 mm drill collar × 38.96 m + Φ127 mm HWDP (heavy weight drill pipe) × 150.36 m + Φ178 mm drilling jar × 5.43 m + Φ127 mm HWDP × 18.71 m + Φ139.7 mm drill pipe. In the drill string dynamics model calculation process, the friction coefficient in the casing is 0.25, and the friction coefficient in the open hole is 0.35.

Results and Discussions
The wells mentioned in Figure 1 are adopted to verify the accuracy of the established intelligent model. The wellbore structure of the example well is shown in Figure 5. Its drill assembly is as follows: Φ215.9 mm bit × 0.3 m + Φ172 mm bent-housing motor drill × 7.42 m + Φ172 mm directional joint × 0.5 m + Φ202 mm stabilizer × 0.64 m + Φ165.1 mm drill collar × 38.96 m + Φ127 mm HWDP (heavy weight drill pipe) × 150.36 m + Φ178 mm drilling jar × 5.43 m + Φ127 mm HWDP × 18.71 m + Φ139.7 mm drill pipe. In the drill string dynamics model calculation process, the friction coefficient in the casing is 0.25, and the friction coefficient in the open hole is 0.35.

Toolface Calculation Results of Drill String Dynamics Model
According to the simulation calculation of the dynamics model, the trend of the toolface change value over time under different well depth conditions is shown in Figure 6 when the bit is lifted from the bottom of the well by rotating the drill string to adjust the toolface. The bit depths corresponding to the four curves in the figure are 1500 m, 2500 m, 3500 m, and 4500 m, respectively. During the toolface adjustment process, the weight on bit is 0, the top drive rotation angle is 5 r, the top drive rotation speed is 10 r/min, and the initial circumferential displacement of each node on the drill string is 0. From Figure 6, it can be seen that when the drill string is rotated at a certain speed at the wellhead for a certain angle, the downhole toolface changes accordingly, and after a certain period of time, the toolface maintains a stable state again. When the well depth is 1500 m, the downhole toolface begins to change after the wellhead drill string rotates for 2 s, and reaches a stable state after 30 s. After the toolface stabilizes, the difference between the wellhead rotation angle and the toolface change value is (10π − 30.21) rad, which is 69 • . When the well depth is 4500 m, the downhole toolface begins to change after the wellhead drill string rotates for 30 s, and reaches a stable state after 400 s. After the toolface stabilizes, the difference between the wellhead rotation angle and the toolface change value is (10π − 12.40) rad, which is 1090 • . The above analysis results indicate that the greater the depth of the drill bit and the greater the friction between the drill string and the wellbore, the longer it takes for the downhole toolface to return to a stable state, and the greater the difference between the change value of the downhole toolface and the rotation angle of the wellhead drill string.
Appl. Sci. 2023, 13, x FOR PEER REVIEW 11 o Figure 5. Wellbore structure of the field data collection well.

Toolface Calculation Results of Drill String Dynamics Model
According to the simulation calculation of the dynamics model, the trend of the to face change value over time under different well depth conditions is shown in Figur when the bit is lifted from the bottom of the well by rotating the drill string to adjust toolface. The bit depths corresponding to the four curves in the figure are 1500 m, 2500 3500 m, and 4500 m, respectively. During the toolface adjustment process, the weight bit is 0, the top drive rotation angle is 5 r, the top drive rotation speed is 10 r/min, and initial circumferential displacement of each node on the drill string is 0. From Figure 6 can be seen that when the drill string is rotated at a certain speed at the wellhead fo certain angle, the downhole toolface changes accordingly, and after a certain period time, the toolface maintains a stable state again. When the well depth is 1500 m, the dow hole toolface begins to change after the wellhead drill string rotates for 2 s, and reache stable state after 30 s. After the toolface stabilizes, the difference between the wellh rotation angle and the toolface change value is ( ) the well depth is 4500 m, the downhole toolface begins to change after the wellhead d string rotates for 30 s, and reaches a stable state after 400 s. After the toolface stabiliz  Figures 7 and 8, it can be seen that the change value after the toolface finally reaches a stable state is independent of the top drive rotation speed when the toolface is adjusted. But, the higher the rotation speed of the top drive, the shorter the time it takes for the toolface to reach a stable state. As shown in Figure 7, when the depth of the drill bit is shallow and the friction between the drill string and the wellbore is small, the change value of the downhole toolface under the inertial action of the drill string rotation may even be greater than the rotation angle of the wellhead top drive at some time; but, eventually it will be smaller than the rotation angle of the wellhead top drive over time. As shown in Figure 8, when the drill bit depth is deeper and the friction between the drill string and the wellbore is greater, the downhole toolface slowly changes, and the change value of the downhole toolface during the entire adjustment process is smaller than the rotation angle of the wellhead top drive.   Figures 7 and 8, it can be seen that the change value after the toolface finally reaches a stable state is independent of the top drive rotation speed when the toolface is adjusted. But, the higher the rotation speed of the top drive, the shorter the time it takes for the toolface to reach a stable state. As shown in Figure 7, when the depth of the drill bit is shallow and the friction between the drill string and the wellbore is small, the change value of the downhole toolface under the inertial action of the drill string rotation may even be greater than the rotation angle of the wellhead top drive at some time; but, eventually it will be smaller than the rotation angle of the wellhead top drive over time. As shown in Figure 8, when the drill bit depth is deeper and the friction between the drill string and the wellbore is greater, the downhole toolface slowly changes, and the change value of the downhole toolface during the entire adjustment process is smaller than the rotation angle of the wellhead top drive.   Figures 9 and 10, it can be seen that under the premise of ensuring that the downhole toolface can change, every increase in the rotation angle of the wellhead drill string will result in the same increase in the value of the downhole toolface after reaching a stable state, which is equal to the increased rotation angle of the wellhead drill string. Before the downhole toolface changes, the top drive needs to rotate at a certain angle to overcome the friction between the drill string and the wellbore to "pre tighten" the drill string. The required top drive rotation angle for pre-tightening the drill string is closely related to the frictional resistance between the drill string and the wellbore. The required top drive torsion angle for pre-tightening the drill string, as shown in Figure 9, is (2π − 5.08) rad, which is 68.94 • . The required top drive torsion angle for pre-tightening the drill string, as shown in Figure 10, is (8π − 3.34) rad, which is 1248.63 • .   Figures 9 and 10, it can be seen that under the premise of ensuring that the do toolface can change, every increase in the rotation angle of the wellhead drill str result in the same increase in the value of the downhole toolface after reaching state, which is equal to the increased rotation angle of the wellhead drill string. Be downhole toolface changes, the top drive needs to rotate at a certain angle to ov the friction between the drill string and the wellbore to "pre tighten" the drill stri required top drive rotation angle for pre-tightening the drill string is closely relate frictional resistance between the drill string and the wellbore. The required to     The calculation results of the drill string dynamics model indicate that the fin tion angle of the downhole bent-housing motor toolface is closely related to the angle of the wellhead drill string and the depth of the bit. The time taken for the to reach a stable state is closely related to the rotation speed of the wellhead dri and the depth of the bit. The calculation results of the drill string dynamics model indicate that the final rotation angle of the downhole bent-housing motor toolface is closely related to the rotation angle of the wellhead drill string and the depth of the bit. The time taken for the toolface to reach a stable state is closely related to the rotation speed of the wellhead drill string and the depth of the bit.

Predicted Toolface Results in the Mode of Adjusting the Toolface by Rotating Drill String at the Wellhead
The parameters of the drill string dynamics model for adjusting the downhole toolface by rotating the drill string at the wellhead include the well trajectory (the depth, deviation angle, azimuth angle), wellbore structure (the difference in friction coefficients between casing and open hole section), drill string assembly (the length, inner diameter, outer diameter, elastic modulus, shear modulus, weight per unit length of each component of the drill string), drilling fluid performance (density, dynamic shear stress, plastic viscosity), drilling engineering parameters (WOB, wellhead drill string rotation angle and rotation speed), and do not include parameters such as bit performance, formation characteristics, interaction between bit and formation, and bent-housing motor performance. All of the above parameters may cause differences between the calculated value and the actual value of the toolface. Due to the on-site data collected from the same drill string assembly in the same formation of a two-dimensional well, the azimuth angle, wellbore structure, drill string assembly, drilling fluid performance, bit performance, and formation characteristics can be considered constant during each toolface adjustment process. The interaction between bit and formation may differ due to the different contact angles between the two. This phenomenon can be expressed by the different deviation angles in the process of artificial intelligence modeling. The WOB values before and after each process of adjusting the toolface by rotating the drill string at the wellhead can be considered to remain unchanged so that the bent-housing motor performance does not affect the toolface adjustment. According to the analysis results of the drill string dynamics model in Section 4.1, it can be concluded that the depth and the rotation angle of the wellhead drill string have a significant impact on the downhole toolface.
In summary, the setting of input parameters for the artificial intelligence prediction model of the toolface, in the mode of adjusting the downhole toolface by rotating the drill string at the wellhead, is shown in Table 1. The output parameter is the predicted value of the downhole toolface. The basic data of the artificial intelligence prediction model of the toolface, in the mode of adjusting the downhole toolface by rotating the drill string at the wellhead, are shown in Table 2.  After analysis and calculation, the Pearson coefficients of each influence factor with the actual rotation angle of the toolface are shown in Table 3. From Table 3, it can be seen that Factor 4 and Factor 5 (wellhead drill string rotation angle and toolface-calculated rotation value) have a strong correlation with the toolface actual rotation value, and Factor 3 (WOB) has a moderate correlation, Factor 1 has a weak correlation with the toolface actual rotation value, and Factor 2 has a very weak or no correlation with the toolface actual rotation value. After retaining a strong correlation for Factor 4 and Factor 5, the accuracy of the actual rotation angle of the downhole toolface, predicted by the BP neural network and the GA-BP neural network under different combinations of influence factors, is shown in Table 4. All the artificial intelligence models listed in Table 4 use the first 24 sets of data in Table 2 as training set samples, and the last 6 sets of data as test set samples. After a comprehensive comparison of computing times, the mean absolute error of the training set MAE-train and test set MAE-test, mean squared error of the training set MSE-train and test set MSE-test, coefficient of determination of the training set R 2 -train, test set R 2 -test, and all data R 2 -all, the following conclusions can be drawn: (1) Under the same combination of influence factors, the GA-BP method has a significant improvement in prediction accuracy compared to the BP method, while also consuming longer computing time. (2) Whether it is the BP method or the GA-BP method, the computing time decreases with the reduction in considered influence factors, but there is no significant difference in prediction accuracy.
It should be noted that the basic data shown in Table 2 are all from a well section where the data variations in depth, deviation angle, and WOB are not significant. In order to prevent a decrease in prediction accuracy due to data mutations, all influence factors are ultimately retained in the prediction model, although this may increase prediction time. After considering all five influence factors, the prediction program code for BP and GA-BP was written in the MATLAB environment. The BP and GA-BP methods have five input layer neurons, one output layer neuron, and five hidden layer neurons. The prediction results of the BP and GA-BP method are shown in Figure 11, and the correlation coefficient R is shown in Figure 12. The accuracy results of the GA-BP method and the BP method are shown in Table 5. By comparing Figures 1 and 11b, it is evident that the accuracy of the GA-BP method is much higher than that of the drill string dynamics model. From  Table 5, it can be seen that the prediction accuracy of the GA-BP method is also much higher than that of the BP method.  Table 5. Toolface prediction accuracy parameters of BP and GA-BP in the mode of adjusting toolface by rotating drill string at the wellhead. efficient R is shown in Figure 12. The accuracy results of the GA-BP method and the method are shown in Table 5. By comparing Figures 1 and 11b, it is evident that the acc racy of the GA-BP method is much higher than that of the drill string dynamics mod From Figures 11 and 12 and Table 5, it can be seen that the prediction accuracy of the G BP method is also much higher than that of the BP method.

(a) BP method prediction results
(b) GA-BP method prediction results

Toolface-Predicted Results in the Mode of Adjusting Toolface by Changing WOB
The essence of adjusting toolface by changing WOB is to change the reactive torque of the bent-housing motor, and then reverse-twist the drill string from the bottom to change the toolface. Therefore, compared to adjusting the toolface through rotating the drill string at the wellhead, the influence factors are the same except that one is the reactive torque of the bent-housing motor and the other is the rotation angle of the drill string at the wellhead. In theory, under the premise of knowing the change value of the reactive torque of the bent-housing motor, the change value of the reverse-twist angle of the bent-housing motor can be calculated based on the drill string dynamics model. However, in the actual modeling process, there are the following two difficulties. (1) It is difficult to obtain the change value of the reactive torque of the bent-housing motor. The theoretical output torque of the bent-housing motor is where ∆p is the drilling fluid pressure difference in the bent-housing motor, and q is the displacement per revolution of the bent-housing motor. However, multiple parties need to coordinate on the drilling site to obtain the value of q from the motor manufacturer. Moreover, as the internal components of the motor wear out, this value of q is still changing. The drilling fluid pressure difference ∆p is also not so accurate, as abnormal situations such as the blockage of a bit water way can induce an increase in ∆p.
(2) The accuracy of the reverse torsion angle variation value solved by the drill string dynamics model struggles achieve the expected level. Because the rotation of the drill string on the toolface for changing the weight on bit adjustment starts from the bottom, and the contact relationship between the drill collar, stabilizer, and other components on the bottom and the wellbore is too complex, even if the reverse torque of the screw drill is accurately known, the toolface change value calculated according to the dynamic model of the drill string has a large error compared with the actual data. Therefore, the dynamic model of the drill string in the mode of adjusting the toolface by changing the WOB was abandoned and replaced with the parameter of WOB. The output torque of the same motor is positively linearly correlated with the WOB, which has been a consensus formed in the drilling industry for many years. Finally, the input parameters of the toolface artificial intelligence prediction model in the mode of adjusting the toolface by changing the WOB are shown in Table 6, and the output parameter is the predicted change value of the toolface. The basic data of the artificial intelligence prediction model of the toolface in the mode of adjusting the toolface by changing the WOB are shown in Table 7.
After analysis and calculation, the Pearson coefficient of each influence factor and the actual rotation angle of the toolface are shown in Table 8. From Table 8, it can be seen that Factor 8 (WOB change value) has a strong correlation with the toolface actual rotation value, while Factor 6 (Depth) and Factor 7 (Deviation angle) have a moderate correlation with the toolface actual rotation value.
After retaining the strong correlation factor, Factor 8, the accuracy of the actual rotation angle of the downhole toolface predicted by the BP neural network and the GA-BP neural network, under different combinations of influence factors, is shown in Table 9. All the artificial intelligence models listed in Table 8 use the first 17 sets of data in Table 6 as the training set samples, and the last 6 sets of data as test-set samples. After comprehensive comparisons of computing time, the mean absolute error of the training set MAE-train and test set MAE-test, mean squared error of the training set MSE-train and test set MSE-test, coefficient of determination of the training set R 2 -train, test set R 2 -test, and all data R 2 -all, regarding the prediction time and accuracy of the BP method and GA-BP method, the same conclusion can be drawn as under adjusting the toolface by rotating the drill string at the wellhead. The BP and GA-BP prediction results after considering all three influence factors are shown in Figure 13, and the correlation coefficient R is shown in Figure 14. The BP and GA-BP methods have three input layer neurons, one output layer neuron, and five hidden layer neurons. From Figures 13 and 14 and Table 10, it can be seen that the prediction accuracy of the GA-BP method is much higher than that of the BP method.  -all, regarding the prediction time and accuracy of the BP method and GA-BP method, the same conclusion can be drawn as under adjusting the toolface by rotating the drill string at the wellhead. The BP and GA-BP prediction results after considering all three influence factors are shown in Figure 13, and the correlation coefficient R is shown in Figure 14. The BP and GA-BP methods have three input layer neurons, one output layer neuron, and five hidden layer neurons. From Figures 13 and 14 and Table 10, it can be seen that the prediction accuracy of the GA-BP method is much higher than that of the BP method.        The training and testing results of the intelligent control model of the toolface under the above two scenarios show that in the 2D wells with the same formation, the same type of bit, the same screw drill, and the same drill assembly, the prediction absolute error under the mode of adjusting the toolface by rotating the drill string at the wellhead is within 10.9783 • , and the prediction absolute error under the mode of adjusting the toolface by changing the WOB is within 18.8833 • . Reference [8] holds that "If the measurement value is very close to the target value, for example, within the range of target ± 20 • , which is generally considered good in slide drilling, the toolface setting job is done." So, the established GA-BP neural network can meet the accuracy requirements of the toolface control of the bent-housing motor, and can save the time wasted waiting for the toolface to upload, and the subsequent repeated control. In the actual drilling process, the two scenarios are used together, which can effectively prevent an abnormal drilling time. This kind of intelligent method can replace an experienced drilling engineer to guide the rapid and accurate adjustment of the toolface in the short term. In the later stage, we will continue to optimize our GA-BP intelligent prediction model to be suitable for toolface prediction in different formation wells in the same block using different drill bits, downhole motors, and drill string assemblies. Once the prediction accuracy of the model can be guaranteed, this prediction method will serve as a subsystem to provide algorithm support for the intelligent drilling of the directional well and horizontal well. Combined with an automatic drilling rig, downhole measurement, and control and powerful data transmission systems, an intelligent control system of directional wells and horizontal wells trajectory is finally formed.

Conclusions
In this paper, a method based on a drill string dynamics model is proposed to adjust the toolface of a bent-housing motor. Firstly, the dynamics model of the drill string is used to calculate the change value of the bottom hole toolface under the condition that the rotation angle of the drill string at the wellhead is known. Then, the GA-BP neural network is used to fit the calculated change value of the bottom hole toolface, well depth, deviation angle, weight on bit, wellhead drill string rotation angle, and the actual change value of the downhole toolface, and the trained network is used to predict the change value of the downhole toolface in advance. In addition, under the condition of changing the WOB to change the toolface, taking the well depth, deviation angle, and WOB change value as input items and the change value of the toolface as output items, the relationship between the well depth, WOB, and the change value of the toolface is obtained by fitting with the GA-BP neural network. The results show that the prediction error is within 10.9783 • under the condition of rotating the drill string at the wellhead to change the toolface, and the error is within 18.8833 • under the mode of changing the WOB to change the toolface, which can meet the control requirements of the directional well horizontal well trajectory. The proposed method can directly guide the drilling platform workers to adjust and control the toolface quickly and accurately. This method can also provide algorithm support for directional horizontal well trajectory control. With an intelligent drilling rig, downhole measurement, and control and data transmission systems, an intelligent directional horizontal well trajectory control system can finally be formed. Institutional Review Board Statement: Not applicable.

Informed Consent Statement: Not applicable.
Data Availability Statement: All data generated or analyzed during this study are included in this published article.

Conflicts of Interest:
The authors declare no conflict of interest.