Class: Honeybee::EnergyMaterial
- Inherits:
-
ModelObject
- Object
- ModelObject
- Honeybee::EnergyMaterial
- Defined in:
- lib/honeybee/material/opaque.rb,
lib/to_openstudio/material/opaque.rb,
lib/from_openstudio/material/opaque.rb
Instance Attribute Summary
Attributes inherited from ModelObject
#errors, #openstudio_object, #warnings
Class Method Summary collapse
Instance Method Summary collapse
- #defaults ⇒ Object
- #find_existing_openstudio_object(openstudio_model) ⇒ Object
- #to_openstudio(openstudio_model) ⇒ Object
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_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 |
# File 'lib/from_openstudio/material/opaque.rb', line 38 def self.from_material(material) # create an empty hash hash = {} hash[:type] = 'EnergyMaterial' # 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[:thickness] = material.thickness hash[:conductivity] = material.conductivity hash[:density] = material.density hash[:specific_heat] = material.specificHeat 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 hash[:thermal_absorptance] = material.thermalAbsorptance hash[:solar_absorptance] = material.solarAbsorptance hash[:visible_absorptance] = material.visibleAbsorptance hash end |
Instance Method Details
#defaults ⇒ Object
37 38 39 |
# File 'lib/honeybee/material/opaque.rb', line 37 def defaults @@schema[:components][:schemas][:EnergyMaterial][:properties] end |
#find_existing_openstudio_object(openstudio_model) ⇒ Object
39 40 41 42 43 |
# File 'lib/to_openstudio/material/opaque.rb', line 39 def find_existing_openstudio_object(openstudio_model) object = openstudio_model.getStandardOpaqueMaterialByName(@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 86 |
# File 'lib/to_openstudio/material/opaque.rb', line 45 def to_openstudio(openstudio_model) # create standard opaque OpenStudio material os_opaque_mat = OpenStudio::Model::StandardOpaqueMaterial.new(openstudio_model) os_opaque_mat.setName(@hash[:identifier]) unless @hash[:display_name].nil? os_opaque_mat.setDisplayName(@hash[:display_name]) end os_opaque_mat.setThickness(@hash[:thickness]) os_opaque_mat.setConductivity(@hash[:conductivity]) os_opaque_mat.setDensity(@hash[:density]) os_opaque_mat.setSpecificHeat(@hash[:specific_heat]) # assign roughness if it exists if @hash[:roughness] os_opaque_mat.setRoughness(@hash[:roughness]) else os_opaque_mat.setRoughness(defaults[:roughness][:default]) end # assign thermal absorptance if it exists if @hash[:thermal_absorptance] os_opaque_mat.setThermalAbsorptance(@hash[:thermal_absorptance]) else os_opaque_mat.setThermalAbsorptance(defaults[:thermal_absorptance][:default]) end # assign solar absorptance if it exists if @hash[:solar_absorptance] os_opaque_mat.setSolarAbsorptance(@hash[:solar_absorptance]) else os_opaque_mat.setSolarAbsorptance(defaults[:solar_absorptance][:default]) end # assign visible absorptance if it exists if @hash[:visible_absorptance] os_opaque_mat.setVisibleAbsorptance(@hash[:visible_absorptance]) else os_opaque_mat.setVisibleAbsorptance(defaults[:visible_absorptance][:default]) end os_opaque_mat end |