File size: 4,733 Bytes
60cca7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
"""
Main application file for HVAC Load Calculator

This is the main entry point for the HVAC Load Calculator web application.
It sets up the Streamlit interface and navigation between different pages.
"""

import streamlit as st
import os
import sys
from pathlib import Path

# Add the parent directory to sys.path to import modules
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

# Import pages
from pages.cooling_calculator import cooling_calculator
from pages.heating_calculator import heating_calculator

# Set page configuration
st.set_page_config(
    page_title="HVAC Load Calculator",
    page_icon="🔥❄️",
    layout="wide",
    initial_sidebar_state="expanded"
)

# Define main function
def main():
    """Main function for the HVAC Load Calculator web application."""
    
    # Add custom CSS
    st.markdown("""
    <style>
    .main-header {
        font-size: 2.5rem;
        color: #1E88E5;
        text-align: center;
        margin-bottom: 1rem;
    }
    .sub-header {
        font-size: 1.5rem;
        color: #424242;
        margin-bottom: 1rem;
    }
    .info-box {
        background-color: #E3F2FD;
        padding: 1rem;
        border-radius: 0.5rem;
        margin-bottom: 1rem;
    }
    </style>
    """, unsafe_allow_html=True)
    
    # Sidebar navigation
    st.sidebar.title("HVAC Load Calculator")
    st.sidebar.image("https://img.icons8.com/fluency/96/air-conditioner.png", width=100)
    
    # Navigation options
    page = st.sidebar.radio(
        "Select Calculator",
        ["Home", "Cooling Load Calculator", "Heating Load Calculator"]
    )
    
    # Display selected page
    if page == "Home":
        display_home_page()
    elif page == "Cooling Load Calculator":
        cooling_calculator()
    elif page == "Heating Load Calculator":
        heating_calculator()
    
    # Footer
    st.sidebar.markdown("---")
    st.sidebar.info(
        "HVAC Load Calculator v1.0\n\n"
        "Based on ASHRAE calculation methods\n\n"
        "© 2025"
    )


def display_home_page():
    """Display the home page."""
    
    st.markdown('<h1 class="main-header">HVAC Load Calculator</h1>', unsafe_allow_html=True)
    st.markdown('<h2 class="sub-header">A Modern Tool for HVAC Design</h2>', unsafe_allow_html=True)
    
    # Introduction
    st.markdown("""
    <div class="info-box">
    <p>Welcome to the HVAC Load Calculator! This tool helps you calculate cooling and heating loads for buildings
    using the ASHRAE method. It's designed for educational purposes to help students understand the factors
    that influence HVAC load calculations.</p>
    </div>
    """, unsafe_allow_html=True)
    
    # Features
    st.markdown("### Features")
    
    col1, col2 = st.columns(2)
    
    with col1:
        st.markdown("""
        #### Cooling Load Calculator
        - Calculate sensible and latent cooling loads
        - Account for conduction, solar radiation, infiltration, and internal gains
        - Visualize load components with charts and tables
        - Export results for assignments
        """)
    
    with col2:
        st.markdown("""
        #### Heating Load Calculator
        - Calculate peak heating loads
        - Account for conduction, infiltration, and ventilation
        - Estimate annual heating energy requirements
        - Visualize load components with charts and tables
        """)
    
    # How to use
    st.markdown("### How to Use")
    st.markdown("""
    1. Select either the Cooling Load Calculator or Heating Load Calculator from the sidebar
    2. Fill in the required information in each step
    3. Review any warnings that appear (you can proceed with warnings)
    4. Calculate results and analyze the output
    5. Export results for your assignments
    """)
    
    # Reference data
    st.markdown("### Reference Data")
    st.markdown("""
    The calculator includes reference data for:
    - Building materials (walls, roofs, floors)
    - Glass types and shading coefficients
    - Climate data for various locations
    - Occupancy patterns and internal gains
    
    This data is based on ASHRAE standards and guidelines.
    """)
    
    # Get started button
    col1, col2, col3 = st.columns([1, 2, 1])
    with col2:
        st.markdown("### Get Started")
        cooling_button = st.button("Go to Cooling Load Calculator")
        heating_button = st.button("Go to Heating Load Calculator")
    
    if cooling_button:
        st.session_state.page = "Cooling Load Calculator"
        st.experimental_rerun()
    
    if heating_button:
        st.session_state.page = "Heating Load Calculator"
        st.experimental_rerun()


# Run the application
if __name__ == "__main__":
    main()