Module: OsLib_Constructions

Defined in:
lib/openstudio/extension/core/os_lib_constructions.rb

Overview

******************************************************************************* OpenStudio(R), Copyright © 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

(1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

(3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission from the respective party.

(4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works may not use the “OpenStudio” trademark, “OS”, “os”, or any other confusingly similar designation without specific prior written permission from Alliance for Sustainable Energy, LLC.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************

Class Method Summary collapse

Class Method Details

.addNewLayerToConstruction(construction, options = {}) ⇒ Object

add new material to outside of a construction



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 113

def self.addNewLayerToConstruction(construction, options = {})
  # set defaults to use if user inputs not passed in
  defaults = {
    'cloneConstruction' => false, # in future give user option to clone or change live construction
    'layerIndex' => 0, # 0 will be outside. Measure writer should validate any non 0 layerIndex passed in.
    'name' => "#{construction.name} - new material",
    'roughness' => nil,
    'thickness' => nil,
    'conductivity' => nil,
    'density' => nil,
    'specificHeat' => nil,
    'thermalAbsorptance' => nil,
    'solarAbsorptance' => nil,
    'visibleAbsorptance' => nil
  }

  # merge user inputs with defaults
  options = defaults.merge(options)

  # TODO: - would be nice to grab surface properties from previous exposed material

  # make new material
  exposedMaterialNew = OpenStudio::Model::StandardOpaqueMaterial.new(construction.model)
  exposedMaterialNew.setName(options['name'])

  # set requested material properties
  if !options['roughness'].nil? then exposedMaterialNew.setRoughness(options['roughness']) end
  if !options['thickness'].nil? then exposedMaterialNew.setThickness(options['thickness']) end
  if !options['conductivity'].nil? then exposedMaterialNew.setConductivity(options['conductivity']) end
  if !options['density'].nil? then exposedMaterialNew.setDensity(options['density']) end
  if !options['specificHeat'].nil? then exposedMaterialNew.setSpecificHeat(options['specificHeat']) end
  if !options['thermalAbsorptance'].nil? then exposedMaterialNew.setThermalAbsorptance(options['thermalAbsorptance']) end
  if !options['solarAbsorptance'].nil? then exposedMaterialNew.setSolarAbsorptance(options['solarAbsorptance']) end
  if !options['visibleAbsorptance'].nil? then exposedMaterialNew.setVisibleAbsorptance(options['visibleAbsorptance']) end

  # add material to construction
  construction.insertLayer(options['layerIndex'], exposedMaterialNew)

  result = exposedMaterialNew
  return result
end

.createConstructionWithSimpleGlazing(model, runner = nil, options = {}) ⇒ Object

create simple glazing material



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 256

def self.createConstructionWithSimpleGlazing(model, runner = nil, options = {})
  # set defaults to use if user inputs not passed in
  defaults = {
    'constructionName' => nil,
    'materialName' => nil,
    'uFactor' => nil,
    'solarHeatGainCoef' => nil,
    'visibleTransmittance' => nil
  }

  # merge user inputs with defaults
  options = defaults.merge(options)

  # create construction and material and link them together
  construction = OpenStudio::Model::Construction.new(model)
  if !options['constructionName'].nil? then construction.setName(options['constructionName'].to_s) end
  material = OpenStudio::Model::SimpleGlazing.new(model)
  if !options['materialName'].nil? then material.setName(options['materialName'].to_s) end

  # add material to construction
  construction.insertLayer(0, material)

  # set material properties
  if !options['uFactor'].nil? then material.setUFactor(options['uFactor']) end
  if !options['solarHeatGainCoef'].nil? then material.setSolarHeatGainCoefficient(options['solarHeatGainCoef']) end
  if !options['visibleTransmittance'].nil? then material.setVisibleTransmittance(options['visibleTransmittance']) end

  # create info message
  if !runner.nil? # todo - need to look for bad visible transmittance here
    uFactorSiToIpConversion = OpenStudio.convert(material.uFactor, 'W/m^2*K', 'Btu/ft^2*h*R').get
    # version check to support 2.x and 3.x
    if Gem::Version.new(OpenStudio::openStudioVersion) > Gem::Version.new("2.9.1")
      runner.registerInfo("Created #{construction.name} construction. U-factor: #{OpenStudio.toNeatString(uFactorSiToIpConversion, 2, true)}(Btu/ft^2*h*R), SHGC: #{material.solarHeatGainCoefficient}, VT: #{material.getVisibleTransmittance.get}.")
    else
      runner.registerInfo("Created #{construction.name} construction. U-factor: #{OpenStudio.toNeatString(uFactorSiToIpConversion, 2, true)}(Btu/ft^2*h*R), SHGC: #{material.getSolarHeatGainCoefficient}, VT: #{material.getVisibleTransmittance.get}.")
    end
  end

  result = construction
  return result
end

.getConstructionSRI(construction) ⇒ Object

sri of exposed surface of a construction (calculation from K-12 AEDG, derived from ASTM E1980 assuming medium wind speed)



240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 240

def self.getConstructionSRI(construction)
  exposedMaterial = construction.to_LayeredConstruction.get.getLayer(0)
  solarAbsorptance = exposedMaterial.to_OpaqueMaterial.get.solarAbsorptance
  thermalEmissivity = exposedMaterial.to_OpaqueMaterial.get.thermalAbsorptance
  # lines below just for testing
  # solarAbsorptance = 1 - 0.65
  # thermalEmissivity = 0.86

  x = (20.797 * solarAbsorptance - 0.603 * thermalEmissivity) / (9.5205 * thermalEmissivity + 12.0)
  sri = 123.97 - 141.35 * x + 9.6555 * x * x

  result = sri
  return result
end

.getTotalCostOfSelectedConstructions(constructionArray) ⇒ Object

get cost of selected constructions



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 299

def self.getTotalCostOfSelectedConstructions(constructionArray)
  envelope_cost = 0

  # loop through selected constructions
  constructionArray.each do |construction|
    next if construction.getNetArea == 0
    const_llcs = construction.lifeCycleCosts
    const_llcs.each do |const_llc|
      if const_llc.category == 'Construction'
        envelope_cost += const_llc.totalCost
      end
    end
  end

  result = envelope_cost
  return result
end

.inferInsulationLayer(construction, minThermalResistance) ⇒ Object

infer insulation layer from a construction



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 38

def self.inferInsulationLayer(construction, minThermalResistance)
  construction_layers = construction.layers
  counter = 0
  max_resistance = 0
  thermal_resistance_array = []

  # loop through construction layers and infer insulation layer/material
  construction_layers.each do |construction_layer|
    construction_thermal_resistance = construction_layer.to_OpaqueMaterial.get.thermalResistance
    if !thermal_resistance_array.empty?
      if construction_thermal_resistance > max_resistance
        thermal_resistance_array = [construction_layer, counter, construction_thermal_resistance]
        max_resistance = construction_thermal_resistance
      end
    else
      thermal_resistance_array = [construction_layer, counter, construction_thermal_resistance]
    end
    counter += 1
  end

  # test against minimum
  if max_resistance > minThermalResistance
    minTestPass = true
  else
    minTestPass = false
  end

  result = {
    'construction' => construction,
    'construction_layer' => thermal_resistance_array[0],
    'layer_index' => thermal_resistance_array[1],
    'construction_thermal_resistance' => thermal_resistance_array[2],
    'insulationFound' => minTestPass
  }

  return result
end

.reportConstructionSetConstructions(constructionSet) ⇒ Object

report names of constructions in a construction set



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 318

def self.reportConstructionSetConstructions(constructionSet)
  constructionArray = []

  # populate exterior surfaces
  if constructionSet.defaultExteriorSurfaceConstructions.is_initialized
    surfaceSet = constructionSet.defaultExteriorSurfaceConstructions.get
    if surfaceSet.floorConstruction.is_initialized then constructionArray << surfaceSet.floorConstruction.get end
    if surfaceSet.wallConstruction.is_initialized then constructionArray << surfaceSet.wallConstruction.get end
    if surfaceSet.roofCeilingConstruction.is_initialized then constructionArray << surfaceSet.roofCeilingConstruction.get end
  end
  # populate interior surfaces
  if constructionSet.defaultInteriorSurfaceConstructions.is_initialized
    surfaceSet = constructionSet.defaultInteriorSurfaceConstructions.get
    if surfaceSet.floorConstruction.is_initialized then constructionArray << surfaceSet.floorConstruction.get end
    if surfaceSet.wallConstruction.is_initialized then constructionArray << surfaceSet.wallConstruction.get end
    if surfaceSet.roofCeilingConstruction.is_initialized then constructionArray << surfaceSet.roofCeilingConstruction.get end
  end
  # populate ground surfaces
  if constructionSet.defaultGroundContactSurfaceConstructions.is_initialized
    surfaceSet = constructionSet.defaultGroundContactSurfaceConstructions.get
    if surfaceSet.floorConstruction.is_initialized then constructionArray << surfaceSet.floorConstruction.get end
    if surfaceSet.wallConstruction.is_initialized then constructionArray << surfaceSet.wallConstruction.get end
    if surfaceSet.roofCeilingConstruction.is_initialized then constructionArray << surfaceSet.roofCeilingConstruction.get end
  end
  # populate exterior sub-surfaces
  if constructionSet.defaultExteriorSubSurfaceConstructions.is_initialized
    subSurfaceSet = constructionSet.defaultExteriorSubSurfaceConstructions.get
    if subSurfaceSet.fixedWindowConstruction.is_initialized then constructionArray << subSurfaceSet.fixedWindowConstruction.get end
    if subSurfaceSet.operableWindowConstruction.is_initialized then constructionArray << subSurfaceSet.operableWindowConstruction.get end
    if subSurfaceSet.doorConstruction.is_initialized then constructionArray << subSurfaceSet.doorConstruction.get end
    if subSurfaceSet.glassDoorConstruction.is_initialized then constructionArray << subSurfaceSet.glassDoorConstruction.get end
    if subSurfaceSet.overheadDoorConstruction.is_initialized then constructionArray << subSurfaceSet.overheadDoorConstruction.get end
    if subSurfaceSet.skylightConstruction.is_initialized then constructionArray << subSurfaceSet.skylightConstruction.get end
    if subSurfaceSet.tubularDaylightDomeConstruction.is_initialized then constructionArray << subSurfaceSet.tubularDaylightDomeConstruction.get end
    if subSurfaceSet.tubularDaylightDiffuserConstruction.is_initialized then constructionArray << subSurfaceSet.tubularDaylightDiffuserConstruction.get end
  end
  # populate interior sub-surfaces
  if constructionSet.defaultInteriorSubSurfaceConstructions.is_initialized
    subSurfaceSet = constructionSet.defaultInteriorSubSurfaceConstructions.get
    if subSurfaceSet.fixedWindowConstruction.is_initialized then constructionArray << subSurfaceSet.fixedWindowConstruction.get end
    if subSurfaceSet.operableWindowConstruction.is_initialized then constructionArray << subSurfaceSet.operableWindowConstruction.get end
    if subSurfaceSet.doorConstruction.is_initialized then constructionArray << subSurfaceSet.doorConstruction.get end
    if subSurfaceSet.glassDoorConstruction.is_initialized then constructionArray << subSurfaceSet.glassDoorConstruction.get end
    if subSurfaceSet.overheadDoorConstruction.is_initialized then constructionArray << subSurfaceSet.overheadDoorConstruction.get end
    if subSurfaceSet.skylightConstruction.is_initialized then constructionArray << subSurfaceSet.skylightConstruction.get end
    if subSurfaceSet.tubularDaylightDomeConstruction.is_initialized then constructionArray << subSurfaceSet.tubularDaylightDomeConstruction.get end
    if subSurfaceSet.tubularDaylightDiffuserConstruction.is_initialized then constructionArray << subSurfaceSet.tubularDaylightDiffuserConstruction.get end
  end
  # populate misc surfaces
  if constructionSet.interiorPartitionConstruction.is_initialized
    constructionArray << constructionSet.interiorPartitionConstruction.get
  end
  if constructionSet.spaceShadingConstruction.is_initialized
    constructionArray << constructionSet.spaceShadingConstruction.get
  end
  if constructionSet.buildingShadingConstruction.is_initialized
    constructionArray << constructionSet.buildingShadingConstruction.get
  end
  if constructionSet.siteShadingConstruction.is_initialized
    constructionArray << constructionSet.siteShadingConstruction.get
  end

  result = constructionArray
  return result
end

.setConstructionSurfaceProperties(construction, options = {}) ⇒ Object

set material surface properties for specific layer in construction. this should work on OS:Material and OS:MasslessOpaqueMaterial



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 156

def self.setConstructionSurfaceProperties(construction, options = {})
  # set defaults to use if user inputs not passed in
  defaults = {
    'cloneConstruction' => false, # in future give user option to clone or change live construction
    'nameConstruction' => "#{construction.name} - adj", # not currently used
    'cloneMaterial' => true,
    'roughness' => nil,
    'thermalAbsorptance' => nil,
    'solarAbsorptance' => nil,
    'visibleAbsorptance' => nil
  }

  # merge user inputs with defaults
  options = defaults.merge(options)

  exposedMaterial = construction.to_LayeredConstruction.get.getLayer(0)
  if options['cloneMaterial']

    # clone material
    exposedMaterialNew = exposedMaterial.clone(construction.model).to_StandardOpaqueMaterial.get # to_StandardOpaqueMaterial is needed to access roughness, otherwise to_OpaqueMaterial would have been fine.
    exposedMaterialNew.setName("#{exposedMaterial.name} - adj")

    # connect new material to original construction
    construction.eraseLayer(0)
    construction.insertLayer(0, exposedMaterialNew)

  else
    exposedMaterialNew = exposedMaterial.to_StandardOpaqueMaterial.get # not being cloned but still want to rename
    exposedMaterialNew.setName("#{exposedMaterial.name} - adj")
  end

  # TODO: - need to test with MasslessOpaqueMaterial. Add test if doesn't return anything when use to_StandardOpaqueMaterial.get

  # set requested material properties
  if !options['roughness'].nil? then exposedMaterialNew.setRoughness(options['roughness']) end
  if !options['thermalAbsorptance'].nil? then exposedMaterialNew.setThermalAbsorptance(options['thermalAbsorptance']) end
  if !options['solarAbsorptance'].nil? then exposedMaterialNew.setSolarAbsorptance(options['solarAbsorptance']) end
  if !options['visibleAbsorptance'].nil? then exposedMaterialNew.setVisibleAbsorptance(options['visibleAbsorptance']) end

  result = { 'exposedMaterial' => exposedMaterial, 'exposedMaterialNew' => exposedMaterialNew }
  return result
end

.setMaterialSurfaceProperties(material, options = {}) ⇒ Object

similar to setMaterialSurfaceProperties but I just pass a material in. Needed this to set material properties for interior walls and both sides of interior partitions.



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 200

def self.setMaterialSurfaceProperties(material, options = {})
  # set defaults to use if user inputs not passed in
  defaults = {
    'cloneMaterial' => true,
    'roughness' => nil,
    'thermalAbsorptance' => nil,
    'solarAbsorptance' => nil,
    'visibleAbsorptance' => nil
  }

  # merge user inputs with defaults
  options = defaults.merge(options)

  if options['cloneMaterial']
    # clone material
    materialNew = exposedMaterial.clone(construction.model).get
    materialNew.setName("#{materialNew.name} - adj")
  else
    materialNew = material # not being cloned
    materialNew.setName("#{materialNew.name} - adj")
  end

  # to_StandardOpaqueMaterial is needed to access roughness, otherwise to_OpaqueMaterial would have been fine.
  if !materialNew.to_StandardOpaqueMaterial.empty?
    materialNew = materialNew.to_StandardOpaqueMaterial.get
  elsif !materialNew.to_MasslessOpaqueMaterial.empty?
    materialNew = materialNew.to_MasslessOpaqueMaterial.get
  end

  # set requested material properties
  if !options['roughness'].nil? then materialNew.setRoughness(options['roughness']) end
  if !options['thermalAbsorptance'].nil? then materialNew.setThermalAbsorptance(options['thermalAbsorptance']) end
  if !options['solarAbsorptance'].nil? then materialNew.setSolarAbsorptance(options['solarAbsorptance']) end
  if !options['visibleAbsorptance'].nil? then materialNew.setVisibleAbsorptance(options['visibleAbsorptance']) end

  result = { 'material' => material, 'materialNew' => materialNew }
  return result
end

.setMaterialThermalResistance(material, thermalResistance, options = {}) ⇒ Object

change thermal resistance of opaque materials



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/openstudio/extension/core/os_lib_constructions.rb', line 77

def self.setMaterialThermalResistance(material, thermalResistance, options = {})
  # set defaults to use if user inputs not passed in
  defaults = {
    'cloneMaterial' => true, # in future give user option to clone or change live material
    'name' => "#{material.name} - adj"
  }

  # merge user inputs with defaults
  options = defaults.merge(options)

  # clone input material
  new_material = material.clone(material.model)
  new_material = new_material.to_OpaqueMaterial.get
  new_material.setName(options['name'])

  # edit insulation material
  new_material_matt = new_material.to_Material
  if !new_material_matt.empty?
    starting_thickness = new_material_matt.get.thickness
    target_thickness = starting_thickness * thermalResistance / material.to_OpaqueMaterial.get.thermalResistance
    final_thickness = new_material_matt.get.setThickness(target_thickness)
  end
  new_material_massless = new_material.to_MasslessOpaqueMaterial
  if !new_material_massless.empty?
    final_thermal_resistance = new_material_massless.get.setThermalResistance(thermalResistance)
  end
  new_material_airgap = new_material.to_AirGap
  if !new_material_airgap.empty?
    final_thermal_resistance = new_material_airgap.get.setThermalResistance(thermalResistance)
  end

  result = new_material
  return result
end