tbd 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +3 -0
  3. data/.github/workflows/pull_request.yml +72 -0
  4. data/.gitignore +23 -0
  5. data/.rspec +3 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.md +21 -0
  8. data/README.md +154 -0
  9. data/Rakefile +60 -0
  10. data/json/midrise.json +64 -0
  11. data/json/tbd_5ZoneNoHVAC.json +19 -0
  12. data/json/tbd_5ZoneNoHVAC_btap.json +91 -0
  13. data/json/tbd_seb_n2.json +41 -0
  14. data/json/tbd_seb_n4.json +57 -0
  15. data/json/tbd_warehouse10.json +24 -0
  16. data/json/tbd_warehouse5.json +37 -0
  17. data/lib/measures/tbd/LICENSE.md +21 -0
  18. data/lib/measures/tbd/README.md +136 -0
  19. data/lib/measures/tbd/README.md.erb +42 -0
  20. data/lib/measures/tbd/docs/.gitkeep +1 -0
  21. data/lib/measures/tbd/measure.rb +327 -0
  22. data/lib/measures/tbd/measure.xml +460 -0
  23. data/lib/measures/tbd/resources/geo.rb +714 -0
  24. data/lib/measures/tbd/resources/geometry.rb +351 -0
  25. data/lib/measures/tbd/resources/model.rb +1431 -0
  26. data/lib/measures/tbd/resources/oslog.rb +381 -0
  27. data/lib/measures/tbd/resources/psi.rb +2229 -0
  28. data/lib/measures/tbd/resources/tbd.rb +55 -0
  29. data/lib/measures/tbd/resources/transformation.rb +121 -0
  30. data/lib/measures/tbd/resources/ua.rb +986 -0
  31. data/lib/measures/tbd/resources/utils.rb +1636 -0
  32. data/lib/measures/tbd/resources/version.rb +3 -0
  33. data/lib/measures/tbd/tests/tbd_full_PSI.json +17 -0
  34. data/lib/measures/tbd/tests/tbd_tests.rb +222 -0
  35. data/lib/tbd/geo.rb +714 -0
  36. data/lib/tbd/psi.rb +2229 -0
  37. data/lib/tbd/ua.rb +986 -0
  38. data/lib/tbd/version.rb +25 -0
  39. data/lib/tbd.rb +93 -0
  40. data/sponsors/canada.png +0 -0
  41. data/sponsors/quebec.png +0 -0
  42. data/tbd.gemspec +43 -0
  43. data/tbd.schema.json +571 -0
  44. data/v291_MacOS.md +110 -0
  45. metadata +191 -0
