Class: Honeybee::VentilationOpening

Inherits:
ModelObject show all
Defined in:
lib/honeybee/ventcool/opening.rb,
lib/to_openstudio/ventcool/opening.rb

Instance Attribute Summary

Attributes inherited from ModelObject

#errors, #openstudio_object, #warnings

Instance Method Summary collapse

Methods inherited from ModelObject

#allowable_types, clean_identifier, clean_name, #find_existing_openstudio_object, #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 Method Details

#compute_height(surface) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/to_openstudio/ventcool/opening.rb', line 198

def compute_height(surface)
  # derive the height (difference in z values) of a surface
  verts = surface.vertices
  min_pt = verts[0].z
  max_pt = verts[0].z
  verts.each do |v|
    if v.z < min_pt
      min_pt = v.z
    elsif v.z > max_pt
      max_pt = v.z
    end
  end
  # quarter the window height to get the height from midpoint of lower opening to neutral pressure level
  (max_pt - min_pt) / 4
end

#defaultsObject



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

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

#defaults_controlObject



41
42
43
# File 'lib/honeybee/ventcool/opening.rb', line 41

def defaults_control
  @@schema[:components][:schemas][:VentilationControlAbridged][:properties]
end

#to_openstudio(openstudio_model, parent, vent_control_hash) ⇒ Object



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
# File 'lib/to_openstudio/ventcool/opening.rb', line 39

def to_openstudio(openstudio_model, parent, vent_control_hash)
  # create wind and stack object and set identifier
  os_opening = OpenStudio::Model::ZoneVentilationWindandStackOpenArea.new(openstudio_model)
  os_opening.setName(parent.name.get + '_Opening')

  # assign the opening area
  if @hash[:fraction_area_operable]
    os_opening.setOpeningArea(@hash[:fraction_area_operable]  * parent.netArea)
  else
    os_opening.setOpeningArea(
      defaults[:fraction_area_operable][:default] * parent.netArea)
  end

  # assign the height
  if @hash[:fraction_height_operable]
    os_opening.	setHeightDifference(
      @hash[:fraction_height_operable]  * compute_height(parent))
  else
    os_opening.	setHeightDifference(
      defaults[:fraction_height_operable][:default] * compute_height(parent))
  end

  # assign the azimuth
  az_degrees = parent.azimuth * 180 / Math::PI
  os_opening.setEffectiveAngle(az_degrees.round())

  # assign the discharge coefficient
  if @hash[:discharge_coefficient]
    os_opening.setDischargeCoefficientforOpening(@hash[:discharge_coefficient])
  else
    os_opening.setDischargeCoefficientforOpening(
      defaults[:discharge_coefficient][:default])
  end

  # assign the wind pressure coefficient
  if @hash[:wind_cross_vent]
    os_opening.autocalculateOpeningEffectiveness()
  else
    os_opening.setOpeningEffectiveness(0)
  end

  # set all of the ventilation control properties
  if vent_control_hash
    # assign min_indoor_temperature
    if vent_control_hash[:min_indoor_temperature]
      os_opening.setMinimumIndoorTemperature(vent_control_hash[:min_indoor_temperature])
    else
      os_opening.setMinimumIndoorTemperature(
        defaults_control[:min_indoor_temperature][:default])
    end
    # assign max_indoor_temperature
    if vent_control_hash[:max_indoor_temperature]
      os_opening.setMaximumIndoorTemperature(vent_control_hash[:max_indoor_temperature])
    else
      os_opening.setMaximumIndoorTemperature(
        defaults_control[:max_indoor_temperature][:default])
    end
    # assign min_outdoor_temperature
    if vent_control_hash[:min_outdoor_temperature]
      os_opening.setMinimumOutdoorTemperature(vent_control_hash[:min_outdoor_temperature])
    else
      os_opening.setMinimumOutdoorTemperature(
        defaults_control[:min_outdoor_temperature][:default])
    end
    # assign max_outdoor_temperature
    if vent_control_hash[:max_outdoor_temperature]
      os_opening.setMaximumOutdoorTemperature(vent_control_hash[:max_outdoor_temperature])
    else
      os_opening.setMaximumOutdoorTemperature(
        defaults_control[:max_outdoor_temperature][:default])
    end
    # assign delta_temperature
    if vent_control_hash[:delta_temperature]
      os_opening.setDeltaTemperature(vent_control_hash[:delta_temperature])
    else
      os_opening.setDeltaTemperature(
        defaults_control[:delta_temperature][:default])
    end
    # assign schedule if it exists
    if vent_control_hash[:schedule]
      vent_sch = openstudio_model.getScheduleByName(vent_control_hash[:schedule])
      unless vent_sch.empty?
        vent_sch_object = vent_sch.get
        os_opening.setOpeningAreaFractionSchedule(vent_sch_object)
      end
    end
  end

  os_opening
