Spaces:
Sleeping
Sleeping
Update utils/cooling_load.py
Browse files- utils/cooling_load.py +80 -18
utils/cooling_load.py
CHANGED
@@ -674,31 +674,39 @@ class CoolingLoadCalculator:
|
|
674 |
window: Window component
|
675 |
outdoor_temp: Outdoor temperature (°C)
|
676 |
indoor_temp: Indoor temperature (°C)
|
677 |
-
month: Design month
|
678 |
hour: Hour of the day
|
679 |
-
latitude: Latitude (e.g., '
|
680 |
shading_coefficient: Default shading coefficient
|
681 |
adjusted_shgc: Adjusted SHGC from external drapery calculation (optional)
|
682 |
-
glazing_type: Glazing type (e.g., 'Single Clear'
|
683 |
frame_type: Frame type (e.g., 'Aluminum without Thermal Break') (optional)
|
684 |
|
685 |
Returns:
|
686 |
Dictionary with conduction, solar, and total loads in Watts
|
687 |
"""
|
688 |
try:
|
|
|
689 |
latitude = self.validate_latitude(latitude)
|
690 |
month = self.validate_month(month)
|
691 |
hour = self.validate_hour(hour)
|
692 |
if self.debug_mode:
|
693 |
logger.debug(f"calculate_window_cooling_load: latitude={latitude}, month={month}, hour={hour}, orientation={window.orientation.value}, glazing_type={glazing_type}, frame_type={frame_type}")
|
694 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
695 |
# Initialize CLTDCalculator
|
696 |
cltd_calculator = CLTDCalculator(
|
697 |
indoor_temp=indoor_temp,
|
698 |
outdoor_max_temp=outdoor_temp,
|
699 |
outdoor_daily_range=11.7, # Default from drapery.py
|
700 |
latitude=latitude,
|
701 |
-
month=
|
702 |
)
|
703 |
|
704 |
# Determine U-factor and SHGC
|
@@ -748,14 +756,37 @@ class CoolingLoadCalculator:
|
|
748 |
if self.debug_mode:
|
749 |
logger.debug(f"Using shading coefficient: {effective_shading_coefficient} (adjusted_shgc={adjusted_shgc}, drapery={'enabled' if hasattr(window, 'drapery') and window.drapery and window.drapery.enabled else 'disabled'})")
|
750 |
|
751 |
-
# Solar load
|
752 |
try:
|
753 |
-
|
754 |
-
|
755 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
756 |
orientation=window.orientation.value,
|
757 |
-
hour=hour
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
758 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
759 |
except Exception as e:
|
760 |
if self.debug_mode:
|
761 |
logger.error(f"get_scl failed for latitude={latitude}, month={month}, orientation={window.orientation.value}: {str(e)}")
|
@@ -800,31 +831,39 @@ class CoolingLoadCalculator:
|
|
800 |
skylight: Skylight component
|
801 |
outdoor_temp: Outdoor temperature (°C)
|
802 |
indoor_temp: Indoor temperature (°C)
|
803 |
-
month: Design month
|
804 |
hour: Hour of the day
|
805 |
-
latitude: Latitude (e.g., '
|
806 |
shading_coefficient: Default shading coefficient
|
807 |
adjusted_shgc: Adjusted SHGC from external drapery calculation (optional)
|
808 |
-
glazing_type: Glazing type (e.g., 'Single Clear'
|
809 |
frame_type: Frame type (e.g., 'Aluminum without Thermal Break') (optional)
|
810 |
|
811 |
Returns:
|
812 |
Dictionary with conduction, solar, and total loads in Watts
|
813 |
"""
|
814 |
try:
|
|
|
815 |
latitude = self.validate_latitude(latitude)
|
816 |
month = self.validate_month(month)
|
817 |
hour = self.validate_hour(hour)
|
818 |
if self.debug_mode:
|
819 |
logger.debug(f"calculate_skylight_cooling_load: latitude={latitude}, month={month}, hour={hour}, orientation=Horizontal, glazing_type={glazing_type}, frame_type={frame_type}")
|
820 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
821 |
# Initialize CLTDCalculator
|
822 |
cltd_calculator = CLTDCalculator(
|
823 |
indoor_temp=indoor_temp,
|
824 |
outdoor_max_temp=outdoor_temp,
|
825 |
outdoor_daily_range=11.7, # Default from drapery.py
|
826 |
latitude=latitude,
|
827 |
-
month=
|
828 |
)
|
829 |
|
830 |
# Determine U-factor and SHGC
|
@@ -873,14 +912,37 @@ class CoolingLoadCalculator:
|
|
873 |
if self.debug_mode:
|
874 |
logger.debug(f"Using shading coefficient: {effective_shading_coefficient} (adjusted_shgc={adjusted_shgc}, drapery={'enabled' if hasattr(skylight, 'drapery') and skylight.drapery and skylight.drapery.enabled else 'disabled'})")
|
875 |
|
876 |
-
# Solar load
|
877 |
try:
|
878 |
-
|
879 |
-
|
880 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
881 |
orientation='Horizontal',
|
882 |
-
hour=hour
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
883 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
except Exception as e:
|
885 |
if self.debug_mode:
|
886 |
logger.error(f"get_scl failed for latitude={latitude}, month={month}, orientation=Horizontal: {str(e)}")
|
|
|
674 |
window: Window component
|
675 |
outdoor_temp: Outdoor temperature (°C)
|
676 |
indoor_temp: Indoor temperature (°C)
|
677 |
+
month: Design month (e.g., 'JUL')
|
678 |
hour: Hour of the day
|
679 |
+
latitude: Latitude (e.g., '40N')
|
680 |
shading_coefficient: Default shading coefficient
|
681 |
adjusted_shgc: Adjusted SHGC from external drapery calculation (optional)
|
682 |
+
glazing_type: Glazing type (e.g., 'Single Clear') (optional)
|
683 |
frame_type: Frame type (e.g., 'Aluminum without Thermal Break') (optional)
|
684 |
|
685 |
Returns:
|
686 |
Dictionary with conduction, solar, and total loads in Watts
|
687 |
"""
|
688 |
try:
|
689 |
+
# Validate inputs
|
690 |
latitude = self.validate_latitude(latitude)
|
691 |
month = self.validate_month(month)
|
692 |
hour = self.validate_hour(hour)
|
693 |
if self.debug_mode:
|
694 |
logger.debug(f"calculate_window_cooling_load: latitude={latitude}, month={month}, hour={hour}, orientation={window.orientation.value}, glazing_type={glazing_type}, frame_type={frame_type}")
|
695 |
|
696 |
+
# Convert month string to integer for CLTDCalculator
|
697 |
+
month_map = {'JAN': 1, 'FEB': 2, 'MAR': 3, 'APR': 4, 'MAY': 5, 'JUN': 6,
|
698 |
+
'JUL': 7, 'AUG': 8, 'SEP': 9, 'OCT': 10, 'NOV': 11, 'DEC': 12}
|
699 |
+
month_int = month_map.get(month.upper(), 7) # Default to July
|
700 |
+
if self.debug_mode:
|
701 |
+
logger.debug(f"Month converted: {month} -> {month_int}")
|
702 |
+
|
703 |
# Initialize CLTDCalculator
|
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 |
|
712 |
# Determine U-factor and SHGC
|
|
|
756 |
if self.debug_mode:
|
757 |
logger.debug(f"Using shading coefficient: {effective_shading_coefficient} (adjusted_shgc={adjusted_shgc}, drapery={'enabled' if hasattr(window, 'drapery') and window.drapery and window.drapery.enabled else 'disabled'})")
|
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 |
+
lat1_str = f"{lat1}N"
|
766 |
+
lat2_str = f"{lat2}N"
|
767 |
+
|
768 |
+
scl1 = cltd_calculator.ashrae_tables.get_scl(
|
769 |
+
latitude=lat1_str,
|
770 |
orientation=window.orientation.value,
|
771 |
+
hour=hour,
|
772 |
+
month=month_int
|
773 |
+
)
|
774 |
+
scl2 = cltd_calculator.ashrae_tables.get_scl(
|
775 |
+
latitude=lat2_str,
|
776 |
+
orientation=window.orientation.value,
|
777 |
+
hour=hour,
|
778 |
+
month=month_int
|
779 |
)
|
780 |
+
|
781 |
+
# Interpolate SCL
|
782 |
+
if lat1 == lat2:
|
783 |
+
scl = scl1
|
784 |
+
else:
|
785 |
+
weight = (lat_value - lat1) / (lat2 - lat1)
|
786 |
+
scl = scl1 + weight * (scl2 - scl1)
|
787 |
+
|
788 |
+
if self.debug_mode:
|
789 |
+
logger.debug(f"SCL interpolated: scl1={scl1}, scl2={scl2}, lat1={lat1}, lat2={lat2}, weight={weight}, scl={scl}")
|
790 |
except Exception as e:
|
791 |
if self.debug_mode:
|
792 |
logger.error(f"get_scl failed for latitude={latitude}, month={month}, orientation={window.orientation.value}: {str(e)}")
|
|
|
831 |
skylight: Skylight component
|
832 |
outdoor_temp: Outdoor temperature (°C)
|
833 |
indoor_temp: Indoor temperature (°C)
|
834 |
+
month: Design month (e.g., 'JUL')
|
835 |
hour: Hour of the day
|
836 |
+
latitude: Latitude (e.g., '40N')
|
837 |
shading_coefficient: Default shading coefficient
|
838 |
adjusted_shgc: Adjusted SHGC from external drapery calculation (optional)
|
839 |
+
glazing_type: Glazing type (e.g., 'Single Clear') (optional)
|
840 |
frame_type: Frame type (e.g., 'Aluminum without Thermal Break') (optional)
|
841 |
|
842 |
Returns:
|
843 |
Dictionary with conduction, solar, and total loads in Watts
|
844 |
"""
|
845 |
try:
|
846 |
+
# Validate inputs
|
847 |
latitude = self.validate_latitude(latitude)
|
848 |
month = self.validate_month(month)
|
849 |
hour = self.validate_hour(hour)
|
850 |
if self.debug_mode:
|
851 |
logger.debug(f"calculate_skylight_cooling_load: latitude={latitude}, month={month}, hour={hour}, orientation=Horizontal, glazing_type={glazing_type}, frame_type={frame_type}")
|
852 |
|
853 |
+
# Convert month string to integer for CLTDCalculator
|
854 |
+
month_map = {'JAN': 1, 'FEB': 2, 'MAR': 3, 'APR': 4, 'MAY': 5, 'JUN': 6,
|
855 |
+
'JUL': 7, 'AUG': 8, 'SEP': 9, 'OCT': 10, 'NOV': 11, 'DEC': 12}
|
856 |
+
month_int = month_map.get(month.upper(), 7) # Default to July
|
857 |
+
if self.debug_mode:
|
858 |
+
logger.debug(f"Month converted: {month} -> {month_int}")
|
859 |
+
|
860 |
# Initialize CLTDCalculator
|
861 |
cltd_calculator = CLTDCalculator(
|
862 |
indoor_temp=indoor_temp,
|
863 |
outdoor_max_temp=outdoor_temp,
|
864 |
outdoor_daily_range=11.7, # Default from drapery.py
|
865 |
latitude=latitude,
|
866 |
+
month=month_int
|
867 |
)
|
868 |
|
869 |
# Determine U-factor and SHGC
|
|
|
912 |
if self.debug_mode:
|
913 |
logger.debug(f"Using shading coefficient: {effective_shading_coefficient} (adjusted_shgc={adjusted_shgc}, drapery={'enabled' if hasattr(skylight, 'drapery') and skylight.drapery and skylight.drapery.enabled else 'disabled'})")
|
914 |
|
915 |
+
# Solar load with latitude interpolation
|
916 |
try:
|
917 |
+
lat_value = float(latitude.replace('N', ''))
|
918 |
+
latitudes = [24, 32, 40, 48, 56]
|
919 |
+
lat1 = max([lat for lat in latitudes if lat <= lat_value], default=24)
|
920 |
+
lat2 = min([lat for lat in latitudes if lat >= lat_value], default=56)
|
921 |
+
lat1_str = f"{lat1}N"
|
922 |
+
lat2_str = f"{lat2}N"
|
923 |
+
|
924 |
+
scl1 = cltd_calculator.ashrae_tables.get_scl(
|
925 |
+
latitude=lat1_str,
|
926 |
orientation='Horizontal',
|
927 |
+
hour=hour,
|
928 |
+
month=month_int
|
929 |
+
)
|
930 |
+
scl2 = cltd_calculator.ashrae_tables.get_scl(
|
931 |
+
latitude=lat2_str,
|
932 |
+
orientation='Horizontal',
|
933 |
+
hour=hour,
|
934 |
+
month=month_int
|
935 |
)
|
936 |
+
|
937 |
+
# Interpolate SCL
|
938 |
+
if lat1 == lat2:
|
939 |
+
scl = scl1
|
940 |
+
else:
|
941 |
+
weight = (lat_value - lat1) / (lat2 - lat1)
|
942 |
+
scl = scl1 + weight * (scl2 - scl1)
|
943 |
+
|
944 |
+
if self.debug_mode:
|
945 |
+
logger.debug(f"SCL interpolated: scl1={scl1}, scl2={scl2}, lat1={lat1}, lat2={lat2}, weight={weight}, scl={scl}")
|
946 |
except Exception as e:
|
947 |
if self.debug_mode:
|
948 |
logger.error(f"get_scl failed for latitude={latitude}, month={month}, orientation=Horizontal: {str(e)}")
|