File size: 799 Bytes
d9b7ac4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import streamlit as st
import math

# Application title
st.title("Pipe Size Calculator")

# Input fields for flow rate and velocity
flow_rate = st.number_input("Enter flow rate (m³/s):", min_value=0.0, step=0.01, format="%.2f")
velocity = st.number_input("Enter velocity (m/s):", min_value=0.0, step=0.01, format="%.2f")

# Calculate and display the recommended pipe diameter
if flow_rate > 0 and velocity > 0:
    # Calculate pipe diameter in meters
    diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity))
    
    # Convert diameter to centimeters for better readability
    diameter_cm = diameter * 100
    st.success(f"Recommended Pipe Diameter: {diameter:.4f} meters ({diameter_cm:.2f} cm)")
else:
    st.warning("Please enter valid positive values for both flow rate and velocity.")