Class: OpenStudio::Model::SpaceType

Inherits:
Object
  • Object
show all
Defined in:
lib/openstudio-standards/standards/Standards.SpaceType.rb

Overview

Reopen the OpenStudio class to add methods to apply standards to this object

Instance Method Summary collapse

Instance Method Details

#apply_internal_load_schedules(template, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration, make_thermostat) ⇒ Bool

Sets the schedules for the selected internal loads to typical schedules. Get the default schedule set for this space type if one exists or make one if none exists. For each category that is selected, add the typical schedule for this category to the default schedule set. This method does not alter any schedules of any internal loads that does not inherit from the default schedule set.

schedules listed for the space type. This thermostat is not hooked to any zone by this method, but may be found and used later.

Parameters:

  • set_people (Bool)

    if true, set the occupancy and activity schedules

  • set_lights (Bool)

    if true, set the lighting schedule

  • set_electric_equipment (Bool)

    if true, set the electric schedule schedule

  • set_gas_equipment (Bool)

    if true, set the gas equipment density

  • set_infiltration (Bool)

    if true, set the infiltration schedule

  • make_thermostat (Bool)

    if true, makes a thermostat for this space type from the

Returns:

  • (Bool)

    returns true if successful, false if not



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 456

def apply_internal_load_schedules(template, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration, make_thermostat)
  # Get the standards data
  space_type_properties = get_standards_data(template)

  # Get the default schedule set
  # or create a new one if none exists.
  default_sch_set = nil
  if defaultScheduleSet.is_initialized
    default_sch_set = defaultScheduleSet.get
  else
    default_sch_set = OpenStudio::Model::DefaultScheduleSet.new(model)
    default_sch_set.setName("#{name} Schedule Set")
    setDefaultScheduleSet(default_sch_set)
  end

  # People
  if set_people
    occupancy_sch = space_type_properties['occupancy_schedule']
    unless occupancy_sch.nil?
      default_sch_set.setNumberofPeopleSchedule(model.add_schedule(occupancy_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set occupancy schedule to #{occupancy_sch}.")
    end

    occupancy_activity_sch = space_type_properties['occupancy_activity_schedule']
    unless occupancy_activity_sch.nil?
      default_sch_set.setPeopleActivityLevelSchedule(model.add_schedule(occupancy_activity_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set occupant activity schedule to #{occupancy_activity_sch}.")
    end

  end

  # Lights
  if set_lights

    lighting_sch = space_type_properties['lighting_schedule']
    unless lighting_sch.nil?
      default_sch_set.setLightingSchedule(model.add_schedule(lighting_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set lighting schedule to #{lighting_sch}.")
    end

  end

  # Electric Equipment
  if set_electric_equipment

    elec_equip_sch = space_type_properties['electric_equipment_schedule']
    unless elec_equip_sch.nil?
      default_sch_set.setElectricEquipmentSchedule(model.add_schedule(elec_equip_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set electric equipment schedule to #{elec_equip_sch}.")
    end

  end

  # Gas Equipment
  if set_gas_equipment

    gas_equip_sch = space_type_properties['gas_equipment_schedule']
    unless gas_equip_sch.nil?
      default_sch_set.setGasEquipmentSchedule(model.add_schedule(gas_equip_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set gas equipment schedule to #{gas_equip_sch}.")
    end

  end

  # Infiltration
  if set_infiltration

    infiltration_sch = space_type_properties['infiltration_schedule']
    unless infiltration_sch.nil?
      default_sch_set.setInfiltrationSchedule(model.add_schedule(infiltration_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set infiltration schedule to #{infiltration_sch}.")
    end

  end

  # Thermostat
  if make_thermostat

    thermostat = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(model)
    thermostat.setName("#{name} Thermostat")

    heating_setpoint_sch = space_type_properties['heating_setpoint_schedule']
    unless heating_setpoint_sch.nil?
      thermostat.setHeatingSetpointTemperatureSchedule(model.add_schedule(heating_setpoint_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set heating setpoint schedule to #{heating_setpoint_sch}.")
    end

    cooling_setpoint_sch = space_type_properties['cooling_setpoint_schedule']
    unless cooling_setpoint_sch.nil?
      thermostat.setCoolingSetpointTemperatureSchedule(model.add_schedule(cooling_setpoint_sch))
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set cooling setpoint schedule to #{cooling_setpoint_sch}.")
    end

  end

  return true
end

#apply_internal_loads(template, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration) ⇒ Bool

Sets the selected internal loads to standards-based or typical values. For each category that is selected get all load instances. Remove all but the first instance if multiple instances. Add a new instance/definition if no instance exists. Modify the definition for the remaining instance to have the specified values. This method does not alter any loads directly assigned to spaces. This method skips plenums.

Also, assign reasonable clothing, air velocity, and work efficiency inputs to allow reasonable thermal comfort metrics to be calculated. to return air, fraction radiant, and fraction visible.

Parameters:

  • set_people (Bool)

    if true, set the people density.

  • set_lights (Bool)

    if true, set the lighting density, lighting fraction

  • set_electric_equipment (Bool)

    if true, set the electric equipment density

  • set_gas_equipment (Bool)

    if true, set the gas equipment density

  • set_ventilation (Bool)

    if true, set the ventilation rates (per-person and per-area)

  • set_infiltration (Bool)

    if true, set the infiltration rates

Returns:

  • (Bool)

    returns true if successful, false if not



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
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 80

def apply_internal_loads(template, set_people, set_lights, set_electric_equipment, set_gas_equipment, set_ventilation, set_infiltration)
  # Skip plenums
  # Check if the space type name
  # contains the word plenum.
  if name.get.to_s.downcase.include?('plenum')
    return false
  end
  if standardsSpaceType.is_initialized
    if standardsSpaceType.get.downcase.include?('plenum')
      return false
    end
  end

  # Get the standards data
  space_type_properties = get_standards_data(template)

  # Need to add a check, or it'll crash on space_type_properties['occupancy_per_area'].to_f below
  if space_type_properties.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} was not found in the standards data.")
    return false
  end
  # People
  people_have_info = false
  occupancy_per_area = space_type_properties['occupancy_per_area'].to_f
  people_have_info = true unless occupancy_per_area.zero?

  if set_people && people_have_info

    # Remove all but the first instance
    instances = people.sort
    if instances.size.zero?
      # Create a new definition and instance
      definition = OpenStudio::Model::PeopleDefinition.new(model)
      definition.setName("#{name} People Definition")
      instance = OpenStudio::Model::People.new(definition)
      instance.setName("#{name} People")
      instance.setSpaceType(self)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} had no people, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{name}.")
        inst.remove
      end
    end

    # Modify the definition of the instance
    instances.each do |inst|
      definition = inst.peopleDefinition
      unless occupancy_per_area.zero?
        definition.setPeopleperSpaceFloorArea(OpenStudio.convert(occupancy_per_area / 1000, 'people/ft^2', 'people/m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set occupancy to #{occupancy_per_area} people/1000 ft^2.")
      end

      # Clothing schedule for thermal comfort metrics
      clothing_sch = model.getScheduleRulesetByName('Clothing Schedule')
      if clothing_sch.is_initialized
        clothing_sch = clothing_sch.get
      else
        clothing_sch = OpenStudio::Model::ScheduleRuleset.new(model)
        clothing_sch.setName('Clothing Schedule')
        clothing_sch.defaultDaySchedule.setName('Clothing Schedule Default Winter Clothes')
        clothing_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1.0)
        sch_rule = OpenStudio::Model::ScheduleRule.new(clothing_sch)
        sch_rule.daySchedule.setName('Clothing Schedule Summer Clothes')
        sch_rule.daySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.5)
        sch_rule.setStartDate(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(5), 1))
        sch_rule.setEndDate(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(9), 30))
      end
      inst.setClothingInsulationSchedule(clothing_sch)

      # Air velocity schedule for thermal comfort metrics
      air_velo_sch = model.getScheduleRulesetByName('Air Velocity Schedule')
      if air_velo_sch.is_initialized
        air_velo_sch = air_velo_sch.get
      else
        air_velo_sch = OpenStudio::Model::ScheduleRuleset.new(model)
        air_velo_sch.setName('Air Velocity Schedule')
        air_velo_sch.defaultDaySchedule.setName('Air Velocity Schedule Default')
        air_velo_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0.2)
      end
      inst.setAirVelocitySchedule(air_velo_sch)

      # Work efficiency schedule for thermal comfort metrics
      work_efficiency_sch = model.getScheduleRulesetByName('Work Efficiency Schedule')
      if work_efficiency_sch.is_initialized
        work_efficiency_sch = work_efficiency_sch.get
      else
        work_efficiency_sch = OpenStudio::Model::ScheduleRuleset.new(model)
        work_efficiency_sch.setName('Work Efficiency Schedule')
        work_efficiency_sch.defaultDaySchedule.setName('Work Efficiency Schedule Default')
        work_efficiency_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), 0)
      end
      inst.setWorkEfficiencySchedule(work_efficiency_sch)
    end

  end

  # Lights
  lights_have_info = false
  lighting_per_area = space_type_properties['lighting_per_area'].to_f
  lighting_per_person = space_type_properties['lighting_per_person'].to_f
  lights_frac_to_return_air = space_type_properties['lighting_fraction_to_return_air'].to_f
  lights_frac_radiant = space_type_properties['lighting_fraction_radiant'].to_f
  lights_frac_visible = space_type_properties['lighting_fraction_visible'].to_f
  lights_have_info = true unless lighting_per_area.zero?
  lights_have_info = true unless lighting_per_person.zero?

  if set_lights && lights_have_info

    # Remove all but the first instance
    instances = lights.sort
    if instances.size.zero?
      definition = OpenStudio::Model::LightsDefinition.new(model)
      definition.setName("#{name} Lights Definition")
      instance = OpenStudio::Model::Lights.new(definition)
      instance.setName("#{name} Lights")
      instance.setSpaceType(self)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} had no lights, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{name}.")
        inst.remove
      end
    end

    # Modify the definition of the instance
    instances.each do |inst|
      definition = inst.lightsDefinition
      unless lighting_per_area.zero?
        definition.setWattsperSpaceFloorArea(OpenStudio.convert(lighting_per_area.to_f, 'W/ft^2', 'W/m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set LPD to #{lighting_per_area} W/ft^2.")
      end
      unless lighting_per_person.zero?
        definition.setWattsperPerson(OpenStudio.convert(lighting_per_person.to_f, 'W/person', 'W/person').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set lighting to #{lighting_per_person} W/person.")
      end
      unless lights_frac_to_return_air.zero?
        definition.setReturnAirFraction(lights_frac_to_return_air)
      end
      unless lights_frac_radiant.zero?
        definition.setFractionRadiant(lights_frac_radiant)
      end
      unless lights_frac_visible.zero?
        definition.setFractionVisible(lights_frac_visible)
      end
    end

    # If additional lights are specified, add those too
    additional_lighting_per_area = space_type_properties['additional_lighting_per_area'].to_f
    unless additional_lighting_per_area.zero?
      # Create the lighting definition
      additional_lights_def = OpenStudio::Model::LightsDefinition.new(model)
      additional_lights_def.setName("#{name} Additional Lights Definition")
      additional_lights_def.setWattsperSpaceFloorArea(OpenStudio.convert(additional_lighting_per_area.to_f, 'W/ft^2', 'W/m^2').get)
      additional_lights_def.setReturnAirFraction(lights_frac_to_return_air)
      additional_lights_def.setFractionRadiant(lights_frac_radiant)
      additional_lights_def.setFractionVisible(lights_frac_visible)

      # Create the lighting instance and hook it up to the space type
      additional_lights = OpenStudio::Model::Lights.new(additional_lights_def)
      additional_lights.setName("#{name} Additional Lights")
      additional_lights.setSpaceType(self)
    end

  end

  # Electric Equipment
  elec_equip_have_info = false
  elec_equip_per_area = space_type_properties['electric_equipment_per_area'].to_f
  elec_equip_frac_latent = space_type_properties['electric_equipment_fraction_latent'].to_f
  elec_equip_frac_radiant = space_type_properties['electric_equipment_fraction_radiant'].to_f
  elec_equip_frac_lost = space_type_properties['electric_equipment_fraction_lost'].to_f
  elec_equip_have_info = true unless elec_equip_per_area.zero?

  if set_electric_equipment && elec_equip_have_info

    # Remove all but the first instance
    instances = electricEquipment.sort
    if instances.size.zero?
      definition = OpenStudio::Model::ElectricEquipmentDefinition.new(model)
      definition.setName("#{name} Elec Equip Definition")
      instance = OpenStudio::Model::ElectricEquipment.new(definition)
      instance.setName("#{name} Elec Equip")
      instance.setSpaceType(self)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} had no electric equipment, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{name}.")
        inst.remove
      end
    end

    # Modify the definition of the instance
    instances.each do |inst|
      definition = inst.electricEquipmentDefinition
      unless elec_equip_per_area.zero?
        definition.setWattsperSpaceFloorArea(OpenStudio.convert(elec_equip_per_area.to_f, 'W/ft^2', 'W/m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set electric EPD to #{elec_equip_per_area} W/ft^2.")
      end
      unless elec_equip_frac_latent.zero?
        definition.setFractionLatent(elec_equip_frac_latent)
      end
      unless elec_equip_frac_radiant.zero?
        definition.setFractionRadiant(elec_equip_frac_radiant)
      end
      unless elec_equip_frac_lost.zero?
        definition.setFractionLost(elec_equip_frac_lost)
      end
    end

  end

  # Gas Equipment
  gas_equip_have_info = false
  gas_equip_per_area = space_type_properties['gas_equipment_per_area'].to_f
  gas_equip_frac_latent = space_type_properties['gas_equipment_fraction_latent'].to_f
  gas_equip_frac_radiant = space_type_properties['gas_equipment_fraction_radiant'].to_f
  gas_equip_frac_lost = space_type_properties['gas_equipment_fraction_lost'].to_f
  gas_equip_have_info = true unless gas_equip_per_area.zero?

  if set_gas_equipment && gas_equip_have_info

    # Remove all but the first instance
    instances = gasEquipment.sort
    if instances.size.zero?
      definition = OpenStudio::Model::GasEquipmentDefinition.new(model)
      definition.setName("#{name} Gas Equip Definition")
      instance = OpenStudio::Model::GasEquipment.new(definition)
      instance.setName("#{name} Gas Equip")
      instance.setSpaceType(self)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} had no gas equipment, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{name}.")
        inst.remove
      end
    end

    # Modify the definition of the instance
    instances.each do |inst|
      definition = inst.gasEquipmentDefinition
      unless gas_equip_per_area.zero?
        definition.setWattsperSpaceFloorArea(OpenStudio.convert(gas_equip_per_area.to_f, 'Btu/hr*ft^2', 'W/m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set gas EPD to #{elec_equip_per_area} Btu/hr*ft^2.")
      end
      unless gas_equip_frac_latent.zero?
        definition.setFractionLatent(gas_equip_frac_latent)
      end
      unless gas_equip_frac_radiant.zero?
        definition.setFractionRadiant(gas_equip_frac_radiant)
      end
      unless gas_equip_frac_lost.zero?
        definition.setFractionLost(gas_equip_frac_lost)
      end
    end

  end

  # Ventilation
  ventilation_have_info = false
  ventilation_per_area = space_type_properties['ventilation_per_area'].to_f
  ventilation_per_person = space_type_properties['ventilation_per_person'].to_f
  ventilation_ach = space_type_properties['ventilation_air_changes'].to_f
  ventilation_have_info = true unless ventilation_per_area.zero?
  ventilation_have_info = true unless ventilation_per_person.zero?
  ventilation_have_info = true unless ventilation_ach.zero?

  # Get the design OA or create a new one if none exists
  ventilation = designSpecificationOutdoorAir
  if ventilation.is_initialized
    ventilation = ventilation.get
  else
    ventilation = OpenStudio::Model::DesignSpecificationOutdoorAir.new(model)
    ventilation.setName("#{name} Ventilation")
    setDesignSpecificationOutdoorAir(ventilation)
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} had no ventilation specification, one has been created.")
  end

  if set_ventilation && ventilation_have_info

    # Modify the ventilation properties
    ventilation.setOutdoorAirMethod('Sum')
    unless ventilation_per_area.zero?
      ventilation.setOutdoorAirFlowperFloorArea(OpenStudio.convert(ventilation_per_area.to_f, 'ft^3/min*ft^2', 'm^3/s*m^2').get)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set ventilation per area to #{ventilation_per_area} cfm/ft^2.")
    end
    unless ventilation_per_person.zero?
      ventilation.setOutdoorAirFlowperPerson(OpenStudio.convert(ventilation_per_person.to_f, 'ft^3/min*person', 'm^3/s*person').get)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set ventilation per person to #{ventilation_per_person} cfm/person.")
    end
    unless ventilation_ach.zero?
      ventilation.setOutdoorAirFlowAirChangesperHour(ventilation_ach)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set ventilation to #{ventilation_ach} ACH.")
    end

  elsif set_ventilation && !ventilation_have_info

    # All space types must have a design spec OA
    # object for ventilation controls to work correctly,
    # even if the values are all zero.
    ventilation.setOutdoorAirFlowperFloorArea(0)
    ventilation.setOutdoorAirFlowperPerson(0)
    ventilation.setOutdoorAirFlowAirChangesperHour(0)

  end

  # Infiltration
  infiltration_have_info = false
  infiltration_per_area_ext = space_type_properties['infiltration_per_exterior_area'].to_f
  infiltration_per_area_ext_wall = space_type_properties['infiltration_per_exterior_wall_area'].to_f
  infiltration_ach = space_type_properties['infiltration_air_changes'].to_f
  unless infiltration_per_area_ext.zero? && infiltration_per_area_ext_wall.zero? && infiltration_ach.zero?
    infiltration_have_info = true
  end

  if set_infiltration && infiltration_have_info

    # Remove all but the first instance
    instances = spaceInfiltrationDesignFlowRates.sort
    if instances.size.zero?
      instance = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(model)
      instance.setName("#{name} Infiltration")
      instance.setSpaceType(self)
      OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} had no infiltration objects, one has been created.")
      instances << instance
    elsif instances.size > 1
      instances.each_with_index do |inst, i|
        next if i.zero?
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Removed #{inst.name} from #{name}.")
        inst.remove
      end
    end

    # Modify each instance
    instances.each do |inst|
      unless infiltration_per_area_ext.zero?
        inst.setFlowperExteriorSurfaceArea(OpenStudio.convert(infiltration_per_area_ext.to_f, 'ft^3/min*ft^2', 'm^3/s*m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set infiltration to #{ventilation_ach} per ft^2 exterior surface area.")
      end
      unless infiltration_per_area_ext_wall.zero?
        inst.setFlowperExteriorWallArea(OpenStudio.convert(infiltration_per_area_ext_wall.to_f, 'ft^3/min*ft^2', 'm^3/s*m^2').get)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set infiltration to #{infiltration_per_area_ext_wall} per ft^2 exterior wall area.")
      end
      unless infiltration_ach.zero?
        inst.setAirChangesperHour(infiltration_ach)
        OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{name} set infiltration to #{ventilation_ach} ACH.")
      end
    end

  end
end

#apply_rendering_color(template) ⇒ Bool

Sets the color for the space types as shown in the SketchUp plugin using render by space type.

Parameters:

  • target (string)

    template for lookup

Returns:

  • (Bool)

    returns true if successful, false if not.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 40

def apply_rendering_color(template)
  # Get the standards data
  space_type_properties = get_standards_data(template)

  # Set the rendering color of the space type
  rgb = space_type_properties['rgb']
  if rgb.nil?
    return false
  end

  rgb = rgb.split('_')
  r = rgb[0].to_i
  g = rgb[1].to_i
  b = rgb[2].to_i
  rendering_color = OpenStudio::Model::RenderingColor.new(model)
  rendering_color.setRenderingRedValue(r)
  rendering_color.setRenderingGreenValue(g)
  rendering_color.setRenderingBlueValue(b)
  setRenderingColor(rendering_color)

  return true
end

#get_construction_properties(template, intended_surface_type, standards_construction_type) ⇒ hash

Returns standards data for selected construction

Parameters:

  • target (string)

    template for lookup

  • intended_surface_type (string)

    template for lookup

  • standards_construction_type (string)

    template for lookup

Returns:

  • (hash)

    hash of construction properties



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 560

def get_construction_properties(template, intended_surface_type, standards_construction_type)
  # get building_category value
  building_category = if !get_standards_data(template).nil? && get_standards_data(template)['is_residential'] == 'Yes'
                        'Residential'
                      else
                        'Nonresidential'
                      end

  # get climate_zone_set
  climate_zone = model.get_building_climate_zone_and_building_type['climate_zone']
  climate_zone_set = model.find_climate_zone_set(climate_zone, template)

  # populate search hash
  search_criteria = {
    'template' => template,
    'climate_zone_set' => climate_zone_set,
    'intended_surface_type' => intended_surface_type,
    'standards_construction_type' => standards_construction_type,
    'building_category' => building_category
  }

  # switch to use this but update test in standards and measures to load this outside of the method
  construction_properties = model.find_object($os_standards['construction_properties'], search_criteria)

  return construction_properties
end

#get_standards_data(template) ⇒ hash

Returns standards data for selected space type and template

Parameters:

  • target (string)

    template for lookup

Returns:

  • (hash)

    hash of internal loads for different load types



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/openstudio-standards/standards/Standards.SpaceType.rb', line 8

def get_standards_data(template)
  standards_building_type = if standardsBuildingType.is_initialized
                              standardsBuildingType.get
                            end
  standards_space_type = if standardsSpaceType.is_initialized
                           standardsSpaceType.get
                         end

  # populate search hash
  search_criteria = {
    'template' => template,
    'building_type' => standards_building_type,
    'space_type' => standards_space_type
  }

  # lookup space type properties

  space_type_properties = model.find_object($os_standards['space_types'], search_criteria)

  if space_type_properties.nil?
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "Space type properties lookup failed: #{search_criteria}.")
    space_type_properties = {}
  end

  return space_type_properties
end