Class: Honeybee::PeopleAbridged

Inherits:
ModelObject show all
Defined in:
lib/honeybee/load/people.rb,
lib/to_openstudio/load/people.rb,
lib/from_openstudio/load/people.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
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/from_openstudio/load/people.rb', line 38

def self.from_load(load)
    # create an empty hash
    hash = {}
    hash[:type] = 'PeopleAbridged'
    # set hash values from OpenStudio Object
    hash[:identifier] = clean_name(load.nameString)
    unless load.displayName.empty?
        hash[:display_name] = (load.displayName.get).force_encoding("UTF-8")
    end
    #TODO: Is there a default occupancy schedule since it is a required field in HB but not
    #in OS
    unless load.numberofPeopleSchedule.empty?
        schedule = load.numberofPeopleSchedule.get
        hash[:occupancy_schedule] = schedule.nameString
    end
    unless load.activityLevelSchedule.empty?
        schedule = load.activityLevelSchedule.get
        hash[:activity_schedule] = schedule.nameString
    end
    load_def = load.peopleDefinition
    unless load_def.peopleperSpaceFloorArea.empty?
        hash[:people_per_area] = load_def.peopleperSpaceFloorArea.to_f
    end
    hash[:radiant_fraction] = load_def.fractionRadiant
    unless load_def.isSensibleHeatFractionAutocalculated
        sensible_fraction = load_def.sensibleHeatFraction
        unless sensible_fraction.empty
            hash[:latent_fraction] = 1 - sensible_fraction.get
        end
    end
   hash
end

Instance Method Details

#defaultsObject



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

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

#find_existing_openstudio_object(openstudio_model) ⇒ Object



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

def find_existing_openstudio_object(openstudio_model)
  model_people = openstudio_model.getPeopleByName(@hash[:identifier])
  return model_people.get unless model_people.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
88
89
90
91
# File 'lib/to_openstudio/load/people.rb', line 45

def to_openstudio(openstudio_model)

  # create people OpenStudio object and set identifier
  os_people_def = OpenStudio::Model::PeopleDefinition.new(openstudio_model)
  os_people = OpenStudio::Model::People.new(os_people_def)
  os_people_def.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_people_def.setDisplayName(@hash[:display_name])
  end
  os_people.setName(@hash[:identifier])

  # assign people per space floor area
  os_people_def.setPeopleperSpaceFloorArea(@hash[:people_per_area])

  # assign activity schedule
  activity_sch = openstudio_model.getScheduleByName(@hash[:activity_schedule])
  unless activity_sch.empty?
    activity_sch_object = activity_sch.get
    os_people.setActivityLevelSchedule(activity_sch_object)
  end

  # assign occupancy schedule
  occupancy_sch = openstudio_model.getScheduleByName(@hash[:occupancy_schedule])
  unless occupancy_sch.empty?
    occupancy_sch_object = occupancy_sch.get
    os_people.setNumberofPeopleSchedule(occupancy_sch_object)
  end

  # assign radiant fraction if it exists
  if @hash[:radiant_fraction]
    os_people_def.setFractionRadiant(@hash[:radiant_fraction])
  else
    os_people_def.setFractionRadiant(defaults[:radiant_fraction][:default])
  end

  # assign latent fraction if it exists
  if @hash[:latent_fraction]
    if @hash[:latent_fraction].is_a? Numeric
      sensible_fraction = 1 - (@hash[:latent_fraction])
      os_people_def.setSensibleHeatFraction(sensible_fraction)
    else
      os_people_def.autocalculateSensibleHeatFraction()
    end
  end

  os_people
end