RPT / RPT.py
dhhien's picture
Upload 18 files
a055e67
import streamlit as st
import pandas as pd
from rockphypy import EM
from rockphypy import Fluid
import numpy as np
import matplotlib.pyplot as plt
#print('cho chet that')
# Plotly imports
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import plotly.figure_factory as ff
import plotly.express as px
plt.rcParams['font.size']=14
plt.rcParams['font.family']='arial'
#import rockphypy # import the module
from rockphypy import QI, GM, Fluid
def RPT_template(las_file, well_data):
st.title('Rock physics template building')
if not las_file:
st.warning('No file has been uploaded')
st.write('Input parameters')
tab1, tab2, tab3, tab4 = st.tabs(["Matrix", "Cement", "Fluid", "RPT"])
with tab1:
st.header("Matrix")
K0=st.number_input('Bulk modulus of matrix',value=36.6, placeholder="Type a number...")
G0=st.number_input('Shear modulus of matrix',value=45, placeholder="Type a number...")
D0=st.number_input('Density of matrix',value=2.65, placeholder="Type a number...")
phi_c=st.number_input(r'Critical porosity, $\rm \phi_c$',value=0.4, placeholder='Type a number...')
Cn=st.number_input('Number of contacts',value=10, placeholder='Type a number...')
#st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
with tab2:
st.header("Cements")
Kc=st.number_input('Bulk modulus of cement',value=37, placeholder="Type a number...")
Gc=st.number_input('Shear modulus of cement',value=45, placeholder="Type a number...")
Dc=st.number_input('Density of cement',value=2.65, placeholder="Type a number...")
phib = st.number_input('Critical cement porosity',value=0.3,placeholder="Type a number ...")
#st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
with tab3:
st.header("Fluid")
Kb=st.number_input('Bulk modulus of brine water',value=2.5, placeholder="Type a number...")
Db=st.number_input('Density of brine water',value=1.0, placeholder="Type a number...")
Ko=st.number_input('Bulk modulus of oil',value=1.5, placeholder="Type a number...")
Do=st.number_input('Density of oil',value=0.8, placeholder="Type a number...")
Kg=st.number_input('Bulk modulus of gas',value=0.8, placeholder="Type a number...")
Dg=st.number_input('Density of gas',value=0.05, placeholder="Type a number...")
#st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
with tab4:
st.header('Rock physics template')
columns = list(well_data.columns)
#st.write()
option=st.selectbox('Select curve for color',columns)
phi = np.linspace(0.1,phi_c,10) #define porosity range according to critical porosity
sw=np.linspace(0,1,5) # water saturation
sigma=20
f=0.5
values = st.slider('Select a range display', np.min(well_data[option]), np.max(well_data[option]),
(np.min(well_data[option]), np.max(well_data[option])))
#print(values[0])
#print(values[1])
mask = (well_data[option] >= values[0]) & (well_data[option] <= values[1])
# Us e the mask to index the DataFrame and then get the index
indices = well_data.index[mask]
#well_data[well_data['Depth'] > ].index.tolist()
#Vp=1000000000*0.0003048/well_data['DT'][well_data['DEPTH']>values[0] and well_data['DEPTH']<values[1]]
#Vs=1000000000*0.0003048/well_data['DTS'][well_data['DEPTH']>values[0] and well_data['DEPTH']<values[1]]
#rhob=well_data['RHOB'][well_data['DEPTH']>values[0] and well_data['DEPTH']<values[1]]
Vp=1000000000*0.0003048/well_data['DT'][indices]
Vs=1000000000*0.0003048/well_data['DTS'][indices]
rhob=well_data['RHOB'][indices]
IP= Vp*rhob
PS= Vp/Vs
sand_model = st.selectbox('Rock physics model',('Stiffsand', 'Softsand', 'Contact Cement', 'Constant Cement',
'Increase Cement', 'User inputs'))
if (sand_model=='Stiffsand'):
Kdry, Gdry = GM.stiffsand(K0, G0, phi, phi_c, Cn, sigma, f=0) # stiff sand
elif (sand_model=='Softsand'):
Kdry, Gdry = GM.softsand(K0, G0, phi, phi_c, Cn, sigma, f=0)
elif(sand_model=='Contact Cement'):
Kdry, Gdry = GM.contactcement(K0, G0, Kc, Gc, phi, phi_c, Cn, scheme=2)
Kdry[phi<phib]=np.nan
elif(sand_model == 'Constant Cement'):
Kdry, Gdry = GM.constantcement(phib,K0, G0, Kc, Gc, phi, phi_c, Cn, scheme=2)
Kdry[phi>phib]=np.nan
elif(sand_model == 'Increase Cement'):
Kdry, Gdry = GM.MUHS(K0, G0, Kc, Gc, phi, phib, phi_c, Cn, scheme=2)
Kdry[phi>phib]=np.nan
elif(sand_model == 'User inputs'):
Kdry, Gdry = GM.softsand(K0, G0, phi, phi_c, Cn, sigma, f=0)
fluid_type = st.selectbox('Fluid type',('Gas','Oil'))
if (fluid_type=='Gas'):
fig=QI.plot_rpt(Kdry,Gdry,K0,D0,Kb,Db,Kg,Dg,phi,sw)
elif (fluid_type=='Oil'):
fig=QI.plot_rpt(Kdry,Gdry,K0,D0,Kb,Db,Ko,Do,phi,sw)
fig.set_size_inches(9, 6)
plt.grid()
plt.scatter(IP,PS, c=well_data[option][indices],edgecolors='grey',s=80,alpha=1,cmap='Greens_r')
cbar=plt.colorbar()
#cbar.set_label(r'$\rm \sigma_{eff}$ (MPa)')
cbar.set_label(option)
plt.xlabel('AI (m/s*g/cc)')
plt.xlim(1000,14000)
plt.ylim(1.4,2.8)
st.pyplot(fig)