Spaces:
Sleeping
Sleeping
Update app/hvac_loads.py
Browse files- app/hvac_loads.py +22 -6
app/hvac_loads.py
CHANGED
@@ -711,7 +711,7 @@ class TFMCalculations:
|
|
711 |
|
712 |
elif sim_type in ["Summer Extreme", "Summer Typical", "Winter Extreme", "Winter Typical"]:
|
713 |
period_key = sim_type.lower().replace(" ", "_")
|
714 |
-
period = climate_data.get("typical_extreme_periods", {}).get(period_key
|
715 |
if not period:
|
716 |
logger.warning(f"No data found for {sim_type} in typical_extreme_periods.")
|
717 |
return []
|
@@ -721,9 +721,15 @@ class TFMCalculations:
|
|
721 |
end_day = period["end"]["day"]
|
722 |
for data in hourly_data:
|
723 |
month, day = data["month"], data["day"]
|
724 |
-
|
725 |
-
|
726 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
727 |
|
728 |
return filtered_data
|
729 |
|
@@ -752,7 +758,12 @@ class TFMCalculations:
|
|
752 |
@staticmethod
|
753 |
def calculate_tfm_loads(components: Dict, hourly_data: List[Dict], indoor_conditions: Dict, internal_loads: Dict, building_info: Dict, sim_period: Dict, hvac_settings: Dict) -> List[Dict]:
|
754 |
"""Calculate TFM loads for heating and cooling with user-defined filters and temperature threshold."""
|
755 |
-
|
|
|
|
|
|
|
|
|
|
|
756 |
temp_loads = []
|
757 |
building_orientation = building_info.get("orientation_angle", 0.0)
|
758 |
operating_periods = hvac_settings.get("operating_hours", [{"start": 8, "end": 18}])
|
@@ -779,6 +790,10 @@ class TFMCalculations:
|
|
779 |
outdoor_temp = hour_data["dry_bulb"]
|
780 |
month = hour_data["month"]
|
781 |
day = hour_data["day"]
|
|
|
|
|
|
|
|
|
782 |
indoor_cond = TFMCalculations.get_indoor_conditions(indoor_conditions, hour, outdoor_temp, month, day, adaptive_setpoints)
|
783 |
indoor_temp = indoor_cond["temperature"]
|
784 |
conduction_cooling = conduction_heating = solar = internal = ventilation_cooling = ventilation_heating = infiltration_cooling = infiltration_heating = 0
|
@@ -834,7 +849,8 @@ class TFMCalculations:
|
|
834 |
"infiltration_cooling": infiltration_cooling,
|
835 |
"infiltration_heating": infiltration_heating,
|
836 |
"total_cooling": total_cooling,
|
837 |
-
"total_heating": total_heating
|
|
|
838 |
})
|
839 |
loads_by_day = defaultdict(list)
|
840 |
for load in temp_loads:
|
|
|
711 |
|
712 |
elif sim_type in ["Summer Extreme", "Summer Typical", "Winter Extreme", "Winter Typical"]:
|
713 |
period_key = sim_type.lower().replace(" ", "_")
|
714 |
+
period = climate_data.get("typical_extreme_periods", {}).get(period_key)
|
715 |
if not period:
|
716 |
logger.warning(f"No data found for {sim_type} in typical_extreme_periods.")
|
717 |
return []
|
|
|
721 |
end_day = period["end"]["day"]
|
722 |
for data in hourly_data:
|
723 |
month, day = data["month"], data["day"]
|
724 |
+
# Handle year-end wrap-around
|
725 |
+
if start_month > end_month:
|
726 |
+
if (month > start_month or (month == start_month and day >= start_day)) or \
|
727 |
+
(month < end_month or (month == end_month and day <= end_day)):
|
728 |
+
filtered_data.append(data)
|
729 |
+
else:
|
730 |
+
if (month > start_month or (month == start_month and day >= start_day)) and \
|
731 |
+
(month < end_month or (month == end_month and day <= end_day)):
|
732 |
+
filtered_data.append(data)
|
733 |
|
734 |
return filtered_data
|
735 |
|
|
|
758 |
@staticmethod
|
759 |
def calculate_tfm_loads(components: Dict, hourly_data: List[Dict], indoor_conditions: Dict, internal_loads: Dict, building_info: Dict, sim_period: Dict, hvac_settings: Dict) -> List[Dict]:
|
760 |
"""Calculate TFM loads for heating and cooling with user-defined filters and temperature threshold."""
|
761 |
+
# Access climate_data for ground temperatures
|
762 |
+
climate_data = st.session_state.project_data["climate_data"]
|
763 |
+
ground_temperatures = climate_data.get("ground_temperatures", {})
|
764 |
+
logger.debug(f"Ground temperatures available: {ground_temperatures.keys()}")
|
765 |
+
|
766 |
+
filtered_data = TFMCalculations.filter_hourly_data(hourly_data, sim_period, climate_data)
|
767 |
temp_loads = []
|
768 |
building_orientation = building_info.get("orientation_angle", 0.0)
|
769 |
operating_periods = hvac_settings.get("operating_hours", [{"start": 8, "end": 18}])
|
|
|
790 |
outdoor_temp = hour_data["dry_bulb"]
|
791 |
month = hour_data["month"]
|
792 |
day = hour_data["day"]
|
793 |
+
# For future enhancement: Retrieve ground temperature for the current month
|
794 |
+
ground_temp = ground_temperatures.get("0.5", [20.0]*12)[month-1] if ground_temperatures else 20.0
|
795 |
+
logger.debug(f"Ground temperature for month {month}: {ground_temp:.1f}°C")
|
796 |
+
|
797 |
indoor_cond = TFMCalculations.get_indoor_conditions(indoor_conditions, hour, outdoor_temp, month, day, adaptive_setpoints)
|
798 |
indoor_temp = indoor_cond["temperature"]
|
799 |
conduction_cooling = conduction_heating = solar = internal = ventilation_cooling = ventilation_heating = infiltration_cooling = infiltration_heating = 0
|
|
|
849 |
"infiltration_cooling": infiltration_cooling,
|
850 |
"infiltration_heating": infiltration_heating,
|
851 |
"total_cooling": total_cooling,
|
852 |
+
"total_heating": total_heating,
|
853 |
+
"ground_temperature": ground_temp # Included for future enhancement
|
854 |
})
|
855 |
loads_by_day = defaultdict(list)
|
856 |
for load in temp_loads:
|