Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,59 @@
|
|
1 |
import streamlit as st
|
2 |
import math
|
3 |
|
4 |
-
#
|
5 |
-
st.
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Input fields
|
9 |
-
|
10 |
-
|
|
|
11 |
|
12 |
-
# Calculate pipe diameter
|
13 |
-
if st.button("
|
14 |
if velocity > 0:
|
15 |
# Pipe diameter formula: D = sqrt(4 * Q / (π * V))
|
16 |
diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity))
|
17 |
diameter_mm = diameter * 1000 # Convert meters to mm
|
18 |
st.success(f"Recommended Pipe Diameter: {diameter_mm:.2f} mm")
|
19 |
else:
|
20 |
-
st.error("
|
21 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import math
|
3 |
|
4 |
+
# Set page config with an icon and title
|
5 |
+
st.set_page_config(page_title="Pipe Sizing Helper", page_icon="🛠️")
|
6 |
+
|
7 |
+
# Custom style
|
8 |
+
st.markdown(
|
9 |
+
"""
|
10 |
+
<style>
|
11 |
+
.title {
|
12 |
+
font-size: 2.5rem;
|
13 |
+
color: #4CAF50;
|
14 |
+
font-weight: bold;
|
15 |
+
}
|
16 |
+
.subtitle {
|
17 |
+
font-size: 1.25rem;
|
18 |
+
color: #333;
|
19 |
+
}
|
20 |
+
.stButton>button {
|
21 |
+
background-color: #4CAF50;
|
22 |
+
color: white;
|
23 |
+
border-radius: 8px;
|
24 |
+
padding: 10px 20px;
|
25 |
+
font-size: 1rem;
|
26 |
+
}
|
27 |
+
</style>
|
28 |
+
""",
|
29 |
+
unsafe_allow_html=True,
|
30 |
+
)
|
31 |
+
|
32 |
+
# App header
|
33 |
+
st.markdown('<div class="title">Pipe Sizing Helper</div>', unsafe_allow_html=True)
|
34 |
+
st.markdown(
|
35 |
+
'<div class="subtitle">Get recommendations for pipe sizes based on flow rate and permissible velocity.</div>',
|
36 |
+
unsafe_allow_html=True,
|
37 |
+
)
|
38 |
+
|
39 |
+
# App layout
|
40 |
+
st.image(
|
41 |
+
"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Pipe_icon.svg/1024px-Pipe_icon.svg.png",
|
42 |
+
width=100,
|
43 |
+
) # Add an icon image
|
44 |
+
st.divider()
|
45 |
|
46 |
# Input fields
|
47 |
+
st.header("Input Parameters")
|
48 |
+
flow_rate = st.number_input("Flow Rate (m³/s):", min_value=0.0, step=0.01, value=0.0)
|
49 |
+
velocity = st.number_input("Permissible Velocity (m/s):", min_value=0.1, step=0.01, value=0.1)
|
50 |
|
51 |
+
# Calculate pipe diameter when button is clicked
|
52 |
+
if st.button("Generate Recommended Pipe Diameter"):
|
53 |
if velocity > 0:
|
54 |
# Pipe diameter formula: D = sqrt(4 * Q / (π * V))
|
55 |
diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity))
|
56 |
diameter_mm = diameter * 1000 # Convert meters to mm
|
57 |
st.success(f"Recommended Pipe Diameter: {diameter_mm:.2f} mm")
|
58 |
else:
|
59 |
+
st.error("Permissible velocity must be greater than zero.")
|
|