Machine learning algorithm for prediction of stuck pipe incidents using statistical data: case study in middle east oil fields

One of the most troublesome issues in the drilling industry is stuck drill pipes. Drilling activities will be costly and time-consuming due to stuck pipe issues. As a result, predicting a stuck pipe can be more useful. This study aims to use an artificial intelligence technology called hybrid particle swarm optimization neural network (PSO-based ANN) to predict the probability of a stuck pipe in a Middle East oil field. In this field, a total of 85 wells were investigated. Therefore, to predict this problem, we must examine and determine the role of drilling parameters by creating an appropriate model. In this case, an artificial neural network is used to solve and model the problem. In this way, by processing the parameters of wells with and without being stuck in this field, the stuck or non-stuck of drilling pipes in future wells is predicted. To create a PSO-based ANN model database, mud characteristics, geometry, hydraulic, and drilling parameters were gathered from well daily drilling reports. In addition, two databases for directional and vertical wells were established. There are two types of datasets used for each database: stuck and non-stuck. It was discovered that the PSO-based ANN model could predict the incidence of a stuck pipe with an accuracy of over 80% for both directional and vertical wells. This study divided data from several cases into four sections: 17 ½″, 12 ¼″, 8 ½″, and 6 1/8″. The key reasons for sticking and the mechanics have been thoroughly investigated for each section. The methodology presented in this paper enables the Middle East drilling industry to estimate the risk of stuck pipe occurrence during the well planning procedure.


Introduction
The most costly unplanned drilling occurrence for an operator is sticking a Drilling BHA, which results in the loss of equipment, hole footage, and maybe endangers well objectives. Stuck pipe events have the highest number of nonproductive times (NPT) in the drilling industry, ahead of well control incidents, waiting on the weather (WOW), lost circulation, equipment failures, and rig issues (Dushaishi et al. 2020;Amadi 2015). The annual cost to the industry is estimated to be in the billions of dollars (Hunter and Ollerenshaw, 2014). Today, one of the ways to predict drilling pipe stuck is to use artificial neural networks (Ahmadi and Chen, 2020). The particle swarm optimization (PSO) technique trains the multilayered feed-forward neural networks to discriminate the different operating conditions (Ahmadi 2012;Ahmadi et al. 2015). In 2007, Miri et al. conducted two models to predict differential sticking. They built the database model by creating 109 datasets representing 61 differentially stuck pipe incidents and 48 non-stuck pipe events. The following drilling parameters are included in the database model's input parameters: differential pressure, hole depth, and mud characteristics (API fluid loss, solid percent, mud filtrate viscosity, plastic viscosity, yield point, initial gel strength, and 10 min gel strength). Researchers utilized a back-propagation method, multilayer perceptron (MLP), and radial basis functions (RBF) for feed-forward networks. The research found that these networks are validated after 3401 epochs for the MLP network and 4264 epochs for the RBF network, and they can estimate the error of around 1%. They also discovered that the RBF model's test findings are more accurate than the MLP model's. Shadizadeh et al. used an artificial neural network to predict the probability of a stuck pipe in 2010. They tested their model on databases with a total of 275 cases in them. Datasets for the model were acquired from daily drilling reports (DDRs) in one of Iran's oil fields by Shadizadeh et al. There were 115 stuck cases and 160 non-stuck cases in the database. Non-stuck data were gathered when the wells were entirely safe and had not become stuck in the same broad operating zones. The created model produced a reasonable outcome, with over 90% accuracy. Incidents with stuck pipes occur all around the world. However, due to the nature and structure of drilled formations, certain areas are more damaged than others. Al Dushaishi et al. 2021 established a model that consists of easily adaptable logical requirements that forecast stuck pipe events and provide a suitable treatment to unstick the pipe. Using simple and limited input inputs, their created approach could predict stuck pipe incidents with a 90% accuracy. Their prediction accuracy for removing the clogged pipe was 84 percent for the stuck pipe remedy model. The proposed models for stuck pipe events and remedy forecasts provide logical criteria based on simple quantities that may be used quickly in that oil field. A stuck pipe occurrence in one of the Middle East oil fields is investigated in this research. Most of the drilled wells in this field, according to DDRs, have had at least one stuck difficulty during their drilling operation. This issue has shown itself in every aspect of the well profile. In this industry, the cause of stuck pipes is significantly different. Tight hole problems, differential sticking, hole cleaning, and geometry problems are the most common stuck in this discipline. According to DDRs in the desired oil field, the processes used to liberate pipes in some cases are exceedingly time-consuming and costly. In this field, optimizing drilling parameters, mud characteristics, and geometry factors to reduce the danger of sticking can save time and money. A total of 85 wells in this field are investigated in this study. The wellbore is divided into four portions: hole Sections. 17 ½″, 12 ¼″, 8 ½″, and 6 1/8″.

3
The causes of becoming stuck are investigated in each area. This field also investigates the number of stuck cases for each Formation, the types of sticking, the procedures used to free the pipes, and the major reasons for getting stuck. After that, input parameters are chosen to build a model for predicting the chance of a stuck pipe in the desired field. Selected variables are normalized, and two databases for vertical and directional wells are created. Finally, in the vertical and directed wells database, an artificial Intelligence method integrating neural networks and particle swarm optimization (PSO) is used to predict stuck pipe probability. Artificial neural networks and swarm particle optimization are two machine learning approaches used in this study since they are both powerful prediction techniques. The classification of problems into stuck and non-stuck cases is done using a PSO-based ANN model. The output variable is stuck pipe probability, while the input variables are drilling, mud, geometry, and hydraulic parameters.

