AhmadMughal's picture
Update app.py
c448c2b verified
import streamlit as st
from PIL import Image
# Set Page Config
st.set_page_config(
page_title="HVAC System Calculator",
page_icon="⚙️", # Changed to an engineering-related icon
layout="wide",
initial_sidebar_state="expanded",
)
# Title and Description
st.title("⚙️ MEP HVAC System Calculator")
st.markdown("""
An interactive tool for MEP engineers to perform HVAC calculations:
- **CFM to Ton Conversion**
- **Heat Load Calculation**
- **System Selection**
- **AC Unit Requirements**
Use the sidebar to select tasks and input space parameters. Detailed recommendations are provided after the calculations.
""")
# Sidebar for User Input
st.sidebar.title("User Input")
task = st.sidebar.selectbox("Choose a Task", [
"CFM to Ton Conversion",
"Heat Load Calculation",
"System Selection",
"AC Unit Requirements"
])
# Functions for calculations
def cfm_to_ton(cfm):
return cfm / 400
def calculate_heat_load(volume, occupants, appliances):
return (volume * 5) + (occupants * 500) + appliances
def recommend_system(heat_load):
if heat_load <= 24000:
return "Split AC", "Up to 24,000 BTU"
elif heat_load <= 60000:
return "Package Unit", "24,001 - 60,000 BTU"
elif heat_load <= 120000:
return "FAU (Forced Air Unit)", "60,001 - 120,000 BTU"
else:
return "EAU (Evaporative Air Unit)", "120,001+ BTU"
def calculate_ac_units(heat_load, capacity_per_unit):
return int((heat_load / capacity_per_unit) + 0.5)
# Task-specific logic
if task == "CFM to Ton Conversion":
st.header("CFM to Ton Conversion")
cfm = st.number_input("Enter CFM (Cubic Feet per Minute)", min_value=0.0, step=1.0)
if st.button("Convert"):
if cfm:
tons = cfm_to_ton(cfm)
st.success(f"Equivalent Tons: {tons:.2f}")
st.markdown("### Description and Recommendation")
st.write("CFM (Cubic Feet per Minute) is the volume of air moved per minute. Converting it into tons helps select the appropriate HVAC system.")
elif task == "Heat Load Calculation":
st.header("Heat Load Calculation")
st.markdown("Enter the dimensions of the space:")
col1, col2, col3 = st.columns(3)
with col1:
length = st.number_input("Length (in feet)", min_value=0.0, step=1.0)
with col2:
width = st.number_input("Width (in feet)", min_value=0.0, step=1.0)
with col3:
height = st.number_input("Height (in feet)", min_value=0.0, step=1.0)
col4, col5 = st.columns(2)
with col4:
occupants = st.number_input("Number of Occupants", min_value=0, step=1)
with col5:
appliances = st.number_input("Appliances Heat Load (in BTU)", min_value=0.0, step=100.0)
if st.button("Calculate Heat Load"):
volume = length * width * height
if volume:
heat_load = calculate_heat_load(volume, occupants, appliances)
st.success(f"Heat Load: {heat_load:.2f} BTU")
st.markdown("### Description and Recommendation")
st.write("Heat load is essential for determining the cooling requirements. Ensure to account for appliance and occupant heat contributions.")
elif task == "System Selection":
st.header("System Selection")
heat_load = st.number_input("Enter Heat Load (in BTU)", min_value=0.0, step=100.0)
if st.button("Recommend System"):
if heat_load:
system, details = recommend_system(heat_load)
st.success(f"Recommended System: {system}")
st.info(f"Details: {details}")
st.markdown("### Description and Recommendation")
st.write(f"{system} systems are typically used for spaces requiring {details} cooling capacity. Consult with a professional for final selection.")
elif task == "AC Unit Requirements":
st.header("AC Unit Requirements")
col1, col2 = st.columns(2)
with col1:
heat_load = st.number_input("Enter Total Heat Load (in BTU)", min_value=0.0, step=100.0)
with col2:
capacity_per_unit = st.number_input("Capacity per Unit (in BTU)", min_value=1000.0, step=100.0)
if st.button("Calculate Units"):
if heat_load and capacity_per_unit:
units_required = calculate_ac_units(heat_load, capacity_per_unit)
st.success(f"Number of AC Units Required: {units_required}")
st.markdown("### Description and Recommendation")
st.write(f"For a total heat load of {heat_load:.2f} BTU, {units_required} unit(s) with a capacity of {capacity_per_unit:.2f} BTU each are required.")
# Footer
st.markdown("---")
st.markdown("Built with ❤️ using Streamlit for MEP Engineers")