Class: Honeybee::ConstructionSetAbridged

Inherits:
ModelObject show all
Defined in:
lib/honeybee/construction_set.rb,
lib/to_openstudio/construction_set.rb,
lib/from_openstudio/construction_set.rb

Instance Attribute Summary

Attributes inherited from ModelObject

#errors, #openstudio_object, #warnings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ModelObject

#allowable_types, clean_identifier, clean_name, #initialize, #method_missing, read_from_disk, truncate

Constructor Details

This class inherits a constructor from Honeybee::ModelObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Honeybee::ModelObject

Class Method Details

.from_construction_set(construction_set) ⇒ Object



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
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
138
139
# File 'lib/from_openstudio/construction_set.rb', line 38

def self.from_construction_set(construction_set)
    # create an empty hash
    hash = {}
    hash[:type] = 'ConstructionSetAbridged'
    # set hash values from OpenStudio Object
    hash[:identifier] = clean_name(construction_set.nameString)
    unless construction_set.displayName.empty?
      hash[:display_name] = (construction_set.displayName.get).force_encoding("UTF-8")
    end
    hash[:wall_set] = {}
    hash[:floor_set] = {}
    hash[:aperture_set] = {}
    hash[:door_set] = {}
    hash[:roof_ceiling_set] = {}

    # get interior surface constructions
    unless construction_set.defaultInteriorSurfaceConstructions.empty?
      int_surf_construction = construction_set.defaultInteriorSurfaceConstructions.get
      # get interior wall construction
      unless int_surf_construction.wallConstruction.empty?
        int_wall_const = int_surf_construction.wallConstruction.get
        hash[:wall_set][:interior_construction] = clean_name(int_wall_const.nameString)
      end
      # get interior floor construction
      unless int_surf_construction.floorConstruction.empty?
        int_floor_const = int_surf_construction.floorConstruction.get
        hash[:floor_set][:interior_construction] = clean_name(int_floor_const.nameString)
      end
      # get interior roofceiling construction
      unless int_surf_construction.roofCeilingConstruction.empty?
        int_roof_const = int_surf_construction.roofCeilingConstruction.get
        hash[:roof_ceiling_set][:interior_construction] = clean_name(int_roof_const.nameString)
      end
    end

    # get interior subsurface constructions
    unless construction_set.defaultInteriorSubSurfaceConstructions.empty?
      int_subsurf_const = construction_set.defaultInteriorSubSurfaceConstructions.get
      unless int_subsurf_const.fixedWindowConstruction.empty?
        int_wind_const = int_subsurf_const.fixedWindowConstruction.get
        hash[:aperture_set][:window_construction] = clean_name(int_wind_const.nameString)
      end
      # get interior door construction
      unless int_subsurf_const.doorConstruction.empty?
        int_door_const = int_subsurf_const.doorConstruction.get
        hash[:door_set][:interior_construction] = clean_name(int_door_const.nameString)
      end
      # get interior glass door construction
      unless int_subsurf_const.glassDoorConstruction.empty?
        int_glass_door_const = int_subsurf_const.glassDoorConstruction.get
        hash[:door_set][:interior_glass_construction] = clean_name(int_glass_door_const.nameString)
      end
    end
    
    # get exterior surface constructions
    unless construction_set.defaultExteriorSurfaceConstructions.empty?
      ext_surf_const = construction_set.defaultExteriorSurfaceConstructions.get
      # get exterior wall construction
      unless ext_surf_const.wallConstruction.empty?
        ext_wall_const = ext_surf_const.wallConstruction.get
        hash[:wall_set][:exterior_construction] = clean_name(ext_wall_const.nameString)
      end
      # get exterior floor construction
      unless ext_surf_const.floorConstruction.empty?
        ext_floor_const = ext_surf_const.floorConstruction.get
        hash[:floor_set][:exterior_construction] = clean_name(ext_floor_const.nameString)
      end
      # get exterior roofceiling construction
      unless ext_surf_const.roofCeilingConstruction.empty?
        ext_roof_const = ext_surf_const.roofCeilingConstruction.get
        hash[:roof_ceiling_set][:exterior_construction] = clean_name(ext_roof_const.nameString)
      end
    end

    # get exterior subsurface construction
    unless construction_set.defaultExteriorSubSurfaceConstructions.empty?
      ext_subsurf_const = construction_set.defaultExteriorSubSurfaceConstructions.get
      # get exterior operable window construction
      unless ext_subsurf_const.operableWindowConstruction.empty?
        ext_wind_const = ext_subsurf_const.operableWindowConstruction.get
        hash[:aperture_set][:operable_construction] = clean_name(ext_wind_const.nameString)
      end
      # get exterior skylight construction
      unless ext_subsurf_const.skylightConstruction.empty?
        ext_skylight_const = ext_subsurf_const.skylightConstruction.get
        hash[:aperture_set][:skylight_construction] = clean_name(ext_skylight_const.nameString)
      end
      # get exterior door construction
      unless ext_subsurf_const.doorConstruction.empty?
        ext_door_const = ext_subsurf_const.doorConstruction.get
        hash[:door_set][:exterior_construction] = clean_name(ext_door_const.nameString)
      end
      # get exterior overhead door construction
      unless ext_subsurf_const.overheadDoorConstruction.empty?
        ext_ovhd_door_const = ext_subsurf_const.overheadDoorConstruction.get
        hash[:door_set][:overhead_construction] = clean_name(ext_ovhd_door_const.nameString)
      end
    end

    hash