end

#to_openstudio_afn(openstudio_model, parent) ⇒ Object



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
# File 'lib/to_openstudio/ventcool/opening.rb', line 130

def to_openstudio_afn(openstudio_model, parent)
  # get the tilt and BC of the parent so that we can use the correct AFN object
  srf_tilt = parent.tilt.to_f * (180 / Math::PI)
  srf_bc = parent.outsideBoundaryCondition.to_s

  # process the flow_coefficient_closed and flow exponent
  if @hash[:flow_coefficient_closed] and @hash[:flow_coefficient_closed] != 0
    flow_coefficient = @hash[:flow_coefficient_closed]
  else
    flow_coefficient = 1.0e-09  # set it to a very small number
  end
  flow_exponent = defaults[:flow_exponent_closed][:default].to_f

  # process the opening area
  if @hash[:fraction_area_operable]
    open_fac = @hash[:fraction_area_operable]
  else
    open_fac = defaults[:fraction_area_operable][:default]
  end

  # create an opening obj
  if srf_tilt < 10 || srf_tilt > 170
    if srf_bc == 'Outdoors'
      # create a crack object to represent an exterior in-operable horizontal skylight
      open_fac = nil
      os_opening = OpenStudio::Model::AirflowNetworkCrack.new(
        openstudio_model, flow_coefficient, flow_exponent, $afn_reference_crack)
    else
      # create a HorizontalOpening object to represent the interior horizontal window
      discharge_coeff = defaults[:discharge_coefficient][:default].to_f
      if srf_tilt < 10
        slope_ang = 90 - srf_tilt
      else
        slope_ang = 90 - (180 - srf_tilt)
      end
      os_opening = OpenStudio::Model::AirflowNetworkHorizontalOpening.new(
        openstudio_model, flow_coefficient, flow_exponent, slope_ang, discharge_coeff)
    end
  else
    # create the simple opening object for the Aperture or Door using default values
    two_way_thresh = defaults[:two_way_threshold][:default].to_f
    discharge_coeff = defaults[:discharge_coefficient][:default].to_f
    os_opening = OpenStudio::Model::AirflowNetworkSimpleOpening.new(
      openstudio_model, flow_coefficient, flow_exponent, two_way_thresh, discharge_coeff)

    # assign the flow exponent when the opening is closed
    if @hash[:flow_exponent_closed]
      os_opening.setAirMassFlowExponentWhenOpeningisClosed(@hash[:flow_exponent_closed])
    end
    # assign the minimum difference for two-way flow
    if @hash[:two_way_threshold]
      os_opening.setMinimumDensityDifferenceforTwoWayFlow(@hash[:two_way_threshold])
    end
    # assign the discharge coefficient
    if @hash[:discharge_coefficient]
      os_opening.setDischargeCoefficient(@hash[:discharge_coefficient])
    end
  end

  # create the AirflowNetworkSurface and assign the opening factor
  os_afn_srf = parent.getAirflowNetworkSurface(os_opening)
  unless open_fac.nil?
    os_afn_srf.setWindowDoorOpeningFactorOrCrackFactor(open_fac)
  end

  open_fac
end