Class: Honeybee::WindowConstructionShadeAbridged

Inherits:
ModelObject
  • Object
show all
Defined in:
lib/honeybee/construction/windowshade.rb,
lib/to_openstudio/construction/windowshade.rb

Instance Attribute Summary collapse

Attributes inherited from ModelObject

#errors, #openstudio_object, #warnings

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

Instance Attribute Details

#constructionObject (readonly)

Returns the value of attribute construction.



39
40
41
# File 'lib/to_openstudio/construction/windowshade.rb', line 39

def construction
  @construction
end

#control_typeObject (readonly)

Returns the value of attribute control_type.



39
40
41
# File 'lib/to_openstudio/construction/windowshade.rb', line 39

def control_type
  @control_type
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



39
40
41
# File 'lib/to_openstudio/construction/windowshade.rb', line 39

def schedule
  @schedule
end

#setpointObject (readonly)

Returns the value of attribute setpoint.



39
40
41
# File 'lib/to_openstudio/construction/windowshade.rb', line 39

def setpoint
  @setpoint
end

#shade_constructionObject (readonly)

Returns the value of attribute shade_construction.



39
40
41
# File 'lib/to_openstudio/construction/windowshade.rb', line 39

def shade_construction
  @shade_construction
end

#shade_locationObject (readonly)

Returns the value of attribute shade_location.



39
40
41
# File 'lib/to_openstudio/construction/windowshade.rb', line 39

def shade_location
  @shade_location
end

#shade_materialObject (readonly)

Returns the value of attribute shade_material.



39
40
41
# File 'lib/to_openstudio/construction/windowshade.rb', line 39

def shade_material
  @shade_material
end

Instance Method Details

#defaultsObject



38
39
40
# File 'lib/honeybee/construction/windowshade.rb', line 38

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

#find_existing_openstudio_object(openstudio_model) ⇒ Object



41
42
43
44
45
# File 'lib/to_openstudio/construction/windowshade.rb', line 41

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

#split_gas_gap(openstudio_model, original_gap, shade_material) ⇒ Object



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
# File 'lib/to_openstudio/construction/windowshade.rb', line 186

def split_gas_gap(openstudio_model, original_gap, shade_material)
    # split a gas gap material in two when it is interrupeted by a shade/blind
    if shade_material.is_a? OpenStudio::Model::Blind
      shd_thick = 0
    else
      shd_thick = shade_material.thickness
    end
    gap_thick = (original_gap.thickness - shd_thick) / 2
    gap_thick = gap_thick.round(4)
    if gap_thick.to_s.end_with?('5')
      gap_thick = gap_thick + 0.0005
    end
    gap_thick = gap_thick.round(3)
    gap_id_start = original_gap.name.get + '_Split' + gap_thick.to_s
    new_gap_init = openstudio_model.getMaterialByName(gap_id_start)
    if new_gap_init.is_initialized
      new_gap = new_gap_init.get
    else
      gap_obj = $gas_gap_hash[original_gap.name.get]
      new_gap = gap_obj.to_openstudio(openstudio_model)
      new_gap.setName(original_gap.name.get + gap_thick.to_s)
      new_gap.setThickness(gap_thick)
    end
    new_gap
end

#to_openstudio(openstudio_model) ⇒ Object



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
# File 'lib/to_openstudio/construction/windowshade.rb', line 47