end

Instance Method Details

#assign_constr_to_set_ext(openstudio_model, constr_subset, face_type, constr_id_ext) ⇒ Object

get exterior construction subset



271
272
273
274
275
276
# File 'lib/to_openstudio/construction_set.rb', line 271

def assign_constr_to_set_ext(openstudio_model, constr_subset, face_type, constr_id_ext)
  unless constr_id_ext.empty?
    constr_id = constr_id_ext.get
    check_constr_type(constr_id, face_type, constr_subset)
  end
end

#assign_constr_to_set_grd(openstudio_model, constr_subset, face_type, constr_id_grd) ⇒ Object

get ground construction subset



279
280
281
282
283
284
# File 'lib/to_openstudio/construction_set.rb', line 279

def assign_constr_to_set_grd(openstudio_model, constr_subset, face_type, constr_id_grd)
  unless constr_id_grd.empty?
    constr_id = constr_id_grd.get
    check_constr_type(constr_id, face_type, constr_subset)
  end
end

#assign_constr_to_set_int(openstudio_model, constr_subset, face_type, constr_id_int) ⇒ Object

get interior construction subset



263
264
265
266
267
268
# File 'lib/to_openstudio/construction_set.rb', line 263

def assign_constr_to_set_int(openstudio_model, constr_subset, face_type, constr_id_int)
  unless constr_id_int.empty?
    constr_id = constr_id_int.get
    check_constr_type(constr_id, face_type, constr_subset)
  end
end

#check_constr_type(constr_id, face_type, constr_subset) ⇒ Object

check face type and assign to construction subset



287
288
289
290
291
292
293
294
295
# File 'lib/to_openstudio/construction_set.rb', line 287

def check_constr_type(constr_id, face_type, constr_subset)
  if face_type == 'Wall'
    constr_subset.setWallConstruction(constr_id)
  elsif face_type == 'Floor'
    constr_subset.setFloorConstruction(constr_id)
  else
   constr_subset.setRoofCeilingConstruction(constr_id)
  end
end

#defaultsObject



37
38
39
# File 'lib/honeybee/construction_set.rb', line 37

def defaults
  @@schema[:components][:schemas][:ConstructionSetAbridged][:properties]
end

#find_existing_openstudio_object(openstudio_model) ⇒ Object



38
39
40
41
42
# File 'lib/to_openstudio/construction_set.rb', line 38

def find_existing_openstudio_object(openstudio_model)
  object = openstudio_model.getDefaultConstructionSetByName(@hash[:identifier])
  return object.get if object.is_initialized
  nil
end

#get_window_construction(openstudio_model, construction_identifier) ⇒ Object

assign window construction with a check for dynamic constructions



298
299
300
301
302
303
304
305
306
307
308
# File 'lib/to_openstudio/construction_set.rb', line 298

def get_window_construction(openstudio_model, construction_identifier)
  os_construction = nil
  constr_ref = openstudio_model.getConstructionByName(construction_identifier)
  if !constr_ref.empty?
    os_construction = constr_ref.get
  elsif !$window_dynamic_hash.nil? && !$window_dynamic_hash[construction_identifier].nil?
    os_construction = $window_dynamic_hash[construction_identifier].constructions[0]
  end

  os_construction
end

#to_openstudio(openstudio_model) ⇒ Object



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
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
138
139
140
141
142
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
# File 'lib/to_openstudio/construction_set.rb', line 44

