mabuseif commited on
Commit
6c7f69e
·
verified ·
1 Parent(s): b8a5fdb

Update app/hvac_loads.py

Browse files
Files changed (1) hide show
  1. app/hvac_loads.py +33 -11
app/hvac_loads.py CHANGED
@@ -61,17 +61,17 @@ class AdaptiveComfortModel:
61
  for i, key in enumerate(daily_keys):
62
  trm = running_means[i]
63
  if acceptability == "80":
64
- t_min = 0.31 * trm + 13.5
65
- t_max = 0.31 * trm + 22.5
66
  elif acceptability == "85":
67
- t_min = 0.31 * trm + 13.9
68
- t_max = 0.31 * trm + 22.1
69
  elif acceptability == "95":
70
- t_min = 0.31 * trm + 14.7
71
- t_max = 0.31 * trm + 20.7
72
  else: # Default to 90%
73
- t_min = 0.31 * trm + 14.3
74
- t_max = 0.31 * trm + 21.3
75
  setpoints[key] = (t_min + t_max) / 2
76
  return setpoints
77
 
@@ -809,7 +809,27 @@ class TFMCalculations:
809
  total_surface_area += comp_area
810
  opaque_components.append(comp)
811
  logger.debug(f"Total surface area for opaque components: {total_surface_area:.2f} m²")
812
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  for hour_data in filtered_data:
814
  hour = hour_data["hour"]
815
  outdoor_temp = hour_data["dry_bulb"]
@@ -948,7 +968,8 @@ class TFMCalculations:
948
  "total_heating": total_heating,
949
  "ground_temperature": ground_temp,
950
  "solar_by_orientation": dict(solar_by_orientation),
951
- "conduction_by_orientation": dict(conduction_by_orientation)
 
952
  })
953
 
954
  loads_by_day = defaultdict(list)
@@ -994,7 +1015,6 @@ def display_hvac_results_ui(loads: List[Dict[str, Any]], run_id: str = "default"
994
  if peak_cooling:
995
  st.write(f"**Peak Cooling Load**: {peak_cooling['total_cooling']:.2f} kW")
996
  st.write(f"Occurred on: {peak_cooling['month']}/{peak_cooling['day']} at {peak_cooling['hour']}:00")
997
- # Add ventilation and infiltration sensible/latent metrics
998
  vent_sensible = sum(system.get("sensible_load", 0.0) for system in st.session_state.project_data["internal_loads"].get("ventilation", []))
999
  vent_latent = sum(system.get("latent_load", 0.0) for system in st.session_state.project_data["internal_loads"].get("ventilation", []))
1000
  inf_sensible = sum(system.get("sensible_load", 0.0) for system in st.session_state.project_data["internal_loads"].get("infiltration", []))
@@ -1003,12 +1023,14 @@ def display_hvac_results_ui(loads: List[Dict[str, Any]], run_id: str = "default"
1003
  st.metric("Ventilation Latent Cooling", f"{vent_latent:.2f} kW")
1004
  st.metric("Infiltration Sensible Cooling", f"{inf_sensible:.2f} kW")
1005
  st.metric("Infiltration Latent Cooling", f"{inf_latent:.2f} kW")
 
1006
  else:
1007
  st.write("**Peak Cooling Load**: 0.00 kW")
1008
  st.metric("Ventilation Sensible Cooling", "0.00 kW")
1009
  st.metric("Ventilation Latent Cooling", "0.00 kW")
1010
  st.metric("Infiltration Sensible Cooling", "0.00 kW")
1011
  st.metric("Infiltration Latent Cooling", "0.00 kW")
 
1012
 
1013
  with col2:
1014
  st.subheader("Heating Equipment Sizing")
 
61
  for i, key in enumerate(daily_keys):
62
  trm = running_means[i]
63
  if acceptability == "80":
64
+ t_min = 0.31 * trm + 14.3 - 3.0
65
+ t_max = 0.31 * trm + 14.3 + 3.0
66
  elif acceptability == "85":
67
+ t_min = 0.31 * trm + 14.3 - 2.5
68
+ t_max = 0.31 * trm + 14.3 + 2.5
69
  elif acceptability == "95":
70
+ t_min = 0.31 * trm + 14.3 - 1.5
71
+ t_max = 0.31 * trm + 14.3 + 1.5
72
  else: # Default to 90%
73
+ t_min = 0.31 * trm + 14.3 - 2.0
74
+ t_max = 0.31 * trm + 14.3 + 2.0
75
  setpoints[key] = (t_min + t_max) / 2
76
  return setpoints
77
 
 
809
  total_surface_area += comp_area
810
  opaque_components.append(comp)
811
  logger.debug(f"Total surface area for opaque components: {total_surface_area:.2f} m²")
812
+
813
+ unmet_hours = 0
814
+ for hour_data in filtered_data:
815
+ hour = hour_data["hour"]
816
+ outdoor_temp = hour_data["dry_bulb"]
817
+ month = hour_data["month"]
818
+ day = hour_data["day"]
819
+ ground_temp = ground_temperatures.get("0.5", [20.0]*12)[month-1] if ground_temperatures else 20.0
820
+ logger.debug(f"Ground temperature for month {month}: {ground_temp:.1f}°C")
821
+
822
+ indoor_cond = TFMCalculations.get_indoor_conditions(indoor_conditions, hour, outdoor_temp, month, day, adaptive_setpoints)
823
+ indoor_temp = indoor_cond["temperature"]
824
+
825
+ if indoor_conditions["type"] == "ASHRAE 55 Adaptive Comfort":
826
+ key = (hour_data["month"], hour_data["day"])
827
+ t_comf = adaptive_setpoints.get(key, 24.0)
828
+ t_min = t_comf - (2.0 if indoor_conditions.get("adaptive_acceptability", "90") == "90" else 3.0)
829
+ t_max = t_comf + (2.0 if indoor_conditions.get("adaptive_acceptability", "90") == "90" else 3.0)
830
+ if indoor_temp < t_min or indoor_temp > t_max:
831
+ unmet_hours += 1
832
+
833
  for hour_data in filtered_data:
834
  hour = hour_data["hour"]
835
  outdoor_temp = hour_data["dry_bulb"]
 
968
  "total_heating": total_heating,
969
  "ground_temperature": ground_temp,
970
  "solar_by_orientation": dict(solar_by_orientation),
971
+ "conduction_by_orientation": dict(conduction_by_orientation),
972
+ "unmet_hours": unmet_hours
973
  })
