Spaces:
Sleeping
Sleeping
# app.py | |
import streamlit as st | |
import math | |
# Page Configuration | |
st.set_page_config( | |
page_title="π§ Pipe Sizing Helper", | |
page_icon="π§", | |
layout="centered" | |
) | |
# Custom CSS for Styling | |
st.markdown(""" | |
<style> | |
.title { | |
text-align: center; | |
font-size: 2.5em; | |
font-weight: bold; | |
color: #4CAF50; | |
} | |
.subtitle { | |
text-align: center; | |
font-size: 1.2em; | |
color: #555; | |
} | |
.result { | |
text-align: center; | |
font-size: 1.3em; | |
font-weight: bold; | |
color: #2196F3; | |
} | |
.footer { | |
text-align: center; | |
margin-top: 50px; | |
font-size: 0.9em; | |
color: #777; | |
} | |
</style> | |
""", unsafe_allow_html=True) | |
# Header | |
st.markdown("<h1 class='title'>π§ Pipe Sizing Helper</h1>", unsafe_allow_html=True) | |
st.markdown("<p class='subtitle'>Calculate optimal pipe size based on flow rate and velocity</p>", unsafe_allow_html=True) | |
# User Inputs | |
st.subheader("π‘ Input Parameters") | |
flow_rate = st.number_input("π Enter Flow Rate (mΒ³/s):", min_value=0.0, format="%.4f") | |
velocity = st.number_input("π¨ Enter Permissible Velocity (m/s):", min_value=0.1, format="%.2f") | |
# Calculate Pipe Diameter | |
if st.button("π Calculate Pipe Diameter"): | |
if velocity > 0 and flow_rate > 0: | |
# Formula: Diameter = sqrt((4 * Flow Rate) / (Ο * Velocity)) | |
diameter = math.sqrt((4 * flow_rate) / (math.pi * velocity)) | |
st.markdown(f"<p class='result'>β Recommended Pipe Diameter: {diameter:.2f} meters</p>", unsafe_allow_html=True) | |
else: | |
st.warning("β οΈ Please enter valid positive values for flow rate and velocity.") | |
# Footer | |
st.markdown("<p class='footer'>π» <b>Developed by ChatGPT</b></p>", unsafe_allow_html=True) | |