def to_openstudio(openstudio_model)
  # create the constructionset object
  os_constr_set = OpenStudio::Model::DefaultConstructionSet.new(openstudio_model)
  os_constr_set.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_constr_set.setDisplayName(@hash[:display_name])
  end
  int_surf_const = OpenStudio::Model::DefaultSurfaceConstructions.new(openstudio_model)
  ext_surf_const = OpenStudio::Model::DefaultSurfaceConstructions.new(openstudio_model)
  grnd_surf_const = OpenStudio::Model::DefaultSurfaceConstructions.new(openstudio_model)
  int_subsurf_const = OpenStudio::Model::DefaultSubSurfaceConstructions.new(openstudio_model)
  ext_subsurf_const = OpenStudio::Model::DefaultSubSurfaceConstructions.new(openstudio_model)

  os_constr_set.setDefaultInteriorSurfaceConstructions(int_surf_const)
  os_constr_set.setDefaultExteriorSurfaceConstructions(ext_surf_const)
  os_constr_set.setDefaultGroundContactSurfaceConstructions(grnd_surf_const)
  os_constr_set.setDefaultInteriorSubSurfaceConstructions(int_subsurf_const)
  os_constr_set.setDefaultExteriorSubSurfaceConstructions(ext_subsurf_const)

  # determine the frame type for measure tags
  frame_type = 'Metal Framing with Thermal Break'
  id_str = @hash[:identifier].to_s
  if id_str.scan(/(?=WoodFramed)/).count > 0
    frame_type = 'Non-Metal Framing'
  end

  # assign any constructions in the wall set
  if @hash[:wall_set]
    if @hash[:wall_set][:interior_construction]
      int_wall_ref = openstudio_model.getConstructionByName(@hash[:wall_set][:interior_construction])
      unless int_wall_ref.empty?
        interior_wall = int_wall_ref.get
        int_surf_const.setWallConstruction(interior_wall)
        os_constr_set.setAdiabaticSurfaceConstruction(interior_wall)
      end
    end
    if @hash[:wall_set][:exterior_construction]
      ext_wall_ref = openstudio_model.getConstructionByName(@hash[:wall_set][:exterior_construction])
      unless ext_wall_ref.empty?
        exterior_wall = ext_wall_ref.get
        ext_surf_const.setWallConstruction(exterior_wall)
      end
    end
    if @hash[:wall_set][:ground_construction]
      grd_wall_ref = openstudio_model.getConstructionByName(@hash[:wall_set][:ground_construction])
      unless grd_wall_ref.empty?
        ground_wall = grd_wall_ref.get
        grnd_surf_const.setWallConstruction(ground_wall)
      end
    end
  end

  # assign any constructions in the floor set
  if @hash[:floor_set]
    if @hash[:floor_set][:interior_construction]
      constr_id_int = openstudio_model.getConstructionByName(@hash[:floor_set][:interior_construction])
      assign_constr_to_set_int(openstudio_model, int_surf_const, 'Floor',
        constr_id_int)
    end
    if @hash[:floor_set][:exterior_construction]
      constr_id_ext = openstudio_model.getConstructionByName(@hash[:floor_set][:exterior_construction])
      assign_constr_to_set_ext(openstudio_model, ext_surf_const, 'Floor',
        constr_id_ext
      )
    end
    if @hash[:floor_set][:ground_construction]
      constr_id_grd = openstudio_model.getConstructionByName(@hash[:floor_set][:ground_construction])
      assign_constr_to_set_grd(openstudio_model, grnd_surf_const, 'Floor',
        constr_id_grd)
    end
  end

  # assign any constructions in the roof ceiling set
  if @hash[:roof_ceiling_set]
    if @hash[:roof_ceiling_set][:interior_construction]
      constr_id_int = openstudio_model.getConstructionByName(@hash[:roof_ceiling_set][:interior_construction])
      assign_constr_to_set_int(openstudio_model, int_surf_const, 'Roof',
        constr_id_int)
    end
    if @hash[:roof_ceiling_set][:exterior_construction]
      constr_id_ext = openstudio_model.getConstructionByName(@hash[:roof_ceiling_set][:exterior_construction])
      assign_constr_to_set_ext(openstudio_model, ext_surf_const, 'Roof',
        constr_id_ext)
    end
    if @hash[:roof_ceiling_set][:ground_construction]
      constr_id_grd = openstudio_model.getConstructionByName(@hash[:roof_ceiling_set][:ground_construction])
      assign_constr_to_set_grd(openstudio_model, grnd_surf_const, 'Roof',
        constr_id_grd)
    end
  end

  # assign any constructions in the aperture set
  if @hash[:aperture_set]
    if @hash[:aperture_set][:interior_construction]
      interior_aperture = get_window_construction(openstudio_model, @hash[:aperture_set][:interior_construction])
      unless interior_aperture.nil?
        int_subsurf_const.setFixedWindowConstruction(interior_aperture)
        int_subsurf_const.setOperableWindowConstruction(interior_aperture)
      end
    end
    if @hash[:aperture_set][:window_construction]
      window_aperture = get_window_construction(openstudio_model, @hash[:aperture_set][:window_construction])
      unless window_aperture.nil?
        ext_subsurf_const.setFixedWindowConstruction(window_aperture)
        std_info = window_aperture.standardsInformation
        std_info.setFenestrationType('Fixed Window')
        std_info.setFenestrationFrameType(frame_type)
        std_info.setIntendedSurfaceType('ExteriorWindow')
      end
    end
    if @hash[:aperture_set][:skylight_construction]
      skylight_aperture = get_window_construction(openstudio_model, @hash[:aperture_set][:skylight_construction])
      unless skylight_aperture.nil?
        ext_subsurf_const.setSkylightConstruction(skylight_aperture)
        std_info = skylight_aperture.standardsInformation
        std_info.setFenestrationType('Fixed Window')
        std_info.setFenestrationFrameType(frame_type)
        if std_info.intendedSurfaceType.empty?
          std_info.setIntendedSurfaceType('Skylight')
        end
      end
    end
    if @hash[:aperture_set][:operable_construction]
      operable_aperture = get_window_construction(openstudio_model, @hash[:aperture_set][:operable_construction])
      unless operable_aperture.nil?
        ext_subsurf_const.setOperableWindowConstruction(operable_aperture)
        std_info = operable_aperture.standardsInformation
        if std_info.fenestrationType.empty?
          std_info.setFenestrationType('Operable Window')
        end
        std_info.setFenestrationFrameType(frame_type)
        std_info.setIntendedSurfaceType('ExteriorWindow')
      end
    end
  end

  # assign any constructions in the door set
  if @hash[:door_set]
    if @hash[:door_set][:interior_construction]
      int_door_ref = openstudio_model.getConstructionByName(
        @hash[:door_set][:interior_construction])
      unless int_door_ref.empty?
        interior_door = int_door_ref.get
        int_subsurf_const.setDoorConstruction(interior_door)
      end
    end
    if @hash[:door_set][:exterior_construction]
      ext_door_ref = openstudio_model.getConstructionByName(
        @hash[:door_set][:exterior_construction])
      unless ext_door_ref.empty?
        exterior_door = ext_door_ref.get
        ext_subsurf_const.setDoorConstruction(exterior_door)
        std_info = exterior_door.standardsInformation
        if std_info.intendedSurfaceType.empty?
          std_info.setIntendedSurfaceType('ExteriorDoor')
        end
      end
    end
    if @hash[:door_set][:overhead_construction]
      overhead_door_ref = openstudio_model.getConstructionByName(
        @hash[:door_set][:overhead_construction])
      unless overhead_door_ref.empty?
        overhead_door = overhead_door_ref.get
        ext_subsurf_const.setOverheadDoorConstruction(overhead_door)
        std_info = overhead_door.standardsInformation
        if std_info.intendedSurfaceType.empty?
          std_info.setIntendedSurfaceType('OverheadDoor')
        end
      end
    end
    if @hash[:door_set][:exterior_glass_construction]
      exterior_glass_door = get_window_construction(openstudio_model, @hash[:door_set][:exterior_glass_construction])
      unless exterior_glass_door.nil?
        ext_subsurf_const.setGlassDoorConstruction(exterior_glass_door)
        std_info = exterior_glass_door.standardsInformation
        if std_info.fenestrationType.empty?
          std_info.setFenestrationType('Glazed Door')
        end
        std_info.setFenestrationFrameType(frame_type)
        if std_info.intendedSurfaceType.empty?
          std_info.setIntendedSurfaceType('GlassDoor')
        end
      end
    end
    if @hash[:door_set][:interior_glass_construction]
      interior_glass_door = get_window_construction(openstudio_model, @hash[:door_set][:interior_glass_construction])
      unless interior_glass_door.nil?
        int_subsurf_const.setGlassDoorConstruction(interior_glass_door)
      end
    end
  end

  # assign any shading constructions to construction set
  if @hash[:shade_construction]
    shade_ref = openstudio_model.getConstructionByName(@hash[:shade_construction])
    unless shade_ref.empty?
      shade_construction = shade_ref.get
      os_constr_set.setSpaceShadingConstruction(shade_construction)
    end
  end

  # assign any air boundary constructions to construction set
  if @hash[:air_boundary_construction]
    air_ref = openstudio_model.getConstructionAirBoundaryByName(@hash[:air_boundary_construction])
    unless air_ref.empty?
      air_construction = air_ref.get
      os_constr_set.setInteriorPartitionConstruction(air_construction)
    end
    air_ref = openstudio_model.getConstructionByName(@hash[:air_boundary_construction])
    unless air_ref.empty?
      air_construction = air_ref.get
      os_constr_set.setInteriorPartitionConstruction(air_construction)
    end
  end

  os_constr_set
end