Class: BTAP::Attributes

Inherits:
Object
  • Object
show all
Defined in:
lib/openstudio-standards/btap/attributes.rb

Overview

Class for accessing and pre-processing model attributes.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model:, standard:, tbd_enabled:, tbd_edge_tallies:) ⇒ Attributes

Returns a new instance of Attributes.

Parameters:



67
68
69
70
71
72
73
74
75
76
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
111
112
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
# File 'lib/openstudio-standards/btap/attributes.rb', line 67

def initialize(model:, standard:, tbd_enabled:, tbd_edge_tallies:)
  @model            = model
  @standard         = standard
  @costing_database = Database.instance
  @tbd_enabled      = tbd_enabled
  @tbd_edge_tallies = tbd_edge_tallies
  @tbd_compliance   = @model.getBuilding.additionalProperties.hasFeature("tbd_compliance") ?
                        @model.getBuilding.additionalProperties.getFeatureAsBoolean("tbd_compliance").get : nil

  # Surfaces considered for envelope costing and carbon.
  @surface_types = [
    "ExteriorWall",
    "ExteriorRoof",
    "ExteriorFloor",
    "InterzonalRoof",
    "InterzonalSkylightWalls",
    "InterzonalFloor",
    "ExteriorFixedWindow",
    "ExteriorOperableWindow",
    "ExteriorSkylight",
    "ExteriorTubularDaylightDiffuser",
    "ExteriorTubularDaylightDome",
    "ExteriorDoor",
    "ExteriorGlassDoor",
    "ExteriorOverheadDoor",
    "GroundContactWall",
    "GroundContactRoof",
    "GroundContactFloor"
  ]

  # Formatted dictionary of surface types from camel case to snake case
  # for neat reporting.
  @surface_types_to_snake = @surface_types.map { |type|
    [type, type.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase] }.to_h

  @surface_types_to_envelope_type = {
    "ExteriorWall"                    => "wall",
    "ExteriorRoof"                    => "roof",
    "ExteriorFloor"                   => "floor",
    "InterzonalRoof"                  => "roof",
    "InterzonalFloor"                 => "floor",

    # TODO: Although we don't have specific constructions on interzonal
    # skylight walls, using external wall constructions is better than
    # ignoring them.
    "InterzonalSkylightWalls"         => "wall",
    "ExteriorFixedWindow"             => "window",
    "ExteriorOperableWindow"          => "window",
    "ExteriorSkylight"                => "skylight",
    "ExteriorTubularDaylightDiffuser" => "skylight",
    "ExteriorTubularDaylightDome"     => "skylight",
    "ExteriorDoor"                    => "door",
    "ExteriorGlassDoor"               => "door_glass",
    "ExteriorOverheadDoor"            => "door",
    "GroundContactWall"               => "bg_wall",
    "GroundContactRoof"               => "bg_roof",
    "GroundContactFloor"              => "slab"
  }

  # Store area, cost, and carbon emission tallies of assemblies by surface
  # type, stored as hashes as some surface types may have different
  # assemblies.
  @surface_types_to_assembly_tallies = @surface_types.to_h { |surface_type| [surface_type, {}] }

  @zones         = []
  @spaces        = []
  @constructions = {}

  self.compile_model
  self.compile_constructions
end

Class Attribute Details

.surface_types_to_assembly_names ⇒ Object (readonly)

[Hash]



45
46
47
# File 'lib/openstudio-standards/btap/attributes.rb', line 45

def surface_types_to_assembly_names
  @surface_types_to_assembly_names
end

Instance Attribute Details

#constructions ⇒ Object (readonly)

[Hash]



41
42
43
# File 'lib/openstudio-standards/btap/attributes.rb', line 41

def constructions
  @constructions
end

#model ⇒ Object (readonly)

[OpenStudio::Model::Model]



33
34
35
# File 'lib/openstudio-standards/btap/attributes.rb', line 33

def model
  @model
end