Literature review
One of the major early stuck pipe prediction techniques is multivariate statistical analysis. Historically this technique was developed in the 1930s. Using MSA to predict stuck pipe occurrences was initially brought by Hempkins et al. through research done in 1985. Hempkins et al. claimed that before 1985 there had not been any statistical analysis that could bring some study to stuck pipe avoidance. Their study was applied to wells in the Gulf of Mexico. One major drive that forced scholars in the oil industry to explore several proactive approaches to predict stuck pipe is the high rate of sticking problems in the early 1980s, especially in the Gulf of Mexico and North Sea (Hempkins et al.). The authors stated that, between 1981 and 1984, almost 131 stuck pipe incidents were reported in the Gulf of Mexico. The research of Hempkins et al. included 131 stuck pipe cases and 20 drilling variables. They utilized discriminant analysis to develop discriminant functions, equations derived from correlations based on relationships between dependent and independent drilling parameters that would lead to the stuck pipe. These functions are set to classify the input data according to values of their parameters into three groups: mechanical stuck, differential stuck, and non-stuck pipe. The authors found that discriminant analysis brought an 81-87% success rate. In other words, the model can correctly classify the data into their predetermined groups by 81-87%. In 1994, Biegler and Kuhn constructed a model that could predict stuck pipe using the same technique of MSA. Their model included physical parameters of stuck pipe and large drilling datasets. Biegler and Kuhn claimed that their model could predict or detect stuck pipes and identify the driving mechanism of pipe sticking. Thus, the current model can optimize the drilling parameters and lead to stuck avoidance. However, their model was limited to water-based mud, and commercial software was used to analyze the data. There were eight independent, meaningful physical variables selected for each well. The model can optimize these variables during well planning to minimize the risk of stuck pipes. Siruvuri et al., in 2006, were the first researchers who used artificial neural networks to predict stuck pipes. They claimed that neural network modeling could provide better and more accurate solutions for the problems associated with differential sticking events. The researchers constructed a database model that contained 200 datasets, where 120 were reported as differentially stuck pipe and 50 as non-stuck pipe. Also, 35 datasets were used for cross-validation. The remaining dataset rows were used for testing purposes. They separated your database to conduct studies for the waterbased and oil-based sticking phenomenon. The datasets belonged to different fields which are located in the Gulf of Mexico. The authors constructed a simple three-layer generalized feed-forward neural network model. The number of neurons in the first layer (input layer) is dictated by the problem considered and consist of ten processing element. The number of neurons in the second layer (hidden layer) is automatically adjusted according to the strength of the data. Finally, the output layer includes two processing elements: differential stuck or no-stuck. To assess the model prediction performance, the authors calculated and examined two quantitative measures for predicted accuracy calculated and examined: MSE and final MSE. Finally, they observed that the proposed model could approximate the error with ± 5%. Additionally, Sirivuri et al. found that the accuracy of the predictive model depends on the size of the database and the variables selected for the analysis. Miri et al. (2007), conducted research that utilized two models to predict differential sticking. They collected data from 32 wells drilled in the Persian Gulf from different fields (Soroush, Norouz, Abouzar, Forouzan, Salman, Dena, Doroud) during 1998-2006 that experienced differential pipe sticking, and 31 wells that did not experience differential pipe sticking to construct the database for the neural network to predict the risk of differential pipe sticking. Most of the wells were side-tracked and horizontal, and stuck pipe events have occurred in reservoir layers of wells in which oil-based or synthetic drilling fluids were being used to drill. Scholars assumed that oil and synthetic fluids would perform the same. Therefore, the neural network database model will be prepared to study oilbased and synthetic drilling fluids together. They constructed a database model by formulating 109 datasets representing 61 differentially stuck pipe incidents and 48 non-stuck pipe incidents. Each of these datasets has been classified either as stuck or not-stuck. The input parameters of the database model include the following drilling parameters: differential pressure, hole depth, and mud properties (API fluid loss, solid percent, mud filtrate viscosity, plastic viscosity, yield point, initial gel strength, and 10 min gel strength). They claimed that independence in the variable selection makes it possible to predict the occurrence conditions for the differentially stuck pipe. The output values range from zero to one, corresponding zero to non-stuck cases, and 1 to stuck issues. Values between zero and one roughly represent levels of risk. They divided your database into training, validation, and test data that assigned 85, 5, and 15 percent to the theme, respectively. Researchers used a back-propagation algorithm, feed-forward networks, multilayer perceptron (MLP), and radial basis functions (RBF). Both models, MLP and RBF, consisted of four layers. In their study, Miri et al. adjusted the number of neurons in each layer like before research (Sirivuri et al.). They applied two transfer functions Tan-hAxon and Linear Sigmoid Axon, to transform hidden and output layers. Results of the study showed that after 3401 epochs for MLP network and 4264 epochs for the RBF network, these networks are validated, and they can approximate the error of around 1%. Also, they found that test results for the RBF model are more accurate than the MLP model. In 2009, Adriana et al. research presented a study of applying fuzzy logic concepts to the problem of differentially stuck pipes. They claimed that these methods could estimate the risk of stuck pipe occurrence in the well-planning procedure and during drilling in real time. Researchers made a database for their model that included three major data groups: mechanical, differential, and non-stuck. These groups form the basis of the entire Adriana et al. project analysis. They classified wells into 59 differentials, 68 mechanical stuck pipes, and 58 non-stuck as control input in the entire analysis. Also, Adriana et al. utilized discriminant analysis to generate a predictive model of group membership based on similar characteristics of each group. To reduce independent variables for the fuzzy input, they defined dimensionless groups. Consequently, they reduced input parameters from 18 variables into five dimensionless forms by combining initial parameters. They used a fuzzy model and neural network to predict stuck pipe occurrences and provide the optimal values of the variables necessary to move a well from the stuck region into the non-stuck area. In Adriana et al. models, the redefined variables were used as independent variables, and F1, F2 discriminant functions from the discriminant analysis were used as the control input. The data are divided by using 75% of the data for training and 25% data for checking. According to the outputs of their models, they found that the neural network had less misclassification than the fuzzy logic. In 2010, Shadizadeh et al. applied the artificial neural network to predict stuck pipe probability. They used their model on databases that involved a total number of 275 cases. Shadizadeh et al. collected datasets of the model from the daily drilling reports (DDRs) in one of the Iranian oil fields. The database contained 115 stuck and 160 non-stuck cases. Non-stuck data were collected from days that the wells were completely safe and had not become stuck in the same general areas of operation. Researchers selected input parameters between many parameters based on two criteria: (1) There must be a spread of parameter values in the databases. This allows the neural network to approximate the function more easily.
(2) The variable must not be dependent on other input variables only. A parameter may depend on other input variables but must also be dependent on a parameter that is not an input variable.
According to the above criteria, some parameters were removed from the analysis. These parameters are WOB, CA, MW, true vertical depth (TVD), solid percent, flow rate, API fluid loss, loss at formation, and Pf. This study defined a new dimensionless parameter as geometric factor (GF) to reduce the remaining parameters. This parameter is related to geometry parameters and included several parameters. In this work, the available data have been normalized into the range of 0-1, according to the drilling fluid condition in the different hole sections. They classified the study data into two groups: dynamic and static types. The drilling fluid is in circulation in dynamic conditions, while it is not circulating during static conditions. Finally, differential pressure, pH, GF, RPM, ROP, and PV were considered for dynamic conditions. The final selected network has a three-layer feedforward and back-propagation with a sigmoid-type activation function in the hidden and output layers. The number of neurons in the input, hidden, and output layers is 6, 3, and 1. The final parameters are differential pressure, GF, pH, YP, PV, and GL. The final network is a three-layer feed-forward back-propagation network with correspondingly six, four, and one neuron in its input, hidden, and output layers. Activation functions are "tansig" and "logsig" in the hidden and output layers. The result of constructed model was reasonable with over 90% of accuracy. Al-Baiyat et al., in 2012, conducted research that included two models of machine learning to predict stuck pipe incidents. In addition to the neural network technique, Al-Baiyat et al. used another artificial intelligence method supporting vector machines (SVMs). The authors constructed a database that denoted as Group-X.
Datasets of Group-X were retrieved from the technical paper SPE 120128 by . The total number of selected datasets for learning in Group-X was 48 and 18 for testing. The datasets from Group-X were sorted into testing or learning randomly but evenly distributed among the class labels. For Group-X datasets, each set had a target that is denoted by a stuck index as DS: differential stuck, MS: mechanical stuck, or NS: non-stuck. The constructed ANN model for this research was based on the multilayer perceptrons. Researchers built an ANN model for Group-X that was contained 18 neurons for the input layer since the number of parameters provided for that group is 18. Also, based on the optimization process, it has been found that the number of neurons in the hidden layer in the Group-X model was the number of inputs plus one, which was 19 in this case. Since the model will produce one class label for each dataset (either stuck or non-stuck), the output layer was designed to have a single neuron. The two most common activation functions in artificial neural networks were implemented; Sigmoid and Tanh. According to the sequence of activation functions, four scenarios in the ANN models were constructed for their project. They claimed that ANNs and SVMs are powerful tools for predicting stuck pipe incidents which are otherwise very complicated because of the number of variables. Also, the researchers have shown that machine learning techniques can predict the stuck pipe with reasonable accuracy, which is more than 83% based on the data that have been utilized. Al-Baiyat research showed that SVMs are more accurate in stuck pipe prediction than ANNs based on the data used. Another work in 2013 done by Chamkalani et al. demonstrated the usage of the support vector machine model to predict stuck pipe. A new model is developed using different wells' drilling parameters such as measured depth, mud weight, plastic viscosity, yield point, gel strengths, PH, and solid percent. The method incorporates hybrid least square support vector regression and coupled simulated annealing (CSA) optimization technique (LSSVM-CSA) for efficient tuning of SVR hyperparameters. The algorithm is applied to classify the stuck types, i.e., differential stuck or mechanical stuck. The data used for this study were collected from a Middle East oil field (Shoraka et al. 2011). Two hundred and nineteen sets of data were gathered in which non-stock had a portion of 109 data, mechanical acquired 51 datasets, and the remaining 59 data were allotted to differential sticking. The authors found that the model created in the study came up with a higher 95% success rate to classify the data into three groups of stuck pipes.