974
 
975
  loads_by_day = defaultdict(list)
 
1015
  if peak_cooling:
1016
  st.write(f"**Peak Cooling Load**: {peak_cooling['total_cooling']:.2f} kW")
1017
  st.write(f"Occurred on: {peak_cooling['month']}/{peak_cooling['day']} at {peak_cooling['hour']}:00")
 
1018
  vent_sensible = sum(system.get("sensible_load", 0.0) for system in st.session_state.project_data["internal_loads"].get("ventilation", []))
1019
  vent_latent = sum(system.get("latent_load", 0.0) for system in st.session_state.project_data["internal_loads"].get("ventilation", []))
1020
  inf_sensible = sum(system.get("sensible_load", 0.0) for system in st.session_state.project_data["internal_loads"].get("infiltration", []))
 
1023
  st.metric("Ventilation Latent Cooling", f"{vent_latent:.2f} kW")
1024
  st.metric("Infiltration Sensible Cooling", f"{inf_sensible:.2f} kW")
1025
  st.metric("Infiltration Latent Cooling", f"{inf_latent:.2f} kW")
1026
+ st.metric("Unmet Hours (Adaptive Comfort)", loads[-1].get("unmet_hours", 0))
1027
  else:
1028
  st.write("**Peak Cooling Load**: 0.00 kW")
1029
  st.metric("Ventilation Sensible Cooling", "0.00 kW")
1030
  st.metric("Ventilation Latent Cooling", "0.00 kW")
1031
  st.metric("Infiltration Sensible Cooling", "0.00 kW")
1032
  st.metric("Infiltration Latent Cooling", "0.00 kW")
1033
+ st.metric("Unmet Hours (Adaptive Comfort)", loads[-1].get("unmet_hours", 0) if loads else 0)
1034
 
1035
  with col2:
1036
  st.subheader("Heating Equipment Sizing")