Skip to content

Commit

Permalink
Merge pull request #94 from NREL/fix/SetWindowToWallRatio-triangulati…
Browse files Browse the repository at this point in the history
…on-non-planar-surfaces

fix SetWindowToWallRatio triangulation
  • Loading branch information
DavidGoldwasser authored Mar 3, 2022
2 parents e304679 + 7ce6727 commit 76ab1d7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
11 changes: 11 additions & 0 deletions lib/measures/SetWindowToWallRatioByFacade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ This will only impact exterior surfaces with specified orientation



### Triangulation Minimum Area (m^2)
Triangulated surfaces less than this will not be created.
**Name:** triangulation_min_area,
**Type:** Double,
**Units:** ,
**Required:** true,
**Model Dependent:** false







15 changes: 14 additions & 1 deletion lib/measures/SetWindowToWallRatioByFacade/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ def arguments(model)
triangulate.setDefaultValue(true)
args << triangulate

# triangulation minimum area
triangulation_min_area = OpenStudio::Measure::OSArgument.makeDoubleArgument('triangulation_min_area', true)
triangulation_min_area.setDisplayName('Triangulation Minimum Area (m^2)')
triangulation_min_area.setDescription('Triangulated surfaces less than this will not be created.')
triangulation_min_area.setDefaultValue(0.001) # Two vertices < 0.01 meters apart are coincident in EnergyPlus (SurfaceGeometry.cc).
args << triangulation_min_area

return args
end

Expand All @@ -117,6 +124,7 @@ def run(model, runner, user_arguments)
split_at_doors = runner.getStringArgumentValue('split_at_doors', user_arguments)
inset_tri_sub = runner.getBoolArgumentValue('inset_tri_sub', user_arguments)
triangulate = runner.getBoolArgumentValue('triangulate', user_arguments)
triangulation_min_area = runner.getDoubleArgumentValue('triangulation_min_area', user_arguments)

# check reasonableness of fraction
if wwr == 0
Expand Down Expand Up @@ -384,8 +392,13 @@ def run(model, runner, user_arguments)
subSurface.remove
end

# triangulate surface
ss.triangulation.each do |tri|
new_surface = OpenStudio::Model::Surface.new(tri, model)
if new_surface.grossArea < triangulation_min_area
new_surface.remove
next
end
new_surface.setSpace(ss.space.get)
if ss.construction.is_initialized && !ss.isConstructionDefaulted
new_surface.setConstruction(ss.construction.get)
Expand All @@ -397,7 +410,7 @@ def run(model, runner, user_arguments)
end

# remove orig surface
ss.remove
ss.remove
end

else
Expand Down
37 changes: 23 additions & 14 deletions lib/measures/SetWindowToWallRatioByFacade/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.0</schema_version>
<name>set_window_to_wall_ratio_by_facade</name>
<uid>c567a0bf-a7d9-4a06-afe9-bf7df79e6bf8</uid>
<version_id>a02e024d-a1ca-413a-90e2-372cfc217228</version_id>
<version_modified>20210929T221458Z</version_modified>
<version_id>518c5be8-b109-4e18-b0fb-63e460ac82cc</version_id>
<version_modified>20220226T150940Z</version_modified>
<xml_checksum>6DE831F7</xml_checksum>
<class_name>SetWindowToWallRatioByFacade</class_name>
<display_name>Set Window to Wall Ratio by Facade</display_name>
Expand Down Expand Up @@ -153,6 +153,15 @@ The measure doesn?t have any cost or lifecycle arguments, however If lifecycle o
</choice>
</choices>
</argument>
<argument>
<name>triangulation_min_area</name>
<display_name>Triangulation Minimum Area (m^2)</display_name>
<description>Triangulated surfaces less than this will not be created.</description>
<type>Double</type>
<required>true</required>
<model_dependent>false</model_dependent>
<default_value>0.001</default_value>
</argument>
</arguments>
<outputs />
<provenances />
Expand Down Expand Up @@ -212,18 +221,18 @@ The measure doesn?t have any cost or lifecycle arguments, however If lifecycle o
<usage_type>readmeerb</usage_type>
<checksum>232D0477</checksum>
</file>
<file>
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>C85B9D94</checksum>
</file>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>A21A3ED2</checksum>
</file>
<file>
<filename>prototype_sec_sch.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>581DA01B</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
Expand All @@ -233,19 +242,19 @@ The measure doesn?t have any cost or lifecycle arguments, however If lifecycle o
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>6631CF18</checksum>
<checksum>A8258A30</checksum>
</file>
<file>
<filename>SetWindowToWallRatioByFacade_Test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>0F626DE3</checksum>
<checksum>E24E266E</checksum>
</file>
<file>
<filename>prototype_sec_sch.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>581DA01B</checksum>
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>7FCCDC8E</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ def test_SetWindowToWallRatioByFacade_fail

# get arguments and test that they are what we are expecting
arguments = measure.arguments(model)
assert_equal(7, arguments.size)
assert_equal(8, arguments.size)
assert_equal('wwr', arguments[0].name)
assert_equal('sillHeight', arguments[1].name)
assert_equal('facade', arguments[2].name)
assert_equal('exl_spaces_not_incl_fl_area', arguments[3].name)
assert_equal('split_at_doors', arguments[4].name)
assert_equal('inset_tri_sub', arguments[5].name)
assert_equal('triangulate', arguments[6].name)
assert_equal('triangulation_min_area', arguments[7].name)

# set argument values to bad values and run the measure
argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
Expand Down

0 comments on commit 76ab1d7

Please sign in to comment.