A newer version of the Streamlit SDK is available:
1.52.2
HVAC Calculator Technical Documentation
System Architecture
The HVAC Calculator is built using a modular architecture with the following components:
- User Interface Layer: Streamlit-based web interface
- Application Layer: Core calculation and processing logic
- Data Layer: Data models, reference data, and persistence
Component Diagram
+----------------------------------+
| User Interface |
| +----------------------------+ |
| | Streamlit Web App | |
| +----------------------------+ |
+----------------------------------+
|
v
+----------------------------------+
| Application Layer |
| +------------+ +------------+ |
| | Calculation | | Data | |
| | Engine | | Processing | |
| +------------+ +------------+ |
| +------------+ +------------+ |
| |Visualization| | Data | |
| | Components | | Validation | |
| +------------+ +------------+ |
+----------------------------------+
|
v
+----------------------------------+
| Data Layer |
| +------------+ +------------+ |
| | Models | | Reference | |
| | | | Data | |
| +------------+ +------------+ |
| +------------+ +------------+ |
| | Climate | | Data | |
| | Data | | Persistence| |
| +------------+ +------------+ |
+----------------------------------+
Technology Stack
- Frontend: Streamlit (Python-based web framework)
- Backend: Python 3.10+
- Data Processing: Pandas, NumPy
- Visualization: Plotly, Matplotlib
- Data Export: OpenPyXL, XlsxWriter
- Testing: Python unittest framework
Module Descriptions
App Module
The app module contains the Streamlit application components:
main.py: Main application entry point and navigationbuilding_info_form.py: Building information input formcomponent_selection.py: Component selection interfaceresults_display.py: Results display moduledata_validation.py: Data validation moduledata_persistence.py: Data persistence moduledata_export.py: Data export module
Data Module
The data module contains data models and reference data:
building_components.py: Building component data modelsreference_data.py: Reference data for materials and construction typesclimate_data.py: ASHRAE 169 climate data moduleashrae_tables.py: ASHRAE tables implementation (CLTD, SCL, CLF)
Utils Module
The utils module contains utility functions and calculation engines:
component_library.py: Component library with preset and custom componentsu_value_calculator.py: U-value calculator for material assembliesshading_system.py: Shading system for windowsarea_calculation_system.py: Area calculation and validation systempsychrometrics.py: Psychrometric calculations for air propertiesheat_transfer.py: Shared heat transfer calculation functionscooling_load.py: Cooling load calculations (CLTD/CLF method)heating_load.py: Heating load calculations (steady-state method)component_visualization.py: Hierarchical component visualizationscenario_comparison.py: Scenario comparison visualizationpsychrometric_visualization.py: Psychrometric visualizationtime_based_visualization.py: Time-based visualization
Tests Module
The tests module contains test cases:
test_calculator.py: Comprehensive tests for calculator components
Data Flow
- User Input: User enters building information, climate data, and component details
- Data Validation: Input data is validated for completeness and correctness
- Calculation: Cooling and heating loads are calculated using ASHRAE methods
- Visualization: Results are visualized using various charts and tables
- Export: Results can be exported in various formats (CSV, Excel, JSON)
Calculation Methods
Cooling Load Calculation
The cooling load calculation uses the CLTD/CLF method from ASHRAE:
Walls and Roofs: Uses Cooling Load Temperature Difference (CLTD) method
- Q = U × A × CLTD
- CLTD values are adjusted for latitude, month, and time of day
Windows: Uses Solar Cooling Load (SCL) method
- Q = U × A × CLTD + A × SC × SCL
- SCL values are adjusted for latitude, month, and time of day
Internal Gains: Uses Cooling Load Factor (CLF) method
- Q = q × CLF
- CLF values are adjusted for zone type and hours of operation
Infiltration and Ventilation: Uses sensible and latent heat equations
- Q_sensible = ρ × Q × cp × ΔT
- Q_latent = ρ × Q × hfg × Δw
Heating Load Calculation
The heating load calculation uses the steady-state method:
Building Envelope: Uses steady-state conduction
- Q = U × A × ΔT
- ΔT is the difference between indoor and outdoor design temperatures
Infiltration and Ventilation: Uses sensible heat equation
- Q = ρ × Q × cp × ΔT
Internal Gains: Considered as heat sources that offset heating load
- Q_heating = Q_envelope - Q_internal
Data Models
Building Component Models
All building components inherit from a base Component class:
class Component:
id: str
name: str
component_type: ComponentType
u_value: float
area: float
Specific component types extend this base class:
Wall: Adds orientation, wall_type, and wall_groupRoof: Adds orientation, roof_type, and roof_groupFloor: Adds floor_typeWindow: Adds orientation, shgc, vt, window_type, glazing_layers, gas_fill, and low_e_coatingDoor: Adds orientation and door_type
Climate Data Model
The climate data model includes:
- Climate zones
- Design conditions (summer and winter)
- Monthly temperature data
- Solar radiation data
Reference Data
Reference data includes:
- Wall types and properties
- Roof types and properties
- Floor types and properties
- Window types and properties
- Door types and properties
- Material properties (conductivity, density, specific heat)
Persistence and Export
Data Persistence
- Projects are saved in JSON format with a
.hvacextension - All component data is properly serialized, including enums and complex objects
- Project history is maintained in the session state for quick access to previous work
Data Export
- CSV export provides individual tables for different components and results
- Excel export creates a comprehensive report with multiple sheets
- JSON scenario export preserves all calculation results and input data
- Batch export creates a ZIP file containing all scenarios
Deployment
Local Deployment
To run the application locally:
- Install the required dependencies:
pip install streamlit pandas numpy plotly matplotlib openpyxl xlsxwriter
- Run the Streamlit application:
cd hvac_calculator
streamlit run app/main.py
Hugging Face Space Deployment
To deploy to Hugging Face Space:
- Create a new Space on Hugging Face
- Select Streamlit as the Space SDK
- Upload the application files
- Configure the
requirements.txtfile - Set the app file to
app/main.py
Performance Considerations
- The application is designed to run efficiently in a web browser
- Calculation methods are optimized for speed and accuracy
- Large datasets (e.g., ASHRAE tables) are loaded only when needed
- Visualizations use efficient rendering techniques
Security Considerations
- All data processing is done client-side
- No sensitive data is transmitted to external servers
- Project files are stored locally on the user's computer
- No authentication is required for basic usage
Future Enhancements
- Additional calculation methods (e.g., Heat Balance Method)
- Support for more complex building geometries
- Integration with BIM software
- Enhanced 3D visualization
- Cloud-based project storage
- Collaborative editing features
Conclusion
This technical documentation provides an overview of the HVAC Calculator's architecture, components, and implementation details. For more information, please refer to the code documentation and user guide.