#spaces ⇒ Object (readonly)

[Array[OpenStudio::Model::Space]]



35
36
37
# File 'lib/openstudio-standards/btap/attributes.rb', line 35

def spaces
  @spaces
end

#surface_types ⇒ Object (readonly)

[Array]



36
37
38
# File 'lib/openstudio-standards/btap/attributes.rb', line 36

def surface_types
  @surface_types
end

#surface_types_to_assembly_tallies ⇒ Object (readonly)

[Hash]



42
43
44
# File 'lib/openstudio-standards/btap/attributes.rb', line 42

def surface_types_to_assembly_tallies
  @surface_types_to_assembly_tallies
end

#surface_types_to_snake ⇒ Object (readonly)

[Hash]



40
41
42
# File 'lib/openstudio-standards/btap/attributes.rb', line 40

def surface_types_to_snake
  @surface_types_to_snake
end

#tbd_compliance ⇒ Object (readonly)

[Boolean]



39
40
41
# File 'lib/openstudio-standards/btap/attributes.rb', line 39

def tbd_compliance
  @tbd_compliance
end

#tbd_edge_tallies ⇒ Object (readonly)

[Hash]



38
39
40
# File 'lib/openstudio-standards/btap/attributes.rb', line 38

def tbd_edge_tallies
  @tbd_edge_tallies
end

#tbd_enabled ⇒ Object (readonly)

[Boolean]



37
38
39
# File 'lib/openstudio-standards/btap/attributes.rb', line 37

def tbd_enabled
  @tbd_enabled
end

#zones ⇒ Object (readonly)

[Array[OpenStudio::Model::Zone]]



34
35
36
# File 'lib/openstudio-standards/btap/attributes.rb', line 34

def zones
  @zones
end

Instance Method Details

#compile_construction_attributes(construction:, name:, entry:) ⇒ Object

Parameters:

  • construction: (OpenStudio::Model::ConstructionBase)
  • name: (Hash) —

    Assembly name.

  • entry: (Hash) —

    BTAP construction attributes.



301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/openstudio-standards/btap/attributes.rb', line 301

def compile_construction_attributes(construction:, name:, entry:)
    construction_btap            = {}
    construction_btap["type"]    = entry["type"]
    construction_btap["rsi"]     = 1 / construction.additionalProperties.getFeatureAsDouble("btap_uo").get
    construction_btap["subsets"] = \
      entry["usi"].transform_keys { |usi| 1 / usi.to_f }.map { |rsi, hash| hash["rsi"] = rsi; hash }

    construction_btap["shgc"] = OpenstudioStandards::Constructions.construction_get_solar_transmittance(
      construction.to_Construction.get) unless construction.isOpaque

    @constructions[name] = construction_btap
end

#compile_construction_by_type(construction:, surface_type:) ⇒ Object

Parameters:

  • construction: (OpenStudio::Model::ConstructionBase)
  • surface_type: (String)


278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/openstudio-standards/btap/attributes.rb', line 278

def compile_construction_by_type(construction:, surface_type:)
  assembly_name = construction.additionalProperties.getFeatureAsString("btap_id").get

  # If the construction isn't already present in the  `@constructions` hash,
  # add it in.
  unless @constructions.key?(assembly_name)
    compile_construction_attributes(
      construction: construction,
      name: assembly_name,
      entry: @costing_database["constructions"][@surface_types_to_envelope_type[surface_type]][assembly_name])
  end

  # Only include the assembly in the tallies hash if its area is non-zero.
  area = construction.additionalProperties.getFeatureAsDouble("btap_area").get
  unless area == 0
    @surface_types_to_assembly_tallies[surface_type][assembly_name] = {}
    @surface_types_to_assembly_tallies[surface_type][assembly_name]["area"] = area
  end
end

#compile_constructions ⇒ Object

Fetch the additional properties in each default construction set which reflects the attributes of all the surfaces of a type. Populate the members of the @constructions and @surface_types_to_assembly_tallies hashes.



