Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,12 +37,17 @@ def calculate_pressure_drop(diameter, flow_rate, density, viscosity, length=1.0)
|
|
37 |
|
38 |
# Streamlit App
|
39 |
st.title("Pressure Drop Calculator for Straight Pipe")
|
|
|
|
|
|
|
|
|
40 |
|
41 |
# Inputs
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
|
47 |
# Get fluid properties
|
48 |
fluid_props = get_fluid_properties(fluid)
|
@@ -54,17 +59,23 @@ if fluid_props["density"] and fluid_props["viscosity"]:
|
|
54 |
pressure_drop, reynolds = calculate_pressure_drop(diameter, flow_rate, density, viscosity, pipe_length)
|
55 |
|
56 |
# Output results
|
57 |
-
st.
|
58 |
-
st.write(f"Reynolds Number
|
59 |
-
st.write(f"Pressure Drop
|
60 |
|
61 |
# Flow type
|
62 |
if reynolds < 2000:
|
63 |
-
st.
|
64 |
else:
|
65 |
-
st.
|
66 |
else:
|
67 |
st.error("Invalid fluid selected or missing properties.")
|
68 |
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
# Streamlit App
|
39 |
st.title("Pressure Drop Calculator for Straight Pipe")
|
40 |
+
st.write("""
|
41 |
+
This tool calculates the pressure drop in a straight pipe for both laminar and turbulent flow conditions.
|
42 |
+
Provide the necessary inputs below, and the app will determine the pressure drop and Reynolds number.
|
43 |
+
""")
|
44 |
|
45 |
# Inputs
|
46 |
+
st.sidebar.header("Input Parameters")
|
47 |
+
diameter = st.sidebar.slider("Pipe Diameter (m)", min_value=0.01, max_value=1.0, value=0.1, step=0.01)
|
48 |
+
flow_rate = st.sidebar.slider("Flow Rate (L/s)", min_value=0.001, max_value=100.0, value=1.0, step=0.1) / 1000 # Convert to m^3/s
|
49 |
+
fluid = st.sidebar.selectbox("Fluid Type", ["Water", "Oil", "Air"])
|
50 |
+
pipe_length = st.sidebar.slider("Pipe Length (m)", min_value=0.1, max_value=100.0, value=10.0, step=0.1)
|
51 |
|
52 |
# Get fluid properties
|
53 |
fluid_props = get_fluid_properties(fluid)
|
|
|
59 |
pressure_drop, reynolds = calculate_pressure_drop(diameter, flow_rate, density, viscosity, pipe_length)
|
60 |
|
61 |
# Output results
|
62 |
+
st.subheader("Results")
|
63 |
+
st.write(f"**Reynolds Number:** {reynolds:.2f}")
|
64 |
+
st.write(f"**Pressure Drop:** {pressure_drop:.2f} Pa")
|
65 |
|
66 |
# Flow type
|
67 |
if reynolds < 2000:
|
68 |
+
st.success("Flow Type: Laminar")
|
69 |
else:
|
70 |
+
st.success("Flow Type: Turbulent")
|
71 |
else:
|
72 |
st.error("Invalid fluid selected or missing properties.")
|
73 |
|
74 |
+
st.write("""
|
75 |
+
---
|
76 |
+
### How to Use
|
77 |
+
1. Adjust the input parameters using the sidebar.
|
78 |
+
2. View the calculated pressure drop and Reynolds number.
|
79 |
+
|
80 |
+
**Note:** Ensure all inputs are within valid physical ranges.
|
81 |
+
""")
|