Field description
The Dezful Embayment, which encompasses 45 oil fields and is frequently associated with gas caps, is one of the Middle East's most prolific locations. Aghajari, Ahwaz, Bibi Hakimeh, Gachsaran, Mansuri, Marun, and Rag-e Safid are all classified as supergiants since they contain 10 to 50 billion barrels of oil in place. Figure 1 depicts these oil fields. The desired oil field is the subject of this case study. In 1956, the chosen oil field, one of the Middle East's most major supergiant oil fields, was discovered. This oil field is located in the southwest of Iran, in the center section of the north Dezful region. It features an anticline structure 72 km long and 6 km wide with an NW-SE trending symmetrical anticlinal. With 1,000,000 barrels per day, the Asmari Formation and Bangestan Group are its primary reservoirs.

Well schematic and geological formations in desired oil field
• The well design is chosen based on subsurface data such as formation pressures, strengths, constitution, cost goals, and drilling approach preferences. Figure 2 depicts a typical schematic of a well profile in the desired oil field. Figure 2 also shows that the well design consists of four hole sections: 17 ½″, 12 ¼″, 8 ½″, and 6 1/8″. • A.J., MN, and GS7 formations are common in the 17 ½″ hole sector. To isolate the 17 ½″ hole, a 13 5/8″ casing shoe is put into the GS6 Formation. In the Dezful Embayment, the AJ Formation has the thickest layer. Silty marls, carbonated sandstones, and siltstones form up the upper part of AJ. This formation constitutes laminate red marls or gypsum veins, mud fissures, and grained siltstones. This formation is often drilled with 62-70 PCF water base mud. Gray marl with limestone blades includes the MN formation. With AJ, the upper contact surface is gradual, while the lower contact surface is very sharp and clear with GS. The GS7 formation comprises anhydrite, gray marl, and limestone at the top of the Gachsaran Formation. It has a thickness of nearly 92 m in the desired oil field. GS7 is usually under low pressure. • From GS6 to CR, a 12 ¼″ hole is drilled. This range contains the formations GS6, GS5, GS4, GS3, GS2, and CR. Isolate this hole with 9 5/8″ casing before drilling an 8 ½″ hole. Casing shoe is put in CR formation at 9 5/8″. The Gachsaran formation consists of evaporating anhydrite and salt with a small porosity and is deformable when compressed. There are seven members in the evaporating Gachsaran Formation. The Asmari Reservoir Formation's lowest member, member 1, is the caprock. Members 2 to 5 are particularly harmful due to the enormous pressures generated by the saline water it contains. Members 6 and 7 are usually under a lot of stress. As previously stated, the 13 5/8″ casing shoe is put in the first layer of anhydrite at GS6. • CR, AS, PD, GU, and IL formations are usually observed in the 8 ½″ hole section. A 7″ liner guards this area. A 7″ shoe indicates the top of the SV formation. Limestones, dolomitic limestones, and argillaceous limestones constitute the Asmari formation (one of the most well-known carbonate reservoirs in the world). The Asmari Formation, which ranges in thickness from 250 to 500 m and is rich in large Foraminifera, is a high-energy limestone with outstanding reservoir properties throughout the Dezful Embayment. A significant fracture system often improves reservoir quality near the tops of high-relief anticlines. The Asmari becomes sandy (Ahwaz Sandstone Member) at its base in the SW Dezful Embayment, increasing its porosity. The Gachsaran Formation is evaporated by the thick caps of the Asmari, forming  0  100  200  300  400  500  600  700  800  900  1000  1100  1200  1300  1400  1500  1600  1700  1800  1900  2000  2100  2200  2300  2400  2500  2600  2700  2800  2900  3000  3100  3200  3300  3400  3500  3600  3700  3800  3900  4000  4100  4200  4300 0 17 ½" hole secƟon protect with13 5/8" casing Casing shoe @ top of GS6 12 ¼" hole secƟon protect with 9 5/8" casing Casing shoe @ CR 8 ½" hole secƟon protect with 7" liner liner shoe @ top of SV 6 1/8" hole secƟon protect with 5" liner, Liner shoe @SV

