Skip to content

Commit 62ec271

Browse files
committed
Completes 'Warehouse' addSkylights unittest
1 parent 60f9f6f commit 62ec271

File tree

2 files changed

+78
-18
lines changed

2 files changed

+78
-18
lines changed

src/osut/osut.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7637,9 +7637,9 @@ def addSkyLights(spaces=[], opts=dict) -> float:
76377637
sset["roof" ] = roof
76387638
sset["space" ] = space
76397639
sset["m" ] = space.multiplier()
7640-
sset["sidelit"] = rooms[space]["sidelit"]
7640+
sset["sidelit"] = rooms[ide]["sidelit"]
76417641
sset["sloped" ] = isSloped(roof)
7642-
sset["t0" ] = rooms[space]["t0"]
7642+
sset["t0" ] = rooms[ide]["t0"]
76437643
sset["t" ] = openstudio.Transformation.alignFace(vtx)
76447644
ssets.append(sset)
76457645

@@ -7991,11 +7991,11 @@ def addSkyLights(spaces=[], opts=dict) -> float:
79917991
if round(ly, 2) < round(sp, 2): continue
79927992

79937993
if well:
7994-
cols = int(round(width / (wxl + sp)), 2)
7995-
rows = int(round(depth / (wyl + sp)), 2)
7994+
cols = int(round(width / (wxl + sp), 2))
7995+
rows = int(round(depth / (wyl + sp), 2))
79967996
else:
7997-
cols = int(round(width / (wx + sp)), 2)
7998-
rows = int(round(depth / (wy + sp)), 2)
7997+
cols = int(round(width / (wx + sp), 2))
7998+
rows = int(round(depth / (wy + sp), 2))
79997999

80008000
if cols < 2: continue
80018001
if rows < 2: continue
@@ -8303,8 +8303,9 @@ def addSkyLights(spaces=[], opts=dict) -> float:
83038303

83048304
# Favour (large) arrays if meeting residual target, unless constrained.
83058305
if "array" in fpm2:
8306-
if round(fpm2["array"]["m2"], 2) >= round(dm2, 2):
8307-
if not fpm2["tight"]: pattern = "array"
8306+
if dm2 < fpm2["array"]["m2"]:
8307+
if "tight" not in fpm2["array"] or fpm2["array"]["tight"] is False:
8308+
pattern = "array"
83088309

83098310
if not pattern:
83108311
fpm2 = dict(sorted(fpm2.items(), key=lambda f2: f2[1]["m2"]))
@@ -8684,16 +8685,17 @@ def addSkyLights(spaces=[], opts=dict) -> float:
86848685
dY = st["dY"]
86858686

86868687
for j in range(st["rows"]):
8687-
sub = {}
8688-
sub["type" ] = "Skylight"
8689-
sub["count" ] = st["cols"]
8690-
sub["width" ] = w1
8691-
sub["height" ] = d1
8692-
sub["id" ] = "%s:%d:%d" % (roof.nameString(), i, j)
8693-
sub["sill" ] = dY + j * (2 * dY + d1)
8694-
if st["dX"]: sub["r_buffer"] = st["dX"]
8695-
if st["dX"]: sub["l_buffer"] = st["dX"]
8696-
if frame: sub["frame" ] = frame
8688+
sub = {}
8689+
sub["type" ] = "Skylight"
8690+
sub["count" ] = st["cols"]
8691+
sub["width" ] = w1
8692+
sub["height"] = d1
8693+
sub["id" ] = "%s:%d:%d" % (roof.nameString(), i, j)
8694+
sub["sill" ] = dY + j * (2 * dY + d1)
8695+
8696+
if "dX" in st and st["dX"]: sub["r_buffer"] = st["dX"]
8697+
if "dX" in st and st["dX"]: sub["l_buffer"] = st["dX"]
8698+
if frame: sub["frame"] = frame
86978699

86988700
addSubs(roof, sub, False, True, True)
86998701

tests/test_osut.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5283,6 +5283,64 @@ def test34_generated_skylight_wells(self):
52835283
self.assertEqual(o.status(), 0)
52845284
del model
52855285

5286+
# --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- #
5287+
path = openstudio.path("./tests/files/osms/in/warehouse.osm")
5288+
model = translator.loadModel(path)
5289+
self.assertTrue(model)
5290+
model = model.get()
5291+
5292+
for space in model.getSpaces():
5293+
ide = space.nameString()
5294+
if not space.partofTotalFloorArea(): continue
5295+
5296+
sidelit = osut.isDaylit(space, True, False)
5297+
toplit = osut.isDaylit(space, False)
5298+
if "Office" in ide: self.assertTrue(sidelit)
5299+
if "Storage" in ide: self.assertFalse(sidelit)
5300+
if "Office" in ide: self.assertFalse(toplit)
5301+
if "Storage" in ide: self.assertTrue(toplit)
5302+
5303+
bulk = model.getSpaceByName("Zone3 Bulk Storage")
5304+
fine = model.getSpaceByName("Zone2 Fine Storage")
5305+
self.assertTrue(bulk)
5306+
self.assertTrue(fine)
5307+
bulk = bulk.get()
5308+
fine = fine.get()
5309+
5310+
# No overhangs/attics. Calculation of roof area for SRR% is more intuitive.
5311+
gra_bulk = osut.grossRoofArea(bulk)
5312+
gra_fine = osut.grossRoofArea(fine)
5313+
5314+
bulk_roof_m2 = sum([ruf.grossArea() for ruf in osut.roofs(bulk)])
5315+
fine_roof_m2 = sum([ruf.grossArea() for ruf in osut.roofs(fine)])
5316+
self.assertAlmostEqual(gra_bulk, bulk_roof_m2, places=2)
5317+
self.assertAlmostEqual(gra_fine, fine_roof_m2, places=2)
5318+
5319+
# Initial SSR%.
5320+
bulk_skies = osut.facets(bulk, "Outdoors", "Skylight")
5321+
sky_area1 = sum([sk.grossArea() for sk in bulk_skies])
5322+
ratio1 = sky_area1 / bulk_roof_m2
5323+
self.assertAlmostEqual(sky_area1, 47.57, places=2)
5324+
self.assertAlmostEqual(ratio1, 0.01, places=2)
5325+
5326+
srr = 0.04
5327+
opts = {}
5328+
opts["srr" ] = srr
5329+
opts["size" ] = 2.4
5330+
opts["clear"] = True
5331+
rm2 = osut.addSkyLights(bulk, opts)
5332+
5333+
bulk_skies = osut.facets(bulk, "Outdoors", "Skylight")
5334+
sky_area2 = sum([sk.grossArea() for sk in bulk_skies])
5335+
self.assertAlmostEqual(sky_area2, 128.19, places=2)
5336+
ratio2 = sky_area2 / rm2
5337+
self.assertAlmostEqual(ratio2, srr, places=2)
5338+
5339+
model.save("./tests/files/osms/out/warehouse_sky.osm", True)
5340+
5341+
self.assertEqual(o.status(), 0)
5342+
del model
5343+
52865344
def test35_facet_retrieval(self):
52875345
o = osut.oslg
52885346
self.assertEqual(o.status(), 0)

0 commit comments

Comments
 (0)