openstudio-model-articulation 0.8.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +12 -5
- data/Jenkinsfile +1 -1
- data/README.md +2 -0
- data/lib/measures/SimplifyGeometryToSlicedBar/measure.rb +32 -37
- data/lib/measures/SimplifyGeometryToSlicedBar/measure.xml +34 -80
- data/lib/measures/SimplifyGeometryToSlicedBar/resources/os_lib_cofee.rb +10 -9
- data/lib/measures/SpaceTypeAndConstructionSetWizard/measure.rb +10 -13
- data/lib/measures/SpaceTypeAndConstructionSetWizard/measure.xml +28 -28
- data/lib/measures/blended_space_type_from_floor_area_ratios/measure.rb +31 -14
- data/lib/measures/blended_space_type_from_floor_area_ratios/measure.xml +36 -36
- data/lib/measures/blended_space_type_from_model/measure.rb +12 -5
- data/lib/measures/blended_space_type_from_model/measure.xml +47 -47
- data/lib/measures/create_DOE_prototype_building/measure.rb +1 -1
- data/lib/measures/create_DOE_prototype_building/measure.xml +19 -875
- data/lib/measures/create_bar_from_building_type_ratios/README.md +2 -13
- data/lib/measures/create_bar_from_building_type_ratios/measure.rb +122 -30
- data/lib/measures/create_bar_from_building_type_ratios/measure.xml +108 -349
- data/lib/measures/create_bar_from_deer_building_type_ratios/README.md +21 -1
- data/lib/measures/create_bar_from_deer_building_type_ratios/measure.rb +120 -18
- data/lib/measures/create_bar_from_deer_building_type_ratios/measure.xml +94 -32
- data/lib/measures/create_bar_from_doe_building_type_ratios/measure.rb +127 -18
- data/lib/measures/create_bar_from_doe_building_type_ratios/measure.xml +48 -26
- data/lib/measures/create_bar_from_model/measure.rb +17 -18
- data/lib/measures/create_bar_from_model/measure.xml +41 -41
- data/lib/measures/create_bar_from_space_type_ratios/README.md +1 -1
- data/lib/measures/create_bar_from_space_type_ratios/measure.rb +94 -14
- data/lib/measures/create_bar_from_space_type_ratios/measure.xml +104 -63
- data/lib/measures/create_baseline_building/measure.xml +33 -33
- data/lib/measures/create_deer_prototype_building/measure.xml +15 -15
- data/lib/measures/create_parametric_schedules/measure.rb +17 -20
- data/lib/measures/create_parametric_schedules/measure.xml +15 -15
- data/lib/measures/create_typical_building_from_model/README.md +16 -16
- data/lib/measures/create_typical_building_from_model/measure.rb +84 -18
- data/lib/measures/create_typical_building_from_model/measure.xml +159 -211
- data/lib/measures/create_typical_deer_building_from_model/README.md +38 -5
- data/lib/measures/create_typical_deer_building_from_model/measure.rb +84 -12
- data/lib/measures/create_typical_deer_building_from_model/measure.xml +165 -65
- data/lib/measures/create_typical_doe_building_from_model/README.md +17 -4
- data/lib/measures/create_typical_doe_building_from_model/measure.rb +84 -12
- data/lib/measures/create_typical_doe_building_from_model/measure.xml +125 -65
- data/lib/measures/deer_space_type_and_construction_set_wizard/measure.rb +13 -16
- data/lib/measures/deer_space_type_and_construction_set_wizard/measure.xml +72 -29
- data/lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.rb +4 -4
- data/lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.xml +21 -21
- data/lib/measures/merge_spaces_from_external_file/measure.rb +4 -4
- data/lib/measures/merge_spaces_from_external_file/measure.xml +34 -34
- data/lib/measures/radiant_slab_with_doas/README.md +0 -8
- data/lib/measures/radiant_slab_with_doas/measure.rb +2 -11
- data/lib/measures/radiant_slab_with_doas/measure.xml +31 -40
- data/lib/measures/replace_geometry_by_story/measure.rb +6 -10
- data/lib/measures/replace_geometry_by_story/measure.xml +19 -19
- data/lib/measures/set_nist_infiltration_correlations/measure.rb +34 -25
- data/lib/measures/set_nist_infiltration_correlations/measure.xml +38 -38
- data/lib/openstudio/model_articulation/version.rb +1 -1
- data/openstudio-model-articulation.gemspec +11 -4
- metadata +69 -16
- data/lib/measures/SimplifyGeometryToSlicedBar/resources/os_lib_geometry.rb +0 -1174
- data/lib/measures/SimplifyGeometryToSlicedBar/resources/os_lib_helper_methods.rb +0 -367
- data/lib/measures/create_typical_building_from_model/resources/Model.hvac.rb +0 -608
@@ -1,367 +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
|
-
|
208
|
-
# Report the message in the correct way
|
209
|
-
if msg.logLevel == OpenStudio::Info
|
210
|
-
@runner.registerInfo(msg.logMessage)
|
211
|
-
elsif msg.logLevel == OpenStudio::Warn
|
212
|
-
@runner.registerWarning("[#{msg.logChannel}] #{msg.logMessage}")
|
213
|
-
elsif msg.logLevel == OpenStudio::Error
|
214
|
-
@runner.registerError("[#{msg.logChannel}] #{msg.logMessage}")
|
215
|
-
elsif msg.logLevel == OpenStudio::Debug && @debug
|
216
|
-
@runner.registerInfo("DEBUG - #{msg.logMessage}")
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
@runner.registerInfo("Total Time = #{(Time.new - @start_time).round}sec.")
|
221
|
-
end
|
222
|
-
|
223
|
-
def self.check_upstream_measure_for_arg(runner, arg_name)
|
224
|
-
# 2.x methods (currently setup for measure display name but snake_case arg names)
|
225
|
-
arg_name_value = {}
|
226
|
-
runner.workflow.workflowSteps.each do |step|
|
227
|
-
if step.to_MeasureStep.is_initialized
|
228
|
-
measure_step = step.to_MeasureStep.get
|
229
|
-
|
230
|
-
measure_name = measure_step.measureDirName
|
231
|
-
if measure_step.name.is_initialized
|
232
|
-
measure_name = measure_step.name.get # this is instance name in PAT
|
233
|
-
end
|
234
|
-
if measure_step.result.is_initialized
|
235
|
-
result = measure_step.result.get
|
236
|
-
result.stepValues.each do |arg|
|
237
|
-
name = arg.name
|
238
|
-
value = arg.valueAsVariant.to_s
|
239
|
-
if name == arg_name
|
240
|
-
arg_name_value[:value] = value
|
241
|
-
arg_name_value[:measure_name] = measure_name
|
242
|
-
return arg_name_value # stop after find first one
|
243
|
-
end
|
244
|
-
end
|
245
|
-
else
|
246
|
-
# puts "No result for #{measure_name}"
|
247
|
-
end
|
248
|
-
else
|
249
|
-
# puts "This step is not a measure"
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
return arg_name_value
|
254
|
-
end
|
255
|
-
|
256
|
-
# populate choice argument from model objects. areaType should be string like "floorArea" or "exteriorArea"
|
257
|
-
# 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.
|
258
|
-
def self.getAreaOfSpacesInArray(model, spaceArray, areaType = 'floorArea')
|
259
|
-
# find selected floor spaces, make array and get floor area.
|
260
|
-
totalArea = 0
|
261
|
-
spaceAreaHash = {}
|
262
|
-
spaceArray.each do |space|
|
263
|
-
spaceArea = eval("space.#{areaType}*space.multiplier")
|
264
|
-
spaceAreaHash[space] = spaceArea
|
265
|
-
totalArea += spaceArea
|
266
|
-
end
|
267
|
-
|
268
|
-
result = { 'totalArea' => totalArea, 'spaceAreaHash' => spaceAreaHash }
|
269
|
-
return result
|
270
|
-
end
|
271
|
-
|
272
|
-
# runs conversion and neat string, and returns value with units in string, optionally before or after the value
|
273
|
-
def self.neatConvertWithUnitDisplay(double, fromString, toString, digits, unitBefore = false, unitAfter = true, space = true, parentheses = true)
|
274
|
-
# convert units
|
275
|
-
doubleConverted = OpenStudio.convert(double, fromString, toString)
|
276
|
-
if !doubleConverted.nil?
|
277
|
-
doubleConverted = doubleConverted.get
|
278
|
-
else
|
279
|
-
puts "Couldn't convert values, check string choices passed in. From: #{fromString}, To: #{toString}"
|
280
|
-
end
|
281
|
-
|
282
|
-
# get neat version of converted
|
283
|
-
neatConverted = OpenStudio.toNeatString(doubleConverted, digits, true)
|
284
|
-
|
285
|
-
# add prefix
|
286
|
-
if unitBefore
|
287
|
-
if space == true && parentheses == true
|
288
|
-
prefix = "(#{toString}) "
|
289
|
-
elsif space == true && parentheses == false
|
290
|
-
prefix = "(#{toString})"
|
291
|
-
elsif space == false && parentheses == true
|
292
|
-
prefix = "#{toString} "
|
293
|
-
else
|
294
|
-
prefix = toString.to_s
|
295
|
-
end
|
296
|
-
else
|
297
|
-
prefix = ''
|
298
|
-
end
|
299
|
-
|
300
|
-
# add suffix
|
301
|
-
if unitAfter
|
302
|
-
if space == true && parentheses == true
|
303
|
-
suffix = " (#{toString})"
|
304
|
-
elsif space == true && parentheses == false
|
305
|
-
suffix = "(#{toString})"
|
306
|
-
elsif space == false && parentheses == true
|
307
|
-
suffix = " #{toString}"
|
308
|
-
else
|
309
|
-
suffix = toString.to_s
|
310
|
-
end
|
311
|
-
else
|
312
|
-
suffix = ''
|
313
|
-
end
|
314
|
-
|
315
|
-
finalString = "#{prefix}#{neatConverted}#{suffix}"
|
316
|
-
|
317
|
-
return finalString
|
318
|
-
end
|
319
|
-
|
320
|
-
# helper that loops through lifecycle costs getting total costs under "Construction" and add to counter if occurs during year 0
|
321
|
-
def self.getTotalCostForObjects(objectArray, category = 'Construction', onlyYearFromStartZero = true)
|
322
|
-
counter = 0
|
323
|
-
objectArray.each do |object|
|
324
|
-
object_LCCs = object.lifeCycleCosts
|
325
|
-
object_LCCs.each do |object_LCC|
|
326
|
-
if object_LCC.category == category && (onlyYearFromStartZero == false || object_LCC.yearsFromStart == 0)
|
327
|
-
counter += object_LCC.totalCost
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
return counter
|
333
|
-
end
|
334
|
-
|
335
|
-
# helper that loops through lifecycle costs getting total costs under "Construction" and add to counter if occurs during year 0
|
336
|
-
def self.getSpaceTypeStandardsInformation(spaceTypeArray)
|
337
|
-
# hash of space types
|
338
|
-
spaceTypeStandardsInfoHash = {}
|
339
|
-
|
340
|
-
spaceTypeArray.each do |spaceType|
|
341
|
-
# get standards building
|
342
|
-
if !spaceType.standardsBuildingType.empty?
|
343
|
-
standardsBuilding = spaceType.standardsBuildingType.get
|
344
|
-
else
|
345
|
-
standardsBuilding = nil
|
346
|
-
end
|
347
|
-
|
348
|
-
# get standards space type
|
349
|
-
if !spaceType.standardsSpaceType.empty?
|
350
|
-
standardsSpaceType = spaceType.standardsSpaceType.get
|
351
|
-
else
|
352
|
-
standardsSpaceType = nil
|
353
|
-
end
|
354
|
-
|
355
|
-
# populate hash
|
356
|
-
spaceTypeStandardsInfoHash[spaceType] = [standardsBuilding, standardsSpaceType]
|
357
|
-
end
|
358
|
-
|
359
|
-
return spaceTypeStandardsInfoHash
|
360
|
-
end
|
361
|
-
|
362
|
-
# OpenStudio has built in toNeatString method
|
363
|
-
# OpenStudio::toNeatString(double,2,true)# double,decimals, show commas
|
364
|
-
|
365
|
-
# OpenStudio has built in helper for unit conversion. That can be done using OpenStudio::convert() as shown below.
|
366
|
-
# OpenStudio::convert(double,"from unit string","to unit string").get
|
367
|
-
end
|