Class: Honeybee::ShadeConstruction
- Inherits:
-
ModelObject
- Object
- ModelObject
- Honeybee::ShadeConstruction
- Defined in:
- lib/honeybee/construction/shade.rb,
lib/to_openstudio/construction/shade.rb,
lib/from_openstudio/construction/shade.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_construction(construction) ⇒ 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 81 82 |
# File 'lib/from_openstudio/construction/shade.rb', line 38 def self.from_construction(construction) # create an empty hash hash = {} hash[:type] = 'ShadeConstruction' # set hash values from OpenStudio Object hash[:identifier] = clean_name(construction.nameString) + ' Shade' unless construction.displayName.empty? hash[:display_name] = (construction.displayName.get).force_encoding("UTF-8") end # get outermost construction layers layer = construction.layers[0] if layer.to_StandardGlazing.is_initialized layer = layer.to_StandardGlazing.get hash[:is_specular] = true # set reflectance properties from outermost layer unless layer.frontSideSolarReflectanceatNormalIncidence.empty? hash[:solar_reflectance] = layer.frontSideSolarReflectanceatNormalIncidence.get end unless layer.frontSideVisibleReflectanceatNormalIncidence.empty? hash[:visible_reflectance] = layer.frontSideVisibleReflectanceatNormalIncidence.get end elsif layer.to_StandardOpaqueMaterial.is_initialized layer = layer.to_StandardOpaqueMaterial.get hash[:is_specular] = false # set reflectance properties from outermost layer unless layer.solarReflectance.empty? hash[:solar_reflectance] = layer.solarReflectance.get end unless layer.visibleReflectance.empty? hash[:visible_reflectance] = layer.visibleReflectance.get end elsif layer.to_MasslessOpaqueMaterial.is_initialized layer = layer.to_MasslessOpaqueMaterial.get hash[:is_specular] = false # set reflectance properties from outermost layer unless layer.solarAbsorptance.empty? hash[:solar_reflectance] = 1 - layer.solarAbsorptance.get end unless layer.visibleAbsorptance.empty? hash[:visible_reflectance] = 1 - layer.visibleAbsorptance.get end end hash end |
Instance Method Details
#defaults ⇒ Object
37 38 39 |
# File 'lib/honeybee/construction/shade.rb', line 37 def defaults @@schema[:components][:schemas][:ShadeConstruction][:properties] end |
#find_existing_openstudio_object(openstudio_model) ⇒ Object
39 40 41 42 43 |
# File 'lib/to_openstudio/construction/shade.rb', line 39 def find_existing_openstudio_object(openstudio_model) object = openstudio_model.getConstructionByName(@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 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/to_openstudio/construction/shade.rb', line 45 def to_openstudio(openstudio_model) os_construction = OpenStudio::Model::Construction.new(openstudio_model) os_construction.setName(@hash[:identifier]) unless @hash[:display_name].nil? os_construction.setDisplayName(@hash[:display_name]) end os_materials = OpenStudio::Model::MaterialVector.new # create standard glazing if is specular is true if @hash[:is_specular] == true os_material = OpenStudio::Model::StandardGlazing.new(openstudio_model) # assign solar reflectance if @hash[:solar_reflectance] os_material.setFrontSideSolarReflectanceatNormalIncidence(@hash[:solar_reflectance]) else os_material.setFrontSideSolarReflectanceatNormalIncidence(defaults[:solar_reflectance][:default]) end # assign visible reflectance if @hash[:visible_reflectance] os_material.setFrontSideVisibleReflectanceatNormalIncidence(@hash[:visible_reflectance]) else os_material.setFrontSideVisibleReflectanceatNormalIncidence(defaults[:solar_reflectance][:default]) end # create standard opaque material if is specular is false else os_material = OpenStudio::Model::StandardOpaqueMaterial.new(openstudio_model) # assign solar reflectance if @hash[:solar_reflectance] os_material.setSolarReflectance(OpenStudio::OptionalDouble.new(@hash[:solar_reflectance])) else os_material.setSolarReflectance(OpenStudio::OptionalDouble.new(defaults[:visible_reflectance][:default])) end # assign visible reflectance if @hash[:visible_reflectance] os_material.setVisibleReflectance(OpenStudio::OptionalDouble.new(@hash[:visible_reflectance])) else os_material.setVisibleReflectance(OpenStudio::OptionalDouble.new(defaults[:solar_reflectance][:default])) end # assign specific heat os_material.setSpecificHeat(100) # bug in OpenStudio default Specific Heat is 0.1. end # add materials and set layers to construction os_materials << os_material os_construction.setLayers(os_materials) os_construction end |