Fig. 2
Typical schematic of well profile in desired oil field, Middle East a strong barrier. Asmari and Bangestan reservoirs in the Dezful Embayment oil fields are separated by the Pabdeh and Gurpi formations. • On the other hand, these formations act as barriers for the Dezful Embayment's Bangestan reservoirs. These rocks can approximate marl or shale at times. Pabdeh formation consists of shale and clay-limestone. The Ilam Formation forms the upper part of the Bangestan reservoir. On the Ilam horizon, the Ahwaz Bangestan reservoir has a length of 75 km and a width of 8 km. The Ilam Formation is made up of gray microcrystalline limestone that is thin to medium in thickness and is well-bedded. This layer is overlain by the Sarvak Formation and underlain by the Gurpi Formation. • SV formation is drilled with a 6 1/8″ section. A 5″ liner is used to seal this hole, and a 5″ liner shoe is placed at the bottom of the SV formation. The thick Sarvak limestone (300-1000 m thick) and the thinner Ilam Formation constitute the Bangestan reservoir (50-200 m thick). The thick Gurpi/Pabdeh marls covered these two reservoirs, creating a single reservoir in most Dezful Embayment.
In southern Iran, the Sarvak Formation is one of the rock layers of the Bangestan group. This Formation's carbonate rocks are from the study field's reservoir rock.

