shailesh270690 commited on
Commit
2859808
·
1 Parent(s): 3b7f39f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +97 -0
app.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Assume your existing functions are here (collect_input, check_pump_suitability, etc.)
4
+ def collect_input():
5
+ """
6
+ Collects necessary input data from the user.
7
+ """
8
+ print("Please enter the following data about the well:")
9
+ depth = float(input("Well Depth (meters): "))
10
+ viscosity = float(input("Fluid Viscosity (cP): "))
11
+ flow_rate = float(input("Flow Rate (m³/day): "))
12
+ specific_gravity = float(input("Specific Gravity of Fluid: "))
13
+ temperature = float(input("Temperature (Celsius): "))
14
+ solids_content = float(input("Percentage of Solids (%): "))
15
+ corrosivity = input("Is the fluid corrosive? (yes/no): ").lower() == 'yes'
16
+
17
+ return {
18
+ "depth": depth,
19
+ "viscosity": viscosity,
20
+ "flow_rate": flow_rate,
21
+ "specific_gravity": specific_gravity,
22
+ "temperature": temperature,
23
+ "solids_content": solids_content,
24
+ "corrosivity": corrosivity
25
+ }
26
+
27
+ def check_pump_suitability(well_data):
28
+ """
29
+ Determines the suitability of a progressive cavity pump based on well data.
30
+ """
31
+ # Example criteria (these values can be adjusted based on real-world data and expert advice)
32
+ max_viscosity = 10000 # cP
33
+ max_solids_content = 10 # Percentage
34
+
35
+ if well_data["viscosity"] > max_viscosity:
36
+ return False, "Viscosity too high for progressive cavity pump."
37
+ if well_data["solids_content"] > max_solids_content:
38
+ return False, "Solids content too high for progressive cavity pump."
39
+ if well_data["corrosivity"]:
40
+ return False, "Corrosive fluid not suitable for standard progressive cavity pump."
41
+
42
+ # Further checks can be added here...
43
+
44
+ return True, "Well is suitable for a progressive cavity pump."
45
+
46
+ def display_results(suitability, message):
47
+ """
48
+ Displays the results of the suitability check.
49
+ """
50
+ if suitability:
51
+ print("Result: Suitable.")
52
+ else:
53
+ print("Result: Not Suitable.")
54
+ print("Reason: ", message)
55
+
56
+ def main():
57
+ well_data = collect_input()
58
+ suitability, message = check_pump_suitability(well_data)
59
+ display_results(suitability, message)
60
+
61
+ if __name__ == "__main__":
62
+ main()
63
+
64
+ def assess_pump_suitability(depth, viscosity, flow_rate, specific_gravity, temperature, solids_content, corrosivity):
65
+ well_data = {
66
+ "depth": depth,
67
+ "viscosity": viscosity,
68
+ "flow_rate": flow_rate,
69
+ "specific_gravity": specific_gravity,
70
+ "temperature": temperature,
71
+ "solids_content": solids_content,
72
+ "corrosivity": corrosivity == 'Yes'
73
+ }
74
+ suitability, message = check_pump_suitability(well_data)
75
+ return "Suitable" if suitability else "Not Suitable", message
76
+
77
+ iface = gr.Interface(
78
+ fn=assess_pump_suitability,
79
+ inputs=[
80
+ gr.Number(label="Well Depth (meters)"),
81
+ gr.Number(label="Fluid Viscosity (cP)"),
82
+ gr.Number(label="Flow Rate (m³/day)"),
83
+ gr.Number(label="Specific Gravity of Fluid"),
84
+ gr.Number(label="Temperature (Celsius)"),
85
+ gr.Number(label="Percentage of Solids (%)"),
86
+ gr.Radio(["Yes", "No"], label="Is the fluid corrosive?")
87
+ ],
88
+ outputs=[
89
+ gr.Textbox(label="Suitability"),
90
+ gr.Textbox(label="Reason")
91
+ ],
92
+ title="Progressive Cavity Pump Suitability Assessment",
93
+ description="Enter well data to assess if it's suitable for a progressive cavity pump."
94
+ )
95
+
96
+ if __name__ == "__main__":
97
+ iface.launch(share=True)