Guilianno's picture
Add permeability model app
9f66b5f
Raw History Blame Contribute Delete
5.36 kB
import gradio as gr
import math
# Shokir model constants (Table 3.12)
constants = {
"High GR and low porosity": {"CG1": 0.1769, "CG2": -0.0165, "CG3": -1.3986},
"Above medium GR and medium porosity": {"CG1": 0.1486, "CG2": -0.016, "CG3": -0.9148},
"Medium GR and above medium porosity": {"CG1": 0.1299, "CG2": -0.0196, "CG3": -0.2487},
"Low GR and high porosity": {"CG1": 0.099, "CG2": -0.0221, "CG3": 0.7877}
}
# Mohaghegh model constants
mohaghegh_constants = {
"C1": 38.254,
"C2": -0.5874,
"C3": -0.409438,
"C4": 0.4066
}
# Tables to display
table_1 = """
### Table 1: Correlation Constants for the Shokir model
| Category | CG1 | CG2 | CG3 |
|-------------------------------------|-------|--------|--------|
| High GR and low porosity | 0.1769| -0.0165| -1.3986|
| Above medium GR and medium porosity | 0.1486| -0.016 | -0.9148|
| Medium GR and above medium porosity | 0.1299| -0.0196| -0.2487|
| Low GR and high porosity | 0.099 | -0.0221| 0.7877|
"""
table_2 = """
### Table 2: Range of Applicability for the Shokir model
| Parameter | Low | High | Medium |
|-------------------|----------|---------|---------|
| GR (API units) | 7.64 | 83.56 | 29.5 |
| Core porosity (%) | 5.1 | 36.9 | 26.84 |
| Core permeability (mD) | 0.1 | 9358 | 287.6 |
"""
# Shokir fuzzy logic permeability calculation
def calculate_shokir(GR, phi, category):
try:
CG1, CG2, CG3 = constants[category].values()
log_k = CG1 * phi + CG2 * GR + CG3
k = 10 ** log_k
return f"Permeability (Shokir model): {k:.2f} mD\nThis solution is based on the Shokir fuzzy logic model to estimate permeability in heterogeneous sandstone oil reservoirs using porosity and gamma ray (GR) logs. The model was developed using a large core/log caibrated dataset from a Sandstone reservoir in the Middle east."
except Exception as e:
return f"Error: {str(e)}"
# Mohaghegh permeability calculation
def calculate_mohaghegh(GR, rhoB, ID):
try:
C1, C2, C3, C4 = mohaghegh_constants.values()
k = C1 * (GR ** C2) * (rhoB ** C3) * (ID ** C4)
return f"Permeability (Mohaghegh model): {k:.2f} mD\nThis solution is based on Mohaghegh et al. robust model to predict the permeability with only well log data for wells from which core data is not available. The model was developed using data from the Granny Creek field in West Virginia, which is a highly heterogeneous Formation."
except Exception as e:
return f"Error: {str(e)}"
# Interface
def permeability_app(formula_type, GR, phi=None, category=None, rhoB=None, ID=None):
if formula_type == "Shokir model":
return calculate_shokir(GR, phi, category)
elif formula_type == "Mohaghegh model":
return calculate_mohaghegh(GR, rhoB, ID)
# Gradio interface setup
formula_type = gr.Radio(["Shokir model", "Mohaghegh model"], label="Choose Formula")
GR = gr.Number(label="Gamma Ray (GR, API units)")
phi = gr.Number(label="Effective Porosity (phi, %)", visible=False) # Will show only for Shokir
category = gr.Dropdown(list(constants.keys()), label="Select Category (Table 1)", visible=False)
rhoB = gr.Number(label="Bulk Density (rhoB, g/cc)", visible=False) # Will show only for Mohaghegh
ID = gr.Number(label="Deep Induction Log (ID, Ohm-m)", visible=False)
# Function to update visibility based on formula type
def update_fields(formula_type):
if formula_type == "Shokir model":
return gr.update(visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)
else:
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
# Show output
output = gr.Textbox()
# Additional info for the user
def show_tables():
return f"{table_1}\n\n{table_2}"
# Display the interface
with gr.Blocks() as demo:
gr.Markdown("## Permeability Estimation for Heterogenous Sandstone Formations")
gr.Markdown("These calculations are based on the Shokir and/or Mohaghegh model to predict the permeability of sandstone Formations.")
gr.Markdown("The Shokir model uses gamma ray and porosity values while the Mohaghegh model uses gamma ray, deep induction log and bulk density values.")
gr.Markdown("Table 1 & 2 are used as guides for implementing the Shokir model. Based on your gamma ray and porosity values, select the appropriate category in Table 1.")
gr.Markdown(show_tables()) # Display Table 3.12 and 3.13
with gr.Row():
formula_selector = gr.Radio(["Shokir model", "Mohaghegh model"], label="Choose Formula")
with gr.Row():
GR = gr.Number(label="Gamma Ray (GR, API units)")
phi = gr.Number(label="Effective Porosity (phi, %)")
category = gr.Dropdown(list(constants.keys()), label="Select Category (Table 1)")
rhoB = gr.Number(label="Bulk Density (rhoB, g/cc)")
ID = gr.Number(label="Deep Induction Log (ID, Ohm-m)")
submit_button = gr.Button("Submit")
output = gr.Textbox()
formula_selector.change(fn=update_fields, inputs=formula_selector, outputs=[phi, category, rhoB, ID])
submit_button.click(permeability_app, inputs=[formula_selector, GR, phi, category, rhoB, ID], outputs=output)
demo.launch(share=True)