Skip to content

Commit

Permalink
Merge pull request #118 from rd2/seb
Browse files Browse the repository at this point in the history
Pulls OSut v0.6.0 + SEB fixes
  • Loading branch information
brgix authored Oct 16, 2024
2 parents 483dbdc + 6a5c3fa commit 16410d0
Show file tree
Hide file tree
Showing 11 changed files with 1,691 additions and 1,032 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ task :libraries do

libs = ["topolys", "osut", "oslg", "tbd"]
files = {}

$:.each do |path|
libs.each do |l|
next unless path.include?(l)
Expand Down
12 changes: 6 additions & 6 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>3ebf3217-230b-4420-b679-4bdf8cc51519</version_id>
<version_modified>2024-05-22T14:33:33Z</version_modified>
<version_id>12467d7f-9058-4028-b6f8-0448e81b7fef</version_id>
<version_modified>2024-10-15T18:51:39Z</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 @@ -523,13 +523,13 @@
<filename>psi.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>5ABDA733</checksum>
<checksum>25CD6251</checksum>
</file>
<file>
<filename>tbd.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>E8D38E59</checksum>
<checksum>FCCCAE84</checksum>
</file>
<file>
<filename>transformation.rb</filename>
Expand All @@ -541,13 +541,13 @@
<filename>ua.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>4133AC61</checksum>
<checksum>013BA732</checksum>
</file>
<file>
<filename>utils.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>E3B4AF4B</checksum>
<checksum>CBC3935D</checksum>
</file>
<file>
<filename>version.rb</filename>
Expand Down
59 changes: 18 additions & 41 deletions lib/measures/tbd/resources/psi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1717,49 +1717,26 @@ def process(model = nil, argh = {})
t_model.wires.each do |wire|
next unless surface[:wire] == wire.id # should be a unique match

normal = tbd[:surfaces][id][:n] if tbd[:surfaces].key?(id)
normal = holes[id].attributes[:n] if holes.key?(id)
normal = shades[id][:n] if shades.key?(id)
farthest = Topolys::Point3D.new(origin.x, origin.y, origin.z)
farthest_V = farthest - origin # zero magnitude, initially
inverted = false
i_origin = wire.points.index(origin)
i_terminal = wire.points.index(terminal)
i_last = wire.points.size - 1

if i_terminal == 0
inverted = true unless i_origin == i_last
elsif i_origin == i_last
inverted = true unless i_terminal == 0
else
inverted = true unless i_terminal - i_origin == 1
end
normal = tbd[:surfaces][id][:n] if tbd[:surfaces].key?(id)
normal = holes[id].attributes[:n] if holes.key?(id)
normal = shades[id][:n] if shades.key?(id)
farthest = Topolys::Point3D.new(origin.x, origin.y, origin.z)
farthest_V = farthest - origin # zero magnitude, initially
farthest_mag = 0

wire.points.each do |point|
next if point == origin
next if point == terminal

point_on_plane = edge_plane.project(point)
origin_point_V = point_on_plane - origin
point_V_magnitude = origin_point_V.magnitude
next unless point_V_magnitude > TOL

# Generate a plane between origin, terminal & point. Only consider
# planes that share the same normal as wire.
if inverted
plane = Topolys::Plane3D.from_points(terminal, origin, point)
else
plane = Topolys::Plane3D.from_points(origin, terminal, point)
end

dnx = (normal.x - plane.normal.x).abs
dny = (normal.y - plane.normal.y).abs
dnz = (normal.z - plane.normal.z).abs
next unless dnx < TOL && dny < TOL && dnz < TOL
point_on_plane = edge_plane.project(point)
origin_point_V = point_on_plane - origin
point_V_mag = origin_point_V.magnitude
next unless point_V_mag > TOL
next unless point_V_mag > farthest_mag

farther = point_V_magnitude > farthest_V.magnitude
farthest = point if farther
farthest_V = origin_point_V if farther
farthest = point
farthest_V = origin_point_V
fathest_mag = point_V_mag
end

angle = reference_V.angle(farthest_V)
Expand Down Expand Up @@ -2125,7 +2102,7 @@ def process(model = nil, argh = {})
end

# Label edge as :ceiling if linked to:
# +1 deratable surfaces
# +1 deratable surface(s)
# 1x underatable CONDITIONED floor linked to an unoccupied space
# 1x adjacent CONDITIONED ceiling linked to an occupied space
edge[:surfaces].keys.each do |i|
Expand All @@ -2139,9 +2116,9 @@ def process(model = nil, argh = {})
next if floors[i][:occupied ]

ceiling = floors[i][:boundary]
next unless ceilings.key?(ceiling)
next unless ceilings[ceiling][:conditioned]
next unless ceilings[ceiling][:occupied ]
next unless ceilings.key?(ceiling)
next unless ceilings[ceiling][:conditioned]
next unless ceilings[ceiling][:occupied ]

other = deratables.first unless deratables.first == id
other = deratables.last unless deratables.last == id
Expand Down
20 changes: 10 additions & 10 deletions lib/measures/tbd/resources/tbd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
require_relative "ua"

module TBD
extend OSut # OpenStudio utilities

TOL = OSut::TOL
TOL2 = OSut::TOL2
DBG = OSut::DEBUG # mainly to flag invalid arguments for devs (buggy code)
INF = OSut::INFO # informs TBD user of measure success or failure
WRN = OSut::WARN # e.g. WARN users of 'iffy' .osm inputs (yet not critical)
ERR = OSut::ERR # e.g. flag invalid .osm inputs
FTL = OSut::FATAL # e.g. invalid TBD JSON format/entries
NS = "nameString" # OpenStudio IdfObject nameString method
extend OSut # OpenStudio utilities

TOL = OSut::TOL.dup # default distance tolerance (m)
TOL2 = OSut::TOL2.dup # default area tolerance (m2)
DBG = OSut::DEBUG.dup # github.com/rd2/oslg
INF = OSut::INFO.dup # github.com/rd2/oslg
WRN = OSut::WARN.dup # github.com/rd2/oslg
ERR = OSut::ERR.dup # github.com/rd2/oslg
FTL = OSut::FATAL.dup # github.com/rd2/oslg
NS = OSut::NS.dup # OpenStudio IdfObject nameString method

extend TBD
end
6 changes: 3 additions & 3 deletions lib/measures/tbd/resources/ua.rb
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,8 @@ def ua_summary(date = Time.now, argh = {})
blc.each do |b|
bloc = b1
bloc = b2 if b == :b2
pro_sum = bloc[:pro].values.reduce(:+)
ref_sum = bloc[:ref].values.reduce(:+)
pro_sum = bloc[:pro].values.sum
ref_sum = bloc[:ref].values.sum

if pro_sum > TOL || ref_sum > TOL
ratio = nil
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.2"
report << "* TBD : v3.4.3"
report << "* date : #{ua[:date]}"

if lang == :en
Expand Down
Loading

0 comments on commit 16410d0

Please sign in to comment.