lib/measures/tbd/resources/ua.rb in tbd-3.1.1 vs lib/measures/tbd/resources/ua.rb in tbd-3.2.0

- old
+ new

@@ -1,8 +1,8 @@ # MIT License # -# Copyright (c) 2020-2022 Denis Bourgeois & Dan Macumber +# Copyright (c) 2020-2023 Denis Bourgeois & Dan Macumber # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -45,22 +45,22 @@ return mismatch("lc", lc, cl2, mth, DBG, res) unless lc.is_a?(cl2) return mismatch("hloss", hloss, cl3, mth, DBG, res) unless hloss.is_a?(cl3) return mismatch("film", film, cl3, mth, DBG, res) unless film.is_a?(cl3) return mismatch("Ut", ut, cl3, mth, DBG, res) unless ut.is_a?(cl3) + loss = 0.0 # residual heatloss (not assigned) [W/K] + area = lc.getNetArea lyr = insulatingLayer(lc) lyr[:index] = nil unless lyr[:index].is_a?(Numeric) lyr[:index] = nil unless lyr[:index] >= 0 lyr[:index] = nil unless lyr[:index] < lc.layers.size return invalid("'#{id}' layer index", mth, 0, ERR, res) unless lyr[:index] return zero("'#{id}': heatloss", mth, WRN, res) unless hloss > TOL return zero("'#{id}': films", mth, WRN, res) unless film > TOL return zero("'#{id}': Ut", mth, WRN, res) unless ut > TOL return invalid("'#{id}': Ut", mth, 0, WRN, res) unless ut < 5.678 - - area = lc.getNetArea return zero("'#{id}': net area (m2)", mth, ERR, res) unless area > TOL # First, calculate initial layer RSi to initially meet Ut target. rt = 1 / ut # target construction Rt ro = rsi(lc, film) # current construction Ro @@ -72,22 +72,20 @@ new_u -= u_psi # uprated layer USi to counter psi & khi new_r = 1 / new_u # uprated layer RSi to counter psi & khi return zero("'#{id}': new Rsi", mth, ERR, res) unless new_r > 0.001 - loss = 0.0 # residual heatloss (not assigned) [W/K] - if lyr[:type] == :massless m = lc.getLayer(lyr[:index]).to_MasslessOpaqueMaterial return invalid("'#{id}' massless layer?", mth, 0) if m.empty? m = m.get.clone(model).to_MasslessOpaqueMaterial.get m.setName("#{id} uprated") new_r = 0.001 unless new_r > 0.001 loss = (new_u - 1 / new_r) * area unless new_r > 0.001 m.setThermalResistance(new_r) - else # type == :standard + else # type == :standard m = lc.getLayer(lyr[:index]).to_StandardOpaqueMaterial return invalid("'#{id}' standard layer?", mth, 0) if m.empty? m = m.get.clone(model).to_StandardOpaqueMaterial.get m.setName("#{id} uprated") @@ -593,84 +591,53 @@ next unless type == :wall || type == :ceiling || type == :floor next unless surface.key?(:net) next unless surface[:net] > TOL next unless surface.key?(:u) next unless surface[:u] > TOL - heating = 21.0 - heating = surface[:heating] if surface.key?(:heating) - bloc = b1 - bloc = b2 if heating < 18 - + heating = 21.0 + heating = surface[:heating] if surface.key?(:heating) + bloc = b1 + bloc = b2 if heating < 18 reference = surface.key?(:ref) + if type == :wall areas[:walls][:net ] += surface[:net] - bloc[:pro][:walls ] += surface[:net] * surface[:u ] - bloc[:ref][:walls ] += surface[:net] * surface[:ref] if reference - bloc[:ref][:walls ] += surface[:net] * surface[:u ] unless reference + bloc[:pro][:walls ] += surface[:net] * surface[:u ] + bloc[:ref][:walls ] += surface[:net] * surface[:ref] if reference + bloc[:ref][:walls ] += surface[:net] * surface[:u ] unless reference elsif type == :ceiling areas[:roofs][:net ] += surface[:net] - bloc[:pro][:roofs ] += surface[:net] * surface[:u ] - bloc[:ref][:roofs ] += surface[:net] * surface[:ref] if reference - bloc[:ref][:roofs ] += surface[:net] * surface[:u ] unless reference + bloc[:pro][:roofs ] += surface[:net] * surface[:u ] + bloc[:ref][:roofs ] += surface[:net] * surface[:ref] if reference + bloc[:ref][:roofs ] += surface[:net] * surface[:u ] unless reference else areas[:floors][:net] += surface[:net] - bloc[:pro][:floors] += surface[:net] * surface[:u ] - bloc[:ref][:floors] += surface[:net] * surface[:ref] if reference - bloc[:ref][:floors] += surface[:net] * surface[:u ] unless reference + bloc[:pro][:floors ] += surface[:net] * surface[:u ] + bloc[:ref][:floors ] += surface[:net] * surface[:ref] if reference + bloc[:ref][:floors ] += surface[:net] * surface[:u ] unless reference end - if surface.key?(:doors) - surface[:doors].values.each do |door| - next unless door.key?(:gross) - next unless door[:gross] > TOL - next unless door.key?(:u) - next unless door[:u] > TOL - areas[:walls][:subs ] += door[:gross] if type == :wall - areas[:roofs][:subs ] += door[:gross] if type == :ceiling - areas[:floors][:subs] += door[:gross] if type == :floor - bloc[:pro][:doors ] += door[:gross] * door[:u] + [:doors, :windows, :skylights].each do |subs| + next unless surface.key?(subs) - ok = door.key?(:ref) - bloc[:ref][:doors ] += door[:gross] * door[:ref] if ok - bloc[:ref][:doors ] += door[:gross] * door[:u ] unless ok - end - end + surface[subs].values.each do |sub| + next unless sub.key?(:gross) + next unless sub.key?(:u ) + next unless sub[:gross] > TOL + next unless sub[:u ] > TOL - if surface.key?(:windows) - surface[:windows].values.each do |window| - next unless window.key?(:gross) - next unless window[:gross] > TOL - next unless window.key?(:u) - next unless window[:u] > TOL - areas[:walls][:subs ] += window[:gross] if type == :wall - areas[:roofs][:subs ] += window[:gross] if type == :ceiling - areas[:floors][:subs] += window[:gross] if type == :floor - bloc[:pro][:windows] += window[:gross] * window[:u] - - ok = window.key?(:ref) - bloc[:ref][:windows ] += window[:gross] * window[:ref] if ok - bloc[:ref][:windows ] += window[:gross] * window[:u ] unless ok + gross = sub[:gross] + gross *= sub[:mult ] if sub.key?(:mult) + areas[:walls ][:subs] += gross if type == :wall + areas[:roofs ][:subs] += gross if type == :ceiling + areas[:floors][:subs] += gross if type == :floor + bloc[:pro ][subs ] += gross * sub[:u ] + bloc[:ref ][subs ] += gross * sub[:ref] if sub.key?(:ref) + bloc[:ref ][subs ] += gross * sub[:u ] unless sub.key?(:ref) end end - if surface.key?(:skylights) - surface[:skylights].values.each do |sky| - next unless sky.key?(:gross) - next unless sky[:gross] > TOL - next unless sky.key?(:u) - next unless sky[:u] > TOL - areas[:walls][:subs ] += sky[:gross] if type == :wall - areas[:roofs][:subs ] += sky[:gross] if type == :ceiling - areas[:floors][:subs ] += sky[:gross] if type == :floor - bloc[:pro][:skylights] += sky[:gross] * sky[:u] - - ok = sky.key?(:ref) - bloc[:ref][:skylights] += sky[:gross] * sky[:ref] if ok - bloc[:ref][:skylights] += sky[:gross] * sky[:u ] unless ok - end - end - if surface.key?(:edges) surface[:edges].values.each do |edge| next unless edge.key?(:type) next unless edge.key?(:length) next unless edge[:length] > TOL @@ -951,10 +918,10 @@ model = "" model = "* model : #{ua[:file]}" if ua.key?(:file) && 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.1.1" + report << "* TBD : v3.2.0" report << "* date : #{ua[:date]}" if lang == :en report << "* status : #{msg(status)}" unless status.zero? report << "* status : success !" if status.zero?