File size: 3,455 Bytes
2859808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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)