Selecting and assembling data
Preparing a database for machine learning models is a crucial step. Because noisy inputs result in poor model performance, the datasets must be accurate. A huge database also has a significant impact on the learning process. The model can be trained more effectively if the dataset is large enough. A total of 85 wells in this field were investigated in this investigation. Table 1 shows that 42 of the wells are vertical, whereas 43 are directional. In addition, 60 of the total wells were stuck at least once, while the other wells were drilled without issue. To create the model database, 230 sets were taken from daily drilling reports (DDRs) of the above wells, with 130 sets related to directional wells and 100 sets of data linked to vertical wells. There are 80 datasets of stuck instances and 50 datasets of non-stuck cases in the directional wells database. In addition, the vertical wells database has 50 datasets for stuck points and 50 datasets for non-stuck points, respectively. Non-stuck datasets were chosen from wells that did not report the problem of being stuck in their DDRs (22 wells that were drilled without issue). The control of model calculations will be based on these datasets. Table 2 shows the number of datasets for stuck and non-stuck wells according to well type. These datasets will be used in the modeling portion to create a PSO-based ANN model to predict stuck pipe probability in this field. These datasets will be used as input parameters for the learning process in this model. But first, according to DDR's expertise in this subject, the causes of this phenomenon are studied. As previously stated, the stuck problems have occurred in all portions of wells with hole sizes of 17 ½″, 12 ¼″, 8 ½″, and 6 1/8″. Figure 3a depicts the percentage of each hole size from the stuck incidence. Because each section has a unique geological condition, studying stuck pipe reasons is based on hole size. Drilling parameters, mud characteristics, and other drilling circumstances are also likely to differ from one hole section to the next. As a result, the size of the hole can be used to study stuck situations. It should be noted that the stuck pipe occurrence is a complex issue with numerous variables at play. However, this issue has been researched for each hole size, and the primary cause of sticking has been determined.

Input parameters
Drilling parameters, mud characteristics, geometry parameters, and hydraulic parameters were collected from DDR. The optimal input variables were chosen based on the causes of stuck pipes in this field. Additionally, to optimize the model's performance, the database was divided into two separate databases: vertical and directional wells. All of these characteristics have been chosen so that they are mostly selfcontained. Tables 3 and 4 illustrate these characteristics for vertical and directional cases, respectively.
• Mud Weight (MW) As aforementioned, mud weight plays a critical function in all portions of the well. Additionally, differential sticking and tight hole problems, which are the most  prevalent types of stuck in this field, can be prevented with the proper mud weight. MW versus MD is displayed in Fig. 4 for both stuck and non-stuck cases in all depths of well. As illustrated in Fig. 5, MW for stuck situations is more strongly related to non-stuck issues at certain depth intervals (1000-2000 m and 3000-4000 m). Significant out-of-balance conditions at these intervals may result in differential sticking. • Solids level The kind and amount of solids in the cake determine its properties and the degree to which it sticks to the pipe. It should be noted that raising the cake thickness in a wellbore increases the chances of a stuck pipe. The solid % for stuck and non-stuck cases against MD is shown in Fig. 6. As illustrated in Fig. 7, between 3000 and 4200 m, the solid percent is more suitable for stuck difficulties.
In a stuck situation, the wellbore length can be an effective parameter. Greater strains will be put on the Formation at deeper depth, which could be a significant stuck pipe variable. Additionally, as drilling depth increases, drilling conditions become more difficult, increasing the danger of sticking. Figures 8 and 9 illustrate the number of stuck pipe-cases as a function of the MD interval between 0 and 500 m for vertical and directional wells. As shown in Figs. 10 and 11, most stuck cases occurred at depths greater than 3,000 m in vertical wells. In contrast, most of the stuck points occurred at greater depths than 2000 m in directional wells. Additionally, directional wells are shown to have more stuck problems at shallow depths than vertical wells. • Kick-off Point The kick-off point, or KOP, is defined as the point in the wellbore referred to as a vertical depth below the surface at which the well begins to deviate from vertical in a particular direction at a specific inclination and build-up angle. Generally, this is governed by the well targets and geological conditions. If the KOP is located at a shallow depth, the chance of sticking increases, as the directional section will be the well profile's longest section. In this field, wells identified with their KOP in the 17 ½″ hole section encounter more difficulties than wells located with their KOP in the 12 ¼″ hole section. • Yield Point Y.P. represents the yield stress extrapolated to a zero shear rate. YP is used to determine a mud's ability to lift The slope of the shear stress/shear rate line above the yield point is indicated by PV. A low PV value implies that the mud can drill rapidly due to the low viscosity of the mud exiting the bit. • Gel Strength (Initial and 10 min) Shear stress is determined at a low shear rate after a mud has sat in a quiescent state for some time (10 s and 10 min in the standard API procedure). Certain drilling fluids are thixotropic, gelling when left stagnant and liquefying when sheared. According to the measured gel strength versus time, a drilling fluid's specific gel strength is classified as low-flat (most desirable), progressive, or high-flat (both undesirable). It can be inferred that using the correct values for the YP, PV, and gel strength parameters results in improved hole cleaning and a reduced danger of sticking. It should be noted that the hole cleaning difficulty is one of the desired field's stuck mechanisms.

