En esta entrada se realiza la interfaz gráfica de la razón gas disuelto-petróleo, se toma la misma interfaz de la presión de burbuja y se modifica para esta nueva interfaz. En las siguientes entradas se reutilizará esta misma interfaz agregando los items ya vistos en entradas anteriores.
El
código completo es el siguiente:
import
math as math
from
tkinter import *
import
tkinter as tk
from
tkinter import ttk
import
numpy as np
from
tkinter import messagebox
Decima_Ventana
= Tk()
Decima_Ventana.geometry("450x200")
Decima_Ventana.maxsize(450,200)
Decima_Ventana.minsize(450,200)
Decima_Ventana.title("Razón
Gas Disuelto-Petróleo")
Decima_Ventana.configure(background="gray80",highlightbackground="gray80",highlightcolor="black")
Valores
= ["Standing, M.B.","Lasater, J.A.","Vázquez, M.E. y
Beggs, H.D.","Glaso, O.","TOTAL,
C.F.P","Al-Marhoun, M.A.","Dokla, M.E y Osman
","M.E.Petrosky, G.E., Jr. y Farshad, F.F.","Kartoatmodjo,
T. y Schmidt, Z."]
Variable
= tk.StringVar()
Visor_correlaciones
= ttk.Combobox(Decima_Ventana)
Visor_correlaciones.place(relx=0.01,
rely=0.01, relheight=0.11, relwidth=0.750, bordermode='ignore')
Visor_correlaciones.configure(takefocus="",state="readonly",textvariable
= Variable, justify = "center",values = Valores)
Visor_correlaciones.current(0)
def
Correlaciones_Rgb(event):
try:
#P = 2000 psi
#P2 = 4000 psi
#Pb = 2500 psi
#T = 180 °F
#API = 31 °API
#Yg = 0.95
P =
float(Entrada_1.get()) # psi
Pb =
float(Entrada_2.get()) # psi
T =
float(Entrada_3.get()) # °F
API =
float(Entrada_4.get()) # °API
Yg =
float(Entrada_5.get())
if P <= 0:
messagebox.showwarning("Advertencia!","La
Presión es incorrecta")
elif Pb <= 0:
messagebox.showwarning("Advertencia!","La
Presión de burbuja es incorrecta")
elif T <= 0:
messagebox.showwarning("Advertencia!","La
Temperatura es incorrecta")
elif API <= 0:
messagebox.showwarning("Advertencia!","La
Gravedad API es incorrecta")
elif Yg <= 0:
messagebox.showwarning("Advertencia!","La
Densidad del gas es incorrecta")
else:
if P >=
Pb:
Pb
= Pb
elif P <=
Pb:
Pb
= P
else:
print("Error
Fatal, Reinicie el Equipo ")
Yo =
141.5/(API+131.5)
if
str(Variable.get()) == Valores[0]:
#Correlación
Standing, M.B. para p = 4000 psi (p>pb), por lo que Rs = Rsb
Rs1 =
Yg*(((Pb/18.2)+1.4)*10**(0.0125*API-0.000917*T))**1.2048
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs1,4))
elif
str(Variable.get()) == Valores[1]:
#Correlación
de Lasater, J.A.
Mo
= 630 - 10*API
G
= (Pb*Yg)/(T+460)
if
G < 3.29:
Yg1 = 0.359*np.log(((1.473*Yg*Pb)/(T+460))-0.476)
elif
G >= 3.29:
Yg1
= (((0.121*Pb*Yg)/(T+460))-0.236)**0.281
else:
print("Error")
Rs2
= (132755*Yo*Yg1)/(Mo*(1-Yg1))
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs2,4))
elif
str(Variable.get()) == Valores[2]:
#Correlación
de Vázquez, M.E. y Beggs, H.D.
C1
= 0.0178; C2 = 1.187; C3 = 23.931
Rs3 = (C1*Yg*Pb**C2)*np.exp((C3*API)/(T+460))
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs3,4))
elif
str(Variable.get()) == Valores[3]:
#Correlación
de Glaso, O.
F
= (10)**((2.8869-(14.1811-3.3093*np.log10(Pb))**0.5))
Rs4
= Yg*(F*((API**0.989)/(T**0.172)))**1.2255
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs4,4))
elif
str(Variable.get()) == Valores[4]:
#Correlación
de la TOTAL, C.F.P
C1
= 15.0057; C2 = 0.0152 ; C3 = 4.484*10**-4 ; C4 = 1.095
Rs5 = Yg*((Pb/C1)*10**((C2*API-C3*T)))**C4
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs5,4))
elif
str(Variable.get()) == Valores[5]:
#Correlación
de Al-Marhoun, M.A.
Rs6 =
(185.84321*Pb*Yg**1.87784*Yo**(-3.1437)*(T+460)**(-1.32657))**1.3984
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs6,4))
elif
str(Variable.get()) == Valores[6]:
#Correlación
de Dokla, M.E y Osman , M.E.
Rs7 =
(0.11956*10**(-3)*Pb*Yg**1.01049*Yo**-0.107991*(T+460)**0.952584 )**1.3811
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs7,4))
elif
str(Variable.get()) == Valores[7]:
#Correlación
de Petrosky, G.E., Jr. y Farshad, F.F.
Rs8 =
(Yg**0.8439*((Pb/112.727)+12.34)*10**((7.916*10**-4*API**1.5410-4.561*10**-5*T**1.3911)))**1.73184
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs8,4))
elif
str(Variable.get()) == Valores[8]:
#Correlación
de Kartoatmodjo, T. y Schmidt, Z.
C1
= 0.0315; C2 = 0.7587; C3 = 11.2895; C4 = 0.9143
Rs9
= C1*(Yg**C2)*(Pb**(1/C4))*(10**((C3*API)/(T+460)))
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,round(Rs9,4))
else:
messagebox.showwarning("Advertencia!","La
opción seleccionada rompio la realidad")
except ZeroDivisionError:
messagebox.showwarning("Advertencia!","Los
datos ingresados son incorrectos, por favor revisalos")
except SyntaxError:
messagebox.showwarning("Advertencia!","Los
datos ingresados son incorrectos, por favor revisalos")
except ValueError:
messagebox.showwarning("Advertencia!","Los
datos ingresados son incorrectos, por favor revisalos")
finally:
pass
return
Visor_correlaciones.bind('<<ComboboxSelected>>',
Correlaciones_Rgb)
Recuadro_Entradas
= tk.LabelFrame(Decima_Ventana)
Recuadro_Entradas.place(relx=0.01,
rely=0.13, relheight=0.850, relwidth=0.980)
Recuadro_Entradas.configure(relief='groove',foreground="black",text='''Entradas''',background="gray80",highlightbackground="gray80",highlightcolor="black",width=330)
Mensaje_1
= tk.Message(Recuadro_Entradas)
Mensaje_1.place(relx=0.02,
rely=0.01, height=25, width=80)
Mensaje_1.configure(background="gray80",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center',text='''P''')
Mensaje_2
= tk.Message(Recuadro_Entradas)
Mensaje_2.place(relx=0.21,
rely=0.01, height=25, width=80)
Mensaje_2.configure(background="gray80",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center',text='''Pb''')
Mensaje_3
= tk.Message(Recuadro_Entradas)
Mensaje_3.place(relx=0.40,
rely=0.00, height=25, width=80)
Mensaje_3.configure(background="gray80",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center',text='''T''')
Mensaje_4
= tk.Message(Recuadro_Entradas)
Mensaje_4.place(relx=0.60,
rely=0.00, height=25, width=80)
Mensaje_4.configure(background="gray80",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center',text='''°API''')
Mensaje_5
= tk.Message(Recuadro_Entradas)
Mensaje_5.place(relx=0.80,
rely=0.00, height=25, width=80)
Mensaje_5.configure(background="gray80",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center',text='''Yg''')
Mensaje_7
= tk.Label(Recuadro_Entradas)
Mensaje_7.place(relx=0.21,
rely=0.62, height=25, width=140)
Mensaje_7.configure(background="gray80",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center',text='''Resultado:''')
Mensaje_8
= tk.Label(Recuadro_Entradas)
Mensaje_8.place(relx=0.85,
rely=0.62, height=25, width=50)
Mensaje_8.configure(background="gray80",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center',text='''PCN/BN''')
Entrada_1
= tk.Entry(Recuadro_Entradas)
Entrada_1.place(relx=0.02,
rely=0.18, height=20, width=80)
Entrada_1.configure(background="white",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center')
Entrada_2
= tk.Entry(Recuadro_Entradas)
Entrada_2.place(relx=0.21,
rely=0.18, height=20, width=80)
Entrada_2.configure(background="white",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center')
Entrada_3
= tk.Entry(Recuadro_Entradas)
Entrada_3.place(relx=0.40,
rely=0.18, height=20, width=80)
Entrada_3.configure(background="white",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center')
Entrada_4
= tk.Entry(Recuadro_Entradas)
Entrada_4.place(relx=0.60,
rely=0.18, height=20, width=80)
Entrada_4.configure(background="white",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center')
Entrada_5
= tk.Entry(Recuadro_Entradas)
Entrada_5.place(relx=0.80,
rely=0.18, height=20, width=80)
Entrada_5.configure(background="white",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center')
Salida_1
= tk.Entry(Recuadro_Entradas)
Salida_1.place(relx=0.50,
rely=0.64, height=20, width=140)
Salida_1.configure(background="white",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",justify='center')
Entrada_1.delete(0,tk.END);Entrada_1.insert(tk.END,"");Entrada_1.insert(tk.END,0.00)
Entrada_2.delete(0,tk.END);Entrada_2.insert(tk.END,"");Entrada_2.insert(tk.END,0.00)
Entrada_3.delete(0,tk.END);Entrada_3.insert(tk.END,"");Entrada_3.insert(tk.END,0.00)
Entrada_4.delete(0,tk.END);Entrada_4.insert(tk.END,"");Entrada_4.insert(tk.END,0.00)
Entrada_5.delete(0,tk.END);Entrada_5.insert(tk.END,"");Entrada_5.insert(tk.END,0.00)
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,"");Salida_1.insert(tk.END,0.00)
def
Limpiando():
Entrada_1.delete(0,tk.END);Entrada_1.insert(tk.END,"");Entrada_1.insert(tk.END,0.00)
Entrada_2.delete(0,tk.END);Entrada_2.insert(tk.END,"");Entrada_2.insert(tk.END,0.00)
Entrada_3.delete(0,tk.END);Entrada_3.insert(tk.END,"");Entrada_3.insert(tk.END,0.00)
Entrada_4.delete(0,tk.END);Entrada_4.insert(tk.END,"");Entrada_4.insert(tk.END,0.00)
Entrada_5.delete(0,tk.END);Entrada_5.insert(tk.END,"");Entrada_5.insert(tk.END,0.00)
Salida_1.delete(0,tk.END);Salida_1.insert(tk.END,"");Salida_1.insert(tk.END,0.00)
return
Limpieza
=
Button(Recuadro_Entradas,activebackground="OliveDrab4",activeforeground="black",background="gray80",disabledforeground="#a3a3a3",foreground="#000000",highlightbackground="#d9d9d9",highlightcolor="black",pady="0",text='''Limpieza''',
command = Limpiando).place(relx = 0.23, rely = 0.80, height=25, width=217)
Decima_Ventana.mainloop()
El código devuelve lo siguiente:

No hay comentarios.:
Publicar un comentario