PumpSelect / app.py
shailesh270690's picture
Create app.py
2859808
import gradio as gr
# Assume your existing functions are here (collect_input, check_pump_suitability, etc.)
def collect_input():
"""
Collects necessary input data from the user.
"""
print("Please enter the following data about the well:")
depth = float(input("Well Depth (meters): "))
viscosity = float(input("Fluid Viscosity (cP): "))
flow_rate = float(input("Flow Rate (m³/day): "))
specific_gravity = float(input("Specific Gravity of Fluid: "))
temperature = float(input("Temperature (Celsius): "))
solids_content = float(input("Percentage of Solids (%): "))
corrosivity = input("Is the fluid corrosive? (yes/no): ").lower() == 'yes'
return {
"depth": depth,
"viscosity": viscosity,
"flow_rate": flow_rate,
"specific_gravity": specific_gravity,
"temperature": temperature,
"solids_content": solids_content,
"corrosivity": corrosivity
}
def check_pump_suitability(well_data):
"""
Determines the suitability of a progressive cavity pump based on well data.
"""
# Example criteria (these values can be adjusted based on real-world data and expert advice)
max_viscosity = 10000 # cP
max_solids_content = 10 # Percentage
if well_data["viscosity"] > max_viscosity:
return False, "Viscosity too high for progressive cavity pump."
if well_data["solids_content"] > max_solids_content:
return False, "Solids content too high for progressive cavity pump."
if well_data["corrosivity"]:
return False, "Corrosive fluid not suitable for standard progressive cavity pump."
# Further checks can be added here...
return True, "Well is suitable for a progressive cavity pump."
def display_results(suitability, message):
"""
Displays the results of the suitability check.
"""
if suitability:
print("Result: Suitable.")
else:
print("Result: Not Suitable.")
print("Reason: ", message)
def main():
well_data = collect_input()
suitability, message = check_pump_suitability(well_data)
display_results(suitability, message)
if __name__ == "__main__":
main()
def assess_pump_suitability(depth, viscosity, flow_rate, specific_gravity, temperature, solids_content, corrosivity):
well_data = {
"depth": depth,
"viscosity": viscosity,
"flow_rate": flow_rate,
"specific_gravity": specific_gravity,
"temperature": temperature,
"solids_content": solids_content,
"corrosivity": corrosivity == 'Yes'
}
suitability, message = check_pump_suitability(well_data)
return "Suitable" if suitability else "Not Suitable", message
iface = gr.Interface(
fn=assess_pump_suitability,
inputs=[
gr.Number(label="Well Depth (meters)"),
gr.Number(label="Fluid Viscosity (cP)"),
gr.Number(label="Flow Rate (m³/day)"),
gr.Number(label="Specific Gravity of Fluid"),
gr.Number(label="Temperature (Celsius)"),
gr.Number(label="Percentage of Solids (%)"),
gr.Radio(["Yes", "No"], label="Is the fluid corrosive?")
],
outputs=[
gr.Textbox(label="Suitability"),
gr.Textbox(label="Reason")
],
title="Progressive Cavity Pump Suitability Assessment",
description="Enter well data to assess if it's suitable for a progressive cavity pump."
)
if __name__ == "__main__":
iface.launch(share=True)