@@ -0,0 +1,3 @@
1
+ module Topolys
2
+ VERSION = "0.6.0"
3
+ end
@@ -0,0 +1,17 @@
1
+ {
2
+ "description": "TBD JSON example - full PSI-only",
3
+ "schema": "https://github.com/rd2/tbd/blob/master/tbd.schema.json",
4
+ "psis": [
5
+ {
6
+ "id": "OK",
7
+ "rimjoist": 0.700,
8
+ "parapet": 0.700,
9
+ "fenestration": 0.700,
10
+ "corner": 0.700,
11
+ "balcony": 1.000,
12
+ "party": 0.700,
13
+ "party": 0.800,
14
+ "grade": 0.700
15
+ }
16
+ ]
17
+ }
@@ -0,0 +1,222 @@
1
+ # MIT License
2
+ #
3
+ # Copyright (c) 2020-2022 Denis Bourgeois & Dan Macumber
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require "openstudio"
24
+ require "openstudio/measure/ShowRunnerOutput"
25
+ require "minitest/autorun"
26
+ require "fileutils"
27
+
28
+ require_relative "../measure.rb"
29
+
30
+
31
+ class TBDTest < Minitest::Test
32
+ # def setup
33
+ # end
34
+
35
+ # def teardown
36
+ # end
37
+
38
+ def test_number_of_arguments_and_argument_names
39
+ # create an instance of the measure
40
+ measure = TBDMeasure.new
41
+ # make an empty model
42
+ model = OpenStudio::Model::Model.new
43
+
44
+ # get arguments and test that they are what we are expecting
45
+ arguments = measure.arguments(model)
46
+ assert_equal(14, arguments.size)
47
+ end
48
+
49
+ def test_no_load_tbd_json
50
+ # create an instance of the measure
51
+ measure = TBDMeasure.new
52
+
53
+ # Output dirs
54
+ seed_dir = File.join(__dir__, 'output/no_load_tbd_json/')
55
+ FileUtils.mkdir_p(seed_dir)
56
+ seed_path = File.join(seed_dir, 'in.osm')
57
+
58
+ # create runner with empty OSW
59
+ osw = OpenStudio::WorkflowJSON.new
60
+ osw.setSeedFile(seed_path)
61
+ runner = OpenStudio::Measure::OSRunner.new(osw)
62
+
63
+ # create example test model
64
+ model = OpenStudio::Model::exampleModel
65
+ model.save(seed_path, true)
66
+
67
+ # get arguments
68
+ arguments = measure.arguments(model)
69
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
70
+
71
+ # Create hash of argument values. If the argument has a default that you
72
+ # want to use, you don't need it in the hash.
73
+ args_hash = {}
74
+ args_hash["option" ] = "efficient (BETBG)"
75
+ args_hash["write_tbd_json"] = true
76
+ args_hash["gen_UA_report" ] = true
77
+ args_hash["wall_option" ] = "ALL wall constructions"
78
+ args_hash["wall_ut" ] = 0.5
79
+ # using defaults values from measure.rb for other arguments
80
+
81
+ # populate argument with specified hash value if specified
82
+ arguments.each do |arg|
83
+ temp_arg_var = arg.clone
84
+ gotit = args_hash.key?(arg.name)
85
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if gotit
86
+ argument_map[arg.name] = temp_arg_var
87
+ end
88
+
89
+ # run the measure
90
+ Dir.chdir(seed_dir)
91
+ measure.run(model, runner, argument_map)
92
+ result = runner.result
93
+
94
+ # show the output
95
+ show_output(result)
96
+
97
+ # assert that it ran correctly
98
+ assert_equal('Success', result.value.valueName)
99
+ assert(result.warnings.empty?)
100
+
101
+ # save the model to test output directory
102
+ #output_file_path = "#{File.dirname(__FILE__)}//output/test_output.osm"
103
+ #model.save(output_file_path, true)
104
+ end
105
+
106
+ def test_load_tbd_json
107
+ # create an instance of the measure
108
+ measure = TBDMeasure.new
109
+
110
+ # Output dirs
111
+ seed_dir = File.join(__dir__, "output/load_tbd_json/")
112
+ FileUtils.mkdir_p(seed_dir)
113
+ seed_path = File.join(seed_dir, "in.osm")
114
+
115
+ # create runner with empty OSW
116
+ osw = OpenStudio::WorkflowJSON.new
117
+ osw.setSeedFile(seed_path)
118
+ runner = OpenStudio::Measure::OSRunner.new(osw)
119
+
120
+ # create example test model
121
+ model = OpenStudio::Model::exampleModel
122
+ model.save(seed_path, true)
123
+
124
+ # copy tdb.json next to seed
125
+ origin_pth = File.join(__dir__, "tbd_full_PSI.json")
126
+ target_pth = File.join(seed_dir, "tbd.json")
127
+ FileUtils.cp(origin_pth, target_pth)
128
+
129
+ # get arguments
130
+ arguments = measure.arguments(model)
131
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
132
+
133
+ # Create hash of argument values. If the argument has a default that you
134
+ # want to use, you don't need it in the hash.
135
+ args_hash = {"load_tbd_json" => true}
136
+ # using defaults values from measure.rb for other arguments
137
+
138
+ # populate argument with specified hash value if specified
139
+ arguments.each do |arg|
140
+ temp_arg_var = arg.clone
141
+ if args_hash.key?(arg.name)
142
+ assert(temp_arg_var.setValue(args_hash[arg.name]))
143
+ end
144
+ argument_map[arg.name] = temp_arg_var
145
+ end
146
+
147
+ # run the measure
148
+ Dir.chdir(seed_dir)
149
+ measure.run(model, runner, argument_map)
150
+ result = runner.result
151
+
152
+ # show the output
153
+ show_output(result)
154
+
155
+ # assert that it ran correctly
156
+ assert_equal('Success', result.value.valueName)
157
+ assert(result.warnings.empty?)
158
+
159
+ # save the model to test output directory
160
+ #output_file_path = "#{File.dirname(__FILE__)}//output/test_output.osm"
161
+ #model.save(output_file_path, true)
162
+ end
163
+
164
+ def test_load_tbd_json_error
165
+ # create an instance of the measure
166
+ measure = TBDMeasure.new
167
+
168
+ # Output dirs
169
+ seed_dir = File.join(__dir__, "output/load_tbd_json_error/")
170
+ FileUtils.mkdir_p(seed_dir)
171
+ seed_path = File.join(seed_dir, "in.osm")
172
+
173
+ # create runner with empty OSW
174
+ osw = OpenStudio::WorkflowJSON.new
175
+ osw.setSeedFile(seed_path)
176
+ runner = OpenStudio::Measure::OSRunner.new(osw)
177
+
178
+ # create example test model
179
+ model = OpenStudio::Model::exampleModel
180
+ model.save(seed_path, true)
181
+
182
+ # do not copy tdb.json next to seed
183
+
184
+ # get arguments
185
+ arguments = measure.arguments(model)
186
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
187
+
188
+ # Create hash of argument values. If the argument has a default that you
189
+ # want to use, you don't need it in the hash.
190
+ args_hash = {"load_tbd_json" => true}
191
+ # using defaults values from measure.rb for other arguments
192
+
193
+ # populate argument with specified hash value if specified
194
+ arguments.each do |arg|
195
+ temp_arg_var = arg.clone
196
+ if args_hash.key?(arg.name)
197
+ assert(temp_arg_var.setValue(args_hash[arg.name]))
198
+ end
199
+ argument_map[arg.name] = temp_arg_var
200
+ end
201
+
202
+ # run the measure
203
+ Dir.chdir(seed_dir)
204
+ measure.run(model, runner, argument_map)
205
+ result = runner.result
206
+
207
+ # show the output
208
+ show_output(result)
209
+
210
+ # assert that it ran correctly
211
+ assert_equal('Fail', result.value.valueName)
212
+ assert(result.errors.size == 1)
213
+ assert(result.warnings.size == 1)
214
+ puts result.warnings[0].logMessage
215
+ log_message = "Can't find 'tbd.json' - simulation halted"
216
+ assert(result.warnings[0].logMessage == log_message)
217
+
218
+ # save the model to test output directory
219
+ #output_file_path = "#{File.dirname(__FILE__)}//output/test_output.osm"
220
+ #model.save(output_file_path, true)
221
+ end
222
+ end