mabuseif commited on
Commit
16925ec
·
verified ·
1 Parent(s): 79a702a

Update data/ashrae_tables.py

Browse files
Files changed (1) hide show
  1. data/ashrae_tables.py +23 -8
data/ashrae_tables.py CHANGED
@@ -1078,16 +1078,17 @@ class ASHRAETables:
1078
  raise ValueError(f"Invalid zone {zone} for CLF equipment")
1079
 
1080
  @lru_cache(maxsize=1000)
1081
- def get_cltd(self, element_type: str, group: str, orientation: str, hour: int, latitude: float) -> float:
1082
  """
1083
- Retrieve CLTD value for a given element type, group, orientation, hour, and latitude with interpolation.
1084
  Args:
1085
  element_type: 'wall' or 'roof'.
1086
  group: Group identifier (e.g., 'A', 'B', ..., 'H' for walls; 'A', 'B', ..., 'G' for roofs).
1087
  orientation: Orientation (e.g., 'North', 'East', 'Horizontal' for roofs).
1088
  hour: Hour of the day (0-23).
1089
  latitude: Latitude in degrees (24 to 56).
1090
- Returns: Interpolated CLTD value.
 
1091
  Raises:
1092
  ValueError: If inputs are invalid or out of range.
1093
  """
@@ -1098,9 +1099,16 @@ class ASHRAETables:
1098
  if not 24 <= latitude <= 56:
1099
  raise ValueError("Latitude must be between 24 and 56 degrees")
1100
 
 
 
 
 
 
 
 
 
1101
  # Available latitudes
1102
- latitudes = [24, 32, 36, 44, 56]
1103
- # Find the two closest latitudes for interpolation
1104
  lat1, lat2 = max([lat for lat in latitudes if lat <= latitude], default=24), min([lat for lat in latitudes if lat >= latitude], default=56)
1105
 
1106
  # Load the appropriate table
@@ -1119,9 +1127,16 @@ class ASHRAETables:
1119
 
1120
  # Linear interpolation
1121
  if lat1 == lat2:
1122
- return cltd1
1123
- weight = (latitude - lat1) / (lat2 - lat1)
1124
- return cltd1 + weight * (cltd2 - cltd1)
 
 
 
 
 
 
 
1125
 
1126
  @lru_cache(maxsize=1000)
1127
  def get_scl(self, orientation: str, hour: int, latitude: float, month: str = 'Jul') -> float:
 
1078
  raise ValueError(f"Invalid zone {zone} for CLF equipment")
1079
 
1080
  @lru_cache(maxsize=1000)
1081
+ def get_cltd(self, element_type: str, group: str, orientation: str, hour: int, latitude: float, solar_absorptivity: float = 0.6) -> float:
1082
  """
1083
+ Retrieve CLTD value for a given element type, group, orientation, hour, latitude, and solar absorptivity with interpolation.
1084
  Args:
1085
  element_type: 'wall' or 'roof'.
1086
  group: Group identifier (e.g., 'A', 'B', ..., 'H' for walls; 'A', 'B', ..., 'G' for roofs).
1087
  orientation: Orientation (e.g., 'North', 'East', 'Horizontal' for roofs).
1088
  hour: Hour of the day (0-23).
1089
  latitude: Latitude in degrees (24 to 56).
1090
+ solar_absorptivity: Solar absorptivity of the surface (0.0 to 1.0, default 0.6 for Medium).
1091
+ Returns: Interpolated and corrected CLTD value.
1092
  Raises:
1093
  ValueError: If inputs are invalid or out of range.
1094
  """
 
1099
  if not 24 <= latitude <= 56:
1100
  raise ValueError("Latitude must be between 24 and 56 degrees")
1101
 
1102
+ # Validate inputs
1103
+ is_wall = element_type == 'wall'
1104
+ latitude_str = f"{int(latitude)}N"
1105
+ month = 'Jul' # Default to July for CLTD calculations
1106
+ is_valid, error_msg = self._validate_cltd_inputs(group, orientation, hour, latitude_str, month, solar_absorptivity, is_wall)
1107
+ if not is_valid:
1108
+ raise ValueError(error_msg)
1109
+
1110
  # Available latitudes
1111
+ latitudes = [24, 32, 40, 48, 56]
 
1112
  lat1, lat2 = max([lat for lat in latitudes if lat <= latitude], default=24), min([lat for lat in latitudes if lat >= latitude], default=56)
1113
 
1114
  # Load the appropriate table
 
1127
 
1128
  # Linear interpolation
1129
  if lat1 == lat2:
1130
+ cltd = cltd1
1131
+ else:
1132
+ weight = (latitude - lat1) / (lat2 - lat1)
1133
+ cltd = cltd1 + weight * (cltd2 - cltd1)
1134
+
1135
+ # Apply corrections
1136
+ lm = self.month_correction.get(latitude_str, {}).get(month, 0.0)
1137
+ f = self._load_fenestration_correction().get('Standard', 1.0)
1138
+ corrected_cltd = self.apply_cltd_corrections(cltd, lm, solar_absorptivity, f)
1139
+ return corrected_cltd
1140
 
1141
  @lru_cache(maxsize=1000)
1142
  def get_scl(self, orientation: str, hour: int, latitude: float, month: str = 'Jul') -> float: