Skip to content

HPXML class: Allow multiple program versions #1919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions HPXMLtoOpenStudio/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,15 @@ def init(model, hpxml_bldg, hpxml_header)
hpxml_bldg.delete_adiabatic_subsurfaces() # EnergyPlus doesn't allow this

# Hidden feature: Version of the ANSI/RESNET/ICC 301 Standard to use for equations/assumptions
if hpxml_header.eri_calculation_version.nil?
hpxml_header.eri_calculation_version = 'latest'
if hpxml_header.eri_calculation_versions.size > 1
fail 'Only a single ERI version is supported.'
end
if hpxml_header.eri_calculation_version == 'latest'
hpxml_header.eri_calculation_version = Constants::ERIVersions[-1]

if hpxml_header.eri_calculation_versions.empty?
hpxml_header.eri_calculation_versions = ['latest']
end
if hpxml_header.eri_calculation_versions == ['latest']
hpxml_header.eri_calculation_versions = [Constants::ERIVersions[-1]]
end

# Hidden feature: Whether to override certain assumptions to better match the ASHRAE 140 specification
Expand Down
20 changes: 10 additions & 10 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>ddf8813a-f35c-400b-890b-d26121d86506</version_id>
<version_modified>2025-01-17T00:21:50Z</version_modified>
<version_id>bd5c3b3f-ccda-4dd5-b16a-1b4f7a4d69e4</version_id>
<version_modified>2025-02-03T19:22:20Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -183,13 +183,13 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>28965567</checksum>
<checksum>1EEA4B7B</checksum>
</file>
<file>
<filename>airflow.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>29D991BE</checksum>
<checksum>23B7B4AC</checksum>
</file>
<file>
<filename>battery.rb</filename>
Expand Down Expand Up @@ -327,7 +327,7 @@
<filename>defaults.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>EB4D5A1A</checksum>
<checksum>CF7C5504</checksum>
</file>
<file>
<filename>energyplus.rb</filename>
Expand All @@ -351,13 +351,13 @@
<filename>hotwater_appliances.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>0B205523</checksum>
<checksum>FA4DA1B3</checksum>
</file>
<file>
<filename>hpxml.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>270F2EEB</checksum>
<checksum>89899516</checksum>
</file>
<file>
<filename>hpxml_schema/HPXML.xsd</filename>
Expand Down Expand Up @@ -405,7 +405,7 @@
<filename>lighting.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>7B7F6D4C</checksum>
<checksum>74899E6B</checksum>
</file>
<file>
<filename>location.rb</filename>
Expand Down Expand Up @@ -633,7 +633,7 @@
<filename>waterheater.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>ECEBF85F</checksum>
<checksum>A8560A5A</checksum>
</file>
<file>
<filename>weather.rb</filename>
Expand Down Expand Up @@ -669,7 +669,7 @@
<filename>test_defaults.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>7E9FC2FA</checksum>
<checksum>45AEFA27</checksum>
</file>
<file>
<filename>test_enclosure.rb</filename>
Expand Down
8 changes: 4 additions & 4 deletions HPXMLtoOpenStudio/resources/airflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ def self.apply_natural_ventilation_and_whole_house_fan(runner, model, spaces, hp
vent_program.addLine("Set Tnvsp = (#{htg_sp_sensor.name} + #{clg_sp_sensor.name}) / 2")
else
# No HVAC system; use the average of defaulted heating/cooling setpoints.
htg_weekday_setpoints, htg_weekend_setpoints = Defaults.get_heating_setpoint(HPXML::HVACControlTypeManual, hpxml_header.eri_calculation_version)
clg_weekday_setpoints, clg_weekend_setpoints = Defaults.get_cooling_setpoint(HPXML::HVACControlTypeManual, hpxml_header.eri_calculation_version)
htg_weekday_setpoints, htg_weekend_setpoints = Defaults.get_heating_setpoint(HPXML::HVACControlTypeManual, hpxml_header.eri_calculation_versions[0])
clg_weekday_setpoints, clg_weekend_setpoints = Defaults.get_cooling_setpoint(HPXML::HVACControlTypeManual, hpxml_header.eri_calculation_versions[0])
if htg_weekday_setpoints.split(', ').uniq.size == 1 && htg_weekend_setpoints.split(', ').uniq.size == 1 && htg_weekday_setpoints.split(', ').uniq == htg_weekend_setpoints.split(', ').uniq
default_htg_sp = UnitConversions.convert(htg_weekend_setpoints.split(', ').uniq[0].to_f, 'F', 'C')
else
Expand Down Expand Up @@ -2391,14 +2391,14 @@ def self.apply_infiltration_adjustment_to_conditioned(runner, model, spaces, hpx
infil_program.addLine('Set Qfan_with_ducts = (@Max Qexhaust Qsupply)')

# Total combined air exchange
if Constants::ERIVersions.index(hpxml_header.eri_calculation_version) >= Constants::ERIVersions.index('2022')
if Constants::ERIVersions.index(hpxml_header.eri_calculation_versions[0]) >= Constants::ERIVersions.index('2022')
infil_program.addLine('Set Qimb = (@Abs (Qsupply - Qexhaust))')
infil_program.addLine('If Qinf + Qimb > 0')
infil_program.addLine(' Set Qtot = Qfan_with_ducts + (Qinf^2) / (Qinf + Qimb)')
infil_program.addLine('Else')
infil_program.addLine(' Set Qtot = Qfan_with_ducts')
infil_program.addLine('EndIf')
elsif Constants::ERIVersions.index(hpxml_header.eri_calculation_version) >= Constants::ERIVersions.index('2019')
elsif Constants::ERIVersions.index(hpxml_header.eri_calculation_versions[0]) >= Constants::ERIVersions.index('2019')
# Follow ASHRAE 62.2-2016, Normative Appendix C equations for time-varying total airflow
infil_program.addLine('If Qfan_with_ducts > 0')
# Balanced system if the total supply airflow and total exhaust airflow are within 10% of their average.
Expand Down
5 changes: 3 additions & 2 deletions HPXMLtoOpenStudio/resources/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ module Defaults
# @param convert_shared_systems [Boolean] Whether to convert shared systems to equivalent in-unit systems per ANSI/RESNET/ICC 301
# @return [Array<Hash, Hash>] Maps of HPXML::Zones => DesignLoadValues object, HPXML::Spaces => DesignLoadValues object
def self.apply(runner, hpxml, hpxml_bldg, weather, schedules_file: nil, convert_shared_systems: true)
eri_version = hpxml.header.eri_calculation_version
if eri_version.nil?
if hpxml.header.eri_calculation_versions.nil? || hpxml.header.eri_calculation_versions.empty?
eri_version = 'latest'
else
eri_version = hpxml.header.eri_calculation_versions[0]
end
if eri_version == 'latest'
eri_version = Constants::ERIVersions[-1]
Expand Down
2 changes: 1 addition & 1 deletion HPXMLtoOpenStudio/resources/hotwater_appliances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.apply(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedul
nbeds = hpxml_bldg.building_construction.number_of_bedrooms
n_occ = hpxml_bldg.building_occupancy.number_of_residents
unit_type = hpxml_bldg.building_construction.residential_facility_type
eri_version = hpxml_header.eri_calculation_version
eri_version = hpxml_header.eri_calculation_versions[0]
unit_multiplier = hpxml_bldg.building_construction.number_of_units

# Get appliances, etc.
Expand Down
43 changes: 23 additions & 20 deletions HPXMLtoOpenStudio/resources/hpxml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,11 @@ def initialize(hpxml_element, *args, **kwargs)
:software_program_version, # [String] SoftwareInfo/SoftwareProgramVersion
:apply_ashrae140_assumptions, # [Boolean] SoftwareInfo/extension/ApplyASHRAE140Assumptions
:whole_sfa_or_mf_building_sim, # [Boolean] SoftwareInfo/extension/WholeSFAorMFBuildingSimulation
:eri_calculation_version, # [String] SoftwareInfo/extension/ERICalculation/Version
:co2index_calculation_version, # [String] SoftwareInfo/extension/CO2IndexCalculation/Version
:energystar_calculation_version, # [String] SoftwareInfo/extension/EnergyStarCalculation/Version
:iecc_eri_calculation_version, # [String] SoftwareInfo/extension/IECCERICalculation/Version
:zerh_calculation_version, # [String] SoftwareInfo/extension/ZERHCalculation/Version
:eri_calculation_versions, # [Array<String>] SoftwareInfo/extension/ERICalculation/Version
:co2index_calculation_versions, # [Array<String>] SoftwareInfo/extension/CO2IndexCalculation/Version
:energystar_calculation_versions, # [Array<String>] SoftwareInfo/extension/EnergyStarCalculation/Version
:iecc_eri_calculation_versions, # [Array<String>] SoftwareInfo/extension/IECCERICalculation/Version
:zerh_calculation_versions, # [Array<String>] SoftwareInfo/extension/ZERHCalculation/Version
:timestep, # [Integer] SoftwareInfo/extension/SimulationControl/Timestep (minutes)
:sim_begin_month, # [Integer] SoftwareInfo/extension/SimulationControl/BeginMonth
:sim_begin_day, # [Integer] SoftwareInfo/extension/SimulationControl/BeginDayOfMonth
Expand Down Expand Up @@ -929,16 +929,19 @@ def to_doc(hpxml_doc)
XMLHelper.add_element(software_info, 'SoftwareProgramVersion', @software_program_version, :string) unless @software_program_version.nil?
XMLHelper.add_extension(software_info, 'ApplyASHRAE140Assumptions', @apply_ashrae140_assumptions, :boolean) unless @apply_ashrae140_assumptions.nil?
XMLHelper.add_extension(software_info, 'WholeSFAorMFBuildingSimulation', @whole_sfa_or_mf_building_sim, :boolean) unless @whole_sfa_or_mf_building_sim.nil?
{ 'ERICalculation' => @eri_calculation_version,
'CO2IndexCalculation' => @co2index_calculation_version,
'EnergyStarCalculation' => @energystar_calculation_version,
'IECCERICalculation' => @iecc_eri_calculation_version,
'ZERHCalculation' => @zerh_calculation_version }.each do |element_name, calculation_version|
next if calculation_version.nil?

extension = XMLHelper.create_elements_as_needed(software_info, ['extension'])
calculation = XMLHelper.add_element(extension, element_name)
XMLHelper.add_element(calculation, 'Version', calculation_version, :string)
{ 'ERICalculation' => @eri_calculation_versions,
'CO2IndexCalculation' => @co2index_calculation_versions,
'EnergyStarCalculation' => @energystar_calculation_versions,
'IECCERICalculation' => @iecc_eri_calculation_versions,
'ZERHCalculation' => @zerh_calculation_versions }.each do |element_name, calculation_versions|
calculation_versions = [] if calculation_versions.nil?
if not calculation_versions.empty?
extension = XMLHelper.create_elements_as_needed(software_info, ['extension'])
calculation = XMLHelper.add_element(extension, element_name)
end
calculation_versions.each do |calculation_version|
XMLHelper.add_element(calculation, 'Version', calculation_version, :string)
end
end
if (not @timestep.nil?) || (not @sim_begin_month.nil?) || (not @sim_begin_day.nil?) || (not @sim_end_month.nil?) || (not @sim_end_day.nil?) || (not @temperature_capacitance_multiplier.nil?) || (not @defrost_model_type.nil?) || (not @hvac_onoff_thermostat_deadband.nil?) || (not @heat_pump_backup_heating_capacity_increment.nil?)
extension = XMLHelper.create_elements_as_needed(software_info, ['extension'])
Expand Down Expand Up @@ -975,11 +978,11 @@ def from_doc(hpxml)
@transaction = XMLHelper.get_value(hpxml, 'XMLTransactionHeaderInformation/Transaction', :string)
@software_program_used = XMLHelper.get_value(hpxml, 'SoftwareInfo/SoftwareProgramUsed', :string)
@software_program_version = XMLHelper.get_value(hpxml, 'SoftwareInfo/SoftwareProgramVersion', :string)
@eri_calculation_version = XMLHelper.get_value(hpxml, 'SoftwareInfo/extension/ERICalculation/Version', :string)
@co2index_calculation_version = XMLHelper.get_value(hpxml, 'SoftwareInfo/extension/CO2IndexCalculation/Version', :string)
@iecc_eri_calculation_version = XMLHelper.get_value(hpxml, 'SoftwareInfo/extension/IECCERICalculation/Version', :string)
@energystar_calculation_version = XMLHelper.get_value(hpxml, 'SoftwareInfo/extension/EnergyStarCalculation/Version', :string)
@zerh_calculation_version = XMLHelper.get_value(hpxml, 'SoftwareInfo/extension/ZERHCalculation/Version', :string)
@eri_calculation_versions = XMLHelper.get_values(hpxml, 'SoftwareInfo/extension/ERICalculation/Version', :string)
@co2index_calculation_versions = XMLHelper.get_values(hpxml, 'SoftwareInfo/extension/CO2IndexCalculation/Version', :string)
@iecc_eri_calculation_versions = XMLHelper.get_values(hpxml, 'SoftwareInfo/extension/IECCERICalculation/Version', :string)
@energystar_calculation_versions = XMLHelper.get_values(hpxml, 'SoftwareInfo/extension/EnergyStarCalculation/Version', :string)
@zerh_calculation_versions = XMLHelper.get_values(hpxml, 'SoftwareInfo/extension/ZERHCalculation/Version', :string)
@timestep = XMLHelper.get_value(hpxml, 'SoftwareInfo/extension/SimulationControl/Timestep', :integer)
@sim_begin_month = XMLHelper.get_value(hpxml, 'SoftwareInfo/extension/SimulationControl/BeginMonth', :integer)
@sim_begin_day = XMLHelper.get_value(hpxml, 'SoftwareInfo/extension/SimulationControl/BeginDayOfMonth', :integer)
Expand Down
2 changes: 1 addition & 1 deletion HPXMLtoOpenStudio/resources/lighting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.apply(runner, model, spaces, hpxml_bldg, hpxml_header, schedules_file)
lighting = hpxml_bldg.lighting
unit_multiplier = hpxml_bldg.building_construction.number_of_units
cfa = hpxml_bldg.building_construction.conditioned_floor_area
eri_version = hpxml_header.eri_calculation_version
eri_version = hpxml_header.eri_calculation_versions[0]
n_occ = hpxml_bldg.building_occupancy.number_of_residents

ltg_locns = [HPXML::LocationInterior, HPXML::LocationExterior, HPXML::LocationGarage]
Expand Down
8 changes: 4 additions & 4 deletions HPXMLtoOpenStudio/resources/waterheater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def self.apply_tank(runner, model, spaces, hpxml_bldg, hpxml_header, water_heati
unit_multiplier = hpxml_bldg.building_construction.number_of_units
solar_fraction = get_water_heater_solar_fraction(water_heating_system, hpxml_bldg)
t_set_c = get_t_set_c(water_heating_system.temperature, water_heating_system.water_heater_type)
plant_loop = add_plant_loop(model, t_set_c, hpxml_header.eri_calculation_version, unit_multiplier)
plant_loop = add_plant_loop(model, t_set_c, hpxml_header.eri_calculation_versions[0], unit_multiplier)

act_vol = calc_storage_tank_actual_vol(water_heating_system.tank_volume, water_heating_system.fuel_type)
u, ua, eta_c = disaggregate_tank_losses_and_burner_efficiency(act_vol, water_heating_system, solar_fraction, hpxml_bldg.building_construction.number_of_bedrooms)
Expand Down Expand Up @@ -99,7 +99,7 @@ def self.apply_tankless(runner, model, spaces, hpxml_bldg, hpxml_header, water_h
water_heating_system.heating_capacity = 100000000000.0 * unit_multiplier
solar_fraction = get_water_heater_solar_fraction(water_heating_system, hpxml_bldg)
t_set_c = get_t_set_c(water_heating_system.temperature, water_heating_system.water_heater_type)
plant_loop = add_plant_loop(model, t_set_c, hpxml_header.eri_calculation_version, unit_multiplier)
plant_loop = add_plant_loop(model, t_set_c, hpxml_header.eri_calculation_versions[0], unit_multiplier)

act_vol = 1.0 * unit_multiplier
_u, ua, eta_c = disaggregate_tank_losses_and_burner_efficiency(act_vol, water_heating_system, solar_fraction, hpxml_bldg.building_construction.number_of_bedrooms)
Expand Down Expand Up @@ -142,7 +142,7 @@ def self.apply_hpwh(runner, model, spaces, hpxml_bldg, hpxml_header, water_heati
obj_name = Constants::ObjectTypeWaterHeater
solar_fraction = get_water_heater_solar_fraction(water_heating_system, hpxml_bldg)
t_set_c = get_t_set_c(water_heating_system.temperature, water_heating_system.water_heater_type)
plant_loop = add_plant_loop(model, t_set_c, hpxml_header.eri_calculation_version, unit_multiplier)
plant_loop = add_plant_loop(model, t_set_c, hpxml_header.eri_calculation_versions[0], unit_multiplier)

# Add in schedules for Tamb, RHamb, and the compressor
hpwh_tamb = Model.add_schedule_constant(
Expand Down Expand Up @@ -283,7 +283,7 @@ def self.apply_combi(runner, model, spaces, hpxml_bldg, hpxml_header, water_heat
end

t_set_c = get_t_set_c(water_heating_system.temperature, water_heating_system.water_heater_type)
plant_loop = add_plant_loop(model, t_set_c, hpxml_header.eri_calculation_version, unit_multiplier)
plant_loop = add_plant_loop(model, t_set_c, hpxml_header.eri_calculation_versions[0], unit_multiplier)

# Create water heater
water_heater = apply_water_heater(runner, model,
Expand Down
Loading