• Revolutions per Minute (RPM)
Increased rotational speed speeds up the process of straightening the drill collars. By increasing the RPM of the bit, more opportunities to cut the formation are produced in a given period. In the presented approach, the pipe being stuck is considered to be based on the specified parameter. This parameter is plotted versus MD in Fig. 9 for both stuck and non-stuck conditions. As indicated in Fig. 12, the RPM for stuck issues is lower than for non-stuck difficulties at shallow depths. However, at great depths, the RPM of non-stuck objects is significantly reduced.

Redefining variables
Combining input parameters is a typical data preparation approach in artificial intelligence methods. This combination should be straightforward and rational. In this work, several of the above parameters were reinterpreted as input variables for the user in the PSO-based ANN model. Six parameters have been redefined so that they become dimensionless factors. These are the following parameters: YP, PV, GL10M, GEL10 SEC, KOP, and last shoe. The following new parameters have been defined: Psically, it is evident that when the open hole ratio and curve section ratio rise, the risk of a stuck pipe increases. It is important to remember that this approach has been employed in past works. (4) Viscosity ratio = PV YP   Table 5 for vertical and directional wells-along with the redefined variables listed in Table 6.

Normalization
Normalization of data refers to converting all variables in a database to a given range. When differences in variables have a negative impact on the model's performance, normalization is used. As illustrated in Table 7, the input parameters used in this investigation are quite varied. Thus, data normalization is critical in preprocessing the data for this investigation. Normalization of the database can ensure consistent convergence of weights and biases in ANN models. To normalize the input parameters in this research, the following formula was used: where X (n): normalized value, X (min): minimum of original values, X (max): maximum of original values, X: original value. This formula transforms all data to the interval between 0 and 1. Table 7 illustrates the range of initial parameters for both database scenarios (vertical wells and directional wells).

Stuck pipe prediction using a hybrid PSO-based ANN
A hybrid PSO-based ANN model was used to construct a model for predicting the chance of a stuck pipe. Particle swarm optimization (PSO) is being used in the study to train a feed-forward neural network to improve the convergence rate and learning process. The PSO algorithm is dependent on its implementation in two relationships: where c1 and c2 are positive constants, r1 and r2 are random functions in the range [0,1], x i = (x i1 , x i2 ,…,x id ) represents the ith particle; p i = (p i1 , p i2 ,…,p id ) represents the ith particle's best previous position (the position with the highest fitness value); the symbol g represents the index of the best particle in the population; and v = (v i1 ,v i2 ,…,v id (Amin and Rodin 1998). The PSO algorithm's flowchart is depicted in Fig. 9. As previously stated, the primary objective of training ANNs with PSO is to get weights and biases that minimize the MSE. Particles move throughout the weight and bias space and update their positions during each iteration. The best error sets for the entire system are denoted by gbest, and the best error sets for each particle are indicated by pbest.
Then, the ANN model is trained using the obtained particle positions, and the new error is calculated using new weights and biases until a sufficient mistake is found. Weights and biases are calculated and used for prediction.

Test and train data
As noted previously, two different database models were created to fund vertical and directional wells studies. The database is divided into subsets for training and testing. 80% of the dataset was used for training purposes for each database, and 20% was used to evaluate the model's performance. As shown in Table 8, 80 and 20 sets were assigned to training and testing data in vertical wells, respectively. There are 155 and 20 training and testing datasets for directional wells, respectively. The training and testing data percentages were determined randomly among all datasets in this analysis.

Design of networks
The optimal performance of the PSO-based ANN model can be reached by carefully selecting its parameters. As a result, numerous runs were conducted to determine the optimal parameters. The ANN model used in this study is based on multilayer perceptrons, which were addressed in the preceding chapter. It is worth noting that PSO can only change weights and biases to decrease learning error. In comparison, the network design (number of hidden layers and nodes within each hidden layer) must be optimized.

Number of neurons and layers
The number of layers and neurons for each layer of the developed PSO-based ANN models are shown in Table 9. The input, hidden, and output layers are present in both cases. The input layer represents the problem's input parameters. As a result, the number of neurons in this layer equals the number of problem parameters. Because the number of parameters provided for this scenario is ten, the input layer in the model of the vertical well has ten neurons. To determine your total neural network architecture, you must first select the number of hidden neurons in a layer. Underfitting happens when there are not enough neurons in the hidden layers. Underfitting occurs when there are not enough neurons in the hidden layers to identify the signals in a complicated dataset (Chamkalani et al. 2013). Having too many neurons in the hidden layers might cause several problems. Overfitting may arise if there are too many neurons in the hidden layers. When a neural network has so much information processing capacity that the limited amount of data in the set is insufficient to train all neurons in the hidden layers, this is known as overfitting. Even when there is enough training data, a second issue can arise. Many neurons in the hidden layers can increase the time it takes to train the network. The network results showed that the eight hidden neurons have the best performance. There are numerous rule-of-thumb methods for finding the correct number of neurons to employ in the hidden layers. Here is a summary of a few of them: (Chamkalani et al. 2013).
• The number of hidden neurons should equal the difference between the input and output layer sizes. • The number of hidden neurons should be 2/3 the size of the input layer plus the output layer size. • The number of hidden neurons should not exceed twice the size of the input layer. However, the model was tested in the hidden layer with many neurons. Finally, the model of the vertical well produced the greatest results when seven neurons were counted in the hidden layer. The model will provide a single output for each dataset, a real number indicating the stuck pipe probability, resulting in a single neuron in the output layer. The number of neurons in the directional well model was 11, 8, 1, and 1 neuron in the input, hidden, and output layers, respectively, in the same way, that they were for the vertical wells.
Activation functions Before training the model to add nonlinearity into the network, the transfer function at the active nodes of the feed-forward must be fixed. In practice, before training a neural network, the dataset must be preprocessed. The data are compressed during preprocessing to fit inside the activation function's active range. In neural network (NN) modeling, the activation function is crucial. Choosing the correct activation function for the NN design, on the other hand, is not critical (Al-Baiyat and Heinze, 2012). Many transfer functions have been developed; however, the two most popular neural networks are the logistic functions in artificial and hyperbolic tangent activation. As a result, these functions were used as a transfer function in both well datasets. The following equation gives the logistic activation function: It is a sigmoid (S-shaped) curve, and the outputs are in the range of [0, 1]. Also, the hyperbolic tangent activation function is as follows: It is a sigmoid curve, similar to the logistic function. However, the output range is [1, + 1]. Because of its symmetry, it frequently outperforms the logistic function.

