-
Notifications
You must be signed in to change notification settings - Fork 0
Adds geometry-related functions & tests #3
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
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
a3e8b7c
Adds geometry-related functions & tests
brgix aad82a5
Implements basic 3DVector functions (untested)
brgix c77bcf1
Fixes is_same ('0' as valid list index)
brgix e842406
Implements width/height functions, tests triangulation
brgix 0ba39ac
Adds (yet untested) line segment functions
brgix 8d82211
Rehauls vestibule, plenum conditional checks (tested)
brgix d4e0bd0
Reinstates previous tests
brgix 394a4e5
Completes (tested) ULC & BLC
brgix 8266f63
Fixes & tests collinearity methods
brgix aae7307
Fixes & tests point-line intersection methods
brgix 5ba1ace
Adds a handful of boolean functions
brgix 9f41e35
First try at 'overlaps' - buggy for now
brgix 838fb59
Fixes overlap method - initial tests only
brgix 34ad038
Minor cleanup - post overlap fix
brgix 1f8df35
Partial refactor of 'overlap' (tested)
brgix 8ea89c7
Adds (yet untested) 'offset' & 'outline' methods
brgix 82028fb
Initial tests of 'bounded boxes' methods
brgix d36561c
Tweaks 'overlap' (more testing needed)
brgix 623ebbb
Completes 'fits' & 'overlap' method testing
brgix 33600d1
Completes segments, triads and orientation tests
brgix 9d44c8a
Initial implementation of 'realignedFace' (untested)
brgix 9a4c20e
Completes 'poly' attributes testing
brgix c88bea5
Completes model transformation tests
brgix 2f8ab94
Adds (getter) 'roofs' (tested)
brgix d49f52a
Adds 'isDaylit' (untested)
brgix 8f27186
Minor cleanup
brgix 89ba373
Partial implementation of convexity tests
brgix 635adfd
Implements 'addSubs' (initial testing, more to come ...)
brgix 4fba8e3
Merge branch 'geo' of https://github.com/rd2/pyOSut into geo
brgix 1e4a90a
Updates pyproject.toml
brgix a0bf359
Adds numpy (dependency) in GH Actions pull_request.yml
brgix f838db4
Further testing of 'addSubs' (control case)
brgix 4f57555
Completes 1st round of 'addSubs' testing
brgix b331905
Completes aligned width/height tests
brgix 3f8ec9a
Completes 'WWR insertion' tests
brgix 765d328
Completes 'genShade' fixes/tests
brgix fd3c2d4
Adds 'grossRoofArea' and 'getHorizontalRidges' (untested)
brgix e57e6b6
Adds 'toToplit' - yet untested
brgix 45e1cbd
Adds 'genAnchors' - untested
brgix 7108439
Adds 'genextendedvertices' - untested
brgix 11397bb
Sets up 'addSkylights', fixes 'overlap'
brgix ef390a8
First draft of 'addSkylights': inoperable/inactive for now ...
brgix bfc9440
Purges 'set' variables (conflict with built-in)
brgix fb86a4b
First 'addSkylights' test 'green' (more to come)
brgix 0d99847
Fixes (inter alia) ceiling leader lines (skylights)
brgix 52dc079
Fixes roof leader line issues
brgix a6bca1b
Completes 'SmallOffice' skylight unittests
brgix 60f9f6f
Completes 'SEB' addSkylights unittest
brgix 62ec271
Completes 'Warehouse' addSkylights unittest
brgix 3a1e4f7
Pre-merge cleanup (e.g. resequencing functions)
brgix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ def test01_osm_instantiation(self): | |
| model = openstudio.model.Model() | ||
| self.assertTrue(isinstance(model, openstudio.model.Model)) | ||
| del model | ||
|
|
||
| def test02_tuples(self): | ||
| self.assertEqual(len(osut.sidz()), 6) | ||
| self.assertEqual(len(osut.mass()), 4) | ||
|
|
@@ -5010,6 +5010,180 @@ def test34_generated_skylight_wells(self): | |
|
|
||
| model.save("./tests/files/osms/out/office_attic.osm", True) | ||
|
|
||
| # --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # | ||
| # Side test/comment: Why is it necessary to have 'addSkylights' return | ||
| # gross roof area (see 'rm2' above)? | ||
| # | ||
| # First, retrieving (newly-added) core roofs (i.e. skylight base | ||
| # surfaces). | ||
| rfs1 = osut.facets(core, "Outdoors", "RoofCeiling") | ||
| tot1 = sum([sk.grossArea() for sk in rfs1]) | ||
| net = sum([sk.netArea() for sk in rfs1]) | ||
| self.assertEqual(len(rfs1), 4) | ||
| self.assertAlmostEqual(tot1, 9.06, places=2) # 4x 2.265 m2 | ||
| self.assertAlmostEqual(tot1 - net, sky_area1, places=2) | ||
|
|
||
| # In absence of skylight wells (more importantly, in absence of leader | ||
| # lines anchoring skylight base surfaces), OSut's 'roofs' & | ||
| # 'grossRoofArea' report not only on newly-added base surfaces (or | ||
| # their areas), but also overalpping areas of attic roofs above. | ||
| # Unfortunately, these become unreliable with newly-added skylight wells. | ||
| rfs2 = osut.roofs(core) | ||
| tot2 = sum([sk.grossArea() for sk in rfs2]) | ||
| self.assertAlmostEqual(tot2, tot1, places=2) | ||
| self.assertAlmostEqual(tot2, osut.grossRoofArea(core), places=2) | ||
|
|
||
| # Fortunately, the addition of leader lines does not affect how | ||
| # OpenStudio reports surface areas. | ||
| rfs3 = osut.facets(attic, "Outdoors", "RoofCeiling") | ||
| tot3 = sum([sk.grossArea() for sk in rfs3]) | ||
| self.assertAlmostEqual(tot3 + tot2, total2, places=2) # 598.76 | ||
|
|
||
| # However, as discussed elsewhere (see 'addSkylights' doctring and | ||
| # inline comments), these otherwise valid areas are often overestimated | ||
| # for SRR% calculations (e.g. when overhangs and soffits are explicitely | ||
| # modelled). It is for this reason 'addSkylights' reports gross roof | ||
| # area BEFORE adding skylight wells. For higher-level applications | ||
| # relying on 'addSkylights' (e.g. an OpenStudio measure), it is better | ||
| # to store returned gross roof areas for subsequent reporting purposes. | ||
|
|
||
| # Deeper dive: Why are OSut's 'roofs' and 'grossRoofArea' unreliable | ||
| # with leader lines? Both rely on OSut's 'overlapping', itself relying | ||
| # on OpenStudio's 'join' and 'intersect': if neither are successful in | ||
| # joining (or intersecting) 2x polygons (e.g. attic roof vs cast core | ||
| # ceiling), there can be no identifiable overlap. In such cases, both | ||
| # 'roofs' and 'grossRoofArea' ignore overlapping attic roofs. A demo: | ||
| roof_north = model.getSurfaceByName("Attic_roof_north") | ||
| core_ceiling = model.getSurfaceByName("Core_ZN_ceiling") | ||
| self.assertTrue(roof_north) | ||
| self.assertTrue(core_ceiling) | ||
| roof_north = roof_north.get() | ||
| core_ceiling = core_ceiling.get() | ||
|
|
||
| t = openstudio.Transformation.alignFace(roof_north.vertices()) | ||
| up = openstudio.Point3d(0,0,1) - openstudio.Point3d(0,0,0) | ||
|
|
||
| a_roof_north = t.inverse() * roof_north.vertices() | ||
| a_core_ceiling = t.inverse() * core_ceiling.vertices() | ||
| c_core_ceiling = osut.cast(a_core_ceiling, a_roof_north, up) | ||
|
|
||
| north_m2 = openstudio.getArea(a_roof_north) | ||
| ceiling_m2 = openstudio.getArea(c_core_ceiling) | ||
| self.assertTrue(north_m2) | ||
| self.assertTrue(ceiling_m2) | ||
| self.assertAlmostEqual(north_m2.get(), 192.98, places=2) | ||
| self.assertAlmostEqual(ceiling_m2.get(), 133.81, places=2) | ||
|
|
||
| # So far so good. Ensure clockwise winding. | ||
| a_roof_north = list(a_roof_north) | ||
| c_core_ceiling = list(c_core_ceiling) | ||
| a_roof_north.reverse() | ||
| c_core_ceiling.reverse() | ||
| self.assertFalse(openstudio.join(a_roof_north, c_core_ceiling, TOL2)) | ||
| self.assertFalse(openstudio.intersect(a_roof_north, c_core_ceiling, TOL)) | ||
|
|
||
| # A future revision of OSut's 'roofs' and 'grossRoofArea' would require: | ||
| # - a new method identifying leader lines amongst surface vertices | ||
| # - a new method identifying surface cutouts amongst surface vertices | ||
| # - a method to prune both leader lines and cutouts from surface vertices | ||
| # - have 'roofs' & 'grossRoofArea' rely on the remaining outer vertices | ||
| # ... @todo? | ||
| self.assertEqual(o.status(), 0) | ||
| del model | ||
|
|
||
| # --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # | ||
| # CASE 2: | ||
| path = openstudio.path("./tests/files/osms/in/smalloffice.osm") | ||
| model = translator.loadModel(path) | ||
| self.assertTrue(model) | ||
| model = model.get() | ||
|
|
||
| core = model.getSpaceByName("Core_ZN") | ||
| attic = model.getSpaceByName("Attic") | ||
| self.assertTrue(core) | ||
| self.assertTrue(attic) | ||
| core = core.get() | ||
| attic = attic.get() | ||
|
|
||
| # Tag attic as an INDIRECTLY-CONDITIONED space. | ||
| key = "indirectlyconditioned" | ||
| val = core.nameString() | ||
| self.assertTrue(attic.additionalProperties().setFeature(key, val)) | ||
| self.assertFalse(osut.arePlenums(attic)) | ||
| self.assertFalse(osut.isUnconditioned(attic)) | ||
| self.assertAlmostEqual(osut.setpoints(attic)["heating"], 21.11, places=2) | ||
| self.assertAlmostEqual(osut.setpoints(attic)["cooling"], 23.89, places=2) | ||
|
|
||
| # Here, GRA includes ALL plenum roof surfaces (not just vertically-cast | ||
| # roof areas onto the core ceiling). More roof surfaces == greater | ||
| # skylight areas to meet the SRR% of 5%. | ||
| gra_plenum = osut.grossRoofArea(core) | ||
| self.assertAlmostEqual(gra_plenum, total1, places=2) | ||
|
|
||
| rm2 = osut.addSkyLights(core, dict(srr=srr)) | ||
| if o.logs(): print(o.logs()) | ||
| self.assertAlmostEqual(rm2, total1, places=2) | ||
|
|
||
| # The total skylight area is greater than in CASE 1. Nonetheless, the | ||
| # method is able to meet the requested SRR 5%. This may not be | ||
| # achievable in other circumstances, given the constrained roof/core | ||
| # overlap. Although a plenum vastly larger than the room(s) it serves is | ||
| # rare, it remains certainly problematic for the application of the | ||
| # Canadian NECB reference building skylight requirements. | ||
| core_skies = osut.facets(core, "Outdoors", "Skylight") | ||
| sky_area2 = sum([sk.grossArea() for sk in core_skies]) | ||
| self.assertAlmostEqual(sky_area2, 29.94, places=2) | ||
| ratio2 = sky_area2 / rm2 | ||
| self.assertAlmostEqual(ratio2, srr, places=2) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| model.save("./tests/files/osms/out/office_plenum.osm", True) | ||
|
|
||
| self.assertEqual(o.status(), 0) | ||
| del model | ||
|
|
||
| # --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # | ||
| # CASE 2b: | ||
| path = openstudio.path("./tests/files/osms/in/smalloffice.osm") | ||
| model = translator.loadModel(path) | ||
| self.assertTrue(model) | ||
| model = model.get() | ||
|
|
||
| core = model.getSpaceByName("Core_ZN") | ||
| attic = model.getSpaceByName("Attic") | ||
| self.assertTrue(core) | ||
| self.assertTrue(attic) | ||
| core = core.get() | ||
| attic = attic.get() | ||
|
|
||
| # Again, tagging attic as an INDIRECTLY-CONDITIONED space. | ||
| key = "indirectlyconditioned" | ||
| val = core.nameString() | ||
| self.assertTrue(attic.additionalProperties().setFeature(key, val)) | ||
| self.assertFalse(osut.arePlenums(attic)) | ||
| self.assertFalse(osut.isUnconditioned(attic)) | ||
| self.assertAlmostEqual(osut.setpoints(attic)["heating"], 21.11, places=2) | ||
| self.assertAlmostEqual(osut.setpoints(attic)["cooling"], 23.89, places=2) | ||
|
|
||
| gra_plenum = osut.grossRoofArea(core) | ||
| self.assertAlmostEqual(gra_plenum, total1, places=2) | ||
|
|
||
| # Conflicting argument case: Here, skylight wells must traverse plenums | ||
| # (in this context, "plenum" is an all encompassing keyword for any | ||
| # INDIRECTLY-CONDITIONED, unoccupied space). Yet by passing option | ||
| # "plenum: False", the method is instructed to skip "plenum" skylight | ||
| # wells altogether. | ||
| rm2 = osut.addSkyLights(core, dict(srr=srr, plenum=False)) | ||
| self.assertTrue(o.is_warn()) | ||
| self.assertEqual(len(o.logs()), 1) | ||
| msg = o.logs()[0]["message"] | ||
| self.assertTrue("Empty 'subsets (3)' (osut.addSkyLights)" in msg) | ||
| self.assertAlmostEqual(rm2, total1, places=2) | ||
|
|
||
| core_skies = osut.facets(core, "Outdoors", "Skylight") | ||
| sky_area2 = sum([sk.grossArea() for sk in core_skies]) | ||
| self.assertAlmostEqual(sky_area2, 0.00, places=2) | ||
| self.assertEqual(o.clean(), DBG) | ||
|
|
||
| self.assertEqual(o.status(), 0) | ||
| del model | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both North & South roof surfaces now inherit leader lines and cutouts to accommodate skylight wells. Although roof surfaces inherit such extended vertices (consult generated office_attic.osm file with a text editor), the OpenStudio Application won't necessarily render them - that's OK.
There's now a single eplusout.err file warning on collinear vertices - which is expected. Otherwise, slight (expected) changes in results.
All good for now. More testing to come.