Talha1786's picture
Create app.py
d9b7ac4 verified
raw
history blame
799 Bytes
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.")