mabuseif commited on
Commit
e63e763
·
verified ·
1 Parent(s): 4f7c430

Update app/hvac_loads.py

Browse files
Files changed (1) hide show
  1. app/hvac_loads.py +11 -26
app/hvac_loads.py CHANGED
@@ -149,7 +149,8 @@ class TFMCalculations:
149
  surface_tilt = component.get('surface_tilt', 90.0 if component_type in [ComponentType.WALL, ComponentType.WINDOW] else
150
  0.0 if component_type in [ComponentType.ROOF, ComponentType.SKYLIGHT] else 180.0)
151
  surface_azimuth = component.get('surface_azimuth', 0.0)
152
- h_o = 17.0 if component_type in [ComponentType.WALL, ComponentType.WINDOW, ComponentType.FLOOR] else 23.0
 
153
  emissivity = component.get('emissivity', 0.9 if component_type in [ComponentType.WALL, ComponentType.ROOF] else None)
154
  absorptivity = component.get('absorptivity', 0.6 if component_type in [ComponentType.WALL, ComponentType.ROOF] else 0.0)
155
 
@@ -157,19 +158,13 @@ class TFMCalculations:
157
  # For windows and skylights, adjust h_o and use shgc instead of absorptivity
158
  if component_type in [ComponentType.WINDOW, ComponentType.SKYLIGHT]:
159
  fenestration_name = component.get('fenestration', None)
 
160
  if not fenestration_name:
161
  logger.warning(f"No fenestration defined for {component_name}. Using default SHGC=0.7, h_o={h_o}.")
162
  absorptivity = component.get('shgc', 0.7) # Use shgc as absorptivity for consistency
163
  else:
164
- glazing_material_obj = (project_glazing_materials.get(fenestration_name) or
165
- material_library.library_glazing_materials.get(fenestration_name))
166
- if not glazing_material_obj:
167
- logger.warning(f"Fenestration '{fenestration_name}' not found for {component_name}. Using default SHGC=0.7, h_o={h_o}.")
168
- absorptivity = component.get('shgc', 0.7)
169
- else:
170
- absorptivity = glazing_material_obj.get('shgc', component.get('shgc', 0.7))
171
- h_o = glazing_material_obj.get('h_o', h_o)
172
- logger.debug(f"Using fenestration '{fenestration_name}' for {component_name}: shgc={absorptivity}, h_o={h_o}")
173
  emissivity = None # Emissivity not used for fenestrations
174
 
