<jupyter_start><jupyter_text>PDC ROP model<jupyter_code>import numpy as np
import pandas as pd
import math
import matplotlib.pylab as plt
from scipy.optimize import curve_fit
import seaborn as sns
import itertools
from math import pi
from matplotlib.legend_handler import HandlerPatch
from scipy.optimize import curve_fit
from SALib.sample import saltelli
from SALib.analyze import sobol<jupyter_output><empty_output><jupyter_text>Model<jupyter_code>def Akhtarmanesh_etal_ROP(WOB,RPM,RS,NOC,BR,SR,Dc,NOB,Db):
    


    try:
        
        #Saman model phase I and II
        WOCt = 270*((RPM/80)**0.1)*(11/NOC)*((math.tan(math.radians(BR))/math.tan(math.radians(25)))**0.2)*(Dc/0.51)*(RS/28000)
        # print('WOCt = ', WOCt)                                               
        DOCt = 0.018*((80/RPM)**0.3)*(11/NOC)*(Dc/0.51)
        # print('DOCt = ', DOCt) 
        WOBt = WOCt*NOC
        # print('WOBt = ', WOBt) 
        ROPt = DOCt*RPM*5
        # print('ROPt = ', ROPt) 
        ARS = RS*(1+0.3*(RPM/100))
        # print('ARS = ', ARS) 

        G = 880*((NOB**0.3)/(NOC**1.05))*(Dc*math.cos(math.radians(SR)))/(Db**2)*(math.tan(math.radians(BR))**0.2)
        # print('G = ', G) 
        
        if WOB < WOBt:


            # phase I
            ROP = 0.000002*G*((RPM**0.7)*(WOB**2.6))/ARS
        else:
            # phase II
            ROP = G*(RPM*(WOB-WOBt))/ARS + ROPt
            
    except ZeroDivisionError:
        
        ROP = 999999
        
    return ROP<jupyter_output><empty_output><jupyter_text>Data  Bits PDC bits manufactured by National O<NAME> - NOV (left) and Ulterra (right) are seen at the following image.     DataThe four-row of data used in this study are seen in the following table. Table```|   year | name       |     WOB |   ROP data |   Db |   RPM |   UCS |   NOC |   BR |   SR |   Dc |   NOB ||--------|------------|---------|------------|------|-------|-------|-------|------|------|------|-------||   2019 | SWG        | 2543.8  |    6.2     | 3.75 |    80 | 28000 |    11 |   25 |    1 | 0.51 |     4 ||   2019 | SWG        | 3048.9  |   11.9     | 3.75 |    80 | 28000 |    11 |   25 |    1 | 0.51 |     4 ||   2019 | SWG        | 3538.7  |   19.5     | 3.75 |    80 | 28000 |    11 |   25 |    1 | 0.51 |     4 ||   2019 | SWG        | 4066.2  |   28.6     | 3.75 |    80 | 28000 |    11 |   25 |    1 | 0.51 |     4 |``` Data Dimensions```WOB is in lbfROP data is in ft/hrDb is in inchRPM is in rpmUCS is in psiNOC is dimensionlessBR is dimensionlessDc is in inchNOB is dimensionless```  Read data<jupyter_code>data = pd.read_csv("ROP data.csv")
data.head()
data.tail()
WOB_list = list(data['WOB'])
RPM_list = list(data['RPM'])
Db_list = list(data['Db'])
RS_list = list(data['UCS'])
NOC_list = list(data['NOC'])
NOB_list = list(data['NOB'])
BR_list = list(data['BR'])
SR_list = list(data['SR'])
Dc_list = list(data['Dc'])

ROP_data_list = list(data['ROP data'])<jupyter_output><empty_output><jupyter_text>Comparison between model and data<jupyter_code>model_rop = [Akhtarmanesh_etal_ROP(WOB,RPM,RS,NOC,BR,SR,Dc,NOB,Db) \
             for (WOB,RPM,RS,NOC,BR,SR,Dc,NOB,Db) in \
             zip(WOB_list, RPM_list, RS_list,NOC_list, 
                 BR_list, SR_list,Dc_list, NOB_list,Db_list)]
plt.figure(figsize=(7,7))
plt.scatter(ROP_data_list, model_rop, c='k')
plt.xlim(0,80)
plt.xlabel("ROP Data (ft/hr)")
plt.ylim(0,80)
plt.ylabel("PDC ROP Model estimation (ft/hr)")
plt.show()<jupyter_output><empty_output><jupyter_text>Parameters Interaction Visualization<jupyter_code>problem = {
    'num_vars': 9,
    'names': ['WOB','RPM','RS','NOC','BR','SR','Dc','NOB','Db'],
    'bounds': [[1000,10_000],
              [30,350],
              [10_000,35_000],
              [4,15],
              [5,25],
              [1,3],
              [0.4,0.75],
              [4,15],
              [3,12.25]]}
def evaluate_model(row):
    WOB,RPM,RS,NOC,BR,SR,Dc,NOB,Db = row
    ROP = Akhtarmanesh_etal_ROP(WOB,RPM,RS,NOC,BR,SR,Dc,NOB,Db)
    return ROP
param_values = saltelli.sample(problem, 1024)

Y = np.zeros([param_values.shape[0]])
for i, X in enumerate(param_values):
    Y[i] = evaluate_model(X)
Si = sobol.analyze(problem, Y, print_to_console=False)
Si_filter = {k:Si[k] for k in ['ST','ST_conf','S1','S1_conf']}
Si_df = pd.DataFrame(Si_filter, index=problem['names'])
Si_df
import Interaction_Viz 
Interaction_Viz.Apply(Si, problem, threshold=0.0005)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18013960819635216, 'fraction_numerical': 0.05809502364332358, 'mean_word_length': 2.492138364779874, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '173500', 'license': 'MIT', 'n_tokens_mistral': 1936, 'n_tokens_neox': 1740, 'n_words': 329, 'path': 'Akhtarmanesh et al PDC ROP model/.ipynb_checkpoints/ROP_model-checkpoint.ipynb', 'repo_name': 'Atashnezhad/ROP-Modeling', 'size': '4443'}