openstudio-extension 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +14 -0
  4. data/LICENSE.md +1 -1
  5. data/README.md +2 -0
  6. data/lib/openstudio/extension/runner.rb +12 -8
  7. data/lib/openstudio/extension/runner_config.rb +33 -6
  8. data/lib/openstudio/extension/version.rb +1 -1
  9. data/openstudio-extension.gemspec +6 -6
  10. metadata +15 -66
  11. data/lib/openstudio/extension/core/CreateResults.rb +0 -1033
  12. data/lib/openstudio/extension/core/check_air_sys_temps.rb +0 -160
  13. data/lib/openstudio/extension/core/check_calibration.rb +0 -125
  14. data/lib/openstudio/extension/core/check_cond_zns.rb +0 -54
  15. data/lib/openstudio/extension/core/check_domestic_hot_water.rb +0 -304
  16. data/lib/openstudio/extension/core/check_envelope_conductance.rb +0 -423
  17. data/lib/openstudio/extension/core/check_eui_by_end_use.rb +0 -132
  18. data/lib/openstudio/extension/core/check_eui_reasonableness.rb +0 -105
  19. data/lib/openstudio/extension/core/check_fan_pwr.rb +0 -68
  20. data/lib/openstudio/extension/core/check_internal_loads.rb +0 -363
  21. data/lib/openstudio/extension/core/check_mech_sys_capacity.rb +0 -196
  22. data/lib/openstudio/extension/core/check_mech_sys_efficiency.rb +0 -296
  23. data/lib/openstudio/extension/core/check_mech_sys_part_load_eff.rb +0 -434
  24. data/lib/openstudio/extension/core/check_mech_sys_type.rb +0 -109
  25. data/lib/openstudio/extension/core/check_part_loads.rb +0 -421
  26. data/lib/openstudio/extension/core/check_placeholder.rb +0 -45
  27. data/lib/openstudio/extension/core/check_plant_cap.rb +0 -93
  28. data/lib/openstudio/extension/core/check_plant_temps.rb +0 -129
  29. data/lib/openstudio/extension/core/check_plenum_loads.rb +0 -57
  30. data/lib/openstudio/extension/core/check_pump_pwr.rb +0 -78
  31. data/lib/openstudio/extension/core/check_sch_coord.rb +0 -211
  32. data/lib/openstudio/extension/core/check_schedules.rb +0 -281
  33. data/lib/openstudio/extension/core/check_simultaneous_heating_and_cooling.rb +0 -128
  34. data/lib/openstudio/extension/core/check_supply_air_and_thermostat_temp_difference.rb +0 -118
  35. data/lib/openstudio/extension/core/check_weather_files.rb +0 -102
  36. data/lib/openstudio/extension/core/deer_vintages.rb +0 -281
  37. data/lib/openstudio/extension/core/os_lib_aedg_measures.rb +0 -461
  38. data/lib/openstudio/extension/core/os_lib_constructions.rb +0 -353
  39. data/lib/openstudio/extension/core/os_lib_geometry.rb +0 -1169
  40. data/lib/openstudio/extension/core/os_lib_helper_methods.rb +0 -383
  41. data/lib/openstudio/extension/core/os_lib_hvac.rb +0 -2163
  42. data/lib/openstudio/extension/core/os_lib_lighting_and_equipment.rb +0 -184
  43. data/lib/openstudio/extension/core/os_lib_model_generation.rb +0 -3584
  44. data/lib/openstudio/extension/core/os_lib_model_simplification.rb +0 -1019
  45. data/lib/openstudio/extension/core/os_lib_outdoorair_and_infiltration.rb +0 -135
  46. data/lib/openstudio/extension/core/os_lib_reporting_qaqc.rb +0 -170
  47. data/lib/openstudio/extension/core/os_lib_schedules.rb +0 -933
