-
Notifications
You must be signed in to change notification settings - Fork 0
Tweaks 'genConstruction' (tested) #7
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
Changes from 1 commit
31fe98c
0ca5976
01f0f11
f36e9a2
d4634be
a57c25c
3c630f9
02b8023
ab70a66
a33b3b0
efacdf8
b294f50
8214f2f
7a35d64
7fbf1a2
3721304
c212c30
c2129da
5c33a23
f24ad09
10087e1
512e84b
bb299a7
e4df93b
1c3d672
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,8 +107,8 @@ class _CN: | |
|
|
||
| # Default (~1980s) envelope Uo (W/m2•K), based on surface type. | ||
| _uo = dict( | ||
| shading = None, # N/A | ||
| partition = None, # N/A | ||
| shading = None, # N/A | ||
| partition = None, # N/A | ||
| wall = 0.384, # rated R14.8 hr•ft2F/Btu | ||
| roof = 0.327, # rated R17.6 hr•ft2F/Btu | ||
| floor = 0.317, # rated R17.9 hr•ft2F/Btu (exposed floor) | ||
|
|
@@ -335,9 +335,8 @@ def genConstruction(model=None, specs=dict()): | |
| ide = "OSut.CON." + specs["type"] | ||
| if specs["type"] not in uo(): | ||
| return oslg.invalid("surface type", mth, 2, CN.ERR) | ||
| if "uo" not in specs: | ||
| specs["uo"] = uo()[ specs["type"] ] | ||
|
|
||
| if "uo" not in specs: specs["uo"] = uo()[ specs["type"] ] # can be None | ||
| u = specs["uo"] | ||
|
|
||
| if u: | ||
|
|
@@ -348,6 +347,8 @@ def genConstruction(model=None, specs=dict()): | |
|
|
||
| if u < 0: | ||
| return oslg.negative(id + " Uo", mth, CN.ERR) | ||
| if round(u, 2) == 0: | ||
| return oslg.zero(id + " Uo", mth, CN.ERR) | ||
| if u > 5.678: | ||
| return oslg.invalid(id + " Uo (> 5.678)", mth, 2, CN.ERR) | ||
|
|
||
|
|
@@ -581,15 +582,15 @@ def genConstruction(model=None, specs=dict()): | |
| a["compo" ]["id" ] = "OSut." + mt + ".%03d" % int(d * 1000) | ||
|
|
||
| elif specs["type"] == "window": | ||
| a["glazing"]["u" ] = specs["uo"] | ||
| a["glazing"]["u" ] = u if u else uo()["window"] | ||
| a["glazing"]["shgc"] = 0.450 | ||
| if "shgc" in specs: a["glazing"]["shgc"] = specs["shgc"] | ||
| a["glazing"]["id" ] = "OSut.window" | ||
| a["glazing"]["id" ] += ".U%.1f" % a["glazing"]["u"] | ||
| a["glazing"]["id" ] += ".SHGC%d" % (a["glazing"]["shgc"]*100) | ||
|
|
||
| elif specs["type"] == "skylight": | ||
| a["glazing"]["u" ] = specs["uo"] | ||
| a["glazing"]["u" ] = u if u else uo()["skylight"] | ||
| a["glazing"]["shgc"] = 0.450 | ||
| if "shgc" in specs: a["glazing"]["shgc"] = specs["shgc"] | ||
| a["glazing"]["id" ] = "OSut.skylight" | ||
|
|
@@ -599,14 +600,14 @@ def genConstruction(model=None, specs=dict()): | |
| if a["glazing"]: | ||
| layers = openstudio.model.FenestrationMaterialVector() | ||
|
|
||
| u = a["glazing"]["u" ] | ||
| u0 = a["glazing"]["u" ] | ||
| shgc = a["glazing"]["shgc"] | ||
| lyr = model.getSimpleGlazingByName(a["glazing"]["id"]) | ||
|
|
||
| if lyr: | ||
| lyr = lyr.get() | ||
| else: | ||
| lyr = openstudio.model.SimpleGlazing(model, u, shgc) | ||
| lyr = openstudio.model.SimpleGlazing(model, u0, shgc) | ||
| lyr.setName(a["glazing"]["id"]) | ||
|
|
||
| layers.append(lyr) | ||
|
|
@@ -635,49 +636,54 @@ def genConstruction(model=None, specs=dict()): | |
|
|
||
| layers.append(lyr) | ||
|
|
||
| c = openstudio.model.Construction(layers) | ||
| c = openstudio.model.Construction(layers) | ||
| c.setName(ide) | ||
|
|
||
| # Adjust insulating layer thickness or conductivity to match requested Uo. | ||
| if not a["glazing"]: | ||
| ro = 1 / specs["uo"] - film()[specs["type"]] if specs["uo"] else 0 | ||
| if u and not a["glazing"]: | ||
| ro = 1 / u - flm | ||
|
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. For opaque construction, adjusting insulating layer thickness (to meet a requested assembly Uo factor) is skipped entirely if the requested Uo isn't:
|
||
|
|
||
| if specs["type"] == "door": # 1x layer, adjust conductivity | ||
| layer = c.getLayer(0).to_StandardOpaqueMaterial() | ||
| if ro > 0: | ||
| if specs["type"] == "door": # 1x layer, adjust conductivity | ||
| layer = c.getLayer(0).to_StandardOpaqueMaterial() | ||
|
|
||
| if not layer: | ||
| return oslg.invalid(id + " standard material?", mth, 0) | ||
| if not layer: | ||
| return oslg.invalid(id + " standard material?", mth, 0) | ||
|
|
||
| layer = layer.get() | ||
| k = layer.thickness() / ro | ||
| layer.setConductivity(k) | ||
| layer = layer.get() | ||
| k = layer.thickness() / ro | ||
| layer.setConductivity(k) | ||
|
|
||
| elif ro > 0: # multiple layers, adjust insulating layer thickness | ||
| lyr = insulatingLayer(c) | ||
| else: # multiple layers, adjust insulating layer thickness | ||
| lyr = insulatingLayer(c) | ||
|
|
||
| if not lyr["index"] or not lyr["type"] or not lyr["r"]: | ||
| return oslg.invalid(id + " construction", mth, 0) | ||
| if not lyr["index"] or not lyr["type"] or not lyr["r"]: | ||
| return oslg.invalid(id + " construction", mth, 0) | ||
|
|
||
| index = lyr["index"] | ||
| layer = c.getLayer(index).to_StandardOpaqueMaterial() | ||
| index = lyr["index"] | ||
| layer = c.getLayer(index).to_StandardOpaqueMaterial() | ||
|
|
||
| if not layer: | ||
| return oslg.invalid(id + " material %d" % index, mth, 0) | ||
| if not layer: | ||
| return oslg.invalid(id + " material %d" % index, mth, 0) | ||
|
|
||
| layer = layer.get() | ||
| k = layer.conductivity() | ||
| d = (ro - rsi(c) + lyr["r"]) * k | ||
| layer = layer.get() | ||
| k = layer.conductivity() | ||
| d = (ro - rsi(c) + lyr["r"]) * k | ||
|
|
||
| if d < 0.03: | ||
| return oslg.invalid(id + " adjusted material thickness", mth, 0) | ||
| if d < 0.03: | ||
| m = id + " adjusted material thickness" | ||
| return oslg.invalid(m, mth, 0) | ||
|
|
||
| nom = re.sub(r'[^a-zA-Z]', '', layer.nameString()) | ||
| nom = re.sub(r'OSut', '', nom) | ||
| nom = "OSut." + nom + ".%03d" % int(d * 1000) | ||
| nom = re.sub(r'[^a-zA-Z]', '', layer.nameString()) | ||
| nom = re.sub(r'OSut', '', nom) | ||
| nom = "OSut." + nom + ".%03d" % int(d * 1000) | ||
|
|
||
| if not model.getStandardOpaqueMaterialByName(nom): | ||
| layer.setName(nom) | ||
| layer.setThickness(d) | ||
| if model.getStandardOpaqueMaterialByName(nom): | ||
| omat = model.getStandardOpaqueMaterialByName(nom).get() | ||
| c.setLayer(index, omat) | ||
| else: | ||
| layer.setName(nom) | ||
| layer.setThickness(d) | ||
|
|
||
| return c | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -649,6 +649,41 @@ def test05_construction_generation(self): | |
| self.assertEqual(o.status(), 0) | ||
| del model | ||
|
|
||
| # Invalid Uo (here, skylights and windows inherit default Uo values) | ||
| specs = dict(type="skylight", uo=None) | ||
| model = openstudio.model.Model() | ||
| c = osut.genConstruction(model, specs) | ||
| self.assertEqual(o.status(), 0) | ||
| self.assertFalse(o.logs()) | ||
| self.assertTrue(c) | ||
| self.assertTrue(isinstance(c, openstudio.model.Construction)) | ||
| self.assertEqual(c.nameString(), "OSut.CON.skylight") | ||
| self.assertTrue(c.layers()) | ||
| self.assertEqual(len(c.layers()), 1) | ||
| self.assertEqual(c.layers()[0].nameString(), "OSut.skylight.U3.5.SHGC45") | ||
| r = osut.rsi(c) | ||
| self.assertAlmostEqual(r, 1/osut.uo()["skylight"], places=3) | ||
|
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. In the case of fenestrated assemblies, an invalid Uo request is ignored and the glazing assembly inherits a default OSut Uo (here 3.5 W/m2.K for a skylight). |
||
| self.assertFalse(o.logs()) | ||
| self.assertEqual(o.status(), 0) | ||
| del model | ||
|
|
||
| # Invalid Uo (here, Uo-adjustments are ignored altogether) | ||
| specs = dict(type="wall", uo=None) | ||
| model = openstudio.model.Model() | ||
| c = osut.genConstruction(model, specs) | ||
| self.assertEqual(o.status(), 0) | ||
| self.assertFalse(o.logs()) | ||
| self.assertTrue(c) | ||
| self.assertTrue(isinstance(c, openstudio.model.Construction)) | ||
| self.assertEqual(c.nameString(), "OSut.CON.wall") | ||
| self.assertTrue(c.layers()) | ||
| self.assertEqual(len(c.layers()), 4) | ||
| r = osut.rsi(c) | ||
| self.assertAlmostEqual(1/r, 2.23, places=2) # not matching any defaults | ||
| self.assertFalse(o.logs()) | ||
| self.assertEqual(o.status(), 0) | ||
| del model | ||
|
|
||
| def test06_internal_mass(self): | ||
| o = osut.oslg | ||
| self.assertEqual(o.status(), 0) | ||
|
|
||
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.
A user could set a glazing assembly's
specs["uo"]to None. This is caught and reset here.