mabuseif commited on
Commit
f02f762
·
verified ·
1 Parent(s): b623538

Update app/main.py

Browse files
Files changed (1) hide show
  1. app/main.py +30 -13
app/main.py CHANGED
@@ -116,7 +116,14 @@ class HVACCalculator:
116
  self.data_export = DataExport()
117
  self.cooling_calculator = CoolingLoadCalculator()
118
  self.heating_calculator = HeatingLoadCalculator()
119
- self.drapery = Drapery()
 
 
 
 
 
 
 
120
 
121
  # Persist ClimateData in session_state
122
  if 'climate_data_obj' not in st.session_state:
@@ -898,11 +905,16 @@ class HVACCalculator:
898
  return False, f"Error in roof CLTD calculation: {str(e)}", {}
899
 
900
  for window in building_components.get('windows', []):
901
- adjusted_shgc = self.drapery.adjust_shgc(
902
- base_shgc=window.shgc,
903
- glazing_type=window.glazing_type,
904
- drapery_type=window.drapery_type if hasattr(window, 'drapery_type') else None
905
- )
 
 
 
 
 
906
  load_dict = self.cooling_calculator.calculate_window_cooling_load(
907
  window=window,
908
  outdoor_temp=outdoor_conditions['temperature'],
@@ -958,11 +970,16 @@ class HVACCalculator:
958
  })
959
 
960
  for skylight in building_components.get('skylights', []):
961
- adjusted_shgc = self.drapery.adjust_shgc(
962
- base_shgc=skylight.shgc,
963
- glazing_type=skylight.glazing_type,
964
- drapery_type=skylight.drapery_type if hasattr(skylight, 'drapery_type') else None
965
- )
 
 
 
 
 
966
  load_dict = self.cooling_calculator.calculate_skylight_cooling_load(
967
  skylight=skylight,
968
  outdoor_temp=outdoor_conditions['temperature'],
@@ -1289,7 +1306,7 @@ class HVACCalculator:
1289
  'name': roof.name,
1290
  'orientation': roof.orientation.value,
1291
  'area': roof.area,
1292
- 'u_value': roof.u_value,
1293
  'solar_absorptivity': roof.solar_absorptivity,
1294
  'delta_t': delta_t,
1295
  'load': load / 1000
@@ -1318,7 +1335,7 @@ class HVACCalculator:
1318
  )
1319
  results['detailed_loads']['windows'].append({
1320
  'name': window.name,
1321
- 'orientation': window.orientation.value,
1322
  'area': window.area,
1323
  'u_value': window.u_value,
1324
  'glazing_type': window.glazing_type,
 
116
  self.data_export = DataExport()
117
  self.cooling_calculator = CoolingLoadCalculator()
118
  self.heating_calculator = HeatingLoadCalculator()
119
+ # Initialize Drapery with UI inputs from session state
120
+ self.drapery = Drapery(
121
+ openness=st.session_state.get('drapery_openness', 'Semi-Open'),
122
+ color=st.session_state.get('drapery_color', 'Medium'),
123
+ fullness=st.session_state.get('drapery_fullness', 1.5),
124
+ enabled=st.session_state.get('drapery_enabled', True),
125
+ shading_device=st.session_state.get('shading_device', 'Drapes')
126
+ )
127
 
128
  # Persist ClimateData in session_state
129
  if 'climate_data_obj' not in st.session_state:
 
905
  return False, f"Error in roof CLTD calculation: {str(e)}", {}
906
 
907
  for window in building_components.get('windows', []):
908
+ adjusted_shgc = window.shgc # Default to base SHGC
909
+ if hasattr(window, 'drapery_type') and window.drapery_type and self.drapery.enabled:
910
+ try:
911
+ adjusted_shgc = self.drapery.get_shading_coefficient(window.shgc)
912
+ if st.session_state.get('debug_mode', False):
913
+ st.write(f"Debug: Window {window.name} adjusted SHGC: {adjusted_shgc}")
914
+ except Exception as e:
915
+ if st.session_state.get('debug_mode', False):
916
+ st.error(f"Error adjusting SHGC for window {window.name}: {str(e)}")
917
+ adjusted_shgc = window.shgc
918
  load_dict = self.cooling_calculator.calculate_window_cooling_load(
919
  window=window,
920
  outdoor_temp=outdoor_conditions['temperature'],
 
970
  })
971
 
972
  for skylight in building_components.get('skylights', []):
973
+ adjusted_shgc = skylight.shgc # Default to base SHGC
974
+ if hasattr(skylight, 'drapery_type') and skylight.drapery_type and self.drapery.enabled:
975
+ try:
976
+ adjusted_shgc = self.drapery.get_shading_coefficient(skylight.shgc)
977
+ if st.session_state.get('debug_mode', False):
978
+ st.write(f"Debug: Skylight {skylight.name} adjusted SHGC: {adjusted_shgc}")
979
+ except Exception as e:
980
+ if st.session_state.get('debug_mode', False):
981
+ st.error(f"Error adjusting SHGC for skylight {skylight.name}: {str(e)}")
982
+ adjusted_shgc = skylight.shgc
983
  load_dict = self.cooling_calculator.calculate_skylight_cooling_load(
984
  skylight=skylight,
985
  outdoor_temp=outdoor_conditions['temperature'],
 
1306
  'name': roof.name,
1307
  'orientation': roof.orientation.value,
1308
  'area': roof.area,
1309
+ 'u_value': wall.u_value,
1310
  'solar_absorptivity': roof.solar_absorptivity,
1311
  'delta_t': delta_t,
1312
  'load': load / 1000
 
1335
  )
1336
  results['detailed_loads']['windows'].append({
1337
  'name': window.name,
1338
+ 'orientation': wall.orientation.value,
1339
  'area': window.area,
1340
  'u_value': window.u_value,
1341
  'glazing_type': window.glazing_type,