Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import math
|
3 |
+
|
4 |
+
# Title and Description
|
5 |
+
st.title("🔧 Pipe Sizing Helper")
|
6 |
+
st.write("""
|
7 |
+
This app helps you determine the required pipe diameter based on the flow rate and fluid velocity.
|
8 |
+
Simply input the flow rate (in cubic meters per second) and velocity (in meters per second) to get the pipe diameter.
|
9 |
+
""")
|
10 |
+
|
11 |
+
# Sidebar Instructions
|
12 |
+
st.sidebar.title("How to Use")
|
13 |
+
st.sidebar.write("""
|
14 |
+
1. Enter the flow rate of the fluid in m³/s.
|
15 |
+
2. Enter the velocity of the fluid in m/s.
|
16 |
+
3. Click **Calculate** to get the required pipe diameter.
|
17 |
+
4. Reset inputs using the **Clear Inputs** button.
|
18 |
+
""")
|
19 |
+
|
20 |
+
# User Inputs
|
21 |
+
st.subheader("Input Parameters")
|
22 |
+
flow_rate = st.number_input("Flow Rate (Q) in m³/s:", min_value=0.0, format="%.6f", step=0.01)
|
23 |
+
velocity = st.number_input("Fluid Velocity (v) in m/s:", min_value=0.1, format="%.2f", step=0.1)
|
24 |
+
|
25 |
+
# Calculate Button
|
26 |
+
if st.button("Calculate"):
|
27 |
+
if flow_rate <= 0:
|
28 |
+
st.error("Flow rate must be greater than zero!")
|
29 |
+
elif velocity <= 0:
|
30 |
+
st.error("Velocity must be greater than zero!")
|
31 |
+
else:
|
32 |
+
# Calculate pipe diameter
|
33 |
+
diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity))
|
34 |
+
diameter_mm = diameter * 1000 # Convert to mm
|
35 |
+
st.subheader("Results")
|
36 |
+
st.write(f"**Required Pipe Diameter:** {diameter:.4f} meters ({diameter_mm:.2f} mm)")
|
37 |
+
|
38 |
+
# Reset Inputs
|
39 |
+
if st.button("Clear Inputs"):
|
40 |
+
flow_rate = 0.0
|
41 |
+
velocity = 0.0
|
42 |
+
st.experimental_rerun()
|
43 |
+
|
44 |
+
# Footer
|
45 |
+
st.write("---")
|
46 |
+
st.markdown("💡 **Developed by Abdullah**")
|