Skip to content

Commit

Permalink
Simplify HVACSizing.apply_hvac_fixed_capacities method and minor code…
Browse files Browse the repository at this point in the history
… cleanup. Diffs only expected for files with detailed performance data.
  • Loading branch information
shorowit committed Aug 29, 2023
1 parent 0eea8a0 commit b2b89b8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 45 deletions.
10 changes: 5 additions & 5 deletions HPXMLtoOpenStudio/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>hpxm_lto_openstudio</name>
<uid>b1543b30-9465-45ff-ba04-1d1f85e763bc</uid>
<version_id>2b19a4f6-ac59-4518-8e0d-d4ccb8401a80</version_id>
<version_modified>2023-08-28T17:53:48Z</version_modified>
<version_id>c9097984-bf82-44df-8b93-922c619d3dff</version_id>
<version_modified>2023-08-29T00:37:42Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -244,7 +244,7 @@
<filename>hpxml_defaults.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>3ADB4C22</checksum>
<checksum>5B077503</checksum>
</file>
<file>
<filename>hpxml_schema/HPXML.xsd</filename>
Expand Down Expand Up @@ -274,13 +274,13 @@
<filename>hvac.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>0A49C4D9</checksum>
<checksum>491FF01B</checksum>
</file>
<file>
<filename>hvac_sizing.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>BB2355DB</checksum>
<checksum>F5AD7B80</checksum>
</file>
<file>
<filename>lighting.rb</filename>
Expand Down
24 changes: 23 additions & 1 deletion HPXMLtoOpenStudio/resources/hpxml_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2891,17 +2891,28 @@ def self.apply_hvac_sizing(hpxml, weather, cfa)

# Heating capacities
if htg_sys.heating_capacity.nil? || ((htg_sys.heating_capacity - hvac_sizing_values.Heat_Capacity).abs >= 1.0)
scaling_factor = hvac_sizing_values.Heat_Capacity.round / htg_sys.heating_capacity unless htg_sys.heating_capacity.nil?
# Heating capacity @ 17F
if htg_sys.is_a? HPXML::HeatPump
if (not htg_sys.heating_capacity.nil?) && (not htg_sys.heating_capacity_17F.nil?)
# Fixed value entered; scale w/ heating_capacity in case allow_increased_fixed_capacities=true
htg_cap_17f = htg_sys.heating_capacity_17F * hvac_sizing_values.Heat_Capacity.round / htg_sys.heating_capacity
htg_cap_17f = htg_sys.heating_capacity_17F * scaling_factor
if (htg_sys.heating_capacity_17F - htg_cap_17f).abs >= 1.0
htg_sys.heating_capacity_17F = htg_cap_17f.round
htg_sys.heating_capacity_17F_isdefaulted = true
end
end
end
if not htg_sys.heating_detailed_performance_data.empty?
# Fixed values entered; Scale w/ heating_capacity in case allow_increased_fixed_capacities=true
htg_sys.heating_detailed_performance_data.each do |dp|
htg_cap_dp = dp.capacity * scaling_factor
if (dp.capacity - htg_cap_dp).abs >= 1.0
dp.capacity = htg_cap_dp.round
dp.capacity_isdefaulted = true
end
end
end
htg_sys.heating_capacity = hvac_sizing_values.Heat_Capacity.round
htg_sys.heating_capacity_isdefaulted = true
end
Expand Down Expand Up @@ -2938,6 +2949,17 @@ def self.apply_hvac_sizing(hpxml, weather, cfa)

