Spaces:
Sleeping
Sleeping
Update utils/cooling_load.py
Browse files- utils/cooling_load.py +22 -17
utils/cooling_load.py
CHANGED
@@ -497,7 +497,7 @@ class CoolingLoadCalculator:
|
|
497 |
hour = self.validate_hour(hour)
|
498 |
if self.debug_mode:
|
499 |
logger.debug(f"calculate_wall_cooling_load: latitude={latitude}, month={month}, hour={hour}, wall_group={wall.wall_group}, orientation={wall.orientation.value}, solar_absorptivity={solar_absorptivity}")
|
500 |
-
|
501 |
wall_group = str(wall.wall_group).upper()
|
502 |
if wall_group not in self.valid_wall_groups:
|
503 |
numeric_map = {'1': 'A', '2': 'B', '3': 'C', '4': 'D'}
|
@@ -509,21 +509,23 @@ class CoolingLoadCalculator:
|
|
509 |
if self.debug_mode:
|
510 |
logger.warning(f"Invalid wall group: {wall_group}. Defaulting to 'A'")
|
511 |
wall_group = 'A'
|
512 |
-
|
513 |
try:
|
514 |
-
|
515 |
-
|
|
|
|
|
|
|
|
|
516 |
orientation=wall.orientation.value,
|
517 |
hour=hour,
|
518 |
-
|
519 |
-
latitude=latitude,
|
520 |
-
indoor_temp=indoor_temp,
|
521 |
-
outdoor_temp=outdoor_temp,
|
522 |
solar_absorptivity=solar_absorptivity
|
523 |
)
|
|
|
524 |
except Exception as e:
|
525 |
if self.debug_mode:
|
526 |
-
logger.error(f"
|
527 |
logger.warning("Using default CLTD=8.0°C")
|
528 |
cltd = 8.0
|
529 |
|
@@ -569,7 +571,7 @@ class CoolingLoadCalculator:
|
|
569 |
hour = self.validate_hour(hour)
|
570 |
if self.debug_mode:
|
571 |
logger.debug(f"calculate_roof_cooling_load: latitude={latitude}, month={month}, hour={hour}, roof_group={roof.roof_group}, solar_absorptivity={solar_absorptivity}")
|
572 |
-
|
573 |
roof_group = str(roof.roof_group).upper()
|
574 |
if roof_group not in self.valid_roof_groups:
|
575 |
numeric_map = {'1': 'A', '2': 'B', '3': 'C', '4': 'D', '5': 'E', '6': 'F', '7': 'G', '8': 'G'}
|
@@ -583,18 +585,21 @@ class CoolingLoadCalculator:
|
|
583 |
roof_group = 'A'
|
584 |
|
585 |
try:
|
586 |
-
|
587 |
-
|
|
|
|
|
|
|
|
|
|
|
588 |
hour=hour,
|
589 |
-
|
590 |
-
latitude=latitude,
|
591 |
-
indoor_temp=indoor_temp,
|
592 |
-
outdoor_temp=outdoor_temp,
|
593 |
solar_absorptivity=solar_absorptivity
|
594 |
)
|
|
|
595 |
except Exception as e:
|
596 |
if self.debug_mode:
|
597 |
-
logger.error(f"
|
598 |
logger.warning("Using default CLTD=8.0°C")
|
599 |
cltd = 8.0
|
600 |
|
|
|
497 |
hour = self.validate_hour(hour)
|
498 |
if self.debug_mode:
|
499 |
logger.debug(f"calculate_wall_cooling_load: latitude={latitude}, month={month}, hour={hour}, wall_group={wall.wall_group}, orientation={wall.orientation.value}, solar_absorptivity={solar_absorptivity}")
|
500 |
+
|
501 |
wall_group = str(wall.wall_group).upper()
|
502 |
if wall_group not in self.valid_wall_groups:
|
503 |
numeric_map = {'1': 'A', '2': 'B', '3': 'C', '4': 'D'}
|
|
|
509 |
if self.debug_mode:
|
510 |
logger.warning(f"Invalid wall group: {wall_group}. Defaulting to 'A'")
|
511 |
wall_group = 'A'
|
512 |
+
|
513 |
try:
|
514 |
+
# Convert latitude string (e.g., '40N') to float (e.g., 40.0)
|
515 |
+
lat_value = float(latitude.replace('N', ''))
|
516 |
+
# Get CLTD in °F and convert to °C
|
517 |
+
cltd_f = self.ashrae_tables.get_cltd(
|
518 |
+
element_type='wall',
|
519 |
+
group=wall_group,
|
520 |
orientation=wall.orientation.value,
|
521 |
hour=hour,
|
522 |
+
latitude=lat_value,
|
|
|
|
|
|
|
523 |
solar_absorptivity=solar_absorptivity
|
524 |
)
|
525 |
+
cltd = (cltd_f - 32) * 5 / 9 # Convert °F to °C
|
526 |
except Exception as e:
|
527 |
if self.debug_mode:
|
528 |
+
logger.error(f"get_cltd failed for wall_group={wall_group}: {str(e)}")
|
529 |
logger.warning("Using default CLTD=8.0°C")
|
530 |
cltd = 8.0
|
531 |
|
|
|
571 |
hour = self.validate_hour(hour)
|
572 |
if self.debug_mode:
|
573 |
logger.debug(f"calculate_roof_cooling_load: latitude={latitude}, month={month}, hour={hour}, roof_group={roof.roof_group}, solar_absorptivity={solar_absorptivity}")
|
574 |
+
|
575 |
roof_group = str(roof.roof_group).upper()
|
576 |
if roof_group not in self.valid_roof_groups:
|
577 |
numeric_map = {'1': 'A', '2': 'B', '3': 'C', '4': 'D', '5': 'E', '6': 'F', '7': 'G', '8': 'G'}
|
|
|
585 |
roof_group = 'A'
|
586 |
|
587 |
try:
|
588 |
+
# Convert latitude string (e.g., '40N') to float (e.g., 40.0)
|
589 |
+
lat_value = float(latitude.replace('N', ''))
|
590 |
+
# Get CLTD in °F and convert to °C
|
591 |
+
cltd_f = self.ashrae_tables.get_cltd(
|
592 |
+
element_type='roof',
|
593 |
+
group=roof_group,
|
594 |
+
orientation=roof.orientation.value,
|
595 |
hour=hour,
|
596 |
+
latitude=lat_value,
|
|
|
|
|
|
|
597 |
solar_absorptivity=solar_absorptivity
|
598 |
)
|
599 |
+
cltd = (cltd_f - 32) * 5 / 9 # Convert °F to °C
|
600 |
except Exception as e:
|
601 |
if self.debug_mode:
|
602 |
+
logger.error(f"get_cltd failed for roof_group={roof_group}: {str(e)}")
|
603 |
logger.warning("Using default CLTD=8.0°C")
|
604 |
cltd = 8.0
|
605 |
|