Spaces:
Sleeping
Sleeping
Update data/ashrae_tables.py
Browse files- data/ashrae_tables.py +68 -62
data/ashrae_tables.py
CHANGED
|
@@ -384,6 +384,44 @@ class ASHRAETables:
|
|
| 384 |
"Nov": -3.0, "Dec": -5.0
|
| 385 |
}
|
| 386 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
def get_cltd_wall(self, wall_group: str, orientation: str, hour: int) -> float:
|
| 388 |
"""Get CLTD value for a wall."""
|
| 389 |
if wall_group not in self.cltd_wall:
|
|
@@ -392,95 +430,63 @@ class ASHRAETables:
|
|
| 392 |
orientation_abbr = orientation_map.get(orientation, orientation)
|
| 393 |
if orientation_abbr not in self.cltd_wall[wall_group].columns:
|
| 394 |
raise ValueError(f"Invalid orientation: {orientation}")
|
| 395 |
-
if
|
| 396 |
raise ValueError(f"Invalid hour: {hour}")
|
| 397 |
-
return self.cltd_wall[wall_group].loc[hour, orientation_abbr]
|
| 398 |
|
| 399 |
-
def get_cltd_roof(self, roof_group: str,
|
| 400 |
"""Get CLTD value for a roof."""
|
| 401 |
key = f"{roof_group}_{latitude}"
|
| 402 |
if key not in self.cltd_roof:
|
| 403 |
raise ValueError(f"Invalid roof group or latitude: {key}")
|
| 404 |
-
if
|
| 405 |
raise ValueError(f"Invalid hour: {hour}")
|
| 406 |
-
return self.cltd_roof[key].loc[hour, "HOR"]
|
| 407 |
|
| 408 |
-
def get_scl(self,
|
| 409 |
"""Get SCL value for a window."""
|
| 410 |
key = f"{latitude}_{month}"
|
| 411 |
if key not in self.scl:
|
| 412 |
-
raise ValueError(f"Invalid latitude
|
| 413 |
orientation_map = {e.value: e.name for e in Orientation}
|
| 414 |
orientation_abbr = orientation_map.get(orientation, orientation)
|
| 415 |
if orientation_abbr not in self.scl[key].columns:
|
| 416 |
raise ValueError(f"Invalid orientation: {orientation}")
|
| 417 |
-
if
|
| 418 |
raise ValueError(f"Invalid hour: {hour}")
|
| 419 |
-
return self.scl[key].loc[hour, orientation_abbr]
|
| 420 |
|
| 421 |
-
def get_clf_lights(self,
|
| 422 |
"""Get CLF value for lights."""
|
| 423 |
-
key = f"{zone_type}_{
|
| 424 |
if key not in self.clf_lights.columns:
|
| 425 |
-
raise ValueError(f"Invalid zone type or hours
|
| 426 |
-
if
|
| 427 |
raise ValueError(f"Invalid hour: {hour}")
|
| 428 |
-
return self.clf_lights.loc[hour, key]
|
| 429 |
|
| 430 |
-
def get_clf_people(self,
|
| 431 |
"""Get CLF value for people."""
|
| 432 |
-
key = f"{zone_type}_{
|
| 433 |
if key not in self.clf_people.columns:
|
| 434 |
-
raise ValueError(f"Invalid zone type or hours
|
| 435 |
-
if
|
| 436 |
raise ValueError(f"Invalid hour: {hour}")
|
| 437 |
-
return self.clf_people.loc[hour, key]
|
| 438 |
|
| 439 |
-
def get_clf_equipment(self,
|
| 440 |
"""Get CLF value for equipment."""
|
| 441 |
-
key = f"{zone_type}_{
|
| 442 |
if key not in self.clf_equipment.columns:
|
| 443 |
-
raise ValueError(f"Invalid zone type or hours
|
| 444 |
-
if
|
| 445 |
raise ValueError(f"Invalid hour: {hour}")
|
| 446 |
-
return self.clf_equipment.loc[hour, key]
|
| 447 |
-
|
| 448 |
-
def get_latitude_correction(self, latitude: str, month: str) -> float:
|
| 449 |
-
"""Get latitude correction factor for CLTD/SCL values."""
|
| 450 |
-
if latitude not in self.latitude_correction:
|
| 451 |
-
raise ValueError(f"Invalid latitude: {latitude}")
|
| 452 |
-
if month not in self.latitude_correction[latitude]:
|
| 453 |
-
raise ValueError(f"Invalid month: {month}")
|
| 454 |
-
return self.latitude_correction[latitude][month]
|
| 455 |
-
|
| 456 |
-
def get_color_correction(self, color: str) -> float:
|
| 457 |
-
"""Get color correction factor for CLTD values."""
|
| 458 |
-
if color not in self.color_correction:
|
| 459 |
-
raise ValueError(f"Invalid color: {color}")
|
| 460 |
-
return self.color_correction[color]
|
| 461 |
-
|
| 462 |
-
def get_month_correction(self, month: str) -> float:
|
| 463 |
-
"""Get month correction factor for CLTD values."""
|
| 464 |
-
if month not in self.month_correction:
|
| 465 |
-
raise ValueError(f"Invalid month: {month}")
|
| 466 |
-
return self.month_correction[month]
|
| 467 |
|
| 468 |
-
def
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
""
|
| 473 |
-
cltd = self.get_cltd_wall(wall_group, orientation, hour)
|
| 474 |
-
cltd = self._apply_climatic_corrections(cltd, indoor_temp, outdoor_temp, humidity, solar_radiation,
|
| 475 |
-
"cltd", color, month, latitude)
|
| 476 |
-
return max(0, cltd)
|
| 477 |
|
| 478 |
-
def
|
| 479 |
-
color: str = "Dark", month: str = "Jul",
|
| 480 |
-
indoor_temp: float = 25.5, outdoor_temp: float = 35.0,
|
| 481 |
-
humidity: float = 50, solar_radiation: float = 200) -> float:
|
| 482 |
-
"""Calculate corrected CLTD value for a roof with climatic adjustments."""
|
| 483 |
-
cltd = self.get_cltd_roof(roof_group, hour, latitude)
|
| 484 |
-
cltd = self._apply_climatic_corrections(cltd, indoor_temp, outdoor_temp, humidity, solar_radiation,
|
| 485 |
-
"cltd", color, month, latitude)
|
| 486 |
-
return max(0, cltd)
|
|
|
|
| 384 |
"Nov": -3.0, "Dec": -5.0
|
| 385 |
}
|
| 386 |
|
| 387 |
+
def _apply_climatic_corrections(self, cltd: float, latitude: str, month: str, color: str, outdoor_temp: float, indoor_temp: float) -> float:
|
| 388 |
+
"""
|
| 389 |
+
Apply climatic corrections to CLTD values based on latitude, month, color, and temperature.
|
| 390 |
+
|
| 391 |
+
Args:
|
| 392 |
+
cltd (float): Base CLTD value.
|
| 393 |
+
latitude (str): Latitude (e.g., '32N').
|
| 394 |
+
month (str): Month (e.g., 'Jul').
|
| 395 |
+
color (str): Surface color ('Dark', 'Medium', 'Light').
|
| 396 |
+
outdoor_temp (float): Outdoor design temperature (°C).
|
| 397 |
+
indoor_temp (float): Indoor design temperature (°C).
|
| 398 |
+
|
| 399 |
+
Returns:
|
| 400 |
+
float: Corrected CLTD value (°C).
|
| 401 |
+
"""
|
| 402 |
+
try:
|
| 403 |
+
# Convert temperatures to °F for ASHRAE corrections
|
| 404 |
+
outdoor_temp_f = outdoor_temp * 9/5 + 32
|
| 405 |
+
indoor_temp_f = indoor_temp * 9/5 + 32
|
| 406 |
+
|
| 407 |
+
# Get correction factors
|
| 408 |
+
lat_corr = self.get_latitude_correction(latitude, month)
|
| 409 |
+
month_corr = self.month_correction.get(month, 0.0)
|
| 410 |
+
color_corr = self.color_correction.get(color, 0.0)
|
| 411 |
+
|
| 412 |
+
# Apply temperature difference correction (ASHRAE CLTD correction formula)
|
| 413 |
+
temp_diff = outdoor_temp_f - indoor_temp_f
|
| 414 |
+
design_temp_diff = 85 - 78 # ASHRAE base conditions: 85°F outdoor, 78°F indoor
|
| 415 |
+
temp_corr = (temp_diff - design_temp_diff) * 0.5556 # Convert °F to °C
|
| 416 |
+
|
| 417 |
+
# Total correction
|
| 418 |
+
corrected_cltd = cltd + lat_corr + month_corr + color_corr + temp_corr
|
| 419 |
+
|
| 420 |
+
# Ensure non-negative CLTD
|
| 421 |
+
return max(0.0, corrected_cltd)
|
| 422 |
+
except Exception as e:
|
| 423 |
+
raise ValueError(f"Error applying climatic corrections: {str(e)}")
|
| 424 |
+
|
| 425 |
def get_cltd_wall(self, wall_group: str, orientation: str, hour: int) -> float:
|
| 426 |
"""Get CLTD value for a wall."""
|
| 427 |
if wall_group not in self.cltd_wall:
|
|
|
|
| 430 |
orientation_abbr = orientation_map.get(orientation, orientation)
|
| 431 |
if orientation_abbr not in self.cltd_wall[wall_group].columns:
|
| 432 |
raise ValueError(f"Invalid orientation: {orientation}")
|
| 433 |
+
if hour not in self.cltd_wall[wall_group].index:
|
| 434 |
raise ValueError(f"Invalid hour: {hour}")
|
| 435 |
+
return float(self.cltd_wall[wall_group].loc[hour, orientation_abbr])
|
| 436 |
|
| 437 |
+
def get_cltd_roof(self, roof_group: str, latitude: str, hour: int) -> float:
|
| 438 |
"""Get CLTD value for a roof."""
|
| 439 |
key = f"{roof_group}_{latitude}"
|
| 440 |
if key not in self.cltd_roof:
|
| 441 |
raise ValueError(f"Invalid roof group or latitude: {key}")
|
| 442 |
+
if hour not in self.cltd_roof[key].index:
|
| 443 |
raise ValueError(f"Invalid hour: {hour}")
|
| 444 |
+
return float(self.cltd_roof[key].loc[hour, "HOR"])
|
| 445 |
|
| 446 |
+
def get_scl(self, latitude: str, month: str, orientation: str, hour: int) -> float:
|
| 447 |
"""Get SCL value for a window."""
|
| 448 |
key = f"{latitude}_{month}"
|
| 449 |
if key not in self.scl:
|
| 450 |
+
raise ValueError(f"Invalid latitude or month: {key}")
|
| 451 |
orientation_map = {e.value: e.name for e in Orientation}
|
| 452 |
orientation_abbr = orientation_map.get(orientation, orientation)
|
| 453 |
if orientation_abbr not in self.scl[key].columns:
|
| 454 |
raise ValueError(f"Invalid orientation: {orientation}")
|
| 455 |
+
if hour not in self.scl[key].index:
|
| 456 |
raise ValueError(f"Invalid hour: {hour}")
|
| 457 |
+
return float(self.scl[key].loc[hour, orientation_abbr])
|
| 458 |
|
| 459 |
+
def get_clf_lights(self, zone_type: str, hours_on: str, hour: int) -> float:
|
| 460 |
"""Get CLF value for lights."""
|
| 461 |
+
key = f"{zone_type}_{hours_on}"
|
| 462 |
if key not in self.clf_lights.columns:
|
| 463 |
+
raise ValueError(f"Invalid zone type or hours: {key}")
|
| 464 |
+
if hour not in self.clf_lights.index:
|
| 465 |
raise ValueError(f"Invalid hour: {hour}")
|
| 466 |
+
return float(self.clf_lights.loc[hour, key])
|
| 467 |
|
| 468 |
+
def get_clf_people(self, zone_type: str, hours_occupied: str, hour: int) -> float:
|
| 469 |
"""Get CLF value for people."""
|
| 470 |
+
key = f"{zone_type}_{hours_occupied}"
|
| 471 |
if key not in self.clf_people.columns:
|
| 472 |
+
raise ValueError(f"Invalid zone type or hours: {key}")
|
| 473 |
+
if hour not in self.clf_people.index:
|
| 474 |
raise ValueError(f"Invalid hour: {hour}")
|
| 475 |
+
return float(self.clf_people.loc[hour, key])
|
| 476 |
|
| 477 |
+
def get_clf_equipment(self, zone_type: str, hours_operated: str, hour: int) -> float:
|
| 478 |
"""Get CLF value for equipment."""
|
| 479 |
+
key = f"{zone_type}_{hours_operated}"
|
| 480 |
if key not in self.clf_equipment.columns:
|
| 481 |
+
raise ValueError(f"Invalid zone type or hours: {key}")
|
| 482 |
+
if hour not in self.clf_equipment.index:
|
| 483 |
raise ValueError(f"Invalid hour: {hour}")
|
| 484 |
+
return float(self.clf_equipment.loc[hour, key])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 485 |
|
| 486 |
+
def get_heat_gain(self, source: str) -> float:
|
| 487 |
+
"""Get heat gain value for an internal source."""
|
| 488 |
+
if source not in self.heat_gain["source"].values:
|
| 489 |
+
raise ValueError(f"Invalid source: {source}")
|
| 490 |
+
return float(self.heat_gain[self.heat_gain["source"] == source]["gain"].iloc[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 491 |
|
| 492 |
+
def get_thermal_property
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|