143
144
145
146
147
148
149
150
151
152
153
154
155
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
198
199
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/openstudio-standards/btap/attributes.rb', line 143

def compile_constructions

  @model.getDefaultConstructionSets.each do |set|

    # Plenum construction sets don't contain any information pertinent to
    # costing, skip them.
    if set.nameString =~ /PLENUM$/
      next

    # Attic construction sets concern insulated interzonal surfaces. This
    # also concerns crawlspaces, of which the interzonal floors will be
    # tallied.
    elsif set.nameString =~ /ATTIC$/

      compile_construction_by_type(
        construction: set.defaultInteriorSurfaceConstructions.get.wallConstruction.get,
        surface_type: "InterzonalSkylightWalls")

      compile_construction_by_type(
        construction: set.defaultInteriorSurfaceConstructions.get.floorConstruction.get,
        surface_type: "InterzonalRoof")

      compile_construction_by_type(
        construction: set.defaultInteriorSurfaceConstructions.get.roofCeilingConstruction.get,
        surface_type: "InterzonalFloor")

    # The following default construction sets concern the surfaces of the
    # whole building:
    elsif set.nameString =~ /BLDG$/
      compile_construction_by_type(
        construction: set.defaultExteriorSurfaceConstructions.get.wallConstruction.get,
        surface_type: "ExteriorWall")

      compile_construction_by_type(
        construction: set.defaultExteriorSurfaceConstructions.get.roofCeilingConstruction.get,
        surface_type: "ExteriorRoof")

      compile_construction_by_type(
        construction: set.defaultExteriorSurfaceConstructions.get.floorConstruction.get,
        surface_type: "ExteriorFloor")

      compile_construction_by_type(
        construction: set.defaultGroundContactSurfaceConstructions.get.wallConstruction.get,
        surface_type: "GroundContactWall")

      # Basement ground contact floors are removed from this default
      # construction set beforehand in prototype creation with the
      # `NECB2011/building_envelope.rb:set_basement_floor_construction()`
      # method since they're uninsulated and shouldn't be costed. So this
      # only tallies slabs on grade.
      compile_construction_by_type(
        construction: set.defaultGroundContactSurfaceConstructions.get.floorConstruction.get,
        surface_type: "GroundContactFloor")

        # From NECB2011 to NECB2025, ground contact floors only need to be
        # insulated wholly in climate zone 8. Otherwise, they need to be
        # insulated only for 1.2m about the perimeter. Insulation for the
        # low-conductnace ground contact floor U-factor variant have been
        # manually seperated into its own assembly below. Also check for the
        # presence of the perimeter additional property which denotes that
        # there are slab on grade ground contact floors.
        if @standard.get_necb_hdd18(model: @model) < 7000 and
           @model.getBuilding.additionalProperties.hasFeature("btap_slab_perimeter_m2")

          isoboard_name = "BTAP-GroundContactFloor-Isoboard"
          compile_construction_attributes(
            construction: set.defaultGroundContactSurfaceConstructions.get.floorConstruction.get,
            name: isoboard_name,
            entry: @costing_database["constructions"]["slab"][isoboard_name])

          @surface_types_to_assembly_tallies["GroundContactFloor"][isoboard_name] = {}
          @surface_types_to_assembly_tallies["GroundContactFloor"][isoboard_name]["area"] = \
            @model.getBuilding.additionalProperties.getFeatureAsDouble("btap_slab_perimeter_m2").get

      end

      compile_construction_by_type(
        construction: set.defaultGroundContactSurfaceConstructions.get.roofCeilingConstruction.get,
        surface_type: "GroundContactRoof")

      compile_construction_by_type(
        construction: set.defaultExteriorSubSurfaceConstructions.get.fixedWindowConstruction.get,
        surface_type: "ExteriorFixedWindow")

      compile_construction_by_type(
        construction: set.defaultExteriorSubSurfaceConstructions.get.operableWindowConstruction.get,
        surface_type: "ExteriorOperableWindow")

      compile_construction_by_type(
        construction: set.defaultExteriorSubSurfaceConstructions.get.skylightConstruction.get,
        surface_type: "ExteriorSkylight")

      compile_construction_by_type(
        construction: set.defaultExteriorSubSurfaceConstructions.get.tubularDaylightDiffuserConstruction.get,
        surface_type: "ExteriorTubularDaylightDiffuser")

      compile_construction_by_type(
        construction: set.defaultExteriorSubSurfaceConstructions.get.tubularDaylightDomeConstruction.get,
        surface_type: "ExteriorTubularDaylightDome")

      compile_construction_by_type(
        construction: set.defaultExteriorSubSurfaceConstructions.get.doorConstruction.get,
        surface_type: "ExteriorDoor")

      compile_construction_by_type(
        construction: set.defaultExteriorSubSurfaceConstructions.get.glassDoorConstruction.get,
        surface_type: "ExteriorGlassDoor")

      compile_construction_by_type(
        construction: set.defaultExteriorSubSurfaceConstructions.get.overheadDoorConstruction.get,
        surface_type: "ExteriorOverheadDoor")

    # Any remaining construction sets will be custom and defined
    # by the user by manually adding additional properties to
    # spaces and will only comprise exterior-facing surfaces.
    # (see NECB2011/building_envelope.rb:add_construction_sets())
    else
      compile_construction_by_type(
        construction: set.defaultExteriorSurfaceConstructions.get.wallConstruction.get,
        surface_type: "ExteriorWall")

      compile_construction_by_type(
        construction: set.defaultExteriorSurfaceConstructions.get.roofCeilingConstruction.get,
        surface_type: "ExteriorRoof")

      compile_construction_by_type(
        construction: set.defaultExteriorSurfaceConstructions.get.floorConstruction.get,
        surface_type: "ExteriorFloor")

    end
  end