@@ -1,383 +0,0 @@
1
- # *******************************************************************************
2
- # OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
3
- # See also https://openstudio.net/license
4
- # *******************************************************************************
5
-
6
- module OsLib_HelperMethods
7
- # populate choice argument from model objects
8
- def self.populateChoiceArgFromModelObjects(model, modelObject_args_hash, includeBuilding = nil)
9
- # populate choice argument for constructions that are applied to surfaces in the model
10
- modelObject_handles = OpenStudio::StringVector.new
11
- modelObject_display_names = OpenStudio::StringVector.new
12
-
13
- # looping through sorted hash of constructions
14
- modelObject_args_hash.sort.map do |key, value|
15
- modelObject_handles << value.handle.to_s
16
- modelObject_display_names << key
17
- end
18
-
19
- unless includeBuilding.nil?
20
- # add building to string vector with space type
21
- building = model.getBuilding
22
- modelObject_handles << building.handle.to_s
23
- modelObject_display_names << includeBuilding
24
- end
25
-
26
- result = { 'modelObject_handles' => modelObject_handles, 'modelObject_display_names' => modelObject_display_names }
27
- return result
28
- end
29
-
30
- # create variables in run from user arguments
31
- def self.createRunVariables(runner, model, user_arguments, arguments)
32
- result = {}
33
-
34
- error = false
35
- # use the built-in error checking
36
- unless runner.validateUserArguments(arguments, user_arguments)
37
- error = true
38
- runner.registerError('Invalid argument values.')
39
- end
40
-
41
- user_arguments.each do |argument|
42
- # get argument info
43
- arg = user_arguments[argument]
44
- arg_type = arg.print.lines($/)[1]
45
-
46
- # create argument variable
47
- if arg_type.include? 'Double, Required'
48
- eval("result[\"#{arg.name}\"] = runner.getDoubleArgumentValue(\"#{arg.name}\", user_arguments)")
49
- elsif arg_type.include? 'Integer, Required'
50
- eval("result[\"#{arg.name}\"] = runner.getIntegerArgumentValue(\"#{arg.name}\", user_arguments)")
51
- elsif arg_type.include? 'String, Required'
52
- eval("result[\"#{arg.name}\"] = runner.getStringArgumentValue(\"#{arg.name}\", user_arguments)")
53
- elsif arg_type.include? 'Boolean, Required'
54
- eval("result[\"#{arg.name}\"] = runner.getBoolArgumentValue(\"#{arg.name}\", user_arguments)")
55
- elsif arg_type.include? 'Choice, Required'
56
- eval("result[\"#{arg.name}\"] = runner.getStringArgumentValue(\"#{arg.name}\", user_arguments)")
57
- else
58
- puts 'not setup to handle all argument types yet, or any optional arguments'
59
- end
60
- end
61
-
62
- if error
63
- return false
64
- else
65
- return result
66
- end
67
- end
68
-
69
- # check choice argument made from model objects
70
- def self.checkChoiceArgFromModelObjects(object, variableName, to_ObjectType, runner, user_arguments)
71
- apply_to_building = false
72
- modelObject = nil
73
- if object.empty?
74
- handle = runner.getStringArgumentValue(variableName, user_arguments)
75
- if handle.empty?
76
- runner.registerError("No #{variableName} was chosen.") # this logic makes this not work on an optional model object argument
77
- else
78
- runner.registerError("The selected #{variableName} with handle '#{handle}' was not found in the model. It may have been removed by another measure.")
79
- end
80
- return false
81
- else
82
- if !eval("object.get.#{to_ObjectType}").empty?
83
- modelObject = eval("object.get.#{to_ObjectType}").get
84
- elsif !object.get.to_Building.empty?
85
- apply_to_building = true
86
- else
87
- runner.registerError("Script Error - argument not showing up as #{variableName}.")
88
- return false
89
- end
90
- end
91
-
92
- result = { 'modelObject' => modelObject, 'apply_to_building' => apply_to_building }
93
- end
94
-
95
- # check choice argument made from model objects
96
- def self.checkOptionalChoiceArgFromModelObjects(object, variableName, to_ObjectType, runner, user_arguments)
97
- apply_to_building = false
98
- modelObject = nil
99
- if object.empty?
100
- handle = runner.getOptionalStringArgumentValue(variableName, user_arguments)
101
- if handle.empty?
102
- # do nothing, this is a valid option
103
- puts 'hello'
104
- modelObject = nil
105
- apply_to_building = false
106
- else
107
- runner.registerError("The selected #{variableName} with handle '#{handle}' was not found in the model. It may have been removed by another measure.")
108
- return false
109
- end
110
- else
111
- if !eval("object.get.#{to_ObjectType}").empty?
112
- modelObject = eval("object.get.#{to_ObjectType}").get
113
- elsif !object.get.to_Building.empty?
114
- apply_to_building = true
115
- else
116
- runner.registerError("Script Error - argument not showing up as #{variableName}.")
117
- return false
118
- end
119
- end
120
-
121
- result = { 'modelObject' => modelObject, 'apply_to_building' => apply_to_building }
122
- end
123
-
124
- # check value of double arguments
125
- def self.checkDoubleAndIntegerArguments(runner, user_arguments, arg_check_hash)
126
- error = false
127
-
128
- # get hash values
129
- min = arg_check_hash['min']
130
- max = arg_check_hash['max']
131
- min_eq_bool = arg_check_hash['min_eq_bool']
132
- max_eq_bool = arg_check_hash['max_eq_bool']
133
-
134
- arg_check_hash['arg_array'].each do |argument|
135
- argument = user_arguments[argument]
136
-
137
- # get arg values
138
- arg_value = nil
139
- if argument.hasValue
140
- arg_value = argument.valueDisplayName.to_f # instead of valueAsDouble so it allows integer arguments as well
141
- elsif argument.hasDefaultValue
142
- arg_value = argument.defaultValueDisplayName.to_f
143
- end
144
- arg_display = argument.displayName
145
-
146
- unless min.nil?
147
- if min_eq_bool
148
- if arg_value < min
149
- runner.registerError("Please enter value greater than or equal to #{min} for #{arg_display}.") # add in argument display name
150
- error = true
151
- end
152
- else
153
- if arg_value <= min
154
- runner.registerError("Please enter value greater than #{min} for #{arg_display}.") # add in argument display name
155
- error = true
156
- end
157
- end
158
- end
159
- unless max.nil?
160
- if max_eq_bool
161
- if arg_value > max
162
- runner.registerError("Please enter value less than or equal to #{max} for #{arg_display}.") # add in argument display name
163
- error = true
164
- end
165
- else
166
- if arg_value >= max
167
- runner.registerError("Please enter value less than #{max} for #{arg_display}.") # add in argument display name
168
- error = true
169
- end
170
- end
171
- end
172
- end
173
-
174
- # check for any errors
175
- if error
176
- return false
177
- else
178
- return true
179
- end
180
- end
181
-
182
- # open channel to log info/warning/error messages
183
- def self.setup_log_msgs(runner, debug = false)
184
- # Open a channel to log info/warning/error messages
185
- @msg_log = OpenStudio::StringStreamLogSink.new
186
- if debug
187
- @msg_log.setLogLevel(OpenStudio::Debug)
188
- else
189
- @msg_log.setLogLevel(OpenStudio::Info)
190
- end
191
- @start_time = Time.new
192
- @runner = runner
193
- end
194
-
195
- # Get all the log messages and put into output
196
- # for users to see.
197
- def self.log_msgs
198
- @msg_log.logMessages.each do |msg|
199
- # DLM: you can filter on log channel here for now
200
- if /openstudio.*/.match(msg.logChannel) # /openstudio\.model\..*/
201
- # Skip certain messages that are irrelevant/misleading
202
- next if msg.logMessage.include?('Skipping layer') || # Annoying/bogus "Skipping layer" warnings
203
- msg.logChannel.include?('runmanager') || # RunManager messages
204
- msg.logChannel.include?('setFileExtension') || # .ddy extension unexpected
205
- msg.logChannel.include?('Translator') || # Forward translator and geometry translator
206
- msg.logMessage.include?('UseWeatherFile') || # 'UseWeatherFile' is not yet a supported option for YearDescription
207
- msg.logMessage.include?('has multiple parents') # 'has multiple parents' is thrown for various types of curves if used in multiple objects
208
-
209
- # Report the message in the correct way
210
- if msg.logLevel == OpenStudio::Info
211
- @runner.registerInfo(msg.logMessage)
212
- elsif msg.logLevel == OpenStudio::Warn
213
- @runner.registerWarning("[#{msg.logChannel}] #{msg.logMessage}")
214
- elsif msg.logLevel == OpenStudio::Error
215
- @runner.registerError("[#{msg.logChannel}] #{msg.logMessage}")
216
- elsif msg.logLevel == OpenStudio::Debug && @debug
217
- @runner.registerInfo("DEBUG - #{msg.logMessage}")
218
- end
219
- end
220
- end
221
- @runner.registerInfo("Total Time = #{(Time.new - @start_time).round}sec.")
222
- end
223
-
224
- def self.check_upstream_measure_for_arg(runner, arg_name)
225
- # 2.x methods (currently setup for measure display name but snake_case arg names)
226
- arg_name_value = {}
227
- runner.workflow.workflowSteps.each do |step|
228
- if step.to_MeasureStep.is_initialized
229
- measure_step = step.to_MeasureStep.get
230
-
231
- measure_name = measure_step.measureDirName
232
- if measure_step.name.is_initialized
233
- measure_name = measure_step.name.get # this is instance name in PAT
234
- end
235
- if measure_step.result.is_initialized
236
- result = measure_step.result.get
237
- result.stepValues.each do |arg|
238
- name = arg.name
239
- # check if value, double, int, or bool
240
- value_type = arg.variantType.valueDescription
241
- if value_type == "Double"
242
- value = arg.valueAsDouble
243
- elsif value_type == "Integer"
244
- value = arg.valueAsInteger
245
- elsif value_type == "Boolean"
246
- value = arg.valueAsBoolean
247
- elsif value_type == "String"
248
- value = arg.valueAsString
249
- else
250
- # catchall for unexpected value types
251
- value = arg.valueAsVariant.to_s
252
- end
253
- if name == arg_name
254
- arg_name_value[:value] = value
255
- arg_name_value[:measure_name] = measure_name
256
- return arg_name_value # stop after find first one
257
- end
258
- end
259
- else
260
- # puts "No result for #{measure_name}"
261
- end
262
- else
263
- # puts "This step is not a measure"
264
- end
265
- end
266
-
267
- return arg_name_value
268
- end
269
-
270
- # populate choice argument from model objects. areaType should be string like "floorArea" or "exteriorArea"
271
- # note: it seems like spaceType.floorArea does account for multiplier, so I don't have to call this method unless I have a custom collection of spaces.
272
- def self.getAreaOfSpacesInArray(model, spaceArray, areaType = 'floorArea')
273
- # find selected floor spaces, make array and get floor area.
274
- totalArea = 0
275
- spaceAreaHash = {}
276
- spaceArray.each do |space|
277
- spaceArea = eval("space.#{areaType}*space.multiplier")
278
- spaceAreaHash[space] = spaceArea
279
- totalArea += spaceArea
280
- end
281
-
282
- result = { 'totalArea' => totalArea, 'spaceAreaHash' => spaceAreaHash }
283
- return result
284
- end
285
-
286
- # runs conversion and neat string, and returns value with units in string, optionally before or after the value
287
- def self.neatConvertWithUnitDisplay(double, fromString, toString, digits, unitBefore = false, unitAfter = true, space = true, parentheses = true)
288
- # convert units
289
- doubleConverted = OpenStudio.convert(double, fromString, toString)
290
- if !doubleConverted.nil?
291
- doubleConverted = doubleConverted.get
292
- else
293
- puts "Couldn't convert values, check string choices passed in. From: #{fromString}, To: #{toString}"
294
- end
295
-
296
- # get neat version of converted
297
- neatConverted = OpenStudio.toNeatString(doubleConverted, digits, true)
298
-
299
- # add prefix
300
- if unitBefore
301
- if space == true && parentheses == true
302
- prefix = "(#{toString}) "
303
- elsif space == true && parentheses == false
304
- prefix = "(#{toString})"
305
- elsif space == false && parentheses == true
306
- prefix = "#{toString} "
307
- else
308
- prefix = toString.to_s
309
- end
310
- else
311
- prefix = ''
312
- end
313
-
314
- # add suffix
315
- if unitAfter
316
- if space == true && parentheses == true
317
- suffix = " (#{toString})"
318
- elsif space == true && parentheses == false
319
- suffix = "(#{toString})"
320
- elsif space == false && parentheses == true
321
- suffix = " #{toString}"
322
- else
323
- suffix = toString.to_s
324
- end
325
- else
326
- suffix = ''
327
- end
328
-
329
- finalString = "#{prefix}#{neatConverted}#{suffix}"
330
-
331
- return finalString
332
- end
333
-
334
- # helper that loops through lifecycle costs getting total costs under "Construction" and add to counter if occurs during year 0
335
- def self.getTotalCostForObjects(objectArray, category = 'Construction', onlyYearFromStartZero = true)
336
- counter = 0
337
- objectArray.each do |object|
338
- object_LCCs = object.lifeCycleCosts
339
- object_LCCs.each do |object_LCC|
340
- if object_LCC.category == category
341
- if onlyYearFromStartZero == false || object_LCC.yearsFromStart == 0
342
- counter += object_LCC.totalCost
343
- end
344
- end
345
- end
346
- end
347
-
348
- return counter
349
- end
350
-
351
- # helper that loops through lifecycle costs getting total costs under "Construction" and add to counter if occurs during year 0
352
- def self.getSpaceTypeStandardsInformation(spaceTypeArray)
353
- # hash of space types
354
- spaceTypeStandardsInfoHash = {}
355
-
356
- spaceTypeArray.each do |spaceType|
357
- # get standards building
358
- if !spaceType.standardsBuildingType.empty?
359
- standardsBuilding = spaceType.standardsBuildingType.get
360
- else
361
- standardsBuilding = nil
362
- end
363
-
364
- # get standards space type
365
- if !spaceType.standardsSpaceType.empty?
366
- standardsSpaceType = spaceType.standardsSpaceType.get
367
- else
368
- standardsSpaceType = nil
369
- end
370
-
371
- # populate hash
372
- spaceTypeStandardsInfoHash[spaceType] = [standardsBuilding, standardsSpaceType]
373
- end
374
-
375
- return spaceTypeStandardsInfoHash
376
- end
377
-
378
- # OpenStudio has built in toNeatString method
379
- # OpenStudio::toNeatString(double,2,true)# double,decimals, show commas
380
-
381
- # OpenStudio has built in helper for unit conversion. That can be done using OpenStudio::convert() as shown below.
382
- # OpenStudio::convert(double,"from unit string","to unit string").get
383
- end