Skip to content

Commit

Permalink
Merge pull request #120 from rd2/exposed
Browse files Browse the repository at this point in the history
KIVA fixes/tests + JSON fixes/tests
  • Loading branch information
brgix authored Nov 22, 2024
2 parents 16410d0 + 1c3e7c8 commit 22f7c2c
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 111 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,19 @@ jobs:
docker exec -t test bundle update
docker exec -t test bundle exec rake
docker kill test
test_390x:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Run Tests
run: |
echo $(pwd)
echo $(ls)
docker pull nrel/openstudio:3.9.0
docker run --name test --rm -d -t -v $(pwd):/work -w /work nrel/openstudio:3.9.0
docker exec -t test pwd
docker exec -t test ls
docker exec -t test bundle update
docker exec -t test bundle exec rake
docker kill test
10 changes: 5 additions & 5 deletions lib/measures/tbd/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>tbd_measure</name>
<uid>8890787b-8c25-4dc8-8641-b6be1b6c2357</uid>
<version_id>12467d7f-9058-4028-b6f8-0448e81b7fef</version_id>
<version_modified>2024-10-15T18:51:39Z</version_modified>
<version_id>70223737-c3ea-4df0-8506-67083c92fb6e</version_id>
<version_modified>2024-11-20T20:02:15Z</version_modified>
<xml_checksum>99772807</xml_checksum>
<class_name>TBDMeasure</class_name>
<display_name>Thermal Bridging and Derating - TBD</display_name>
Expand Down Expand Up @@ -499,7 +499,7 @@
<filename>geo.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>6C7ACC99</checksum>
<checksum>9FAC0CDC</checksum>
</file>
<file>
<filename>geometry.rb</filename>
Expand All @@ -523,7 +523,7 @@
<filename>psi.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>25CD6251</checksum>
<checksum>4B7F3586</checksum>
</file>
<file>
<filename>tbd.rb</filename>
Expand All @@ -541,7 +541,7 @@
<filename>ua.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>013BA732</checksum>
<checksum>626D3BE0</checksum>
</file>
<file>
<filename>utils.rb</filename>
Expand Down
29 changes: 16 additions & 13 deletions lib/measures/tbd/resources/geo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -722,15 +722,10 @@ def resetKIVA(model = nil, boundary = "Foundation")
kva = true unless surface.surfacePropertyExposedFoundationPerimeter.empty?
surface.resetAdjacentFoundation
surface.resetSurfacePropertyExposedFoundationPerimeter
next unless surface.isGroundSurface
next if surface.outsideBoundaryCondition.capitalize == boundary
next unless surface.outsideBoundaryCondition.capitalize == "Foundation"

lc = surface.construction.empty? ? nil : surface.construction.get
surface.setOutsideBoundaryCondition(boundary)
next if boundary == "Ground"
next if lc.nil?

surface.setConstruction(lc) if surface.construction.empty?
end

perimeters = model.getSurfacePropertyExposedFoundationPerimeters
Expand Down Expand Up @@ -834,11 +829,16 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})
edges.each do |code1, edge|
edge[:surfaces].keys.each do |id|
next unless floors.key?(id)

next unless floors[id][:boundary].downcase == "foundation"
next if floors[id].key?(:kiva)

floors[id][:kiva ] = :slab # initially slabs-on-grade
floors[id][:exposed] = 0.0 # slab-on-grade or walkout perimeter
# Initially set as slab-on-grade. Track 'exposed foundation perimeter'.
# - outdoor wall/slab-on-grade edge lengths
# - outdoor wall/basement slab walkout edge lengths
# - basement wall/basement slab edge lengths
floors[id][:kiva ] = :slab
floors[id][:exposed] = 0.0

# Loop around current edge.
edge[:surfaces].keys.each do |i|
Expand All @@ -847,8 +847,9 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})
next unless walls[i][:boundary].downcase == "foundation"
next if walls[i].key?(:kiva)

floors[id][:kiva] = :basement
walls[i ][:kiva] = id
floors[id][:kiva ] = :basement
floors[id][:exposed] += edge[:length]
walls[i ][:kiva ] = id
end

# Loop around current edge.
Expand All @@ -862,7 +863,7 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})

# Loop around other floor edges.
edges.each do |code2, e|
next if code1 == code2 # skip - same edge
next if code1 == code2 # skip - same edge

e[:surfaces].keys.each do |i|
next unless i == id # good - same floor
Expand All @@ -873,8 +874,9 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})
next unless walls[ii][:boundary].downcase == "foundation"
next if walls[ii].key?(:kiva)

floors[id][:kiva] = :basement
walls[ii ][:kiva] = id
floors[id][:kiva ] = :basement
walls[ii ][:kiva ] = id
floors[id][:exposed] += e[:length]
end

e[:surfaces].keys.each do |ii|
Expand All @@ -889,6 +891,7 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})

foundation = OpenStudio::Model::FoundationKiva.new(model)
foundation.setName("KIVA Foundation Floor #{id}")

