Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,75 @@
|
|
1 |
import streamlit as st
|
2 |
import math
|
3 |
|
4 |
-
#
|
5 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity))
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import math
|
3 |
|
4 |
+
# Set page configuration
|
5 |
+
st.set_page_config(
|
6 |
+
page_title="Pipe Size Calculator",
|
7 |
+
page_icon="💧",
|
8 |
+
layout="centered",
|
9 |
+
initial_sidebar_state="expanded",
|
10 |
+
)
|
11 |
|
12 |
+
# Sidebar for input and app information
|
13 |
+
st.sidebar.title("Pipe Size Calculator 💧")
|
14 |
+
st.sidebar.markdown(
|
15 |
+
"""
|
16 |
+
Calculate the **recommended pipe diameter** based on:
|
17 |
+
- Flow Rate (\( Q \)) in cubic meters per second.
|
18 |
+
- Velocity (\( V \)) in meters per second.
|
|
|
19 |
|
20 |
+
Developed for engineers and fluid mechanics enthusiasts! 🌊
|
21 |
+
"""
|
22 |
+
)
|
23 |
+
|
24 |
+
# Main application title
|
25 |
+
st.title("💧 Pipe Size Calculator")
|
26 |
+
|
27 |
+
# Add layout with two columns
|
28 |
+
col1, col2 = st.columns(2)
|
29 |
+
|
30 |
+
# Input section
|
31 |
+
with col1:
|
32 |
+
st.header("Input Parameters")
|
33 |
+
flow_rate = st.number_input(
|
34 |
+
"Enter Flow Rate (m³/s):",
|
35 |
+
min_value=0.0,
|
36 |
+
step=0.01,
|
37 |
+
format="%.2f"
|
38 |
+
)
|
39 |
+
velocity = st.number_input(
|
40 |
+
"Enter Velocity (m/s):",
|
41 |
+
min_value=0.0,
|
42 |
+
step=0.01,
|
43 |
+
format="%.2f"
|
44 |
+
)
|
45 |
+
|
46 |
+
# Add a button to calculate the diameter
|
47 |
+
with col2:
|
48 |
+
st.header("Action")
|
49 |
+
if st.button("Generate Pipe Diameter"):
|
50 |
+
if flow_rate > 0 and velocity > 0:
|
51 |
+
# Calculate pipe diameter
|
52 |
+
diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity))
|
53 |
+
diameter_cm = diameter * 100 # Convert to cm for better readability
|
54 |
+
|
55 |
+
# Display results in success box
|
56 |
+
st.success(
|
57 |
+
f"Recommended Pipe Diameter: \n"
|
58 |
+
f"- **{diameter:.4f} meters** \n"
|
59 |
+
f"- **{diameter_cm:.2f} centimeters**"
|
60 |
+
)
|
61 |
+
else:
|
62 |
+
# Warning for invalid input
|
63 |
+
st.error("Please enter positive values for both flow rate and velocity.")
|
64 |
+
else:
|
65 |
+
st.info("Click the button to calculate the pipe diameter.")
|
66 |
+
|
67 |
+
# Footer with additional info
|
68 |
+
st.sidebar.markdown("---")
|
69 |
+
st.sidebar.markdown(
|
70 |
+
"""
|
71 |
+
**Note:** Ensure flow rate and velocity are within realistic ranges for best results. 🌟
|
72 |
+
Created with ❤️ using [Streamlit](https://streamlit.io).
|
73 |
+
"""
|
74 |
+
)
|
75 |
+
|