diff --git a/HPXMLtoOpenStudio/measure.xml b/HPXMLtoOpenStudio/measure.xml index b0b0e9790e..e7f90578eb 100644 --- a/HPXMLtoOpenStudio/measure.xml +++ b/HPXMLtoOpenStudio/measure.xml @@ -3,8 +3,8 @@ 3.1 hpxm_lto_openstudio b1543b30-9465-45ff-ba04-1d1f85e763bc - 64c3bdea-b4b3-4254-9b2a-23987ae4e9f3 - 2024-10-25T00:51:54Z + bbec5493-815c-45c1-932d-2c632bc5932e + 2024-10-25T17:44:35Z D8922A73 HPXMLtoOpenStudio HPXML to OpenStudio Translator @@ -627,7 +627,7 @@ waterheater.rb rb resource - 6F8A18EC + 0C981353 weather.rb @@ -651,7 +651,7 @@ test_airflow.rb rb test - 4366CDCD + A2FA7350 test_battery.rb @@ -669,7 +669,7 @@ test_enclosure.rb rb test - 26D6E82F + 91E1B449 test_generator.rb @@ -735,7 +735,7 @@ test_validation.rb rb test - 20E56F9D + B290B947 test_water_heater.rb diff --git a/HPXMLtoOpenStudio/resources/waterheater.rb b/HPXMLtoOpenStudio/resources/waterheater.rb index 003b113a8f..dacbd8fd9e 100644 --- a/HPXMLtoOpenStudio/resources/waterheater.rb +++ b/HPXMLtoOpenStudio/resources/waterheater.rb @@ -429,10 +429,8 @@ def self.get_dist_energy_waste_factor(hot_water_distribution) # @param plantloop_map [Hash] Map of HPXML System ID => OpenStudio PlantLoop objects # @return [nil] def self.apply_combi_system_EMS(model, water_heating_systems, plantloop_map) - water_heating_systems.select { |wh| - [HPXML::WaterHeaterTypeCombiStorage, - HPXML::WaterHeaterTypeCombiTankless].include? wh.water_heater_type - }.each do |water_heating_system| + combi_whs = water_heating_systems.select { |wh| [HPXML::WaterHeaterTypeCombiStorage, HPXML::WaterHeaterTypeCombiTankless].include? wh.water_heater_type } + combi_whs.each do |water_heating_system| combi_sys_id = water_heating_system.id # EMS for modulate source side mass flow rate diff --git a/HPXMLtoOpenStudio/tests/test_airflow.rb b/HPXMLtoOpenStudio/tests/test_airflow.rb index fa253f005b..f5ff1452af 100644 --- a/HPXMLtoOpenStudio/tests/test_airflow.rb +++ b/HPXMLtoOpenStudio/tests/test_airflow.rb @@ -622,8 +622,8 @@ def test_ducts_leakage_percent model, _hpxml, hpxml_bldg = _test_measure(args_hash) # Get HPXML values - supply_leakage = hpxml_bldg.hvac_distributions[0].duct_leakage_measurements.select { |m| m.duct_type == HPXML::DuctTypeSupply }[0] - return_leakage = hpxml_bldg.hvac_distributions[0].duct_leakage_measurements.select { |m| m.duct_type == HPXML::DuctTypeReturn }[0] + supply_leakage = hpxml_bldg.hvac_distributions[0].duct_leakage_measurements.find { |m| m.duct_type == HPXML::DuctTypeSupply } + return_leakage = hpxml_bldg.hvac_distributions[0].duct_leakage_measurements.find { |m| m.duct_type == HPXML::DuctTypeReturn } supply_leakage_frac = supply_leakage.duct_leakage_value return_leakage_frac = return_leakage.duct_leakage_value @@ -712,25 +712,25 @@ def test_infiltration_compartmentalization_area def test_infiltration_assumed_height # Base _hpxml, hpxml_bldg = _create_hpxml('base.xml') - infil_volume = hpxml_bldg.air_infiltration_measurements.select { |m| !m.infiltration_volume.nil? }[0].infiltration_volume + infil_volume = hpxml_bldg.air_infiltration_measurements.find { |m| !m.infiltration_volume.nil? }.infiltration_volume infil_height = hpxml_bldg.inferred_infiltration_height(infil_volume) assert_equal(9.75, infil_height) # Test w/o conditioned basement _hpxml, hpxml_bldg = _create_hpxml('base-foundation-unconditioned-basement.xml') - infil_volume = hpxml_bldg.air_infiltration_measurements.select { |m| !m.infiltration_volume.nil? }[0].infiltration_volume + infil_volume = hpxml_bldg.air_infiltration_measurements.find { |m| !m.infiltration_volume.nil? }.infiltration_volume infil_height = hpxml_bldg.inferred_infiltration_height(infil_volume) assert_equal(8, infil_height) # Test w/ walkout basement _hpxml, hpxml_bldg = _create_hpxml('base-foundation-walkout-basement.xml') - infil_volume = hpxml_bldg.air_infiltration_measurements.select { |m| !m.infiltration_volume.nil? }[0].infiltration_volume + infil_volume = hpxml_bldg.air_infiltration_measurements.find { |m| !m.infiltration_volume.nil? }.infiltration_volume infil_height = hpxml_bldg.inferred_infiltration_height(infil_volume) assert_equal(16, infil_height) # Test 2 story building _hpxml, hpxml_bldg = _create_hpxml('base-enclosure-2stories.xml') - infil_volume = hpxml_bldg.air_infiltration_measurements.select { |m| !m.infiltration_volume.nil? }[0].infiltration_volume + infil_volume = hpxml_bldg.air_infiltration_measurements.find { |m| !m.infiltration_volume.nil? }.infiltration_volume infil_height = hpxml_bldg.inferred_infiltration_height(infil_volume) assert_equal(17.75, infil_height) diff --git a/HPXMLtoOpenStudio/tests/test_enclosure.rb b/HPXMLtoOpenStudio/tests/test_enclosure.rb index 2182e253ed..9cc3c5da28 100644 --- a/HPXMLtoOpenStudio/tests/test_enclosure.rb +++ b/HPXMLtoOpenStudio/tests/test_enclosure.rb @@ -619,7 +619,7 @@ def test_windows sf_winter *= window.exterior_shading_factor_winter unless window.exterior_shading_factor_winter.nil? # Check shading transmittance for sky beam and sky diffuse - os_subsurface = model.getSubSurfaces.select { |ss| ss.name.to_s.start_with? window.id }[0] + os_subsurface = model.getSubSurfaces.find { |ss| ss.name.to_s.start_with? window.id } os_ism = nil model.getSurfacePropertyIncidentSolarMultipliers.each do |ism| next unless os_subsurface == ism.subSurface @@ -683,7 +683,7 @@ def test_skylights sf_winter *= skylight.exterior_shading_factor_winter unless skylight.exterior_shading_factor_winter.nil? # Check shading transmittance for sky beam and sky diffuse - os_subsurface = model.getSubSurfaces.select { |ss| ss.name.to_s.start_with? skylight.id }[0] + os_subsurface = model.getSubSurfaces.find { |ss| ss.name.to_s.start_with? skylight.id } os_ism = nil model.getSurfacePropertyIncidentSolarMultipliers.each do |ism| next unless os_subsurface == ism.subSurface diff --git a/HPXMLtoOpenStudio/tests/test_validation.rb b/HPXMLtoOpenStudio/tests/test_validation.rb index d91daf8e30..fad8254852 100644 --- a/HPXMLtoOpenStudio/tests/test_validation.rb +++ b/HPXMLtoOpenStudio/tests/test_validation.rb @@ -344,18 +344,12 @@ def test_schema_schematron_error_messages hpxml_bldg.building_construction.conditioned_floor_area = 898.8 elsif ['enclosure-garage-missing-exterior-wall'].include? error_case hpxml, hpxml_bldg = _create_hpxml('base-enclosure-garage.xml') - hpxml_bldg.walls.select { |w| - w.interior_adjacent_to == HPXML::LocationGarage && - w.exterior_adjacent_to == HPXML::LocationOutside - }.reverse_each do |wall| + hpxml_bldg.walls.select { |w| w.interior_adjacent_to == HPXML::LocationGarage && w.exterior_adjacent_to == HPXML::LocationOutside }.reverse_each do |wall| wall.delete end elsif ['enclosure-garage-missing-roof-ceiling'].include? error_case hpxml, hpxml_bldg = _create_hpxml('base-enclosure-garage.xml') - hpxml_bldg.floors.select { |w| - w.interior_adjacent_to == HPXML::LocationGarage && - w.exterior_adjacent_to == HPXML::LocationAtticUnvented - }.reverse_each do |floor| + hpxml_bldg.floors.select { |w| w.interior_adjacent_to == HPXML::LocationGarage && w.exterior_adjacent_to == HPXML::LocationAtticUnvented }.reverse_each do |floor| floor.delete end elsif ['enclosure-garage-missing-slab'].include? error_case diff --git a/tasks.rb b/tasks.rb index 370f737f76..db92de7d78 100644 --- a/tasks.rb +++ b/tasks.rb @@ -606,10 +606,7 @@ def apply_hpxml_modification_sample_files(hpxml_path, hpxml) elsif hpxml_file == 'base-bldgtype-mf-unit-adjacent-to-other-housing-unit.xml' adjacent_to = HPXML::LocationOtherHousingUnit end - wall = hpxml_bldg.walls.select { |w| - w.interior_adjacent_to == HPXML::LocationConditionedSpace && - w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit - }[0] + wall = hpxml_bldg.walls.find { |w| w.interior_adjacent_to == HPXML::LocationConditionedSpace && w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit } wall.exterior_adjacent_to = adjacent_to hpxml_bldg.floors[0].exterior_adjacent_to = adjacent_to hpxml_bldg.floors[1].exterior_adjacent_to = adjacent_to @@ -636,10 +633,7 @@ def apply_hpxml_modification_sample_files(hpxml_path, hpxml) hpxml_bldg.cooking_ranges[0].location = adjacent_to elsif ['base-bldgtype-mf-unit-adjacent-to-multiple.xml', 'base-bldgtype-mf-unit-adjacent-to-multiple-hvac-none.xml'].include? hpxml_file - wall = hpxml_bldg.walls.select { |w| - w.interior_adjacent_to == HPXML::LocationConditionedSpace && - w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit - }[0] + wall = hpxml_bldg.walls.find { |w| w.interior_adjacent_to == HPXML::LocationConditionedSpace && w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit } wall.delete hpxml_bldg.walls.add(id: "Wall#{hpxml_bldg.walls.size + 1}", exterior_adjacent_to: HPXML::LocationOtherHeatedSpace, @@ -701,10 +695,7 @@ def apply_hpxml_modification_sample_files(hpxml_path, hpxml) area: 150, insulation_assembly_r_value: 2.1, floor_or_ceiling: HPXML::FloorOrCeilingFloor) - wall = hpxml_bldg.walls.select { |w| - w.interior_adjacent_to == HPXML::LocationConditionedSpace && - w.exterior_adjacent_to == HPXML::LocationOtherMultifamilyBufferSpace - }[0] + wall = hpxml_bldg.walls.find { |w| w.interior_adjacent_to == HPXML::LocationConditionedSpace && w.exterior_adjacent_to == HPXML::LocationOtherMultifamilyBufferSpace } hpxml_bldg.windows.add(id: "Window#{hpxml_bldg.windows.size + 1}", area: 50, azimuth: 270, @@ -712,19 +703,13 @@ def apply_hpxml_modification_sample_files(hpxml_path, hpxml) shgc: 0.45, fraction_operable: 0.67, attached_to_wall_idref: wall.id) - wall = hpxml_bldg.walls.select { |w| - w.interior_adjacent_to == HPXML::LocationConditionedSpace && - w.exterior_adjacent_to == HPXML::LocationOtherHeatedSpace - }[0] + wall = hpxml_bldg.walls.find { |w| w.interior_adjacent_to == HPXML::LocationConditionedSpace && w.exterior_adjacent_to == HPXML::LocationOtherHeatedSpace } hpxml_bldg.doors.add(id: "Door#{hpxml_bldg.doors.size + 1}", attached_to_wall_idref: wall.id, area: 20, azimuth: 0, r_value: 4.4) - wall = hpxml_bldg.walls.select { |w| - w.interior_adjacent_to == HPXML::LocationConditionedSpace && - w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit - }[0] + wall = hpxml_bldg.walls.find { |w| w.interior_adjacent_to == HPXML::LocationConditionedSpace && w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit } hpxml_bldg.doors.add(id: "Door#{hpxml_bldg.doors.size + 1}", attached_to_wall_idref: wall.id, area: 20, @@ -1452,10 +1437,7 @@ def apply_hpxml_modification_sample_files(hpxml_path, hpxml) 'base-enclosure-garage.xml', 'base-zones-spaces.xml', 'base-zones-spaces-multiple.xml'].include? hpxml_file - grg_wall = hpxml_bldg.walls.select { |w| - w.interior_adjacent_to == HPXML::LocationGarage && - w.exterior_adjacent_to == HPXML::LocationOutside - }[0] + grg_wall = hpxml_bldg.walls.find { |w| w.interior_adjacent_to == HPXML::LocationGarage && w.exterior_adjacent_to == HPXML::LocationOutside } hpxml_bldg.doors.add(id: "Door#{hpxml_bldg.doors.size + 1}", attached_to_wall_idref: grg_wall.id, area: 70, @@ -1463,7 +1445,7 @@ def apply_hpxml_modification_sample_files(hpxml_path, hpxml) r_value: 4.4) end if ['base-misc-neighbor-shading-bldgtype-multifamily.xml'].include? hpxml_file - wall = hpxml_bldg.walls.select { |w| w.azimuth == hpxml_bldg.neighbor_buildings[0].azimuth }[0] + wall = hpxml_bldg.walls.find { |w| w.azimuth == hpxml_bldg.neighbor_buildings[0].azimuth } wall.exterior_adjacent_to = HPXML::LocationOtherHeatedSpace end if ['base-foundation-vented-crawlspace-above-grade2.xml'].include? hpxml_file