Skip to content

Commit

Permalink
Merge pull request #1158 from NREL/latest-os-hpxml
Browse files Browse the repository at this point in the history
Latest OS-HPXML
  • Loading branch information
joseph-robertson authored Nov 1, 2023
2 parents 3954b3e + d34abe0 commit 3916193
Show file tree
Hide file tree
Showing 169 changed files with 103,875 additions and 61,498 deletions.
318 changes: 176 additions & 142 deletions measures/ApplyUpgrade/measure.rb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions measures/ApplyUpgrade/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>apply_upgrade</name>
<uid>33f1654c-f734-43d1-b35d-9d2856e41b5a</uid>
<version_id>f3532e90-9cb3-44bb-adb9-51ac90998028</version_id>
<version_modified>2023-10-24T01:53:02Z</version_modified>
<version_id>8de2bf4d-f5d8-40fe-adb1-71dc7e9e72f9</version_id>
<version_modified>2023-11-01T17:36:01Z</version_modified>
<xml_checksum>9339BE01</xml_checksum>
<class_name>ApplyUpgrade</class_name>
<display_name>Apply Upgrade</display_name>
Expand Down Expand Up @@ -6330,7 +6330,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>03C861F4</checksum>
<checksum>3055E9F4</checksum>
</file>
<file>
<filename>constants.rb</filename>
Expand All @@ -6342,7 +6342,7 @@
<filename>apply_upgrade_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>B5242812</checksum>
<checksum>9D4AB576</checksum>
</file>
</files>
</measure>
52 changes: 28 additions & 24 deletions measures/ApplyUpgrade/tests/apply_upgrade_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,17 @@ def _test_retaining_capacities(args_hash, expected_capacities)
# Create instance of the measure
measure = ApplyUpgrade.new

# Check for correct capacity values
system_upgrades = measure.get_system_upgrades(hpxml, [], args_hash)
actual_capacities = measure.get_system_capacities(hpxml, system_upgrades)

expected_capacities.each do |str, val|
if val.nil?
assert_nil(actual_capacities[str])
else
assert_equal(val, actual_capacities[str])
hpxml.buildings.each do |hpxml_bldg|
# Check for correct capacity values
system_upgrades = measure.get_system_upgrades(hpxml_bldg, [], args_hash)
actual_capacities = measure.get_system_capacities(hpxml_bldg, system_upgrades)

expected_capacities.each do |str, val|
if val.nil?
assert_nil(actual_capacities[str])
else
assert_equal(val, actual_capacities[str])
end
end
end
end
Expand All @@ -318,24 +320,26 @@ def _test_heat_pump_backup(heat_pump_type, heat_pump_is_ducted, expected_values)
# Create instance of the measure
measure = ApplyUpgrade.new

heating_system = measure.get_heating_system(hpxml)
if heating_system.nil?
assert_nil(expected_values['heat_pump_backup_type'])
puts "\thpxml.heating_systems.size=#{hpxml.heating_systems.size}..."
return
end
hpxml.buildings.each do |hpxml_bldg|
heating_system = measure.get_heating_system(hpxml_bldg)
if heating_system.nil?
assert_nil(expected_values['heat_pump_backup_type'])
puts "\thpxml.heating_systems.size=#{hpxml_bldg.heating_systems.size}..."
return
end

puts "\theat_pump_type='#{heat_pump_type}', heat_pump_is_ducted='#{heat_pump_is_ducted}'..."
puts "\theat_pump_type='#{heat_pump_type}', heat_pump_is_ducted='#{heat_pump_is_ducted}'..."

heat_pump_backup_type = measure.get_heat_pump_backup_type(heating_system, heat_pump_type, heat_pump_is_ducted)
actual_values = measure.get_heat_pump_backup_values(heating_system)
actual_values['heat_pump_backup_type'] = heat_pump_backup_type
heat_pump_backup_type = measure.get_heat_pump_backup_type(heating_system, heat_pump_type, heat_pump_is_ducted)
actual_values = measure.get_heat_pump_backup_values(heating_system)
actual_values['heat_pump_backup_type'] = heat_pump_backup_type

expected_values.each do |str, val|
if val.nil?
assert_nil(actual_values[str])
else
assert_equal(val, actual_values[str])
expected_values.each do |str, val|
if val.nil?
assert_nil(actual_values[str])
else
assert_equal(val, actual_values[str])
end
end
end
end
Expand Down
15 changes: 9 additions & 6 deletions measures/BuildExistingModel/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,19 @@ def run(model, runner, user_arguments)
end

# Get the absolute paths relative to this meta measure in the run directory
new_runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new) # we want only ResStockArguments registered argument values
if not apply_measures(measures_dir, { 'ResStockArguments' => measures['ResStockArguments'] }, new_runner, model, true, 'OpenStudio::Measure::ModelMeasure', nil)
register_logs(runner, new_runner)
resstock_arguments_runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new) # we want only ResStockArguments registered argument values
if not apply_measures(measures_dir, { 'ResStockArguments' => measures['ResStockArguments'] }, resstock_arguments_runner, model, true, 'OpenStudio::Measure::ModelMeasure', nil)
register_logs(runner, resstock_arguments_runner)
return false
end

# Set BuildResidentialHPXML arguments
# Initialize measure keys with hpxml_path arguments
hpxml_path = File.expand_path('../existing.xml')

new_runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
measures['BuildResidentialHPXML'] = [{ 'hpxml_path' => hpxml_path }]

new_runner.result.stepValues.each do |step_value|
resstock_arguments_runner.result.stepValues.each do |step_value|
value = get_value_from_workflow_step_value(step_value)
next if value == ''

Expand Down Expand Up @@ -721,7 +723,8 @@ def run(model, runner, user_arguments)
return true
end

epw_path = Location.get_epw_path(hpxml, hpxml_path)
hpxml_bldg = hpxml.buildings[0]
epw_path = Location.get_epw_path(hpxml_bldg, hpxml_path)
epw_file = OpenStudio::EpwFile.new(epw_path)
register_value(runner, 'weather_file_city', epw_file.city)
register_value(runner, 'weather_file_latitude', epw_file.latitude)
Expand Down
6 changes: 3 additions & 3 deletions measures/BuildExistingModel/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>build_existing_model</name>
<uid>dedf59bb-3b88-4f16-8755-2c1ff5519cbf</uid>
<version_id>31417054-62f8-4a7b-b07c-ab138761774c</version_id>
<version_modified>2023-08-30T17:32:40Z</version_modified>
<version_id>e2f8f2af-f6ea-4f22-a3b9-c42d986f5d35</version_id>
<version_modified>2023-11-01T17:32:43Z</version_modified>
<xml_checksum>2C38F48B</xml_checksum>
<class_name>BuildExistingModel</class_name>
<display_name>Build Existing Model</display_name>
Expand Down Expand Up @@ -328,7 +328,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>C70FC7DE</checksum>
<checksum>6231E134</checksum>
</file>
</files>
</measure>
Loading

0 comments on commit 3916193

Please sign in to comment.