Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 43 additions & 37 deletions src/osut/osut.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand Down Expand Up @@ -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"]
Copy link
Copy Markdown
Member Author

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.

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"
Expand All @@ -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)
Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Member Author

@brgix brgix Aug 5, 2025

Choose a reason for hiding this comment

The 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:

  • successfully converted to a float
  • within postulated (acceptable) range


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

Expand Down
35 changes: 35 additions & 0 deletions tests/test_osut.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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)
Expand Down