Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import math
|
3 |
+
|
4 |
+
# Function to calculate pipe diameter
|
5 |
+
def calculate_diameter(flow_rate, velocity):
|
6 |
+
# Formula to calculate pipe diameter (d = sqrt(4 * Q / (pi * v)))
|
7 |
+
# Where Q is flow rate (in cubic meters per second)
|
8 |
+
# v is the velocity (in meters per second)
|
9 |
+
diameter = math.sqrt(4 * flow_rate / (math.pi * velocity))
|
10 |
+
return diameter
|
11 |
+
|
12 |
+
# Streamlit App
|
13 |
+
def main():
|
14 |
+
st.title("Pipe Sizing Helper")
|
15 |
+
|
16 |
+
# Input fields for flow rate and velocity
|
17 |
+
flow_rate = st.number_input("Enter Flow Rate (m³/s):", min_value=0.0, step=0.01)
|
18 |
+
velocity = st.number_input("Enter Permissible Velocity (m/s):", min_value=0.0, step=0.1)
|
19 |
+
|
20 |
+
# Calculate and display recommended pipe diameter
|
21 |
+
if flow_rate > 0 and velocity > 0:
|
22 |
+
diameter = calculate_diameter(flow_rate, velocity)
|
23 |
+
st.write(f"The recommended pipe diameter is: {diameter:.2f} meters")
|
24 |
+
else:
|
25 |
+
st.write("Please enter valid values for flow rate and velocity.")
|
26 |
+
|
27 |
+
if __name__ == "__main__":
|
28 |
+
main()
|