import streamlit as st import math # Function to calculate pipe diameter based on flow rate and velocity def calculate_diameter(flow_rate, velocity): # Using formula: D = sqrt((4 * Q) / (pi * V)) diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity)) return diameter # Streamlit user interface def main(): st.title("Pipe Sizing Helper") st.write("This app calculates the recommended pipe diameter based on given flow rate and velocity.") # Input fields for flow rate and velocity flow_rate = st.number_input("Enter the flow rate (m³/s):", min_value=0.0, step=0.01) velocity = st.number_input("Enter the permissible velocity (m/s):", min_value=0.1, step=0.1) # Check if both inputs are positive and valid if flow_rate > 0 and velocity > 0: # Calculate the pipe diameter diameter = calculate_diameter(flow_rate, velocity) st.write(f"Recommended pipe diameter: {diameter:.2f} meters") else: st.write("Please enter valid flow rate and velocity.") if __name__ == "__main__": main()