rizwanaidris2 commited on
Commit
548d171
·
verified ·
1 Parent(s): e738714

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import math
3
+
4
+ # Function to calculate pipe diameter based on flow rate and velocity
5
+ def calculate_diameter(flow_rate, velocity):
6
+ # Using formula: D = sqrt((4 * Q) / (pi * V))
7
+ diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity))
8
+ return diameter
9
+
10
+ # Streamlit user interface
11
+ def main():
12
+ st.title("Pipe Sizing Helper")
13
+ st.write("This app calculates the recommended pipe diameter based on given flow rate and velocity.")
14
+
15
+ # Input fields for flow rate and velocity
16
+ flow_rate = st.number_input("Enter the flow rate (m³/s):", min_value=0.0, step=0.01)
17
+ velocity = st.number_input("Enter the permissible velocity (m/s):", min_value=0.1, step=0.1)
18
+
19
+ # Check if both inputs are positive and valid
20
+ if flow_rate > 0 and velocity > 0:
21
+ # Calculate the pipe diameter
22
+ diameter = calculate_diameter(flow_rate, velocity)
23
+ st.write(f"Recommended pipe diameter: {diameter:.2f} meters")
24
+ else:
25
+ st.write("Please enter valid flow rate and velocity.")
26
+
27
+ if __name__ == "__main__":
28
+ main()