{'fraction_non_alphanumeric': 0.0202027490169198, 'fraction_numerical': 0.011796962372379956, 'mean_word_length': 5.032644178454842, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Machine Learning Model for Monitoring Rheological Properties of Synthetic Oil-Based Mud

The drilling fluid rheology is a critical parameter during the oil and gas drilling operation to achieve optimum drilling performance without nonproductive time or extra remedial operation cost. The close monitoring for rheological properties will help the drilling fluid crew to take quick actions to maintain the designed profiles for the drilling fluid rheology, especially when it comes to the flat rheology drilling fluid system, which is a new generation for harsh and specific drilling conditions that require flat profiles for the mud rheology regarding the temperature condition changes. The current study introduces a machine learning application toward predicting the rheology of synthetic oil-based mud (flat rheology type) for the full automation system of monitoring the mud rheological properties. Four models are developed, for the first time, to determine the rheological characteristics of flat rheology synthetic oil-based system using artificial neural networks. The developed models are capable of predicting the plastic and apparent viscosities, yield point, and flow behavior index from only the mud density and Marsh funnel as model inputs. The proposed models were trained and optimized from a real field dataset (369 measurements) with further testing the models using an unseen dataset of 153 data points. The predicted rheological properties achieved a high degree of accuracy versus the actual measurements and showed a coefficient of correlation range from 0.91 to 0.97 with an average absolute percentage error of less than 9.66% during the training and testing phases. Besides, machine learning-based correlations are proposed for estimating the rheological properties on the rig site without running the machine learning system for easy field applications.


INTRODUCTION
During the drilling operations for oil and gas wells, drilling fluids are pumped for many functions such as controlling the drilled formation pressure to prevent any kick situations during drilling the abnormally pressured zones and carrying the drilled cuttings to the surface through the circulation system for good hole cleaning conditions. 1 In addition, drilling fluids provide lubrication and cooling of the drill string and the drill bit and format a filter cake to provide good wellbore stability and prevent mud filtration that causes formation damage. 2 The drilling fluids are classified based on the base fluid for preparing the mud that is mainly oil-or water-based. These two classes are commonly utilized in the petroleum industry during drilling operations. 3−5 Each class provides special technical aspects for the drilling fluid, and therefore, the mud program provides the drilling fluid composition based on the drilled formation sensitivity, drilling fluid activity, level of interest for the drilled section, and safety issues. 6 The composition of the drilling fluids is technically designed to provide efficient filtration and rheological properties for the drilling fluid for better performance during the drilling operations. 7 Synthetic oil-based mud is considered one of the oil-based drilling fluid categories and is mainly customized to be utilized through drilling the reservoir section for better drilling performance and protecting the drilled section from formation damage. 8 Hence, the synthetic oil-based mud system has many advantages such as nondamageable characteristics toward the drilled zones and provide flat rheology performance during drilling operations. Flat rheological properties are required for some specific applications during the oil and gas well drilling such as deep water drilling, extended reach drilling, and cold drilling environment; the concept is to provide flat rheology for the drilling fluid that does not change with the temperature conditions. 9 The flat rheology topic is introduced to the drilling fluid research and field applications with newly developed materials due to its efficient performance. 10 The flat rheology synthetic oil-based mud is one of the flat rheology mud generations that is utilized for harsh and critical drilling conditions for efficient drilling and hydraulic systems that will greatly affect the drilling cost. 11,12 The cost and fluid handling precautions are considered main disadvantages for this mud system in the drilling operations.
1.1. Rheology Measurements and Automation System. The standard procedures for measuring the fluid rheology are followed in the rig site during the drilling operation to monitor the rheology profiles and assure the proficient performance for the drilling fluid by the testing approaches. 13 These measurements provide technical information about the fluid rheological properties in terms of plastic viscosity, mud yield point, and time gel strengths with routine testing with time by the drilling mud crew. It is an essential process to continuously measure the drilling fluid rheology as this affects the mud functions, drilling performance, hydraulics, circulation operations, and pressure losses. 14− 16 Marsh funnel viscosity represents the time for flowing a quantity of fluid volume (930 cm 3 ) through the open orifice of the funnel. 17 A Fann35 rotating viscometer is used for determining the mud rheological properties (viscosity and gel strength of drilling mud) as the device recorded the shear stress versus the shear rate for different speeds at 300 and 600 revolutions per minute (RPM); then, the plastic viscosity (PV), yield point (YP), apparent viscosity (AV), and flow behavior index (n) are, respectively, calculated through the following equations 18 The frequency to measure each fluid property is different based on the critical impact on the well control and drilling operations 19 as the mud density and Marsh funnel viscosity properties are measured every hour from three to four times. The alterations for the collected rheological measurements provide a strong alert about the rock sensitivity and mud activity and stability performance after exposure to the drilled formations. 20 The mud rheological properties were found to have a good relationship with the two common properties for the mud, which are mud weight and Marsh funnel viscosity. In the literature, Pitt 77 and Almahdawi et al. 78 provided two correlations that correlate the mud apparent viscosity to the mud weight and Marsh funnel viscosity as where AV is the apparent viscosity in (cP), ρ m is the mud weight in g/cm 3 , and μ F is Marsh funnel viscosity in seconds. However, the empirical correlations did not provide the required accuracy level. 21 Therefore, the application of machine learning is considered an alternative research horizon for predicting the mud rheological properties to overcome the limitations of the mathematical correlations. Machine learning can be defined as a computational coding process that provides a learning capability from a set of data through the interrelations between parameters. This technique is mainly developed based on data statistical analysis and algorithms to achieve the learning objective for classification or prediction purposes. 22−24 The new research trend is to provide automated systems for monitoring the mud rheological properties through the drilling operations that will save time, be more accurate, and generate the rheology measurements with high frequency. 25−28 New devices are developed in addition to machine learning approaches for this objective; however, the prediction machine learning systems are still needed for a complete loop system for acquiring the rheological properties of different drilling fluid types. 29 1.2. Machine Learning Applications. The recent applications using machine learning techniques for the petroleum data are studied over a wide range of research scope for exploration, drilling, production, field development, and petroleum processing activities. The machine learning applications provided successful improvements for the operation performance, solving technical problems, and cost savings. The machine learning tools were utilized for several studies in drilling operations for optimizing the drilling performance, 30−34 studying the reservoir fluid characteristics 35−40 and reservoir rock properties such as density, 41 porosity 42 and permeability, 43,44 rock geomechanics. 45−49 The drilling fluids' rheological properties were studied through many different studies for developing predictive models for fluid rheology. 50−54 These studies focused on predicting the rheological properties for different mud systems such as oilbased mud, 50,55 water-based drill-in mud, 51 invert emulsion type, 53,56 water-based KCl mud, 57 drilling fluid CaCl 2 , 5858 and water-based NaCl drill-in fluid. 51 These applications contributed to enriching the literature with high-level accuracy machine learning models that are developed for specific mud types.
Consequently, the current study introduces a new machine learning model for predicting the flat rheology synthetic oilbased mud system that will help achieve the optimum drilling performance based on optimizing the mud functions. Hence, the developed models will use the March funnel and mud density measurements to predict the rheological properties of the drilling fluid for better monitoring the mud functionality during the drilling operations on the rig site. The full automation for the mud rheology monitoring is one of the main goals for the current research to provide a full machine learning system for the most common types of drilling fluids in the oil and gas field as invert emulsion, all-oil, and Maxbridg mud systems. 54,59,60 This study introduces machine learning models for monitoring the rheological properties for flat rheology synthetic oil-based mud systems. The artificial neural network (ANN) technique was employed to develop ANN-based models for predicting four rheological properties, which are plastic viscosity (PV), apparent viscosity (AV), yield point (YP), and flow behavior index (η). The prediction models were built to have only two inputs, which are mud weight (ρ m ) and Marsh funnel viscosity (μ F ). Furthermore, the study proposed ANN-based equations for estimating four rheological properties for easy calculation and better tracking for the mud rheology during the drilling operations that will enhance the drilling fluid performance. This introduction will be followed by the detailed approach used in this study in Section 2. All the results from this work are explained and depicted on graphs in Section 3 with complete discussion of the obtained results and comparing them to the previous papers in Section 4. The last section in this paper shows the conclusions of this work.

MATERIALS AND METHODS
The study used collected data for the flat rheology synthetic oilbased mud system. The data were gathered from the mud reports that cover all the measurements for the mud rheology.
The developed models were built by utilizing the ANN tool to develop a separate model for each property based on the model parameter optimization. The model accuracy was determined by calculating the correlation coefficient (R) and the average absolute percentage errors (AAPE) between the actual and predicted values. The closer the R to 1 regardless of being negative or positive, the stronger the relationship between the variables. In this study, the positive correlation coefficient means a direct relationship and negative R means an indirect relationship. 61 There are several machine learning techniques; but in this research, ANN was used because of several advantages. The most important benefit from using the ANN is the ability to extract the weights and biases to be applied in an equation. This makes the research results available for further investigation and comparison. The training phase with ANN can go through several runs with several parameters changing to get the optimum parameters to get the most accurate model.
2.1. Study Approach. The methodology approach for the study started from the data collection for the rheological properties from the mud reports, followed by the data preprocessing for enhancing the data quality by performing data cleaning and filtering to remove the illogic values from the wrong measurements and the outliers. The data statistical analysis is very important especially for determining the data range (minimum to maximum) for each property as this will affect the model application limitations as the wide data range will be better for providing a good range for the training database for the developed models. The data analysis helped reveal the interrelations between the rheological properties and the complexity level for correlating these parameters. Building the models started after the data preprocessing for the high-quality data by optimizing the ANN model parameters for better prediction and studying the sensitivity for each model parameter on the prediction performance. The model performance was checked to determine if the accepted accuracy level is achieved or not based on the R and AAPE values. The model retraining process might be encountered in case the performance level is not accepted. Finally, the best model parameters and results were reported.
2.2. Data Description and Statistics. The recorded parameters covered all the six properties for the flat rheology synthetic oil-based mud, which are plastic viscosity, apparent viscosity, yield point, flow behavior index, and consistency factor (model outputs), in addition to the mud weight and Marsh funnel viscosity (model input parameters). This study introduces a novel contribution regarding selecting only two inputs for the model development, which are mud weight and Marsh funnel viscosity, as the other studies in the literature included other inputs such as the temperature, shear rate, and solid content, 62,63 and hence, the new approach will save time and eliminate the measurement errors to the data. 53 The study uses only mud density and Marsh funnel as model inputs as these parameters have high-frequency measurements (3−4 times per hour) and are easy to measure on the rig site without advanced lab testing.
The dataset covered 522 data points after the data cleaning and preprocessing to remove all the illogic values and outliers. As shown in Table 1, the data represented a wide range for the rheological properties as the mud weight ranged from 70 to 120 pounds per cubic foot (pcf), Marsh funnel ranged from 44 to 120 s, plastic viscosity (PV) ranged from 14 to 74 cP, and    Figure 1 shows the model input and output profiles for the study. 2.3. Data Analysis. The correlation coefficients were studied between the model inputs and outputs and showed a strong direct relationship between the mud weight with both plastic and apparent plastic viscosity (R is 0.70); R is 0.64 between mud weight and flow behavior index, and R is 0.37 between the mud weight with yield point, which is considered the lowest correlation coefficient. The Marsh funnel reported a strong direct relationship with the outputs with R ranging from 0.45 with the flow behavior index to 0.70 with the apparent viscosity as shown in Figure 2.
The model inputs are plotted versus every output individually to study the scatter plots for the data as shown in Figure 3. There is no clear type of relationship between the parameters, and this ensures the complexity of the problem in this study. The application of machine learning is considered helpful for this case as it will provide a high learning capability between the relationships of the parameters.
2.4. Artificial Neural Network Technique. Machine learning has many tools that can be employed for the models' development, and the artificial neural network is one of the most  common tools for machine learning utilization and modeling applications in the petroleum industry. 64−67 The tool has the capability to mimic the biological neural system for thinking by problem learning. 68,69 The structure of the ANN tool starts from a minimum of three layers named the input layer for the input parameters, hidden layer for processing, and output layer for the target parameter prediction. 70−73 The tool has interconnected neurons for linking the layers and affects the performance of the network processing. 74,75 The learning approach for the data is achieved through different learning algorithms. 76 Developing a machine learning model using the ANN tool must be studied through a deep analysis for each network parameter and analysis of its effect on the prediction accuracy. These parameters cover the network function, training function, transfer function, number of hidden layers, and number of neurons in the hidden layer/s. The data were divided into two sets for the training process and testing the model, and different learning algorithms were utilized to obtain the best learning for the relationships between the inputs and output rheological property. For each rheological parameter, the best model parameters were reported based on the best model accuracy.

Model Parameter Optimization.
The model performance is highly affected by the model parameters for the ANN, and hence, sensitivity analysis through many trial procedures for the best model parameters in terms of the number of hidden layer/s, the number of neurons in the hidden layer/s, network function, training function, and transfer function should be performed to record and save all of these parameters. Increasing the number of hidden layers and neurons will help increase the model accuracy; however, this will cause an increase in the computational processing time for running the model. The simple ANN structure with fewer hidden layers and neurons will supply better computational processing time for the model but might not provide high accuracy for the developed model. Hence, achieving the best accuracy results with the simple ANN structure (hidden layers and neurons number) is needed through the sensitivity analysis process for the model development.
The sensitivity analysis was executed for the dataset, and the model accuracy was evaluated through the statistical metrics such as the correlation coefficient (R) and average absolute percentage error (AAPE) between the actual and predicted values. The sensitivity was completed for a wide range of the model parameters, and Table 2 shows the best parameters for each rheological property with the accuracy for the training and testing results.
The sensitivity showed that all the models achieved high results for both training and testing phases during developing the rheology prediction models as R was higher than 0.91 and AAPE was less than 9.6%. The correlation coefficient of testing for the  plastic viscosity model same as the apparent viscosity model, and it was 0.94 which is more than the other two models. The correlation coefficient of testing for the yield point and the behavior index was only 0.92, and the maximum AAPE of testing for all the models was 9.7% for the plastic viscosity model. All models were tested for the neuron number from 5 to 40 using only one hidden layer to have a simple structure for the ANN models, and the N ranged from 10 for the PV and AV model to record 18 for the behavior index model. The best training function for all rheological property models was achieved by Bayesian regularization backpropagation. The optimum transfer functions between the inputs and hidden layer were tan-sigmoid transfer functions for PV, η, and AV models. The YP-developed model has a radial basis transfer function between the inputs and hidden layer.
3.2. Model Training Results. The training of the network was done to obtain the best models that can predict the output rheological property from the input data. Input for all models was only the mud weight and the Marsh funnel viscosity. The training dataset for developing the models is the 369 dataset that is separate from the testing dataset. The predicted values for the training dataset were compared to the actual recorded values to show the models' accuracy.
The final acceptance of the developed models is not decided till the model is tested by the testing dataset that is unseen by the model during the training process. In this research, the accuracy of the predicted values for the training and testing datasets is shown separately to show the quality of the predicted models.
The predicted values were compared to the actual values in terms of R and AAPE. The model that obtained the highest correlation coefficient (R of 0.97) for the training dataset was the apparent viscosity (AV) as shown in the plot of Figure 4d. The yield point has the lowest correlation coefficient for its developed model, which was an R of 0.91 (Figure 4b). Both plastic viscosity and behavior index have the same correlation coefficient of 0.94, which shows excellent accuracy for the models (Figure 4a,c).
The highest average absolute percentage error was for the plastic viscosity (PV) that had only 9.59% (Figure 4a), while the behavior index (η) was the lowest AAPE with only 1.55% (Figure 4c). The apparent viscosity (AV) and the yield point (YP) models were of only 5.13 and 5.65% AAPE (Figure 4b,d).
In addition, the rheological property plots for the actual versus predicted are shown in Figure 5, which shows the high degree of match for the log profiles of each rheological property (PV, YP, η, and AV) as shown in the plots of Figure 5a−d, respectively. The Y-axis shows the index of the data that is the test point measurement.
3.3. Model Testing Results. The main criteria to accept the trained model are the accuracy with a separate dataset that is unseen by the model during training. The chosen testing set is of almost the same range as the training dataset to assure the integrity of the model. The developed models were tested with the unseen dataset (153 data points) for the testing process. The plots of Figure 6 show the testing results for the rheological property prediction for PV, YP, η, and AV rheological property models (Figure 6a−d respectively). The correlation coefficient recorded higher than 0.92 for all models (Figure 6), and the AAPE ranged from 2.69% (for the behavior index model) to 9.66% (for the plastic viscosity model). These AAPE values are accepted based on the values of the rheological properties for the current dataset in addition to the log profiles for the actual and predicted values.
The rheological property profiles were plotted to show the actual versus predicted values for the testing dataset as represented in Figure 7a−d plots for PV, YP, η, and AV rheology models.
The real measurements versus the predicted values were plotted to present the rheology logs based on the obtained results' accuracy from training and testing results. The rheology data profiles proved the accepted accuracy for the models based on the recorded statistical metrics R and AAPE.
3.4. Machine Learning-Based Equations. New ANNbased equations were extracted from the developed ANN rheological prediction models. The ANN-based equations are proposed to be used easily without the need for the developed machine learning code. To utilize the developed empirical correlation, the input values should be normalized to be in the range between −1 and 1 based on the minimum and maximum values for all parameters that are listed in Table 1 8) where N represents the optimized neuron number, w 1 i and w 2 i are the weights between the input layer and the hidden layer and the hidden layer and the output layer respectively. b 1 i is the associated bias with each hidden layer neurons, and b 2 is the associated bias for the output layer. The weights and biases were extracted from the ANN structure of the developed models after saving the final optimized network for each output. The correlations use the weights and biases that are listed in Tables 3−6 for the four rheological properties.

