Class: Honeybee::VentilationAbridged

Inherits:
ModelObject show all
Defined in:
lib/honeybee/load/ventilation.rb,
lib/to_openstudio/load/ventilation.rb,
lib/from_openstudio/load/ventilation.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_load(load) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/from_openstudio/load/ventilation.rb', line 38

def self.from_load(load)
    # create an empty hash
    hash = {}
    hash[:type] = 'VentilationAbridged'
    # set hash values from OpenStudio Object
    hash[:identifier] = clean_name(load.nameString)
    hash[:air_changes_per_hour] = load.outdoorAirFlowAirChangesperHour
    hash[:flow_per_zone] = load.outdoorAirFlowRate
    hash[:flow_per_person] = load.outdoorAirFlowperPerson
    hash[:flow_per_area] = load.outdoorAirFlowperFloorArea
    unless load.outdoorAirFlowRateFractionSchedule.empty?
        sch = load.outdoorAirFlowRateFractionSchedule.get
        if sch.to_ScheduleRuleset.is_initialized or sch.to_ScheduleFixedInterval.is_initialized
            hash[:schedule] = sch.nameString
        end
    end

    hash
end

Instance Method Details

#defaultsObject



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

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

#find_existing_openstudio_object(openstudio_model) ⇒ Object



39
40
41
42
43
# File 'lib/to_openstudio/load/ventilation.rb', line 39

def find_existing_openstudio_object(openstudio_model)
  model_vent = openstudio_model.getDesignSpecificationOutdoorAirByName(@hash[:identifier])
  return model_vent.get unless model_vent.empty?
  nil
end

#to_openstudio(openstudio_model) ⇒ Object



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
# File 'lib/to_openstudio/load/ventilation.rb', line 45

def to_openstudio(openstudio_model)
  # create ventilation openstudio object and set identifier
  os_vent = OpenStudio::Model::DesignSpecificationOutdoorAir.new(openstudio_model)
  os_vent.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_vent.setDisplayName(@hash[:display_name])
  end

  # assign air changes per hour if it exists
  if @hash[:air_changes_per_hour]
    os_vent.setOutdoorAirFlowAirChangesperHour(@hash[:air_changes_per_hour])
  else
    os_vent.setOutdoorAirFlowAirChangesperHour(defaults[:air_changes_per_hour][:default])
  end

  # assign flow per zone if it exists
  if @hash[:flow_per_zone]
    os_vent.setOutdoorAirFlowRate(@hash[:flow_per_zone])
  else
    os_vent.setOutdoorAirFlowRate(defaults[:flow_per_zone][:default])
  end

  # assign flow per person if it exists
  if @hash[:flow_per_person]
    os_vent.setOutdoorAirFlowperPerson(@hash[:flow_per_person])
  end

  # assign flow per area if it exists
  if @hash[:flow_per_area]
    os_vent.setOutdoorAirFlowperFloorArea(@hash[:flow_per_area])
  end

  # assign schedule if it exists
  if @hash[:schedule]
    vent_sch = openstudio_model.getScheduleByName(@hash[:schedule])
    unless vent_sch.empty?
      vent_sch_object = vent_sch.get
      os_vent.setOutdoorAirFlowRateFractionSchedule(vent_sch_object)
    end
  end

  os_vent
end