mabuseif commited on
Commit
6a3b4aa
·
verified ·
1 Parent(s): 5a47894

Update utils/cooling_load.py

Browse files
Files changed (1) hide show
  1. utils/cooling_load.py +13 -15
utils/cooling_load.py CHANGED
@@ -700,7 +700,7 @@ class CoolingLoadCalculator:
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:
@@ -708,12 +708,12 @@ class CoolingLoadCalculator:
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,14 +738,13 @@ class CoolingLoadCalculator:
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
 
@@ -765,7 +764,7 @@ class CoolingLoadCalculator:
765
  if self.debug_mode:
766
  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'})")
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)
@@ -863,7 +862,7 @@ class CoolingLoadCalculator:
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:
@@ -871,12 +870,12 @@ class CoolingLoadCalculator:
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,14 +899,13 @@ class CoolingLoadCalculator:
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
 
 
700
  if self.debug_mode:
701
  logger.debug(f"Month converted: {month} -> {month_int}")
702
 
703
+ # Convert string latitude to numerical for SCL interpolation only
704
  try:
705
  lat_value = float(latitude.replace('N', ''))
706
  except ValueError:
 
708
  logger.error(f"Invalid latitude format: {latitude}. Defaulting to 32.0")
709
  lat_value = 32.0
710
 
711
+ # Initialize CLTDCalculator with string 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=latitude, # Use string 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
  )
743
  if self.debug_mode:
744
+ logger.debug(f"CLTD from CLTDCalculator: {cltd} for glazing_type={glazing_key}, latitude={latitude}")
745
  except Exception as e:
746
  if self.debug_mode:
747
+ logger.error(f"get_cltd_window failed for glazing_type={glazing_key}, latitude={latitude}: {str(e)}")
748
  logger.warning("Using default CLTD=8.0°C")
749
  cltd = 8.0
750
 
 
764
  if self.debug_mode:
765
  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'})")
766
 
767
+ # Solar load with latitude Interpolation
768
  try:
769
  latitudes = [24, 32, 40, 48, 56]
770
  lat1 = max([lat for lat in latitudes if lat <= lat_value], default=24)
 
862
  if self.debug_mode:
863
  logger.debug(f"Month converted: {month} -> {month_int}")
864
 
865
+ # Convert string latitude to numerical for SCL interpolation only
866
  try:
867
  lat_value = float(latitude.replace('N', ''))
868
  except ValueError:
 
870
  logger.error(f"Invalid latitude format: {latitude}. Defaulting to 32.0")
871
  lat_value = 32.0
872
 
873
+ # Initialize CLTDCalculator with string latitude
874
  cltd_calculator = CLTDCalculator(
875
  indoor_temp=indoor_temp,
876
  outdoor_max_temp=outdoor_temp,
877
  outdoor_daily_range=11.7, # Default from drapery.py
878
+ latitude=latitude, # Use string latitude
879
  month=month_int
880
  )
881
 
 
899
  glazing_key = glazing_type if glazing_type in ['Single Clear', 'Double Tinted', 'Low-E', 'Reflective'] else 'SingleClear'
900
  cltd = cltd_calculator.get_cltd_skylight(
901
  glazing_type=glazing_key,
902
+ hour=hour
 
903
  )
904
  if self.debug_mode:
905
+ logger.debug(f"CLTD from CLTDCalculator: {cltd} for glazing_type={glazing_key}, latitude={latitude}")
906
  except Exception as e:
907
  if self.debug_mode:
908
+ logger.error(f"get_cltd_skylight failed for glazing_type={glazing_key}, latitude={latitude}: {str(e)}")
909
  logger.warning("Using default CLTD=8.0°C")
910
  cltd = 8.0
911