Spaces:
Build error
Build error
Download app.py from rashid200gb/PipeSizeHelper: direct link, hf CLI and curl.
- Browser
- Download file 999 Bytes
-
https://huggingface.co/spaces/rashid200gb/PipeSizeHelper/resolve/main/app.py
- Command line
-
hf download hf://spaces/rashid200gb/PipeSizeHelper/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rashid200gb/PipeSizeHelper/resolve/main/app.py
999 Bytes
| import streamlit as st | |
| import math | |
| st.set_page_config(page_title="Pipe Size Helper", layout="centered") | |
| st.title("🔧 Pipe Size Helper") | |
| st.write("Calculate pipe diameter from flow rate and velocity") | |
| # User inputs | |
| flow_rate = st.number_input("Enter flow rate (m³/s)", min_value=0.0001, step=0.0001) | |
| velocity = st.number_input("Enter permissible velocity (m/s)", min_value=0.01, step=0.01) | |
| def calculate_diameter(Q, V): | |
| """Calculate internal diameter in meters using the continuity equation.""" | |
| if V == 0: | |
| return None | |
| area = Q / V | |
| diameter = math.sqrt((4 * area) / math.pi) | |
| return diameter | |
| if st.button("Calculate Pipe Diameter"): | |
| if flow_rate and velocity: | |
| diameter_m = calculate_diameter(flow_rate, velocity) | |
| diameter_mm = diameter_m * 1000 # convert to mm | |
| st.success(f"Required Pipe Diameter: {diameter_m:.4f} meters ({diameter_mm:.2f} mm)") | |
| else: | |
| st.warning("Please enter valid values for both flow rate and velocity.") | |