FlowApp / app.py
bhagwandas's picture
Update app.py
4fff0ef verified
raw
history blame
2.3 kB
# app.py
import streamlit as st
import math
# Page Configuration with Icon
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;
margin-top: 20px;
}
.footer {
text-align: center;
margin-top: 50px;
font-size: 0.9em;
color: #777;
}
.icon {
text-align: center;
font-size: 4em;
color: #FF9800;
}
.button {
text-align: center;
margin-top: 30px;
}
</style>
""", unsafe_allow_html=True)
# Header with Icon
st.markdown("<div class='icon'>πŸ’§</div>", unsafe_allow_html=True)
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")
# Button for Calculation
st.markdown("<div class='button'>", unsafe_allow_html=True)
if st.button("πŸ”„ Generate 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.")
st.markdown("</div>", unsafe_allow_html=True)
# Footer
st.markdown("<p class='footer'>πŸ’» <b>Developed by ChatGPT</b></p>", unsafe_allow_html=True)