lib/measures/tbd/measure.rb in tbd-3.1.1 vs lib/measures/tbd/measure.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
@@ -46,10 +46,19 @@
alter.setDisplayName("Alter OpenStudio model (Apply Measures Now)")
alter.setDescription(dsc)
alter.setDefaultValue(true)
args << alter
+ arg = "sub_tol"
+ dsc = "Proximity tolerance (e.g. 0.100 m) between subsurface edges, e.g. " \
+ "between near-adjacent window jambs."
+ sub_tol = OpenStudio::Measure::OSArgument.makeDoubleArgument(arg, false)
+ sub_tol.setDisplayName("Proximity tolerance (m)")
+ sub_tol.setDescription(dsc)
+ sub_tol.setDefaultValue(TBD::TOL)
+ args << sub_tol
+
arg = "load_tbd_json"
dsc = "Loads existing 'tbd.json' file (under '/files'), may override " \
"'default thermal bridge' set."
load_tbd = OpenStudio::Measure::OSArgument.makeBoolArgument(arg, false)
load_tbd.setDisplayName("Load 'tbd.json'")
@@ -223,10 +232,11 @@
def run(mdl, runner, args)
super(mdl, runner, args)
argh = {}
argh[:alter ] = runner.getBoolArgumentValue("alter_model", args)
+ argh[:sub_tol ] = runner.getDoubleArgumentValue("sub_tol", args)
argh[:load_tbd ] = runner.getBoolArgumentValue("load_tbd_json", args)
argh[:option ] = runner.getStringArgumentValue("option", args)
argh[:write_tbd ] = runner.getBoolArgumentValue("write_tbd_json", args)
argh[:wall_ut ] = runner.getDoubleArgumentValue("wall_ut", args)
argh[:roof_ut ] = runner.getDoubleArgumentValue("roof_ut", args)
@@ -284,10 +294,42 @@
# TBD.log(TBD::INF, "Using inputs from #{argh[:io_path]}") # debugging
# runner.registerInfo("Using inputs from #{argh[:io_path]}") # debugging
end
end
+ # Pre-validate ground-facing constructions for KIVA.
+ if argh[:kiva_force] || argh[:gen_kiva]
+ kva = true
+
+ mdl.getSurfaces.each do |s|
+ id = s.nameString
+ construction = s.construction
+ next unless s.isGroundSurface
+
+ if construction.empty?
+ runner.registerError("Invalid construction for KIVA (#{id})")
+ kva = false if kva
+ else
+ construction = construction.get.to_LayeredConstruction
+
+ if construction.empty?
+ runner.registerError("KIVA requires layered constructions (#{id})")
+ kva = false if kva
+ else
+ construction = construction.get
+
+ unless TBD.standardOpaqueLayers?(construction)
+ runner.registerError("KIVA requires standard materials (#{id})")
+ kva = false if kva
+ end
+ end
+ end
+ end
+
+ return false unless kva
+ end
+
# Process all ground-facing surfaces as foundation-facing.
if argh[:kiva_force]
argh[:gen_kiva] = true
mdl.getSurfaces.each do |s|
@@ -311,10 +353,10 @@
model.addObjects(mdl.toIdfFile.objects)
end
argh[:version ] = model.getVersion.versionIdentifier
tbd = TBD.process(model, argh)
- argh[:io ] = tbd[:io]
+ argh[:io ] = tbd[:io ]
argh[:surfaces] = tbd[:surfaces]
setpoints = TBD.heatingTemperatureSetpoints?(model)
setpoints = TBD.coolingTemperatureSetpoints?(model) || setpoints
argh[:setpoints] = setpoints