DISCUSSION
The current study presented new contributions of the automation process for predicting the mud rheological properties for better monitoring during the drilling operation. As mentioned in Section 2, the study utilized only two features (mud density and Marsh funnel viscosity) to develop the four prediction models, and these two parameters are easy to measure on the rig site in addition to the high frequency of measurement for these parameters during the mud monitoring process (3−4 times per hour). Consequently, the study will provide the rheological properties with high-frequency data based on the input measurement frequency rather than the long time for the experimental lab measurements for the mud rheology.
In addition, the study implemented the ANN technique to build four different models for the mud rheology, and deep sensitivity was checked for the best ANN parameters to acquire the best results for the rheology prediction. It worthy to mention that it might be better to estimate several variables (rheological properties) with only one ANN model; however, it is not applicable in this case due to the complexity of the problem, the   data behavior, in addition to the new trend to use only two inputs for the prediction. The model development process tested this approach during the model development and found that the current results are optimum for this specific approach but might work for another scope or dataset. The obtained results from the developed models were compared with the most common models in the literature to check the model accuracy over the existing model for field applications. The study compared the obtained results with Pitt, 77 and Almahdawi et al. 78 developed correlations for estimating the apparent viscosity. Figure 8 presents the log profile for the testing dataset that shows the good accuracy and high match between the actual measurements and the predicted values from the ANN model; however, the two correlations (Pitt and Almahdawi et al.) show a high degree of overestimation for the AV. The statistical accuracy metrics show that R is 0.82 for Pitt and Almahdawi et al. correlations with high errors (AAPE is 36.1 and 45.9 for Almahdawi et al. and Pitt, respectively). The newly developed ANN-AV model overcomes the two correlations with high accuracy for a high R-value (0.95) and low errors (6.8%) between the predicted and actual measurement of apparent viscosity.

CONCLUSIONS
The current study presented a new contribution for the rheological properties automation monitoring system for the flat rheology synthetic oil-based mud through the machine learning application. The study employed the ANN technique to develop rheological prediction models for the mud plastic and apparent viscosities, yield point, and flow behavior index. The following outcomes are concluded from the obtained results and analysis: • Deep sensitivity analysis for the model parameters was achieved and found that the best parameters are only one hidden layer, from 10 to 18 neurons; the training function is Bayesian regularization backpropagation, with different optimum networks and transfer functions for the developed models. • The training results showed that R is greater than 0.91 and AAPE did not exceed 9.6% for the four models.
• The developed models were tested and showed a great prediction performance in terms of R and AAPE, as R ranges from 0.92 to 0.95 and AAPE from 6.3 to 2.7%. • New ANN-based equations were developed based on the optimized ANN models that can be used to estimate the mud rheology with high accuracy in real-time good  monitoring for the drilling fluid performance without the need to have the code.