Spaces:
Sleeping
Sleeping
Update utils/cooling_load.py
Browse files- utils/cooling_load.py +42 -44
utils/cooling_load.py
CHANGED
@@ -495,30 +495,29 @@ class CoolingLoadCalculator:
|
|
495 |
latitude = self.validate_latitude(latitude)
|
496 |
month = self.validate_month(month)
|
497 |
hour = self.validate_hour(hour)
|
498 |
-
if
|
499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
if
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
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) for get_cltd
|
515 |
-
try:
|
516 |
-
lat_value = float(latitude.replace('N', ''))
|
517 |
-
except ValueError:
|
518 |
-
if self.debug_mode:
|
519 |
-
logger.error(f"Invalid latitude format: {latitude}. Defaulting to 32.0")
|
520 |
-
lat_value = 32.0
|
521 |
-
# Get CLTD in °F and convert to °C
|
522 |
cltd_f = self.ashrae_tables.get_cltd(
|
523 |
element_type='wall',
|
524 |
group=wall_group,
|
@@ -530,7 +529,7 @@ class CoolingLoadCalculator:
|
|
530 |
cltd = (cltd_f - 32) * 5 / 9 # Convert °F to °C
|
531 |
except Exception as e:
|
532 |
if self.debug_mode:
|
533 |
-
logger.error(f"get_cltd failed for wall_group={wall_group}: {str(e)}")
|
534 |
logger.warning("Using default CLTD=8.0°C")
|
535 |
cltd = 8.0
|
536 |
|
@@ -574,30 +573,29 @@ class CoolingLoadCalculator:
|
|
574 |
latitude = self.validate_latitude(latitude)
|
575 |
month = self.validate_month(month)
|
576 |
hour = self.validate_hour(hour)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
if self.debug_mode:
|
578 |
-
logger.debug(f"
|
579 |
|
580 |
-
roof_group = str(roof.roof_group).upper()
|
581 |
-
if roof_group not in self.valid_roof_groups:
|
582 |
-
numeric_map = {'1': 'A', '2': 'B', '3': 'C', '4': 'D', '5': 'E', '6': 'F', '7': 'G', '8': 'G'}
|
583 |
-
if roof_group in numeric_map:
|
584 |
-
roof_group = numeric_map[wall_group]
|
585 |
-
if self.debug_mode:
|
586 |
-
logger.info(f"Mapped roof_group {roof.roof_group} to {roof_group}")
|
587 |
-
else:
|
588 |
-
if self.debug_mode:
|
589 |
-
logger.warning(f"Invalid roof group: {roof_group}. Defaulting to 'A'")
|
590 |
-
roof_group = 'A'
|
591 |
-
|
592 |
try:
|
593 |
-
# Convert latitude string (e.g., '40N') to float (e.g., 40.0) for get_cltd
|
594 |
-
try:
|
595 |
-
lat_value = float(latitude.replace('N', ''))
|
596 |
-
except ValueError:
|
597 |
-
if self.debug_mode:
|
598 |
-
logger.error(f"Invalid latitude format: {latitude}. Defaulting to 32.0")
|
599 |
-
lat_value = 32.0
|
600 |
-
# Get CLTD in °F and convert to °C
|
601 |
cltd_f = self.ashrae_tables.get_cltd(
|
602 |
element_type='roof',
|
603 |
group=roof_group,
|
@@ -609,7 +607,7 @@ class CoolingLoadCalculator:
|
|
609 |
cltd = (cltd_f - 32) * 5 / 9 # Convert °F to °C
|
610 |
except Exception as e:
|
611 |
if self.debug_mode:
|
612 |
-
logger.error(f"get_cltd failed for roof_group={roof_group}: {str(e)}")
|
613 |
logger.warning("Using default CLTD=8.0°C")
|
614 |
cltd = 8.0
|
615 |
|
|
|
495 |
latitude = self.validate_latitude(latitude)
|
496 |
month = self.validate_month(month)
|
497 |
hour = self.validate_hour(hour)
|
498 |
+
wall_group = str(wall.wall_group).upper() if hasattr(wall, 'wall_group') else 'A'
|
499 |
+
numeric_map = {'1': 'A', '2': 'B', '3': 'C', '4': 'D', '5': 'E', '6': 'F', '7': 'G', '8': 'H'}
|
500 |
+
|
501 |
+
if wall_group in numeric_map:
|
502 |
+
wall_group = numeric_map[wall_group]
|
503 |
+
if self.debug_mode:
|
504 |
+
logger.info(f"Mapped wall_group {wall.wall_group} to {wall_group}")
|
505 |
+
elif wall_group not in self.valid_wall_groups:
|
506 |
+
if self.debug_mode:
|
507 |
+
logger.warning(f"Invalid wall group: {wall_group}. Defaulting to 'A'")
|
508 |
+
wall_group = 'A'
|
509 |
|
510 |
+
try:
|
511 |
+
lat_value = float(latitude.replace('N', ''))
|
512 |
+
except ValueError:
|
513 |
+
if self.debug_mode:
|
514 |
+
logger.error(f"Invalid latitude format: {latitude}. Defaulting to 32.0")
|
515 |
+
lat_value = 32.0
|
516 |
+
|
517 |
+
if self.debug_mode:
|
518 |
+
logger.debug(f"Calling get_cltd for wall: group={wall_group}, orientation={wall.orientation.value}, hour={hour}, latitude={lat_value}, solar_absorptivity={solar_absorptivity}")
|
|
|
|
|
519 |
|
520 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
cltd_f = self.ashrae_tables.get_cltd(
|
522 |
element_type='wall',
|
523 |
group=wall_group,
|
|
|
529 |
cltd = (cltd_f - 32) * 5 / 9 # Convert °F to °C
|
530 |
except Exception as e:
|
531 |
if self.debug_mode:
|
532 |
+
logger.error(f"get_cltd failed for wall_group={wall_group}, latitude={lat_value}: {str(e)}")
|
533 |
logger.warning("Using default CLTD=8.0°C")
|
534 |
cltd = 8.0
|
535 |
|
|
|
573 |
latitude = self.validate_latitude(latitude)
|
574 |
month = self.validate_month(month)
|
575 |
hour = self.validate_hour(hour)
|
576 |
+
roof_group = str(roof.roof_group).upper() if hasattr(roof, 'roof_group') else 'A'
|
577 |
+
numeric_map = {'1': 'A', '2': 'B', '3': 'C', '4': 'D', '5': 'E', '6': 'F', '7': 'G', '8': 'G'}
|
578 |
+
|
579 |
+
if roof_group in numeric_map:
|
580 |
+
roof_group = numeric_map[roof_group] # Fixed: Correctly use roof_group
|
581 |
+
if self.debug_mode:
|
582 |
+
logger.info(f"Mapped roof_group {roof.roof_group} to {roof_group}")
|
583 |
+
elif roof_group not in self.valid_roof_groups:
|
584 |
+
if self.debug_mode:
|
585 |
+
logger.warning(f"Invalid roof group: {roof_group}. Defaulting to 'A'")
|
586 |
+
roof_group = 'A'
|
587 |
+
|
588 |
+
try:
|
589 |
+
lat_value = float(latitude.replace('N', ''))
|
590 |
+
except ValueError:
|
591 |
+
if self.debug_mode:
|
592 |
+
logger.error(f"Invalid latitude format: {latitude}. Defaulting to 32.0")
|
593 |
+
lat_value = 32.0
|
594 |
+
|
595 |
if self.debug_mode:
|
596 |
+
logger.debug(f"Calling get_cltd for roof: group={roof_group}, orientation={roof.orientation.value}, hour={hour}, latitude={lat_value}, solar_absorptivity={solar_absorptivity}")
|
597 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
599 |
cltd_f = self.ashrae_tables.get_cltd(
|
600 |
element_type='roof',
|
601 |
group=roof_group,
|
|
|
607 |
cltd = (cltd_f - 32) * 5 / 9 # Convert °F to °C
|
608 |
except Exception as e:
|
609 |
if self.debug_mode:
|
610 |
+
logger.error(f"get_cltd failed for roof_group={roof_group}, latitude={lat_value}: {str(e)}")
|
611 |
logger.warning("Using default CLTD=8.0°C")
|
612 |
cltd = 8.0
|
613 |
|