# A Novel Adaptive Transient Model of Gas Invasion Risk Management While Drilling
## 3 BHP Control Model Development
### Fuzzy PID Controller  
The fuzzy PID controller couples the fuzzy reasoning and the PID controller. It is the adaptive tuning of the control parameters by establishing the membership function of the control parameters, error, and error change ratio and designing the fuzzy control rules. The fuzzy PID controller can adjust the control parameters dynamically, overcome the limitation of fixed parameters in the PID controller, and improve the control efficiency. The core of a fuzzy PID controller is a fuzzy inference machine, which can develop reasonable control rules based on human expert experience and includes three stages, such as fuzzification of the control object, fuzzy inference process, defuzzification of the control parameters, etc. The error and the error change ratio are the input of the model, and the control parameters of PID can be adjusted adaptively by fuzzy control rules. Its robustness will be significant compared with classical PID controllers. In this paper, by coupling the fuzzy inference and PID controller, an intelligent regulation model of BHP based on the fuzzy PID controller is developed, and its control principle is shown in Figure 5.  
(1) Parameter fuzzification  
Firstly, the input parameters are fuzzified. The error \(e(t)\) and error change ratio \(e_{c}(t)\) are two input parameters of the fuzzy PID controller. After parameter fuzzification, fuzzy inference, and defuzzification, the control parameters of PID \(K_{p}\), \(K_{i}\), and \(K_{d}\) are obtained. Figure 4: BHP vs. time for the PI controller method and the PID controller method. Figure 5: BHP regulation model principle based on the fuzzy PID controller. One of the parameters' fuzzification processes is to calculate the fuzzy quantity of the input parameter based on the actual domain \([x_{L},\ x_{H}]\) and its corresponding set domain \([-\text{b},\ b]\) of the fuzzy quantity (\(\hat{x}\)), and the calculation process is as follows:  
\[\hat{x}=k\bigg{(}x-\frac{x_{H}-x_{L}}{2}\bigg{)} \tag{15}\]  
where \(\hat{x}\) is determined by rounding to the nearest whole number, and \(k\) is the quantification factor, which is calculated as follows:  
\[k=\frac{2b}{x_{H}-x_{L}} \tag{16}\]  
Based on the actual condition, it was determined that the domains of the two input parameters \(e\) and \(e_{c}\) were \([-3,\ -2,\ -1,\ 0,\ 1,\ 2,\ 3]\). The control domains of the three output parameters \(K_{\text{p}}\), \(K_{\text{i}}\), and \(K_{\text{d}}\) were \([-3,\ -2,\ -1,\ 0,\ 1,\ 2,\ 3]\), \([0.020,\ 0.013,\ 0.007,\ 0,\ 0.007,\ 0.013,\ 0.020]\), and \([-3,\ -2,\ -1,\ 0,\ 1,\ 2,\ 3]\). The discrete theoretical domain of each parameter corresponds to the following fuzzy geometry \(\{\text{PB},\ \text{PM},\ \text{PS},\ \text{ZE},\ \text{NS},\ \text{NM},\ \text{NB}\}\). Each parameter corresponds to a fuzzy quantity, and its degree of membership to this fuzzy quantity is calculated by the membership function. \[\omega_{B}(x)=\left\{ \begin{array}{cc}0&\text{$x$ is not a member of $B$ at all}\\ (0,1)&\text{$x$ is part of $B$}\\ 1&\text{$x$ is a complete member of $B$}\\ \end{array} \right. \tag{17}\]  
where \(x\) is the element; \(B\) is the set; and \(\omega_{\text{B}}\) is the membership degree of element \(x\) in set \(B\). In this paper, triangular, bell-shaped, and sigmoid-type membership functions are used to calculate the membership of the input parameters to the fuzzy quantities. The triangular membership function is as follows:  
\[\omega(x)=\left\{ \begin{array}{cc}0,&x\leq a_{\text{t}}\\ \frac{k-a_{\text{t}}}{b-a_{\text{t}}},&a_{\text{t}}\leq x\leq b_{\text{t}}\\ \frac{a_{\text{t}}-x}{\alpha-h},&b_{\text{t}}\leq x\leq c_{\text{t}}\\ 0,&c_{\text{t}}\leq x\\ \end{array} \right. \tag{18}\]  
where \(a_{\text{t}}\) is the left foot; \(b_{\text{t}}\) is the peak; and \(c_{\text{t}}\) is the right foot.