Skip to content

Commit

Permalink
Unrelated minor code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
shorowit committed Oct 25, 2024
1 parent ce9220d commit ac06a7c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 51 deletions.
12 changes: 6 additions & 6 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>64c3bdea-b4b3-4254-9b2a-23987ae4e9f3</version_id>
<version_modified>2024-10-25T00:51:54Z</version_modified>
<version_id>bbec5493-815c-45c1-932d-2c632bc5932e</version_id>
<version_modified>2024-10-25T17:44:35Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -627,7 +627,7 @@
<filename>waterheater.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>6F8A18EC</checksum>
<checksum>0C981353</checksum>
</file>
<file>
<filename>weather.rb</filename>
Expand All @@ -651,7 +651,7 @@
<filename>test_airflow.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>4366CDCD</checksum>
<checksum>A2FA7350</checksum>
</file>
<file>
<filename>test_battery.rb</filename>
Expand All @@ -669,7 +669,7 @@
<filename>test_enclosure.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>26D6E82F</checksum>
<checksum>91E1B449</checksum>
</file>
<file>
<filename>test_generator.rb</filename>
Expand Down Expand Up @@ -735,7 +735,7 @@
<filename>test_validation.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>20E56F9D</checksum>
<checksum>B290B947</checksum>
</file>
<file>
<filename>test_water_heater.rb</filename>
Expand Down
6 changes: 2 additions & 4 deletions HPXMLtoOpenStudio/resources/waterheater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions HPXMLtoOpenStudio/tests/test_airflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions HPXMLtoOpenStudio/tests/test_enclosure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions HPXMLtoOpenStudio/tests/test_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 7 additions & 25 deletions tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -701,30 +695,21 @@ 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,
ufactor: 0.33,
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,
Expand Down Expand Up @@ -1452,18 +1437,15 @@ 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,
azimuth: 180,
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
Expand Down

0 comments on commit ac06a7c

Please sign in to comment.