Spaces:
Sleeping
Sleeping
Update utils/heating_load.py
Browse files- utils/heating_load.py +18 -5
utils/heating_load.py
CHANGED
|
@@ -16,6 +16,12 @@ from utils.heat_transfer import HeatTransferCalculations
|
|
| 16 |
# Import data modules
|
| 17 |
from data.building_components import Wall, Roof, Floor, Window, Door, Orientation, ComponentType
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
class HeatingLoadCalculator:
|
| 20 |
"""Class for heating load calculations based on ASHRAE steady-state methods."""
|
| 21 |
|
|
@@ -120,7 +126,11 @@ class HeatingLoadCalculator:
|
|
| 120 |
else:
|
| 121 |
load = self.heat_transfer.conduction_heat_transfer(floor.u_value, floor.area, delta_t)
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
print(f"Debug: Floor {floor.name} load: {load:.2f} W, Delta T: {delta_t:.2f}°C")
|
| 125 |
|
| 126 |
return max(0, load)
|
|
@@ -211,7 +221,11 @@ class HeatingLoadCalculator:
|
|
| 211 |
sensible_load = self.heat_transfer.infiltration_heat_transfer(flow_rate, delta_t)
|
| 212 |
latent_load = self.heat_transfer.infiltration_latent_heat_transfer(flow_rate, delta_w)
|
| 213 |
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
print(f"Debug: Infiltration flow rate: {flow_rate:.6f} m³/s, Sensible load: {sensible_load:.2f} W, Latent load: {latent_load:.2f} W")
|
| 216 |
|
| 217 |
return max(0, sensible_load), max(0, latent_load)
|
|
@@ -476,8 +490,6 @@ class HeatingLoadCalculator:
|
|
| 476 |
|
| 477 |
# Example usage
|
| 478 |
if __name__ == "__main__":
|
| 479 |
-
import streamlit as st
|
| 480 |
-
|
| 481 |
calculator = HeatingLoadCalculator()
|
| 482 |
|
| 483 |
# Example building components
|
|
@@ -508,7 +520,8 @@ if __name__ == "__main__":
|
|
| 508 |
'operating_hours': '8:00-18:00'
|
| 509 |
}
|
| 510 |
|
| 511 |
-
st
|
|
|
|
| 512 |
|
| 513 |
design_loads = calculator.calculate_design_heating_load(components, outdoor_conditions, indoor_conditions, internal_loads)
|
| 514 |
summary = calculator.calculate_heating_load_summary(design_loads)
|
|
|
|
| 16 |
# Import data modules
|
| 17 |
from data.building_components import Wall, Roof, Floor, Window, Door, Orientation, ComponentType
|
| 18 |
|
| 19 |
+
# Safely import streamlit for debug mode
|
| 20 |
+
try:
|
| 21 |
+
import streamlit as st
|
| 22 |
+
except ImportError:
|
| 23 |
+
st = None
|
| 24 |
+
|
| 25 |
class HeatingLoadCalculator:
|
| 26 |
"""Class for heating load calculations based on ASHRAE steady-state methods."""
|
| 27 |
|
|
|
|
| 126 |
else:
|
| 127 |
load = self.heat_transfer.conduction_heat_transfer(floor.u_value, floor.area, delta_t)
|
| 128 |
|
| 129 |
+
# Check debug mode safely
|
| 130 |
+
debug_mode = False
|
| 131 |
+
if st is not None and hasattr(st, 'session_state') and hasattr(st.session_state, 'debug_mode'):
|
| 132 |
+
debug_mode = st.session_state.debug_mode
|
| 133 |
+
if debug_mode:
|
| 134 |
print(f"Debug: Floor {floor.name} load: {load:.2f} W, Delta T: {delta_t:.2f}°C")
|
| 135 |
|
| 136 |
return max(0, load)
|
|
|
|
| 221 |
sensible_load = self.heat_transfer.infiltration_heat_transfer(flow_rate, delta_t)
|
| 222 |
latent_load = self.heat_transfer.infiltration_latent_heat_transfer(flow_rate, delta_w)
|
| 223 |
|
| 224 |
+
# Check debug mode safely
|
| 225 |
+
debug_mode = False
|
| 226 |
+
if st is not None and hasattr(st, 'session_state') and hasattr(st.session_state, 'debug_mode'):
|
| 227 |
+
debug_mode = st.session_state.debug_mode
|
| 228 |
+
if debug_mode:
|
| 229 |
print(f"Debug: Infiltration flow rate: {flow_rate:.6f} m³/s, Sensible load: {sensible_load:.2f} W, Latent load: {latent_load:.2f} W")
|
| 230 |
|
| 231 |
return max(0, sensible_load), max(0, latent_load)
|
|
|
|
| 490 |
|
| 491 |
# Example usage
|
| 492 |
if __name__ == "__main__":
|
|
|
|
|
|
|
| 493 |
calculator = HeatingLoadCalculator()
|
| 494 |
|
| 495 |
# Example building components
|
|
|
|
| 520 |
'operating_hours': '8:00-18:00'
|
| 521 |
}
|
| 522 |
|
| 523 |
+
if st is not None:
|
| 524 |
+
st.session_state.debug_mode = True
|
| 525 |
|
| 526 |
design_loads = calculator.calculate_design_heating_load(components, outdoor_conditions, indoor_conditions, internal_loads)
|
| 527 |
summary = calculator.calculate_heating_load_summary(design_loads)
|