-
Notifications
You must be signed in to change notification settings - Fork 2
Harmonizes use of resetUo() in genConstruction() with pyOSut #26
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 all commits
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # BSD 3-Clause License | ||
| # | ||
| # Copyright (c) 2022-2025, Denis Bourgeois | ||
| # Copyright (c) 2022-2026, Denis Bourgeois | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
|
|
@@ -530,7 +530,7 @@ def resetUo(lc = nil, film = nil, index = nil, uo = nil, uniq = false) | |
| mt.setName(id) | ||
|
|
||
| unless mt.setThermalResistance(r) | ||
| return invalid("Failed #{id}: RSi#{de_r.round(2)}", mth) | ||
| return invalid("Failed #{id}: RSi#{r.round(2)}", mth) | ||
| end | ||
|
|
||
| lc.setLayer(index, mt) | ||
|
|
@@ -546,7 +546,7 @@ def resetUo(lc = nil, film = nil, index = nil, uo = nil, uniq = false) | |
| k = (m.thickness / (r + dR)).clamp(KMIN, KMAX) | ||
| d = (k * (r + dR)).clamp(DMIN, DMAX) | ||
| r = d / k | ||
| id = "OSUT:K#{format('%4.3f', k)}:#{format('%03d', d*1000)[-3..-1]}" | ||
| id = "OSut:K#{format('%4.3f', k)}:#{format('%03d', d*1000)[-3..-1]}" | ||
| mt = lc.model.getStandardOpaqueMaterialByName(id) | ||
|
|
||
| # Existing material? | ||
|
|
@@ -928,7 +928,6 @@ def genConstruction(model = nil, specs = {}) | |
| if u and a[:glazing].empty? | ||
| ro = 1 / u - film | ||
|
|
||
|
|
||
| if ro > RMIN | ||
| if specs[:type] == :door # 1x layer, adjust conductivity | ||
| layer = c.getLayer(0).to_StandardOpaqueMaterial | ||
|
|
@@ -944,27 +943,7 @@ def genConstruction(model = nil, specs = {}) | |
| return invalid("#{id} construction", mth, 0) if lyr[:r ].to_i.zero? | ||
|
|
||
| index = lyr[:index] | ||
| layer = c.getLayer(index).to_StandardOpaqueMaterial | ||
| return invalid("#{id} material @#{index}", mth, 0) if layer.empty? | ||
|
|
||
| layer = layer.get | ||
|
|
||
| k = (layer.thickness / (ro - rsi(c) + lyr[:r])).clamp(KMIN, KMAX) | ||
| d = (k * (ro - rsi(c) + lyr[:r])).clamp(DMIN, DMAX) | ||
|
|
||
| nom = "OSut:" | ||
| nom += layer.nameString.gsub(/[^a-z]/i, "").gsub("OSut", "") | ||
| nom += ":K#{format('%4.3f', k)}:#{format('%03d', d*1000)[-3..-1]}" | ||
|
|
||
| lyr = model.getStandardOpaqueMaterialByName(nom) | ||
|
|
||
| if lyr.empty? | ||
| layer.setName(nom) | ||
| layer.setConductivity(k) | ||
| layer.setThickness(d) | ||
| else | ||
| c.setLayer(index, lyr.get) | ||
| end | ||
| resetUo(c, film, index, u) | ||
|
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. Harmonizes with pyOSut use of resetUo. |
||
| end | ||
| end | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,17 +154,19 @@ | |
| expect(u).to be_within(TOL).of(uo2) | ||
|
|
||
| # Insulated, unfinished outdoor-facing plenum roof (polyiso above 4" slab). | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :roof, uo: uo2, frame: :medium, finish: :medium} | ||
| surface = cls1.genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
| expect(surface).to be_a(OpenStudio::Model::LayeredConstruction) | ||
| expect(surface.layers.size).to eq(3) | ||
| u = 1 / cls1.rsi(surface, film[:roof]) | ||
| expect(u).to be_within(TOL).of(uo2) | ||
| expect(surface.layers[1].nameString).to eq("OSut:polyiso:K0.023:100") | ||
| expect(surface.layers[1].nameString).to eq("OSut:K0.023:100") | ||
| expect(surface.layers[2].nameString).to eq("OSut:concrete:100") | ||
|
|
||
| # Roof above conditioned parking garage (polyiso under 8" slab). | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :roof, uo: uo2, clad: :heavy, frame: :medium, finish: :none} | ||
| surface = cls1.genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
|
|
@@ -173,9 +175,10 @@ | |
| u = 1 / cls1.rsi(surface, film[:roof]) | ||
| expect(u).to be_within(TOL).of(uo2) | ||
| expect(surface.layers[0].nameString).to eq("OSut:concrete:200") | ||
| expect(surface.layers[1].nameString).to eq("OSut:polyiso:K0.023:100") | ||
| expect(surface.layers[1].nameString).to eq("OSut:K0.023:100") | ||
|
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. Method resetUo adjusts a construction's insulating layer properties, e.g.
... the (adjusted) insulating material is renamed accordingly. |
||
|
|
||
| # Uninsulated plenum ceiling tiles (alternative :shading). | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :roof, uo: nil, clad: :none, finish: :none} | ||
| surface = cls1.genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
|
|
@@ -185,37 +188,41 @@ | |
| expect(u).to be_within(TOL).of(uo6) | ||
|
|
||
| # Unfinished, insulated, framed attic floor (blown cellulose). | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :floor, uo: uo2, frame: :heavy, finish: :none} | ||
| surface = cls1.genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
| expect(surface).to be_a(OpenStudio::Model::LayeredConstruction) | ||
| expect(surface.layers.size).to eq(2) | ||
| u = 1 / cls1.rsi(surface, film[:floor]) | ||
| expect(u).to be_within(TOL).of(uo2) | ||
| expect(surface.layers[1].nameString).to eq("OSut:cellulose:K0.023:100") | ||
| expect(surface.layers[1].nameString).to eq("OSut:K0.023:100") | ||
|
|
||
| # Finished, insulated exposed floor (e.g. wood-framed, residential). | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :floor, uo: uo2} | ||
| surface = cls1.genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
| expect(surface).to be_a(OpenStudio::Model::LayeredConstruction) | ||
| expect(surface.layers.size).to eq(3) | ||
| u = 1 / cls1.rsi(surface, film[:floor]) | ||
| expect(u).to be_within(TOL).of(uo2) | ||
| expect(surface.layers[1].nameString).to eq("OSut:mineral:K0.024:100") | ||
| expect(surface.layers[1].nameString).to eq("OSut:K0.024:100") | ||
|
|
||
| # Finished, insulated exposed floor (e.g. 4" slab, steel web joists). | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :floor, uo: uo2, finish: :medium} | ||
| surface = cls1.genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
| expect(surface).to be_a(OpenStudio::Model::LayeredConstruction) | ||
| expect(surface.layers.size).to eq(3) | ||
| u = 1 / cls1.rsi(surface, film[:floor]) | ||
| expect(u).to be_within(TOL).of(uo2) | ||
| expect(surface.layers[1].nameString).to eq("OSut:mineral:K0.023:100") | ||
| expect(surface.layers[1].nameString).to eq("OSut:K0.023:100") | ||
| expect(surface.layers[2].nameString).to eq("OSut:concrete:100") | ||
|
|
||
| # Uninsulated slab-on-grade. | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :slab, frame: :none, finish: :none} | ||
| surface = cls1::genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
|
|
@@ -225,6 +232,7 @@ | |
| expect(surface.layers[1].nameString).to eq("OSut:concrete:100") | ||
|
|
||
| # Insulated slab-on-grade. | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :slab, uo: uo2, finish: :none} | ||
| surface = cls1::genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
|
|
@@ -233,7 +241,7 @@ | |
| u = 1 / cls1::rsi(surface, film[:slab]) | ||
| expect(u).to be_within(TOL).of(uo2) | ||
| expect(surface.layers[0].nameString).to eq("OSut:sand:100") | ||
| expect(surface.layers[1].nameString).to eq("OSut:polyiso:K0.010:043") | ||
| expect(surface.layers[1].nameString).to eq("OSut:K0.010:043") | ||
| expect(surface.layers[2].nameString).to eq("OSut:concrete:100") | ||
|
|
||
| # 8" uninsulated basement wall. | ||
|
|
@@ -247,6 +255,7 @@ | |
| expect(u).to be_within(TOL).of(uo7) | ||
|
|
||
| # 8" interior-insulated, finished basement wall. | ||
| model = OpenStudio::Model::Model.new | ||
| specs = {type: :basement, uo: 2 * uo2, clad: :none} | ||
| surface = cls1::genConstruction(model, specs) | ||
| expect(surface).to_not be_nil | ||
|
|
@@ -255,7 +264,7 @@ | |
| u = 1 / cls1::rsi(surface, film[:basement]) | ||
| expect(u).to be_within(TOL).of(2 * uo2) | ||
| expect(surface.layers[0].nameString).to eq("OSut:concrete:200") | ||
| expect(surface.layers[1].nameString).to eq("OSut:mineral:K0.037:075") | ||
| expect(surface.layers[1].nameString).to eq("OSut:K0.037:075") | ||
| expect(surface.layers[2].nameString).to eq("OSut:drywall:015") | ||
|
|
||
| # Standard, insulated steel door (default Uo = 1.8 W/K•m). | ||
|
|
@@ -291,15 +300,15 @@ | |
| u = 1 / cls1::rsi(surface) | ||
| expect(u).to be_within(TOL).of(uo9) | ||
|
|
||
| # Invalid Uo (here, skylights and windows inherit default Uo values) | ||
| # Invalid Uo (here, skylights and windows inherit default Uo values). | ||
| specs = {type: :skylight, uo: nil} | ||
| surface = cls1::genConstruction(model, specs) | ||
| expect(surface).to be_a(OpenStudio::Model::LayeredConstruction) | ||
| expect(surface.layers.size).to eq(1) | ||
| u = 1 / cls1::rsi(surface) | ||
| expect(u).to be_within(TOL).of(uo[:skylight]) | ||
|
|
||
| # Invalid Uo (here, Uo-adjustments are ignored altogether) | ||
| # Invalid Uo (here, Uo-adjustments are ignored altogether). | ||
| specs = {type: :wall, uo: nil} | ||
| surface = cls1::genConstruction(model, specs) | ||
| expect(surface).to be_a(OpenStudio::Model::LayeredConstruction) | ||
|
|
||
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.
Fixes issue.