**4.4 The use of numerical modeling and machine learning to aid early kick detection**

Flow modeling and simulation is critical for testing and validating early kick detection systems. Mathematical models which account for two-dimensional and three-dimensional transient multiphase flow with due consideration to different flow regimes within the drilling assembly and the annuli, heat transfer between the surrounding formation and the wellbore, and gas solubility are required to adequately capture wellbore dynamics during a kick scenario. Numerical techniques such as Computational Fluid Dynamics, though computationally extensive, are being employed to solve these equations due to the limitations of simplified one-dimensional models and empirical models with simplified assumptions [30]. The use of flow modeling as a kick detection method has been highlighted. Wellbore flow is simulated using a "representative" hydraulic model and then compared to the projected flow rate with actual measured flow rates. Non-linear variations in fluid properties such as density, rheology, gel strength due to multiphase flow (in some cases three phase flow—gas influx, liquid flow, and cuttings transport) are difficult to accurately model thus limiting its use in early kick detection [16]. It is worth noting that most published flow models for EKD are homogeneous-type one-dimensional two-phase drift flux models due to the simplicity of calculating phase velocity and gas fraction [30].

The machine learning approach has also been utilized for kick detection. Data employed has been obtained from different sensors on either actual drilling rigs or lab-scale experiments. Different input parameters have been tested which include majorly prior highlighted primary and secondary kick indicators. Different models have been tested such as Bayesian classifier, decision tree, k-nearest neighbor, random forest, support vector machine, different neural networks, and autoregressive models [31, 32]. Extensive gas-kick datasets were generated autonomously via 108 tests from a pilot-scale test well experimental setup equipped with a complete drilling system and a comprehensive mud logging system for surface monitoring of relevant drilling and geological parameters complimented with Doppler wave sensors just above the BOP for riser monitoring of gas migration and downhole pressure monitoring via pressure gauges. A managed pressure drilling system was coupled to the rig setup with a gas injection system. A polycrystalline diamond compact drilling bit with a bottomhole assembly was used to drill autonomously through a synthetic rock sample. The experimental setup was designed to simulate an actual gas-kick incident that occurred at approximately 4100 m (13,452 ft) during a drilling operation with a water depth of approximately 1000 m (3281 ft). Data preparation and analysis was performed which included raw-data exploration, data cleaning, signal/noise-ratio

analysis, feature scaling, outlier removal, and feature selection using a random forest algorithm which resulted in reduction from the initial 24 parameters to 11 parameters considered important for kick detection. Four parameters (ROP, BHP, Doppler amplitude, and differential flow out capturing delta flow) were considered of utmost importance in early kick detection. The data was further labeled using a six-level risk likelihood criterion instead of the typical two-state alarms ("kick" or "no kick"). The splitting ratio for time-series dataset was 63%, 7%, and 30% among the training, validating, and testing sets, respectively. Of the four machine learning algorithms tested, decision tree, *k*-nearest neighbors, support vector machine, and long shortterm memory (LSTM), the LSTM recurrent neural network algorithm showed the best performance, with early detect gas kicks and proper classification into the six kick alarm levels with minimal false negatives. The maximum detection time delay was 7 s only, which provides sufficient time margin to address the gas kick scenarios. The value in supplementing surface kick detection related parameters with continuous Doppler-ultrasonic-wave parameters measured at the mudline and downhole BHP was demonstrated [33].
