mabuseif commited on
Commit
7a69981
·
verified ·
1 Parent(s): 20d92bc

Upload 2 files

Browse files
Files changed (1) hide show
  1. app/main.py +18 -4
app/main.py CHANGED
@@ -644,6 +644,13 @@ class HVACCalculator:
644
  latitude=outdoor_conditions['latitude'],
645
  shading_coefficient=window.shading_coefficient
646
  )
 
 
 
 
 
 
 
647
  # Pass latitude directly to get_scl method which has its own validation
648
  results['detailed_loads']['windows'].append({
649
  'name': window.name,
@@ -685,13 +692,17 @@ class HVACCalculator:
685
  activity_level=load['activity_level'],
686
  hour=design_loads['design_hour']
687
  )
 
 
 
688
  elif load_type == 'lighting':
689
- load_dict = {'total': self.cooling_calculator.calculate_lights_cooling_load(
690
  power=load['power'],
691
  use_factor=load['usage_factor'],
692
  special_allowance=0.1,
693
  hour=design_loads['design_hour']
694
- )}
 
695
  else:
696
  load_dict = self.cooling_calculator.calculate_equipment_cooling_load(
697
  power=load['power'],
@@ -699,17 +710,20 @@ class HVACCalculator:
699
  radiation_factor=load['radiation_fraction'],
700
  hour=design_loads['design_hour']
701
  )
 
 
 
702
  results['detailed_loads']['internal'].append({
703
  'type': load_type.capitalize(),
704
  'name': load['name'],
705
  'quantity': load.get('num_people', load.get('power', 1)),
706
- 'heat_gain': load_dict.get('sensible', load_dict['total']),
707
  'clf': self.cooling_calculator.ashrae_tables.get_clf_people(
708
  zone_type='A',
709
  hours_occupied=f"{load['hours_in_operation']}h",
710
  hour=design_loads['design_hour']
711
  ) if load_type == 'people' else 1.0,
712
- 'load': load_dict['total'] / 1000
713
  })
714
 
715
  if st.session_state.get('debug_mode', False):
 
644
  latitude=outdoor_conditions['latitude'],
645
  shading_coefficient=window.shading_coefficient
646
  )
647
+ # Ensure load_dict has a 'total' key
648
+ if 'total' not in load_dict:
649
+ if 'conduction' in load_dict and 'solar' in load_dict:
650
+ load_dict['total'] = load_dict['conduction'] + load_dict['solar']
651
+ else:
652
+ load_dict['total'] = window.u_value * window.area * (outdoor_conditions['temperature'] - indoor_conditions['temperature'])
653
+
654
  # Pass latitude directly to get_scl method which has its own validation
655
  results['detailed_loads']['windows'].append({
656
  'name': window.name,
 
692
  activity_level=load['activity_level'],
693
  hour=design_loads['design_hour']
694
  )
695
+ # Ensure load_dict has a 'total' key
696
+ if 'total' not in load_dict and ('sensible' in load_dict or 'latent' in load_dict):
697
+ load_dict['total'] = load_dict.get('sensible', 0) + load_dict.get('latent', 0)
698
  elif load_type == 'lighting':
699
+ light_load = self.cooling_calculator.calculate_lights_cooling_load(
700
  power=load['power'],
701
  use_factor=load['usage_factor'],
702
  special_allowance=0.1,
703
  hour=design_loads['design_hour']
704
+ )
705
+ load_dict = {'total': light_load if light_load is not None else 0}
706
  else:
707
  load_dict = self.cooling_calculator.calculate_equipment_cooling_load(
708
  power=load['power'],
 
710
  radiation_factor=load['radiation_fraction'],
711
  hour=design_loads['design_hour']
712
  )
713
+ # Ensure load_dict has a 'total' key
714
+ if 'total' not in load_dict and ('sensible' in load_dict or 'latent' in load_dict):
715
+ load_dict['total'] = load_dict.get('sensible', 0) + load_dict.get('latent', 0)
716
  results['detailed_loads']['internal'].append({
717
  'type': load_type.capitalize(),
718
  'name': load['name'],
719
  'quantity': load.get('num_people', load.get('power', 1)),
720
+ 'heat_gain': load_dict.get('sensible', load_dict.get('total', 0)),
721
  'clf': self.cooling_calculator.ashrae_tables.get_clf_people(
722
  zone_type='A',
723
  hours_occupied=f"{load['hours_in_operation']}h",
724
  hour=design_loads['design_hour']
725
  ) if load_type == 'people' else 1.0,
726
+ 'load': load_dict.get('total', 0) / 1000
727
  })
728
 
729
  if st.session_state.get('debug_mode', False):