# A Novel Adaptive Transient Model of Gas Invasion Risk Management While Drilling
## 3 BHP Control Model Development
### Proportional-Integral-Derivative (PID) Controller  
The classic PID controller is still a key technology in many industrial control fields because of its good stability, high reliability, simple structure, and convenient control. The PID controller mainly includes three control modules: proportional, integral, and differential, as shown in Figure 3.  
1 The proportional part can quickly adjust the control parameters according to the actual deviation of the control target. 2 The integral part can evaluate the error of each step of regulation and adjust the control parameters to eliminate the system error. 3 The differential part can control in advance according to the error change ratio and suppress the overshoot effectively. The PID controller of BHP regulates the opening of the wellhead throttle valve according to the control error (\(e\)) between the target of the BHP (\(rin\)) and the measured value of the BHP (\(y\)) and regulates BHP automatically, where the control error can be expressed as follows:  
\[e(t)=rin(t)-y(t) \tag{11}\]  
Figure 3: BHP regulation model principle based on the PID controller. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Parameters** & **Values** & **Parameters** & **Values** \\ \hline Vertical Depth & 8000 m & Drill pipe inner diameter & 0.0943 m \\ Drill pipe outer diameter & 0.1143 m & Borehole diameter & 0.1651 m \\ Liquid-phase flow rate & 26.25 kg/s & High-pressure gas permeability & 15/30/45 mD \\ Gas layer drilling open thickness & 5 m & The radius of gas invasion supply & 150 m \\ Drilling fluid injection temperature & 20 °C & Geothermal gradient & 0.02 °C/m \\ Rate of penetration & 2 m/h & Rock chip equivalent diameter & 0.005 m \\ Drilling fluid viscosity & 0.07 Pa-s & The roughness of the ring’s hollow wall surface & 25.4 \(\times\) 10\({}^{-6}\) m \\ Stratigraphic rock density & 2650 kg/m\({}^{3}\) & Drilling fluid density & 1750 kg/m\({}^{3}\) \\ Initial bottom hole differential pressure & 2 MPa & Pool level increment warning value & 2.5 m\({}^{3}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Basic data of the simulated well. First, the automatic regulation control equation for the opening of the wellhead throttle valve is established according to the PID control principle, which is expressed as follows:  
\[\
abla u(t)=K_{\mathrm{P}}e(t)+K_{\mathrm{i}}\!\int_{0}^{t}e(t^{\prime})dt^{ \prime}+K_{\mathrm{d}}\frac{de(t)}{dt} \tag{12}\]  
where \(\
abla u\) is the control variable for throttle opening; \(e\) is the control error, which is the difference between the target BHP and the actual measured BHP; \(K_{\mathrm{P}}\) is the proportionality parameter; \(K_{\mathrm{i}}\) is the integral parameter; and \(K_{\mathrm{d}}\) is the differential parameter. The real-time opening of the throttle is shown below:  
\[u(t)=u(t-1)+K_{\mathrm{P}}e(t)+K_{\mathrm{i}}\!\sum_{t=0}^{t}e(t)+K_{\mathrm{ d}}[e(t)-e(t-1)] \tag{13}\]  
The pressure drop caused by the gas-liquid-solid three-phase in the annulus through the wellhead throttle is calculated by the following equation:  
\[Q=\frac{C_{\mathrm{v}}U\sqrt{\max\!\left(P_{\mathrm{top}}-P_{\mathrm{S}},0 \right)}}{x_{\mathrm{L-S}}/\sqrt{\rho_{\mathrm{L-S},\mathrm{top}}}+x_{ \mathrm{G}}/\left(Y\sqrt{\rho_{\mathrm{G},\mathrm{top}}}\right)} \tag{14}\]  
where \(Q\) is the total mass flow rate through the wellhead throttle in kg/s; \(C_{\mathrm{v}}\) is the fixed constant of the wellhead throttle valve; \(U\) is the wellhead throttle opening; \(P_{\mathrm{top}}\) is the pressure at the wellhead throttle in Pa; \(P_{\mathrm{S}}\) is the pressure at the downstream end of the wellhead throttle in Pa; \(x_{\mathrm{L-S}}\) is the mass flow fraction of the liquid-solid mixture in kg/m\({}^{3}\); \(x_{\mathrm{G}}\) is the mass flow fraction of the gas phase; \(\rho_{\mathrm{L-S},\mathrm{top}}\) is the density of the liquid-solid mixture at the wellhead in kg/m\({}^{3}\); \(\rho_{\mathrm{G},\mathrm{top}}\) is the density of the gas phase at the wellhead in kg/m\({}^{3}\); and \(Y\) is the gas expansion factor.