# Cooling capacities
if clg_sys.cooling_capacity.nil? || ((clg_sys.cooling_capacity - hvac_sizing_values.Cool_Capacity).abs >= 1.0)
scaling_factor = hvac_sizing_values.Cool_Capacity.round / clg_sys.cooling_capacity unless clg_sys.cooling_capacity.nil?
if not clg_sys.cooling_detailed_performance_data.empty?
# Fixed values entered; Scale w/ cooling_capacity in case allow_increased_fixed_capacities=true
clg_sys.cooling_detailed_performance_data.each do |dp|
clg_cap_dp = dp.capacity * scaling_factor
if (dp.capacity - clg_cap_dp).abs >= 1.0
dp.capacity = clg_cap_dp.round
dp.capacity_isdefaulted = true
end
end
end
clg_sys.cooling_capacity = hvac_sizing_values.Cool_Capacity.round
clg_sys.cooling_capacity_isdefaulted = true
end
Expand Down
11 changes: 5 additions & 6 deletions HPXMLtoOpenStudio/resources/hvac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def self.apply_air_source_hvac_systems(model, cooling_system, heating_system,

if not heating_system.nil?
htg_ap = heating_system.additional_properties
is_ducted = !heating_system.distribution_system_idref.nil?
htg_cfm = heating_system.heating_airflow_cfm
if is_heatpump
supp_max_temp = htg_ap.supp_max_temp
Expand Down Expand Up @@ -1212,7 +1211,7 @@ def self.set_heat_detailed_performance_data(heat_pump)
a, b, c, d, e = 0.1914, -1.822, 1.364, -0.07783, 2.221
end
max_cop_47 = a * hspf + b * max_cap_maint_5 + c * max_cap_maint_5**2 + d * max_cap_maint_5 * hspf + e
max_capacity_47 = heat_pump.heating_capacity * get_heat_capacity_ratios(heat_pump, is_ducted)[-1]
max_capacity_47 = heat_pump.heating_capacity * hp_ap.heat_capacity_ratios[-1]
min_capacity_47 = max_capacity_47 / hp_ap.heat_capacity_ratios[-1] * hp_ap.heat_capacity_ratios[0]
min_cop_47 = is_ducted ? max_cop_47 * (-0.0306 * hspf + 1.5385) : max_cop_47 * (-0.01698 * hspf + 1.5907)
max_capacity_5 = max_capacity_47 * max_cap_maint_5
Expand Down Expand Up @@ -1247,18 +1246,18 @@ def self.set_heat_detailed_performance_data(heat_pump)
end

def self.set_cool_detailed_performance_data(heat_pump)
hvac_ap = heat_pump.additional_properties
hp_ap = heat_pump.additional_properties
is_ducted = !heat_pump.distribution_system_idref.nil?
seer = heat_pump.cooling_efficiency_seer

# Default data inputs based on NEEP data
detailed_performance_data = heat_pump.cooling_detailed_performance_data

max_cop_95 = is_ducted ? 0.1953 * seer : 0.06635 * seer + 1.8707
max_capacity_95 = heat_pump.cooling_capacity * get_cool_capacity_ratios(heat_pump, is_ducted)[-1]
min_capacity_95 = max_capacity_95 / hvac_ap.cool_capacity_ratios[-1] * hvac_ap.cool_capacity_ratios[0]
max_capacity_95 = heat_pump.cooling_capacity * hp_ap.cool_capacity_ratios[-1]
min_capacity_95 = max_capacity_95 / hp_ap.cool_capacity_ratios[-1] * hp_ap.cool_capacity_ratios[0]
min_cop_95 = is_ducted ? max_cop_95 * 1.231 : max_cop_95 * (0.01377 * seer + 1.13948)
max_capacity_82 = max_capacity_95 * get_cool_max_capacity_retention_82(hvac_ap)
max_capacity_82 = max_capacity_95 * get_cool_max_capacity_retention_82(hp_ap)
max_cop_82 = is_ducted ? (1.297 * max_cop_95) : (1.375 * max_cop_95)
min_capacity_82 = min_capacity_95 * 1.099
min_cop_82 = is_ducted ? (1.402 * min_cop_95) : (1.333 * min_cop_95)
Expand Down
44 changes: 11 additions & 33 deletions HPXMLtoOpenStudio/resources/hvac_sizing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1861,50 +1861,28 @@ def self.apply_hvac_fixed_capacities(hvac_sizing_values, hvac_heating, hvac_cool

# Override HVAC capacities if values are provided
if not hvac_cooling.nil?
if hvac_cooling.cooling_detailed_performance_data.empty?
fixed_cooling_capacity = hvac_cooling.cooling_capacity
else
fixed_cooling_capacity_max = hvac_cooling.cooling_detailed_performance_data.find { |dp| dp.outdoor_temperature == HVAC::AirSourceCoolRatedODB && dp.capacity_description == HPXML::CapacityDescriptionMaximum }.capacity
fixed_cooling_capacity = fixed_cooling_capacity_max / HVAC.get_cool_capacity_ratios(hvac_cooling, !hvac_cooling.distribution_system_idref.nil?)[-1]
end
fixed_cooling_capacity = hvac_cooling.cooling_capacity
end
if (not fixed_cooling_capacity.nil?) && (hvac_sizing_values.Cool_Capacity > 0)
# scaling factor = fixed / autosized
scaling_factor = fixed_cooling_capacity / hvac_sizing_values.Cool_Capacity
if (not @hpxml.header.allow_increased_fixed_capacities) || (@hpxml.header.allow_increased_fixed_capacities && scaling_factor > 1.0)
# fixed > autosized or not allow increase, use fixed capacity
# scale autosized capacity and airflow to be fixed
if not (@hpxml.header.allow_increased_fixed_capacities && hvac_sizing_values.Cool_Capacity > fixed_cooling_capacity)
# Use fixed size; proportionally adjust autosized airflow & sensible capacity
prev_capacity = hvac_sizing_values.Cool_Capacity
hvac_sizing_values.Cool_Capacity = fixed_cooling_capacity
hvac_sizing_values.Cool_Airflow *= scaling_factor
hvac_sizing_values.Cool_Capacity_Sens *= scaling_factor
# Use user provided nominal capacity for reporting when detailed performance data is provided
hvac_sizing_values.Cool_Capacity = hvac_cooling.cooling_capacity unless hvac_cooling.cooling_detailed_performance_data.empty?
else # allow increase fixed capacity and autosized > fixed
scale_detailed_performance_data_capacities(hvac_cooling.cooling_detailed_performance_data, 1 / scaling_factor) unless hvac_cooling.cooling_detailed_performance_data.empty? # scale detailed performance data up
hvac_sizing_values.Cool_Airflow *= hvac_sizing_values.Cool_Capacity / prev_capacity
hvac_sizing_values.Cool_Capacity_Sens *= hvac_sizing_values.Cool_Capacity / prev_capacity
end
end
if not hvac_heating.nil?
if hvac_heating.heating_detailed_performance_data.empty?
fixed_heating_capacity = hvac_heating.heating_capacity
else
fixed_heating_capacity_max = hvac_heating.heating_detailed_performance_data.find { |dp| dp.outdoor_temperature == HVAC::AirSourceHeatRatedODB && dp.capacity_description == HPXML::CapacityDescriptionMaximum }.capacity
fixed_heating_capacity = fixed_heating_capacity_max / HVAC.get_heat_capacity_ratios(hvac_heating, !hvac_heating.distribution_system_idref.nil?)[-1]
end
fixed_heating_capacity = hvac_heating.heating_capacity
elsif (not hvac_cooling.nil?) && hvac_cooling.has_integrated_heating
fixed_heating_capacity = hvac_cooling.integrated_heating_system_capacity
end
if (not fixed_heating_capacity.nil?) && (hvac_sizing_values.Heat_Capacity > 0)
# scaling factor = fixed / autosized
scaling_factor = fixed_heating_capacity / hvac_sizing_values.Heat_Capacity
if (not @hpxml.header.allow_increased_fixed_capacities) || (@hpxml.header.allow_increased_fixed_capacities && scaling_factor > 1.0)
# fixed > autosized or not allow increase, use fixed capacity
# scale autosized capacity and airflow to be fixed
if not (@hpxml.header.allow_increased_fixed_capacities && hvac_sizing_values.Heat_Capacity > fixed_heating_capacity)
# Use fixed size; proportionally adjust autosized airflow & sensible capacity
prev_capacity = hvac_sizing_values.Heat_Capacity
hvac_sizing_values.Heat_Capacity = fixed_heating_capacity
hvac_sizing_values.Heat_Airflow *= scaling_factor
# Use user provided nominal capacity for reporting when detailed performance data is provided
hvac_sizing_values.Heat_Capacity = hvac_heating.heating_capacity unless (hvac_heating.nil? || hvac_heating.heating_detailed_performance_data.empty?)
else # allow increase fixed capacity and autosized > fixed
scale_detailed_performance_data_capacities(hvac_heating.heating_detailed_performance_data, 1 / scaling_factor) unless (hvac_heating.nil? || hvac_heating.heating_detailed_performance_data.empty?) # scale detailed performance data up
hvac_sizing_values.Heat_Airflow *= hvac_sizing_values.Heat_Capacity / prev_capacity
end
end
if hvac_heating.is_a? HPXML::HeatPump
Expand Down

0 comments on commit b2b89b8

Please sign in to comment.