Spaces:
Sleeping
Sleeping
Update utils/cooling_load.py
Browse files- utils/cooling_load.py +34 -18
utils/cooling_load.py
CHANGED
@@ -700,12 +700,20 @@ class CoolingLoadCalculator:
|
|
700 |
if self.debug_mode:
|
701 |
logger.debug(f"Month converted: {month} -> {month_int}")
|
702 |
|
703 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
704 |
cltd_calculator = CLTDCalculator(
|
705 |
indoor_temp=indoor_temp,
|
706 |
outdoor_max_temp=outdoor_temp,
|
707 |
outdoor_daily_range=11.7, # Default from drapery.py
|
708 |
-
latitude=latitude
|
709 |
month=month_int
|
710 |
)
|
711 |
|
@@ -730,13 +738,14 @@ class CoolingLoadCalculator:
|
|
730 |
cltd = cltd_calculator.get_cltd_window(
|
731 |
glazing_type=glazing_key,
|
732 |
orientation=window.orientation.value,
|
733 |
-
hour=hour
|
|
|
734 |
)
|
735 |
if self.debug_mode:
|
736 |
-
logger.debug(f"CLTD from CLTDCalculator: {cltd} for glazing_type={glazing_key}")
|
737 |
except Exception as e:
|
738 |
if self.debug_mode:
|
739 |
-
logger.error(f"get_cltd_window failed for glazing_type={glazing_key}: {str(e)}")
|
740 |
logger.warning("Using default CLTD=8.0°C")
|
741 |
cltd = 8.0
|
742 |
|
@@ -758,19 +767,18 @@ class CoolingLoadCalculator:
|
|
758 |
|
759 |
# Solar load with latitude interpolation
|
760 |
try:
|
761 |
-
lat_value = float(latitude.replace('N', ''))
|
762 |
latitudes = [24, 32, 40, 48, 56]
|
763 |
lat1 = max([lat for lat in latitudes if lat <= lat_value], default=24)
|
764 |
lat2 = min([lat for lat in latitudes if lat >= lat_value], default=56)
|
765 |
|
766 |
scl1 = cltd_calculator.ashrae_tables.get_scl(
|
767 |
-
latitude=float(lat1),
|
768 |
orientation=window.orientation.value,
|
769 |
hour=hour,
|
770 |
month=month_int
|
771 |
)
|
772 |
scl2 = cltd_calculator.ashrae_tables.get_scl(
|
773 |
-
latitude=float(lat2),
|
774 |
orientation=window.orientation.value,
|
775 |
hour=hour,
|
776 |
month=month_int
|
@@ -787,7 +795,7 @@ class CoolingLoadCalculator:
|
|
787 |
logger.debug(f"SCL interpolated: scl1={scl1}, scl2={scl2}, lat1={lat1}, lat2={lat2}, weight={weight}, scl={scl}")
|
788 |
except Exception as e:
|
789 |
if self.debug_mode:
|
790 |
-
logger.error(f"get_scl failed for latitude={
|
791 |
logger.warning("Using default SCL=100 W/m²")
|
792 |
scl = 100.0
|
793 |
|
@@ -855,12 +863,20 @@ class CoolingLoadCalculator:
|
|
855 |
if self.debug_mode:
|
856 |
logger.debug(f"Month converted: {month} -> {month_int}")
|
857 |
|
858 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
859 |
cltd_calculator = CLTDCalculator(
|
860 |
indoor_temp=indoor_temp,
|
861 |
outdoor_max_temp=outdoor_temp,
|
862 |
outdoor_daily_range=11.7, # Default from drapery.py
|
863 |
-
latitude=latitude
|
864 |
month=month_int
|
865 |
)
|
866 |
|
@@ -884,13 +900,14 @@ class CoolingLoadCalculator:
|
|
884 |
glazing_key = glazing_type if glazing_type in ['Single Clear', 'Double Tinted', 'Low-E', 'Reflective'] else 'SingleClear'
|
885 |
cltd = cltd_calculator.get_cltd_skylight(
|
886 |
glazing_type=glazing_key,
|
887 |
-
hour=hour
|
|
|
888 |
)
|
889 |
if self.debug_mode:
|
890 |
-
logger.debug(f"CLTD from CLTDCalculator: {cltd} for glazing_type={glazing_key}")
|
891 |
except Exception as e:
|
892 |
if self.debug_mode:
|
893 |
-
logger.error(f"get_cltd_skylight failed for glazing_type={glazing_key}: {str(e)}")
|
894 |
logger.warning("Using default CLTD=8.0°C")
|
895 |
cltd = 8.0
|
896 |
|
@@ -912,19 +929,18 @@ class CoolingLoadCalculator:
|
|
912 |
|
913 |
# Solar load with latitude interpolation
|
914 |
try:
|
915 |
-
lat_value = float(latitude.replace('N', ''))
|
916 |
latitudes = [24, 32, 40, 48, 56]
|
917 |
lat1 = max([lat for lat in latitudes if lat <= lat_value], default=24)
|
918 |
lat2 = min([lat for lat in latitudes if lat >= lat_value], default=56)
|
919 |
|
920 |
scl1 = cltd_calculator.ashrae_tables.get_scl(
|
921 |
-
latitude=float(lat1),
|
922 |
orientation='Horizontal',
|
923 |
hour=hour,
|
924 |
month=month_int
|
925 |
)
|
926 |
scl2 = cltd_calculator.ashrae_tables.get_scl(
|
927 |
-
latitude=float(lat2),
|
928 |
orientation='Horizontal',
|
929 |
hour=hour,
|
930 |
month=month_int
|
@@ -941,7 +957,7 @@ class CoolingLoadCalculator:
|
|
941 |
logger.debug(f"SCL interpolated: scl1={scl1}, scl2={scl2}, lat1={lat1}, lat2={lat2}, weight={weight}, scl={scl}")
|
942 |
except Exception as e:
|
943 |
if self.debug_mode:
|
944 |
-
logger.error(f"get_scl failed for latitude={
|
945 |
logger.warning("Using default SCL=100 W/m²")
|
946 |
scl = 100.0
|
947 |
|
|
|
700 |
if self.debug_mode:
|
701 |
logger.debug(f"Month converted: {month} -> {month_int}")
|
702 |
|
703 |
+
# Convert string latitude to numerical for CLTDCalculator and CLTD calculations
|
704 |
+
try:
|
705 |
+
lat_value = float(latitude.replace('N', ''))
|
706 |
+
except ValueError:
|
707 |
+
if self.debug_mode:
|
708 |
+
logger.error(f"Invalid latitude format: {latitude}. Defaulting to 32.0")
|
709 |
+
lat_value = 32.0
|
710 |
+
|
711 |
+
# Initialize CLTDCalculator with numerical latitude
|
712 |
cltd_calculator = CLTDCalculator(
|
713 |
indoor_temp=indoor_temp,
|
714 |
outdoor_max_temp=outdoor_temp,
|
715 |
outdoor_daily_range=11.7, # Default from drapery.py
|
716 |
+
latitude=lat_value, # Use numerical latitude
|
717 |
month=month_int
|
718 |
)
|
719 |
|
|
|
738 |
cltd = cltd_calculator.get_cltd_window(
|
739 |
glazing_type=glazing_key,
|
740 |
orientation=window.orientation.value,
|
741 |
+
hour=hour,
|
742 |
+
latitude=lat_value # Pass numerical latitude
|
743 |
)
|
744 |
if self.debug_mode:
|
745 |
+
logger.debug(f"CLTD from CLTDCalculator: {cltd} for glazing_type={glazing_key}, latitude={lat_value}")
|
746 |
except Exception as e:
|
747 |
if self.debug_mode:
|
748 |
+
logger.error(f"get_cltd_window failed for glazing_type={glazing_key}, latitude={lat_value}: {str(e)}")
|
749 |
logger.warning("Using default CLTD=8.0°C")
|
750 |
cltd = 8.0
|
751 |
|
|
|
767 |
|
768 |
# Solar load with latitude interpolation
|
769 |
try:
|
|
|
770 |
latitudes = [24, 32, 40, 48, 56]
|
771 |
lat1 = max([lat for lat in latitudes if lat <= lat_value], default=24)
|
772 |
lat2 = min([lat for lat in latitudes if lat >= lat_value], default=56)
|
773 |
|
774 |
scl1 = cltd_calculator.ashrae_tables.get_scl(
|
775 |
+
latitude=float(lat1),
|
776 |
orientation=window.orientation.value,
|
777 |
hour=hour,
|
778 |
month=month_int
|
779 |
)
|
780 |
scl2 = cltd_calculator.ashrae_tables.get_scl(
|
781 |
+
latitude=float(lat2),
|
782 |
orientation=window.orientation.value,
|
783 |
hour=hour,
|
784 |
month=month_int
|
|
|
795 |
logger.debug(f"SCL interpolated: scl1={scl1}, scl2={scl2}, lat1={lat1}, lat2={lat2}, weight={weight}, scl={scl}")
|
796 |
except Exception as e:
|
797 |
if self.debug_mode:
|
798 |
+
logger.error(f"get_scl failed for latitude={lat_value}, month={month}, orientation={window.orientation.value}: {str(e)}")
|
799 |
logger.warning("Using default SCL=100 W/m²")
|
800 |
scl = 100.0
|
801 |
|
|
|
863 |
if self.debug_mode:
|
864 |
logger.debug(f"Month converted: {month} -> {month_int}")
|
865 |
|
866 |
+
# Convert string latitude to numerical for CLTDCalculator and CLTD calculations
|
867 |
+
try:
|
868 |
+
lat_value = float(latitude.replace('N', ''))
|
869 |
+
except ValueError:
|
870 |
+
if self.debug_mode:
|
871 |
+
logger.error(f"Invalid latitude format: {latitude}. Defaulting to 32.0")
|
872 |
+
lat_value = 32.0
|
873 |
+
|
874 |
+
# Initialize CLTDCalculator with numerical latitude
|
875 |
cltd_calculator = CLTDCalculator(
|
876 |
indoor_temp=indoor_temp,
|
877 |
outdoor_max_temp=outdoor_temp,
|
878 |
outdoor_daily_range=11.7, # Default from drapery.py
|
879 |
+
latitude=lat_value, # Use numerical latitude
|
880 |
month=month_int
|
881 |
)
|
882 |
|
|
|
900 |
glazing_key = glazing_type if glazing_type in ['Single Clear', 'Double Tinted', 'Low-E', 'Reflective'] else 'SingleClear'
|
901 |
cltd = cltd_calculator.get_cltd_skylight(
|
902 |
glazing_type=glazing_key,
|
903 |
+
hour=hour,
|
904 |
+
latitude=lat_value # Pass numerical latitude
|
905 |
)
|
906 |
if self.debug_mode:
|
907 |
+
logger.debug(f"CLTD from CLTDCalculator: {cltd} for glazing_type={glazing_key}, latitude={lat_value}")
|
908 |
except Exception as e:
|
909 |
if self.debug_mode:
|
910 |
+
logger.error(f"get_cltd_skylight failed for glazing_type={glazing_key}, latitude={lat_value}: {str(e)}")
|
911 |
logger.warning("Using default CLTD=8.0°C")
|
912 |
cltd = 8.0
|
913 |
|
|
|
929 |
|
930 |
# Solar load with latitude interpolation
|
931 |
try:
|
|
|
932 |
latitudes = [24, 32, 40, 48, 56]
|
933 |
lat1 = max([lat for lat in latitudes if lat <= lat_value], default=24)
|
934 |
lat2 = min([lat for lat in latitudes if lat >= lat_value], default=56)
|
935 |
|
936 |
scl1 = cltd_calculator.ashrae_tables.get_scl(
|
937 |
+
latitude=float(lat1),
|
938 |
orientation='Horizontal',
|
939 |
hour=hour,
|
940 |
month=month_int
|
941 |
)
|
942 |
scl2 = cltd_calculator.ashrae_tables.get_scl(
|
943 |
+
latitude=float(lat2),
|
944 |
orientation='Horizontal',
|
945 |
hour=hour,
|
946 |
month=month_int
|
|
|
957 |
logger.debug(f"SCL interpolated: scl1={scl1}, scl2={scl2}, lat1={lat1}, lat2={lat2}, weight={weight}, scl={scl}")
|
958 |
except Exception as e:
|
959 |
if self.debug_mode:
|
960 |
+
logger.error(f"get_scl failed for latitude={lat_value}, month={month}, orientation=Horizontal: {str(e)}")
|
961 |
logger.warning("Using default SCL=100 W/m²")
|
962 |
scl = 100.0
|
963 |
|