# A Novel Adaptive Transient Model of Gas Invasion Risk Management While Drilling
## 3 BHP Control Model Development
### Fuzzy PID Controller
The bell-shaped membership function is as follows:  
\[\omega(x)=\frac{1}{1+\left|\frac{x-\alpha_{\text{b}}}{a_{\text{b}}}\right|^{ 2b_{\text{b}}}} \tag{19}\]  
where \(a_{\text{b}}\) is the parameter that controls the width of the function; \(b_{\text{b}}\) is the parameter that indicates the degree of steepness of the slope of the control function; and \(c_{\text{b}}\) is the center position of the function. The sigmoid-type membership function is as follows:  
\[\omega(x)=\frac{1}{1+e^{-a_{\text{b}}(x-c_{\text{s}})}} \tag{20}\]  
where \(a_{\text{s}}\) is the parameter for controlling the slope of the curve; and \(c_{\text{s}}\) is the center point of the S-shaped curve. The error \(e(t)\), error change ratio \(e_{c}(t)\), and control parameters \(K_{\text{p}}\), \(K_{\text{i}}\), and \(K_{\text{d}}\) of the membership function are shown in Figure 6.  
(2) Fuzzy rules and fuzzy inference  
Analyzing the response mechanism of BHP to the wellhead choke valve opening and considering the adjustment effect of \(K_{\text{P}}\), \(K_{\text{i}}\), and \(K_{\text{d}}\) on the opening degree of the wellhead choke valve and the relationship between them. A fuzzy control rule table for adjusting the \(K_{\text{P}}\), \(K_{\text{i}}\), and \(K_{\text{d}}\) changes corresponding to the error and the error change ratio is established. The fuzzy control rule table for regulation is shown in Tables 5-7. According to the fuzzy rule table of PID control parameters, it can be self-adaptive tuning according to the real-time deviation and deviation change rate of \(K_{\text{P}}\), \(K_{\text{i}}\), and \(K_{\text{d}}\), which overcomes the limitation of fixed classical PID control parameters and improves the responsiveness and adaptability of the fuzzy PID controller significantly. Figure 6: Membership function graph of each parameter. (3) Defuzzification  
The input parameters are still fuzzy vectors after the fuzzy rule inference operation; it is necessary to deblur them to obtain the exact values of the three control parameter variations. Commonly used defuzzification methods are the maximum membership method, area center method, weighted average method, median method, etc. In this paper, the area center method is used for defuzzification, and the center of gravity of the area enclosed by the membership function curve is used as the final output value. This method is more sensitive to the input signal; even if the input value changes slightly, the output value can make a corresponding change, and the calculation formula is as follows:  
\[x_{0}=\frac{\int\limits_{X}x\omega_{x}(x)dx}{\int\limits_{X}\omega_{x}(x)dx} \tag{21}\]  
where \(X\) is the input signal \(x\) of the theoretical domain of the input signal. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \(\Delta K_{\text{i}}\) & **NB** & **NM** & **NS** & **ZE** & **PS** & **PM** & **PB** \\ \hline NB & NB & NB & NM & NM & NS & ZE & ZE \\ NM & NB & NB & NM & NS & NS & ZE & ZE \\ NS & NB & NM & NS & NS & ZE & PS & PS \\ ZE & NM & NM & NS & ZE & PS & PM & PM \\ PS & NM & NS & ZE & PS & PS & PM & PB \\ PM & ZE & ZE & PS & PS & PM & PB & PB \\ PB & ZE & ZE & PS & PM & PM & PB & PB \\ \hline \end{tabular}
\end{table} 
Table 6: Fuzzy rule table of the integral parameter variation \(\Delta K_{\text{i}}\). \begin{table}
\begin{tabular}{c c c c c c c c} \hline \(\Delta K_{\text{d}}\) & **NB** & **NM** & **NS** & **ZE** & **PS** & **PM** & **PB** \\ \hline NB & PS & NS & NB & NB & NB & NM & PS \\ NM & PS & NS & NB & NM & NM & NS & ZE \\ NS & ZE & NS & NM & NM & NS & NS & ZE \\ ZE & ZE & NS & NS & NS & NS & NS & ZE \\ PS & ZE & ZE & ZE & ZE & ZE & ZE & ZE \\ PM & PB & NS & PS & PS & PS & PS & PB \\ PB & PB & PM & PM & PM & PS & PS & PB \\ \hline \end{tabular}
\end{table} 
Table 7: Fuzzy rule table of the differential parameter variation \(\Delta K_{\text{d}}\).