mabuseif commited on
Commit
e3754c7
·
verified ·
1 Parent(s): 6c7f69e

Update app/hvac_loads.py

Browse files
Files changed (1) hide show
  1. app/hvac_loads.py +13 -5
app/hvac_loads.py CHANGED
@@ -618,7 +618,9 @@ class TFMCalculations:
618
  volume = area * building_height
619
  is_weekend = False # Simplified; determine from date in practice
620
  climate_data = st.session_state.project_data.get("climate_data", {})
621
- wind_speed = climate_data.get("hourly_data", [{}])[hour % 24].get("wind_speed", 4.0)
 
 
622
  outdoor_rh = climate_data.get("hourly_data", [{}])[hour % 24].get("relative_humidity", 50.0)
623
  indoor_rh = building_info.get("summer_indoor_design_rh" if mode == "cooling" else "winter_indoor_design_rh", 50.0)
624
  altitude = climate_data.get("location", {}).get("elevation", 0.0)
@@ -636,24 +638,30 @@ class TFMCalculations:
636
  ach = system.get("design_flow_rate", 0.3)
637
  Q = ach * volume / 3600 # m³/s
638
  wind_coeff = 0.23 # LBL model coefficient
639
- ela = Q / (wind_coeff * max(wind_speed, 0.1) ** 2) if wind_speed > 0 else 0.0001 * system_area
640
- infiltration_flow = wind_coeff * ela * (wind_speed ** 2) * fraction
 
 
641
  elif system_type == "Effective Leakage Area":
642
  ela = system.get("effective_air_leakage_area", 100.0) / 10000 # cm² to m²
643
  stack_coeff = system.get("stack_coefficient", 0.0001)
644
  wind_coeff = system.get("wind_coefficient", 0.0001)
 
 
645
  delta_t_abs = abs(delta_t)
646
  Q_stack = stack_coeff * ela * (delta_t_abs ** 0.5)
647
- Q_wind = wind_coeff * ela * (wind_speed ** 2)
648
  infiltration_flow = ((Q_stack ** 2 + Q_wind ** 2) ** 0.5) * fraction
649
  elif system_type == "Flow Coefficient":
650
  c = system.get("flow_coefficient", 0.0001)
651
  n = system.get("pressure_exponent", 0.6)
652
  stack_coeff = system.get("stack_coefficient", 0.0001)
653
  wind_coeff = system.get("wind_coefficient", 0.0001)
 
 
654
  delta_t_abs = abs(delta_t)
655
  delta_p_stack = stack_coeff * delta_t_abs
656
- delta_p_wind = wind_coeff * (wind_speed ** 2)
657
  delta_p = (delta_p_stack ** 2 + delta_p_wind ** 2) ** 0.5
658
  infiltration_flow = c * (delta_p ** n) * system_area * fraction
659
 
 
618
  volume = area * building_height
619
  is_weekend = False # Simplified; determine from date in practice
620
  climate_data = st.session_state.project_data.get("climate_data", {})
621
+ wind_speed = max(climate_data.get("hourly_data", [{}])[hour % 24].get("wind_speed", 4.0), 0.0)
622
+ wind_speed = min(wind_speed, 20.0)
623
+ wind_direction = climate_data.get("hourly_data", [{}])[hour % 24].get("wind_direction", 0.0)
624
  outdoor_rh = climate_data.get("hourly_data", [{}])[hour % 24].get("relative_humidity", 50.0)
625
  indoor_rh = building_info.get("summer_indoor_design_rh" if mode == "cooling" else "winter_indoor_design_rh", 50.0)
626
  altitude = climate_data.get("location", {}).get("elevation", 0.0)
 
638
  ach = system.get("design_flow_rate", 0.3)
639
  Q = ach * volume / 3600 # m³/s
640
  wind_coeff = 0.23 # LBL model coefficient
641
+ relative_angle = abs((wind_direction - system.get("surface_azimuth", 0.0)) % 360)
642
+ wind_coeff_adjusted = wind_coeff * max(0.2, math.cos(math.radians(relative_angle)))
643
+ ela = Q / (wind_coeff_adjusted * max(wind_speed, 0.1) ** 2) if wind_speed > 0 else 0.0001 * system_area
644
+ infiltration_flow = wind_coeff_adjusted * ela * (wind_speed ** 2) * fraction
645
  elif system_type == "Effective Leakage Area":
646
  ela = system.get("effective_air_leakage_area", 100.0) / 10000 # cm² to m²
647
  stack_coeff = system.get("stack_coefficient", 0.0001)
648
  wind_coeff = system.get("wind_coefficient", 0.0001)
649
+ relative_angle = abs((wind_direction - system.get("surface_azimuth", 0.0)) % 360)
650
+ wind_coeff_adjusted = wind_coeff * max(0.2, math.cos(math.radians(relative_angle)))
651
  delta_t_abs = abs(delta_t)
652
  Q_stack = stack_coeff * ela * (delta_t_abs ** 0.5)
653
+ Q_wind = wind_coeff_adjusted * ela * (wind_speed ** 2)
654
  infiltration_flow = ((Q_stack ** 2 + Q_wind ** 2) ** 0.5) * fraction
655
  elif system_type == "Flow Coefficient":
656
  c = system.get("flow_coefficient", 0.0001)
657
  n = system.get("pressure_exponent", 0.6)
658
  stack_coeff = system.get("stack_coefficient", 0.0001)
659
  wind_coeff = system.get("wind_coefficient", 0.0001)
660
+ relative_angle = abs((wind_direction - system.get("surface_azimuth", 0.0)) % 360)
661
+ wind_coeff_adjusted = wind_coeff * max(0.2, math.cos(math.radians(relative_angle)))
662
  delta_t_abs = abs(delta_t)
663
  delta_p_stack = stack_coeff * delta_t_abs
664
+ delta_p_wind = wind_coeff_adjusted * (wind_speed ** 2)
665
  delta_p = (delta_p_stack ** 2 + delta_p_wind ** 2) ** 0.5
666
  infiltration_flow = c * (delta_p ** n) * system_area * fraction
667