end

#compile_model ⇒ Object

Add new accessors for zones, spaces, and surfaces while keeping them sorted for future accesses.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/openstudio-standards/btap/attributes.rb', line 316

def compile_model

  # Iterate through the data structures while also saving their sorted order later for reference.
  @model.instance_variable_set(:@zones_sorted, [])
  @model.getThermalZones.sort.each do |zone|
    @model << zone
    @zones << zone
    zone.instance_variable_set(:@spaces_sorted, [])
    zone.spaces.sort.each do |space|
      if space.spaceType.empty? or
         space.spaceType.get.standardsSpaceType.empty? or
         space.spaceType.get.standardsBuildingType.empty?
        raise("Error: Space type not defined for #{space.name.get}")
      end
      zone    << space
      @spaces << space
    end
  end
end

#compile_window_perimeter ⇒ Object

Only relevant surface-specific tally is window perimeter for BTAP Carbon. Add surface-specific tallies for underatable surfaces. Currently only windows have emissions data for frames.



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/openstudio-standards/btap/attributes.rb', line 339

def compile_window_perimeter
  windows = ["ExteriorFixedWindow", "ExteriorOperableWindow"]
  windows.each do |window|
    @surface_types_to_assembly_tallies[window][self.class.surface_types_to_assembly_names[window]]["perimeter"] = 0
  end

  @spaces.each do |space|
    windows.each do |window|
      assembly_name = self.class.surface_types_to_assembly_names[window]
      BTAP::Geometry::Surfaces::filter_subsurfaces_by_types(BTAP::Geometry::Surfaces::filter_by_boundary_condition(
        space.surfaces, "Outdoors").flat_map(&:subSurfaces), ["FixedWindow", "OperableWindow"]).each do |surface|

        @surface_types_to_assembly_tallies[window][assembly_name]["perimeter"] += \
          BTAP::Geometry::Surfaces.getSurfacePerimeterFromVertices(vertices: surface.vertices)

      end
    end
  end
end