Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import streamlit as st
|
3 |
+
import math
|
4 |
+
|
5 |
+
# Page Configuration
|
6 |
+
st.set_page_config(
|
7 |
+
page_title="π§ Pipe Sizing Helper",
|
8 |
+
page_icon="π§",
|
9 |
+
layout="centered"
|
10 |
+
)
|
11 |
+
|
12 |
+
# Custom CSS for Styling
|
13 |
+
st.markdown("""
|
14 |
+
<style>
|
15 |
+
.title {
|
16 |
+
text-align: center;
|
17 |
+
font-size: 2.5em;
|
18 |
+
font-weight: bold;
|
19 |
+
color: #4CAF50;
|
20 |
+
}
|
21 |
+
.subtitle {
|
22 |
+
text-align: center;
|
23 |
+
font-size: 1.2em;
|
24 |
+
color: #555;
|
25 |
+
}
|
26 |
+
.result {
|
27 |
+
text-align: center;
|
28 |
+
font-size: 1.3em;
|
29 |
+
font-weight: bold;
|
30 |
+
color: #2196F3;
|
31 |
+
}
|
32 |
+
.footer {
|
33 |
+
text-align: center;
|
34 |
+
margin-top: 50px;
|
35 |
+
font-size: 0.9em;
|
36 |
+
color: #777;
|
37 |
+
}
|
38 |
+
</style>
|
39 |
+
""", unsafe_allow_html=True)
|
40 |
+
|
41 |
+
# Header
|
42 |
+
st.markdown("<h1 class='title'>π§ Pipe Sizing Helper</h1>", unsafe_allow_html=True)
|
43 |
+
st.markdown("<p class='subtitle'>Calculate optimal pipe size based on flow rate and velocity</p>", unsafe_allow_html=True)
|
44 |
+
|
45 |
+
# User Inputs
|
46 |
+
st.subheader("π‘ Input Parameters")
|
47 |
+
|
48 |
+
flow_rate = st.number_input("π Enter Flow Rate (mΒ³/s):", min_value=0.0, format="%.4f")
|
49 |
+
velocity = st.number_input("π¨ Enter Permissible Velocity (m/s):", min_value=0.1, format="%.2f")
|
50 |
+
|
51 |
+
# Calculate Pipe Diameter
|
52 |
+
if st.button("π Calculate Pipe Diameter"):
|
53 |
+
if velocity > 0 and flow_rate > 0:
|
54 |
+
# Formula: Diameter = sqrt((4 * Flow Rate) / (Ο * Velocity))
|
55 |
+
diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity))
|
56 |
+
st.markdown(f"<p class='result'>β
Recommended Pipe Diameter: {diameter:.2f} meters</p>", unsafe_allow_html=True)
|
57 |
+
else:
|
58 |
+
st.warning("β οΈ Please enter valid positive values for flow rate and velocity.")
|
59 |
+
|
60 |
+
# Footer
|
61 |
+
st.markdown("<p class='footer'>π» <b>Developed by ChatGPT</b></p>", unsafe_allow_html=True)
|