Particle number and termination criteria
While a small number of particles may fail to convert to a global solution, a large number of particles may cause convergence to be delayed and training time to be extended. Many runs were obtained because there is no theoretical study for determining the optimal number of particles. Increased particle sizes result in lower error values in the vertical well model. However, following a considerable improvement in network performance for swarm sizes of 10-150 particles, some minor variations in error values have occurred for swarm sizes bigger than 150 particles. On the other hand, the running time increases as the size of the swarm (number of particles) grows. As a result, in PSO-based ANN models for vertical wells, a value of 150 particles was chosen as the optimum number of particles.
In comparison, 200 particles were selected similarly for directional wells. The termination criteria are the circumstances that must be met for the iterative process to close. As a termination criterion in this study, the maximum number of iterations was chosen. As a result, the iterative process ends once the maximum number of iterations is achieved. Significant modifications were observed during the initial iterations according to the model's output. The variations in MSE values were reduced as the number of iterations rose.
Nonetheless, until iteration 500, the changes were moderate, and beyond that, the MSE fluctuations were minimal. As a result, the maximum number of iterations was chosen to be 500. This termination condition concluded the iterative process when the maximum number of iterations was reached.

Accuracy and error
The network's output is usually in the [0 1] range. The data are classed as stuck cases if the result is larger than 0.5, and it is classified as non-stuck cases if the output is less than 0.5. The inaccuracy is then calculated using a comparison of actual and expected work. The following is how the error is calculated: The accuracy of any model is determined by the number of outputs correctly identified throughout all datasets. As a result, the model's accuracy is calculated using the formula: Another error function that has been used to determine the error of outputs in prior work is "Mean Square Error" or MSE, which is defined as the following formula: where: MSE = Mean Square Error, stuck index (0 or 1 in this study), T: predicted stuck index (output of the model), N: total number of data for each case.
Because this is a classification problem, 10 and 11 formulas are more relevant for calculating error and accuracy than 12.

Stuck pipe problem in desired oil field
Stuck pipe problems are among the most difficult challenges to solve during a drilling operation at the desired field. According to DDRs, most drilled wells in this field have had at least one stuck pipe occurrence during their drilling operations. This issue has shown itself in every aspect of the well profile. The procedures and methods used in the desired field to free the pipelines are time-consuming and, in some cases, ineffective. Drilling parameters, mud characteristics, and geometry factors can all be optimized to reduce the chance of sticking and save time and money throughout the drilling operation. In this industry, there are various (10) Error = The number of stuck data considered as non -stuck + The number of non -stuck data considered as the stuck total number of data (11) Accuracy = the number of data predicted correctly total number of data reasons for a stuck pipe. Tight hole difficulties, differential sticking, hole cleaning, and incorrect well geometry are the most common stuck in this field. In this section, stuck pipe issues are investigated in all well hole sizes, and a model is developed to estimate stuck pipe probability in this field.

Stuck problems in 17 ½″ hole size
There were twenty-one total stuck incidents in this hole, with seven occurring in vertical wells and fourteen in directional wells. Figure 3b shows that the tight hole mechanism is the most common type of stuck pipe in this area. Most of the issues occurred during the wash and ream, surveying, connection, RIH, and POH operations. Table 10 shows that most of the stuck scenarios in 17 ½″ hole sizes occurred in the AJ Formation. The AJ Formation had the most stuck cases, accounting for 75% of all cases in this section. According to DDRs and other data, the main reason for the stuck pipe in this part is as follows: Swelling of the AJ Formation can occur if the drilling duration in this hole is extended. While a result, like wash and ream, surveying, RIH, and POH activities, is carried out across these swollen formations, the probability of a stuck pipe increases due to the downfall. Inappropriate mud and hydraulic parameters, on the other hand, have a significant impact on the stuck incidence in this hole. Table 11 contains more information on stuck cases in the 17 ½″ hole section. For each stuck example, the formation name, MD of stuck, KOP, hole angle, and stuck condition have been determined in these tables. In addition, the methods employed to release the pipes for each scenario were described. Figure 3c also shows the percentage of stuck pipe for each formation in a hole size of 17 ½″.