floor = model.getSurfaceByName(id)
kiva = false if floor.empty?
next if floor.empty?
Expand Down
6 changes: 3 additions & 3 deletions lib/measures/tbd/resources/psi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1678,8 +1678,8 @@ def process(model = nil, argh = {})
# around edge with respect to a reference vector (perpendicular to the
# edge), +clockwise as one is looking in the opposite position of the edge
# vector. For instance, a vertical edge has a reference vector pointing
# North - surfaces eastward of the edge are (0°,180°], while surfaces
# westward of the edge are (180°,360°].
# North - surfaces eastward of the edge are (0deg,180deg], while surfaces
# westward of the edge are (180deg,360deg].
#
# Much of the following code is of a topological nature, and should ideally
# (or eventually) become available functionality offered by Topolys. Topolys
Expand Down Expand Up @@ -1741,7 +1741,7 @@ def process(model = nil, argh = {})

angle = reference_V.angle(farthest_V)
angle = 0 if angle.nil?
adjust = false # adjust angle [180°, 360°] if necessary
adjust = false # adjust angle [180deg, 360deg] if necessary

if vertical
adjust = true if east.dot(farthest_V) < -TOL
Expand Down
12 changes: 6 additions & 6 deletions lib/measures/tbd/resources/ua.rb
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ def uprate(model = nil, s = {}, argh = {})
# @param [Hash] s TBD surfaces (keys: Openstudio surface names)
# @option s [Bool] :deratable whether surface is deratable, s[][:deratable]
# @option s [:wall, :ceiling, :floor] :type TBD surface type
# @option s [#to_f] :heating applicable heating setpoint temperature in °C
# @option s [#to_f] :cooling applicable cooling setpoint temperature in °C
# @option s [#to_f] :heating applicable heating setpoint temperature in C
# @option s [#to_f] :cooling applicable cooling setpoint temperature in C
# @option s [Hash] :windows TBD surface-specific windows e.g. s[][:windows]
# @option s [Hash] :doors TBD surface-specific doors
# @option s [Hash] :skylights TBD surface-specific skylights
Expand Down Expand Up @@ -466,7 +466,7 @@ def qc33(s = {}, sets = nil, spts = true)
ref = 1 / 5.46
ref = 1 / 3.60 if surface[:type] == :wall

# Adjust for lower heating setpoint (assumes -25°C design conditions).
# Adjust for lower heating setpoint (assumes -25C design conditions).
ref *= 43 / (heating + 25) if heating < 18 && cooling > 40

surface[:ref] = ref
Expand Down Expand Up @@ -628,8 +628,8 @@ def ua_summary(date = Time.now, argh = {})
end

# Set up 2x heating setpoint (HSTP) "blocks" (or bins):
# bloc1: spaces/zones with HSTP >= 18°C
# bloc2: spaces/zones with HSTP < 18°C
# bloc1: spaces/zones with HSTP >= 18C
# bloc2: spaces/zones with HSTP < 18C
# (ref: 2021 Quebec energy code 3.3. UA' trade-off methodology)
# (... can be extended in the future to cover other standards)
#
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def ua_md(ua = {}, lang = :en)
model = "* modèle : #{ua[:file]}" if ua.key?(:file) && lang == :fr
model += " (v#{ua[:version]})" if ua.key?(:version)
report << model unless model.empty?
report << "* TBD : v3.4.3"
report << "* TBD : v3.4.4"
report << "* date : #{ua[:date]}"

if lang == :en
Expand Down
29 changes: 16 additions & 13 deletions lib/tbd/geo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -722,15 +722,10 @@ def resetKIVA(model = nil, boundary = "Foundation")
kva = true unless surface.surfacePropertyExposedFoundationPerimeter.empty?
surface.resetAdjacentFoundation
surface.resetSurfacePropertyExposedFoundationPerimeter
next unless surface.isGroundSurface
next if surface.outsideBoundaryCondition.capitalize == boundary
next unless surface.outsideBoundaryCondition.capitalize == "Foundation"

lc = surface.construction.empty? ? nil : surface.construction.get
surface.setOutsideBoundaryCondition(boundary)
next if boundary == "Ground"
next if lc.nil?

surface.setConstruction(lc) if surface.construction.empty?
end

perimeters = model.getSurfacePropertyExposedFoundationPerimeters
Expand Down Expand Up @@ -834,11 +829,16 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})
edges.each do |code1, edge|
edge[:surfaces].keys.each do |id|
next unless floors.key?(id)

next unless floors[id][:boundary].downcase == "foundation"
next if floors[id].key?(:kiva)

floors[id][:kiva ] = :slab # initially slabs-on-grade
floors[id][:exposed] = 0.0 # slab-on-grade or walkout perimeter
# Initially set as slab-on-grade. Track 'exposed foundation perimeter'.
# - outdoor wall/slab-on-grade edge lengths
# - outdoor wall/basement slab walkout edge lengths
# - basement wall/basement slab edge lengths
floors[id][:kiva ] = :slab
floors[id][:exposed] = 0.0

