Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,88 +1,101 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
-
# Function to calculate pump
|
| 4 |
-
def
|
| 5 |
try:
|
| 6 |
-
|
| 7 |
-
flow_rate = float(flow_rate) # m3/h
|
| 8 |
head = float(head) # meters
|
| 9 |
-
density = float(density) # kg/
|
| 10 |
efficiency = float(efficiency) / 100 # Percentage to decimal
|
| 11 |
-
npsh = float(npsh) # meters
|
| 12 |
speed = float(speed) # RPM
|
| 13 |
impeller_diameter = float(impeller_diameter) # meters
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# Constants
|
| 17 |
-
g = 9.81 # Gravitational acceleration (m/s²)
|
| 18 |
-
|
| 19 |
-
# Calculate Hydraulic Power (kW)
|
| 20 |
-
hydraulic_power = (flow_rate / 3600) * density * g * head / 1000 # kW
|
| 21 |
-
|
| 22 |
-
# Calculate Brake Power (Input Power)
|
| 23 |
-
if efficiency > 0:
|
| 24 |
-
input_power = hydraulic_power / efficiency # kW
|
| 25 |
-
else:
|
| 26 |
-
input_power = 0
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
cavitation_risk = "Low" if npsh > (head * 0.1) else "High"
|
| 30 |
-
|
| 31 |
-
# Reynolds Number for Flow
|
| 32 |
-
reynolds_number = (impeller_diameter * speed * fluid_viscosity) / 1000
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
"
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
except ValueError:
|
| 44 |
return "Invalid input! Please ensure all inputs are numeric."
|
| 45 |
|
| 46 |
-
|
|
|
|
| 47 |
st.title("Pump Design and Performance Calculator")
|
| 48 |
st.subheader("Developed by Ahmad Hassan")
|
| 49 |
st.caption("Supervised by Dr. Hidayatullah Mahar")
|
| 50 |
|
| 51 |
-
# Input
|
| 52 |
-
st.header("Input Parameters
|
| 53 |
flow_rate = st.text_input("Flow Rate (m³/h):", "100")
|
| 54 |
head = st.text_input("Head (meters):", "50")
|
| 55 |
density = st.text_input("Fluid Density (kg/m³):", "1000")
|
| 56 |
efficiency = st.text_input("Pump Efficiency (%):", "75")
|
| 57 |
-
npsh = st.text_input("Net Positive Suction Head (NPSH, meters):", "5")
|
| 58 |
speed = st.text_input("Pump Speed (RPM):", "2900")
|
| 59 |
impeller_diameter = st.text_input("Impeller Diameter (meters):", "0.3")
|
| 60 |
-
|
| 61 |
|
| 62 |
-
#
|
| 63 |
-
st.header("Select
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
# Calculate
|
| 67 |
-
if st.button("Calculate
|
| 68 |
-
result =
|
| 69 |
-
flow_rate, head, density, efficiency,
|
| 70 |
)
|
| 71 |
if isinstance(result, dict):
|
| 72 |
-
st.success("
|
| 73 |
for key, value in result.items():
|
| 74 |
st.write(f"**{key}**: {value}")
|
| 75 |
else:
|
| 76 |
st.error(result)
|
| 77 |
|
| 78 |
-
#
|
| 79 |
st.info(
|
| 80 |
"""
|
| 81 |
### Notes:
|
| 82 |
- **Flow Rate**: Volume of fluid pumped per hour.
|
| 83 |
- **Head**: Pressure increase produced by the pump.
|
| 84 |
- **Efficiency**: Mechanical efficiency of the pump.
|
| 85 |
-
- **
|
| 86 |
-
- **Cavitation Risk**: Indicates the likelihood of cavitation (High/Low).
|
| 87 |
"""
|
| 88 |
)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
+
# Function to calculate pump parameters
|
| 4 |
+
def calculate_parameters(option, flow_rate, head, density, efficiency, speed, impeller_diameter, height):
|
| 5 |
try:
|
| 6 |
+
flow_rate = float(flow_rate) # m³/h
|
|
|
|
| 7 |
head = float(head) # meters
|
| 8 |
+
density = float(density) # kg/m³
|
| 9 |
efficiency = float(efficiency) / 100 # Percentage to decimal
|
|
|
|
| 10 |
speed = float(speed) # RPM
|
| 11 |
impeller_diameter = float(impeller_diameter) # meters
|
| 12 |
+
height = float(height) # meters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
g = 9.81 # Gravitational acceleration (m/s²)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Initialize results
|
| 17 |
+
result = {}
|
| 18 |
+
|
| 19 |
+
if option == "Hydraulic Power":
|
| 20 |
+
hydraulic_power = (flow_rate / 3600) * density * g * head / 1000 # kW
|
| 21 |
+
result["Hydraulic Power (kW)"] = round(hydraulic_power, 2)
|
| 22 |
+
|
| 23 |
+
elif option == "Input Power":
|
| 24 |
+
hydraulic_power = (flow_rate / 3600) * density * g * head / 1000 # kW
|
| 25 |
+
input_power = hydraulic_power / efficiency # Input Power
|
| 26 |
+
result["Input Power (kW)"] = round(input_power, 2)
|
| 27 |
+
|
| 28 |
+
elif option == "Efficiency":
|
| 29 |
+
hydraulic_power = (flow_rate / 3600) * density * g * head / 1000
|
| 30 |
+
input_power = (hydraulic_power / efficiency) if efficiency > 0 else 0
|
| 31 |
+
actual_efficiency = (hydraulic_power / input_power) * 100 if input_power > 0 else 0
|
| 32 |
+
result["Efficiency (%)"] = round(actual_efficiency, 2)
|
| 33 |
+
|
| 34 |
+
elif option == "Impeller Speed":
|
| 35 |
+
impeller_speed = (head / (impeller_diameter ** 2)) * speed
|
| 36 |
+
result["Impeller Speed (RPM)"] = round(impeller_speed, 2)
|
| 37 |
+
|
| 38 |
+
elif option == "Pump Specifications for Height":
|
| 39 |
+
flow_needed = (density * g * height) / 1000 # Simplified flow for the given height
|
| 40 |
+
head_needed = height
|
| 41 |
+
result["Required Head (m)"] = round(head_needed, 2)
|
| 42 |
+
result["Flow Needed (m³/h)"] = round(flow_needed, 2)
|
| 43 |
+
result["Hydraulic Power (kW)"] = round((flow_needed / 3600) * density * g * height / 1000, 2)
|
| 44 |
+
result["Suggested Efficiency (%)"] = 70
|
| 45 |
+
|
| 46 |
+
return result
|
| 47 |
|
| 48 |
except ValueError:
|
| 49 |
return "Invalid input! Please ensure all inputs are numeric."
|
| 50 |
|
| 51 |
+
|
| 52 |
+
# Streamlit App GUI
|
| 53 |
st.title("Pump Design and Performance Calculator")
|
| 54 |
st.subheader("Developed by Ahmad Hassan")
|
| 55 |
st.caption("Supervised by Dr. Hidayatullah Mahar")
|
| 56 |
|
| 57 |
+
# Input Section
|
| 58 |
+
st.header("Input Parameters")
|
| 59 |
flow_rate = st.text_input("Flow Rate (m³/h):", "100")
|
| 60 |
head = st.text_input("Head (meters):", "50")
|
| 61 |
density = st.text_input("Fluid Density (kg/m³):", "1000")
|
| 62 |
efficiency = st.text_input("Pump Efficiency (%):", "75")
|
|
|
|
| 63 |
speed = st.text_input("Pump Speed (RPM):", "2900")
|
| 64 |
impeller_diameter = st.text_input("Impeller Diameter (meters):", "0.3")
|
| 65 |
+
height = st.text_input("Transport Height (meters):", "10")
|
| 66 |
|
| 67 |
+
# Dropdown Menu for Quantity to Calculate
|
| 68 |
+
st.header("Select Quantity to Calculate")
|
| 69 |
+
calculation_option = st.selectbox(
|
| 70 |
+
"Choose a Parameter to Calculate:",
|
| 71 |
+
[
|
| 72 |
+
"Hydraulic Power",
|
| 73 |
+
"Input Power",
|
| 74 |
+
"Efficiency",
|
| 75 |
+
"Impeller Speed",
|
| 76 |
+
"Pump Specifications for Height",
|
| 77 |
+
]
|
| 78 |
+
)
|
| 79 |
|
| 80 |
+
# Button to Calculate
|
| 81 |
+
if st.button("Calculate"):
|
| 82 |
+
result = calculate_parameters(
|
| 83 |
+
calculation_option, flow_rate, head, density, efficiency, speed, impeller_diameter, height
|
| 84 |
)
|
| 85 |
if isinstance(result, dict):
|
| 86 |
+
st.success("Calculation Results:")
|
| 87 |
for key, value in result.items():
|
| 88 |
st.write(f"**{key}**: {value}")
|
| 89 |
else:
|
| 90 |
st.error(result)
|
| 91 |
|
| 92 |
+
# Notes Section
|
| 93 |
st.info(
|
| 94 |
"""
|
| 95 |
### Notes:
|
| 96 |
- **Flow Rate**: Volume of fluid pumped per hour.
|
| 97 |
- **Head**: Pressure increase produced by the pump.
|
| 98 |
- **Efficiency**: Mechanical efficiency of the pump.
|
| 99 |
+
- **Pump Specifications for Height**: Estimates specifications required to transport fluid to a given height.
|
|
|
|
| 100 |
"""
|
| 101 |
)
|