Stuck problems in 12 ¼″ hole size
According to Table 12, directional wells accounted for 21 of the total stuck datasets in this hole size, whereas vertical wells accounted for only three. As a result, directional parameters are crucial in this part. The tangent region of the well profile is usually where a 12 ¼″ hole is found. Furthermore, the tangent section will be tight if the mud weight is less than the acceptable amount for this part. As a result, the drilling pipes may become stuck in a tight hole. On the other side, if the KOP depth is shallow, the tangent portion of the well profile will be the long sector, increasing the chances of getting stuck. Other reasons for becoming stuck in the 12 ¼″ area, according to Fig. 3d, are differential sticking and hole cleaning processes. As shown in Table 12, most of the issues occurred in GS5 Formation. Furthermore, the majority of occurrences of stuck pipe in this hole happened during operations such as wash and ream, connection, drilling, RIH, and POH. Table 13 contains more information on stuck cases in the 12 ¼" hole section. For each stuck case, the formation name, MD of stuck, KOP, hole angle, and stuck condition are listed in this table. In addition, the techniques for releasing pipes are stated for each situation. Figure 3e also shows the percentage of stuck pipe for each formation in a 12 ¼" hole size.

Stuck problems in 8 ½″ hole size
The hole size of 8 1/2″ is the most problematic, accounting for 39% of all stuck records (47 stuck cases). The occurrence of formations with varied pore pressures throughout this hole could be the fundamental reason. AS, PD, GU, and IL forms are typically found in this region. Because the AS (Asmari) formation is a depleted zone, it requires a lower mud weight. Lower formations, such as PD and GU, are high-pressure and require a lot of mud to impact the AS Formation. Differential sticking occurs in three ways in the AS Formation: permeable, porous, and depleted. As a result of these factors, differential sticking has the highest percentage of stuck types in the 8 ½" hole, accounting for 50% (23 occurrences) of total points. For each formation, the average MW (mud weight) that has been used in this hole has been compared to the average MW data of observation wells in this hole (Table 14). Figure 13 shows that the average MW in stuck wells (wells with a stuck pipe) is higher in all formations when compared to observation well data. For both stuck and non-stuck situations, these data are displayed in Fig. 14 versus MD (measured depth). The AS and IL forms, with 14 and 14 stuck points, respectively, are the most challenging formations, as shown in Table 15. Other than differential sticking, there are other explanations for stuck pipe accidents in this scenario. The many causes of being stuck in this region include a tight hole difficulty and incorrect drilling parameters. Figure 3f and g indicates the percentages of stuck pipe for each formation and stuck type in 8 ½" hole sizes, respectively. Stuck problems in 6 1/8″ hole size Thirty-three stuck cases were discovered in 6 1/8″ holes, with 20 cases involving vertical wells and 13 directional wells. SV and IL formations are located in this hole. In SV and IL formations, respectively, stuck pipes occurred 20 and 7 times. In this hole, there was a stuck pipe caused by many

Discussion and evaluation of the results of artificial neural network
The stuck index [0, 1] is used in this study for stuck and non-stuck conditions. So that if the index is equal to zero and one, it indicates non-stuck and stuck, respectively. Also, in all cases, whether vertical or directional wells, if the real conditions and model were the same, then the result (outputs) will be correct for training and testing data. Tables 17,18,19,20,21,22 show the results of the generated models for both datasets, vertical and directional wells. Based on 10   On the other hand, some of the data in correct predicted datasets have the same problem, and in circumstances when they should be close to 1 and predict stuck conditions with high probability, they are close to 0.5. They expect 0.55 for the stuck state, for example. The authenticity of the outcomes is low in these cases. There are numerous mechanisms and types of stuck pipes. Some settings may be effective for each stuck, while others may have no effect. Because a stuck incident is a complex topic, these low-authenticity replies may be natural for particular datasets.

Conclusions
• The results of this paper can be used in pre-drilling planning of directional and vertical wells to optimize the parameters for drilling without stuck of future wells. • In this part, the tight hole problem is the most common kind of stuck in 17 ½″ hole size that may be avoided by using appropriate mud characteristics and reducing drilling time. Increased drilling time in this hole, according to DDRs, causes formation swelling. These swollen formations present an issue with tight holes. • • In directional wells, the hole size of 12 ¼" is crucial.
Twenty-one of the 24 stuck cases in this hole occurred in directional wells. Furthermore, all subjects were in the well profile's tangent section. Moreover, most of the issues occurred in wells where the KOP was located at the 17 ½" hole section. As a result, it can be determined  that directional parameters such as KOP and angle inclination are responsible for most of the stuck issues in this segment. Optimizing these values can reduce the probability of becoming stuck in this hole. • The most problematic hole size is 8 ½", and differential sticking is the most typical type of stuck in this hole. Formations could cause it with varying pore pressures on either side of the hole. In this hole, stuck pipe situations can be prevented by utilizing the appropriate MW value for each formation. In this investigation, MW values for stuck instances were higher than non-stuck cases in all 8 ½" hole formations. As a result, differential sticking in this section may be caused by high mud overbalance pressure.   • It can be stated that geometry parameters considerably affect the model's performance for directional wells based on the input parameters for two groups, vertical and directional wells. In vertical circumstances, however, mud qualities are more essential. • The suggested model may estimate stuck pipe probability during well development in the desired field. It has a reasonable accuracy of over 80% for directional and vertical wells. • The performance of ANN models can be improved by reducing the number of input parameters. New dimensionless parameters were defined in this work by merging some parameters. The addition of new parameters improved the network's findings.
• Optimization of PSO and neural network parameters has a substantial impact on the performance of a PSO-based ANN model.

Funding
The authors state that no funds were allocated to this research paper.