def to_openstudio(openstudio_model)
  # set the unshaded ID to be the whole construction ID so unshaded one is assigned to apertures
  unshd_id = @hash[:identifier]
  @hash[:window_construction][:identifier] = unshd_id
  # derive a new ID for the shaded construction that will not conflict with any bare versions of the construction
  shd_id = @hash[:identifier]  + '_Shaded'
  @hash[:identifier] = shd_id

  # create the unshaded construction
  unshd_constr_obj = WindowConstructionAbridged.new(@hash[:window_construction])
  @construction = unshd_constr_obj.to_openstudio(openstudio_model)

  # create the shaded construction
  @shade_construction = OpenStudio::Model::Construction.new(openstudio_model)
  @shade_construction.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    @shade_construction.setDisplayName(@hash[:display_name])
  end
  # create the layers of the unshaded construction into which we will insert the shade
  os_materials = []
  if @hash.key?(:layers)
    mat_key = :layers
  else
    mat_key = :materials
  end
  @hash[:window_construction][mat_key].each do |material_identifier|
    material = openstudio_model.getMaterialByName(material_identifier)
    unless material.empty?
      os_material = material.get
      os_materials << os_material
    end
  end

  # figure out where to insert the shade material and insert it
  if @hash[:shade_location]
    @shade_location = @hash[:shade_location]
  else
    @shade_location = defaults[:shade_location][:default]
  end

  # insert the shade material
  shd_mat_name = openstudio_model.getMaterialByName(@hash[:shade_material])
  unless shd_mat_name.empty?
    @shade_material = shd_mat_name.get
    obj_type = @shade_material.iddObject.name.to_s
  end
  unless @shade_material.nil?
    if obj_type == 'OS:WindowMaterial:StandardGlazing' || obj_type == 'OS:WindowMaterial:Glazing'
      if @shade_location == 'Interior'
          os_materials[-1] = @shade_material
      elsif @shade_location == 'Exterior' || os_materials.length < 2
          os_materials[0] = @shade_material
      else  # middle glass pane
          os_materials[-3] = @shade_material
      end
    else
      if @shade_location == 'Interior'
          os_materials << @shade_material
      elsif @shade_location == 'Exterior'
          os_materials.unshift(@shade_material)
      else  # between glass shade/blind
        split_gap = split_gas_gap(openstudio_model, os_materials[-2], @shade_material)
        os_materials[-2] = split_gap
        os_materials.insert(-2, @shade_material)
        os_materials.insert(-2, split_gap)
      end
    end
  end

  # assign the layers to the shaded construction
  os_materials_vec = OpenStudio::Model::MaterialVector.new
  os_materials.each do |mat|
    os_materials_vec << mat
  end
  @shade_construction.setLayers(os_materials)

  # set defaults for control type, setpoint, and schedule
  if @hash[:control_type]
    @control_type = @hash[:control_type]
  else
    @control_type = defaults[:control_type][:default]
  end

  if @hash[:setpoint]
    @setpoint = @hash[:setpoint]
  else
    @setpoint = defaults[:setpoint][:default]
  end

  unless @hash[:schedule].nil?
    schedule_ref = openstudio_model.getScheduleByName(@hash[:schedule])
    unless schedule_ref.empty?
        @schedule = schedule_ref.get
        if @control_type == 'AlwaysOn'
            @control_type = 'OnIfScheduleAllows'
        end
    end
  end

  @shade_construction
end

#to_openstudio_shading_control(openstudio_model) ⇒ Object



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
# File 'lib/to_openstudio/construction/windowshade.rb', line 149

def to_openstudio_shading_control(openstudio_model)
  # add a WindowShadingControl object to a model for a given aperture and room
  os_shade_control = OpenStudio::Model::ShadingControl.new(@shade_construction)

  # figure out the shading type
  unless @shade_material.nil?
    obj_type = @shade_material.iddObject.name.to_s
  end
  if obj_type == 'OS:WindowMaterial:StandardGlazing' || obj_type == 'OS:WindowMaterial:Glazing'
    shd_type = 'SwitchableGlazing'
  elsif obj_type == 'OS:WindowMaterial:Blind'
    if @shade_location == 'Between'
      shd_type = 'BetweenGlassBlind'
    else
      shd_type = @shade_location + 'Blind'
    end
  else
    if @shade_location == 'Between'
      shd_type = 'BetweenGlassShade'
    else
      shd_type = @shade_location + 'Shade'
    end
  end
  os_shade_control.setShadingType(shd_type)

  # set the shade control type and schedule
  os_shade_control.setShadingControlType(@control_type)
  unless @setpoint.nil?
    os_shade_control.setSetpoint(@setpoint)
  end
  unless @schedule.nil?
    os_shade_control.setSchedule(@schedule)
  end

  os_shade_control
end