175
  logger.info(f"Surface parameters for {component_name}: tilt={surface_tilt:.1f}, azimuth={surface_azimuth:.1f}, h_o={h_o:.1f}, "
@@ -185,7 +180,7 @@ class TFMCalculations:
185
  surface_azimuth = 0.0
186
  elif component_type == ComponentType.SKYLIGHT:
187
  surface_tilt = 0.0
188
- h_o = 23.0
189
  surface_azimuth = 0.0
190
  elif component_type == ComponentType.FLOOR:
191
  surface_tilt = 180.0
@@ -193,7 +188,7 @@ class TFMCalculations:
193
  surface_azimuth = 0.0
194
  else: # WALL, WINDOW
195
  surface_tilt = 90.0
196
- h_o = 17.0
197
  surface_azimuth = 0.0
198
 
199
  if component_type in [ComponentType.WALL, ComponentType.ROOF]:
@@ -328,7 +323,7 @@ class TFMCalculations:
328
  h_o = 17.0 if component_type == ComponentType.WALL else 23.0
329
  else: # WINDOW, SKYLIGHT
330
  absorptivity = 0.0
331
- h_o = 17.0 if component_type == ComponentType.WINDOW else 23.0
332
 
333
  alpha_rad = math.radians(alpha)
334
  surface_tilt_rad = math.radians(surface_tilt)
@@ -356,18 +351,8 @@ class TFMCalculations:
356
  solar_heat_gain = 0.0
357
 
358
  if component_type in [ComponentType.WINDOW, ComponentType.SKYLIGHT]:
359
- shgc = component.get('shgc', 0.7)
360
- fenestration_name = component.get('fenestration', None)
361
- if fenestration_name:
362
- glazing_material_obj = (project_glazing_materials.get(fenestration_name) or
363
- material_library.library_glazing_materials.get(fenestration_name))
364
- if glazing_material_obj:
365
- shgc = glazing_material_obj.get('shgc', shgc)
366
- h_o = glazing_material_obj.get('h_o', h_o)
367
- else:
368
- logger.warning(f"Fenestration '{fenestration_name}' not found for {component_name}. Using default SHGC=0.7.")
369
-
370
- glazing_type = SolarCalculations.GLAZING_TYPE_MAPPING.get(component.get('name', ''), "Single Clear")
371
  shading_coeff = component.get('shading_coefficient', 1.0) # Aligned with components.py
372
 
373
  shgc_dynamic = shgc * SolarCalculations.calculate_dynamic_shgc(glazing_type, cos_theta)
@@ -680,7 +665,7 @@ class TFMCalculations:
680
  from app.materials_library import MaterialLibrary
681
  st.session_state.material_library = MaterialLibrary()
682
  logger.info("Initialized MaterialLibrary in session_state for solar calculations")
683
-
684
  if indoor_conditions["type"] == "ASHRAE 55 Adaptive Comfort":
685
  acceptability = indoor_conditions.get("adaptive_acceptability", "90")
686
  adaptive_setpoints = AdaptiveComfortModel.generate_adaptive_setpoints(hourly_data, acceptability)
 
149
  surface_tilt = component.get('surface_tilt', 90.0 if component_type in [ComponentType.WALL, ComponentType.WINDOW] else
150
  0.0 if component_type in [ComponentType.ROOF, ComponentType.SKYLIGHT] else 180.0)
151
  surface_azimuth = component.get('surface_azimuth', 0.0)
152
+ h_o = DEFAULT_WINDOW_PROPERTIES["h_o"] if component_type in [ComponentType.WINDOW, ComponentType.SKYLIGHT] else \
153
+ 17.0 if component_type in [ComponentType.WALL, ComponentType.FLOOR] else 23.0
154
  emissivity = component.get('emissivity', 0.9 if component_type in [ComponentType.WALL, ComponentType.ROOF] else None)
155
  absorptivity = component.get('absorptivity', 0.6 if component_type in [ComponentType.WALL, ComponentType.ROOF] else 0.0)
156
 
 
158
  # For windows and skylights, adjust h_o and use shgc instead of absorptivity
159
  if component_type in [ComponentType.WINDOW, ComponentType.SKYLIGHT]:
160
  fenestration_name = component.get('fenestration', None)
161
+ h_o = component.get('h_o', DEFAULT_WINDOW_PROPERTIES["h_o"]) # Use component-stored h_o
162
  if not fenestration_name:
163
  logger.warning(f"No fenestration defined for {component_name}. Using default SHGC=0.7, h_o={h_o}.")
164
  absorptivity = component.get('shgc', 0.7) # Use shgc as absorptivity for consistency
165
  else:
166
+ absorptivity = component.get('shgc', 0.7) # Use component-stored shgc
167
+ logger.debug(f"Using component-stored SHGC for {component_name}: shgc={absorptivity}, h_o={h_o}")
 
 
 
 
 
 
 
168
  emissivity = None # Emissivity not used for fenestrations
169
 
170
  logger.info(f"Surface parameters for {component_name}: tilt={surface_tilt:.1f}, azimuth={surface_azimuth:.1f}, h_o={h_o:.1f}, "
 
180
  surface_azimuth = 0.0
181
  elif component_type == ComponentType.SKYLIGHT:
182
  surface_tilt = 0.0
183
+ h_o = DEFAULT_WINDOW_PROPERTIES["h_o"]
184
  surface_azimuth = 0.0
185
  elif component_type == ComponentType.FLOOR:
186
  surface_tilt = 180.0
 
188
  surface_azimuth = 0.0
189
  else: # WALL, WINDOW
190
  surface_tilt = 90.0
191
+ h_o = DEFAULT_WINDOW_PROPERTIES["h_o"] if component_type == ComponentType.WINDOW else 17.0
192
  surface_azimuth = 0.0
193
 
194
  if component_type in [ComponentType.WALL, ComponentType.ROOF]:
 
323
  h_o = 17.0 if component_type == ComponentType.WALL else 23.0
324
  else: # WINDOW, SKYLIGHT
325
  absorptivity = 0.0
326
+ h_o = DEFAULT_WINDOW_PROPERTIES["h_o"]
327
 
328
  alpha_rad = math.radians(alpha)
329
  surface_tilt_rad = math.radians(surface_tilt)
 
351
  solar_heat_gain = 0.0
352
 
353
  if component_type in [ComponentType.WINDOW, ComponentType.SKYLIGHT]:
354
+ shgc = component.get('shgc', 0.7) # Use component-stored shgc
355
+ glazing_type = SolarCalculations.GLAZING_TYPE_MAPPING.get(component.get('fenestration', ''), "Single Clear")
 
 
 
 
 
 
 
 
 
 
356
  shading_coeff = component.get('shading_coefficient', 1.0) # Aligned with components.py
357
 
358
  shgc_dynamic = shgc * SolarCalculations.calculate_dynamic_shgc(glazing_type, cos_theta)
 
665
  from app.materials_library import MaterialLibrary
666
  st.session_state.material_library = MaterialLibrary()
667
  logger.info("Initialized MaterialLibrary in session_state for solar calculations")
668
+
669
  if indoor_conditions["type"] == "ASHRAE 55 Adaptive Comfort":
670
  acceptability = indoor_conditions.get("adaptive_acceptability", "90")
671
  adaptive_setpoints = AdaptiveComfortModel.generate_adaptive_setpoints(hourly_data, acceptability)