Class: Honeybee::EnergyMaterialNoMass

Inherits:
ModelObject show all
Defined in:
lib/honeybee/material/opaque_no_mass.rb,
lib/to_openstudio/material/opaque_no_mass.rb,
lib/from_openstudio/material/opaque_no_mass.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, #defaults, #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

.defaultsObject



37
38
39
# File 'lib/honeybee/material/opaque_no_mass.rb', line 37

def self.defaults
  @@schema[:components][:schemas][:EnergyMaterialNoMass][:properties]
end

.from_material(material) ⇒ 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
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/from_openstudio/material/opaque_no_mass.rb', line 38

def self.from_material(material)
    # create an empty hash
    hash = {}
    hash[:type] = 'EnergyMaterialNoMass'
    # set hash values from OpenStudio Object
    hash[:identifier] = clean_name(material.nameString)
    unless material.displayName.empty?
      hash[:display_name] = (material.displayName.get).force_encoding("UTF-8")
    end
    hash[:r_value] = material.thermalResistance

    if material.to_MasslessOpaqueMaterial.is_initialized
      # Roughness is a required property for OS MasslessOpaqueMaterial but isn't a listed
      # property for OS AirGap
      case material.roughness.downcase
      when 'veryrough'
        hash[:roughness] == 'VeryRough'
      when 'mediumrough'
        hash[:roughness] == 'MediumRough'
      when 'mediumsmooth'
        hash[:roughness] == 'MediumSmooth'
      when 'verysmooth'
        hash[:roughness] == 'VerySmooth'
      # In case of Rough or Smooth
      else
        hash[:roughness] = material.roughness.titleize
      end
      # check if boost optional object is empty
      unless material.thermalAbsorptance.empty?
        hash[:thermal_absorptance] = material.thermalAbsorptance.get
      end
      # check if boost optional object is empty
      unless material.solarAbsorptance.empty?
        hash[:solar_absorptance] = material.solarAbsorptance.get
      end
      # check if boost optional object is empty
      unless material.visibleAbsorptance.empty?
        hash[:visible_absorptance] = material.visibleAbsorptance.get
      end
    end

    hash
end

Instance Method Details

#find_existing_openstudio_object(openstudio_model) ⇒ Object



39
40
41
42
43
# File 'lib/to_openstudio/material/opaque_no_mass.rb', line 39

def find_existing_openstudio_object(openstudio_model)
  object = openstudio_model.getMasslessOpaqueMaterialByName(@hash[:identifier])
  return object.get if object.is_initialized
  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
# File 'lib/to_openstudio/material/opaque_no_mass.rb', line 45

def to_openstudio(openstudio_model)

  # create no mass material OpenStudio object and set identifier
  os_nomass_mat = OpenStudio::Model::MasslessOpaqueMaterial.new(openstudio_model)
  os_nomass_mat.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_nomass_mat.setDisplayName(@hash[:display_name])
  end
  # assign thermal resistance
  os_nomass_mat.setThermalResistance(@hash[:r_value])

  # assign roughness if it exists
  if @hash[:roughness]
    os_nomass_mat.setRoughness(@hash[:roughness])
  else
    os_nomass_mat.setRoughness(defaults[:roughness][:default])
  end

  # assign thermal absorptance if it exists
  if @hash[:thermal_absorptance]
    os_nomass_mat.setThermalAbsorptance(@hash[:thermal_absorptance])
  else
    os_nomass_mat.setThermalAbsorptance(defaults[:thermal_absorptance][:default])
  end

  # assign solar absorptance if it exists
  if @hash[:solar_absorptance]
    os_nomass_mat.setSolarAbsorptance(@hash[:solar_absorptance])
  else
    os_nomass_mat.setSolarAbsorptance(defaults[:solar_absorptance][:default])
  end

  # assign visible absorptance if it exists
  if @hash[:visible_absorptance]
    os_nomass_mat.setVisibleAbsorptance(@hash[:visible_absorptance])
  else
    os_nomass_mat.setVisibleAbsorptance(defaults[:visible_absorptance][:default])
  end

  os_nomass_mat
end