# Loop around current edge.
edge[:surfaces].keys.each do |i|
Expand All @@ -847,8 +847,9 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})
next unless walls[i][:boundary].downcase == "foundation"
next if walls[i].key?(:kiva)

floors[id][:kiva] = :basement
walls[i ][:kiva] = id
floors[id][:kiva ] = :basement
floors[id][:exposed] += edge[:length]
walls[i ][:kiva ] = id
end

# Loop around current edge.
Expand All @@ -862,7 +863,7 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})

# Loop around other floor edges.
edges.each do |code2, e|
next if code1 == code2 # skip - same edge
next if code1 == code2 # skip - same edge

e[:surfaces].keys.each do |i|
next unless i == id # good - same floor
Expand All @@ -873,8 +874,9 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})
next unless walls[ii][:boundary].downcase == "foundation"
next if walls[ii].key?(:kiva)

floors[id][:kiva] = :basement
walls[ii ][:kiva] = id
floors[id][:kiva ] = :basement
walls[ii ][:kiva ] = id
floors[id][:exposed] += e[:length]
end

e[:surfaces].keys.each do |ii|
Expand All @@ -889,6 +891,7 @@ def kiva(model = nil, walls = {}, floors = {}, edges = {})

foundation = OpenStudio::Model::FoundationKiva.new(model)
foundation.setName("KIVA Foundation Floor #{id}")

floor = model.getSurfaceByName(id)
kiva = false if floor.empty?
next if floor.empty?
Expand Down
6 changes: 3 additions & 3 deletions lib/tbd/psi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1678,8 +1678,8 @@ def process(model = nil, argh = {})
# around edge with respect to a reference vector (perpendicular to the
# edge), +clockwise as one is looking in the opposite position of the edge
# vector. For instance, a vertical edge has a reference vector pointing
# North - surfaces eastward of the edge are (0°,180°], while surfaces
# westward of the edge are (180°,360°].
# North - surfaces eastward of the edge are (0deg,180deg], while surfaces
# westward of the edge are (180deg,360deg].
#
# Much of the following code is of a topological nature, and should ideally
# (or eventually) become available functionality offered by Topolys. Topolys
Expand Down Expand Up @@ -1741,7 +1741,7 @@ def process(model = nil, argh = {})

angle = reference_V.angle(farthest_V)
angle = 0 if angle.nil?
adjust = false # adjust angle [180°, 360°] if necessary
adjust = false # adjust angle [180deg, 360deg] if necessary

if vertical
adjust = true if east.dot(farthest_V) < -TOL
Expand Down
12 changes: 6 additions & 6 deletions lib/tbd/ua.rb
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ def uprate(model = nil, s = {}, argh = {})
# @param [Hash] s TBD surfaces (keys: Openstudio surface names)
# @option s [Bool] :deratable whether surface is deratable, s[][:deratable]
# @option s [:wall, :ceiling, :floor] :type TBD surface type
# @option s [#to_f] :heating applicable heating setpoint temperature in °C
# @option s [#to_f] :cooling applicable cooling setpoint temperature in °C
# @option s [#to_f] :heating applicable heating setpoint temperature in C
# @option s [#to_f] :cooling applicable cooling setpoint temperature in C
# @option s [Hash] :windows TBD surface-specific windows e.g. s[][:windows]
# @option s [Hash] :doors TBD surface-specific doors
# @option s [Hash] :skylights TBD surface-specific skylights
Expand Down Expand Up @@ -466,7 +466,7 @@ def qc33(s = {}, sets = nil, spts = true)
ref = 1 / 5.46
ref = 1 / 3.60 if surface[:type] == :wall

# Adjust for lower heating setpoint (assumes -25°C design conditions).
# Adjust for lower heating setpoint (assumes -25C design conditions).
ref *= 43 / (heating + 25) if heating < 18 && cooling > 40

surface[:ref] = ref
Expand Down Expand Up @@ -628,8 +628,8 @@ def ua_summary(date = Time.now, argh = {})
end

# Set up 2x heating setpoint (HSTP) "blocks" (or bins):
# bloc1: spaces/zones with HSTP >= 18°C
# bloc2: spaces/zones with HSTP < 18°C
# bloc1: spaces/zones with HSTP >= 18C
# bloc2: spaces/zones with HSTP < 18C
# (ref: 2021 Quebec energy code 3.3. UA' trade-off methodology)
# (... can be extended in the future to cover other standards)
#
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def ua_md(ua = {}, lang = :en)
model = "* modèle : #{ua[:file]}" if ua.key?(:file) && lang == :fr
model += " (v#{ua[:version]})" if ua.key?(:version)
report << model unless model.empty?
report << "* TBD : v3.4.3"
report << "* TBD : v3.4.4"
report << "* date : #{ua[:date]}"

if lang == :en
Expand Down
2 changes: 1 addition & 1 deletion lib/tbd/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
# SOFTWARE.

module TBD
VERSION = "3.4.3".freeze # TBD release version
VERSION = "3.4.4".freeze # TBD release version
end
Loading

0 comments on commit 22f7c2c

Please sign in to comment.