Class: Honeybee::EnergyMaterialVegetation

Inherits:
ModelObject
  • Object
show all
Defined in:
lib/honeybee/material/vegetation.rb,
lib/to_openstudio/material/vegetation.rb,
lib/from_openstudio/material/vegetation.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_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
81
82
83
84
85
86
# File 'lib/from_openstudio/material/vegetation.rb', line 38

def self.from_material(material)
    # create an empty hash
    hash = {}
    hash[:type] = 'EnergyMaterialVegetation'
    # 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.conductivityofDrySoil
    hash[:density] = material.densityofDrySoil
    hash[:specific_heat] = material.specificHeatofDrySoil
    hash[:plant_height] = material.heightofPlants
    hash[:leaf_area_index] = material.leafAreaIndex
    hash[:leaf_reflectivity] = material.leafReflectivity
    hash[:leaf_emissivity] = material.leafEmissivity
    hash[:min_stomatal_resist] = material.minimumStomatalResistance
    hash[:sat_vol_moist_cont] = material.saturationVolumetricMoistureContent
    hash[:residual_vol_moist_cont] = material.residualVolumetricMoistureContent
    hash[:init_vol_moist_cont] = material.initialVolumetricMoistureContent
    hash[:moist_diff_model] = material.moistureDiffusionCalculationMethod.titleize
    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
    
    # assign the optional properties
    unless material.thermalAbsorptance.empty?
      hash[:soil_thermal_absorptance] = material.thermalAbsorptance.get
    end
    unless material.solarAbsorptance.empty?
      hash[:soil_solar_absorptance] = material.solarAbsorptance.get
    end
    unless material.visibleAbsorptance.empty?
      hash[:soil_visible_absorptance] = material.visibleAbsorptance.get
    end

    hash
end

Instance Method Details

#defaultsObject



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

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

#find_existing_openstudio_object(openstudio_model) ⇒ Object



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

def find_existing_openstudio_object(openstudio_model)
  object = openstudio_model.getRoofVegetationByName(@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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/to_openstudio/material/vegetation.rb', line 45

def to_openstudio(openstudio_model)
  # create standard opaque OpenStudio material
  os_veg_mat = OpenStudio::Model::RoofVegetation.new(openstudio_model)
  os_veg_mat.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_veg_mat.setDisplayName(@hash[:display_name])
  end
  os_veg_mat.setSoilLayerName(@hash[:identifier] + '{}_SoilLayer')

  # assign thickness if it exists
  if @hash[:thickness]
    os_veg_mat.setThickness(@hash[:thickness])
  else
    os_veg_mat.setThickness(defaults[:thickness][:default])
  end

  # assign conductivity if it exists
  if @hash[:conductivity]
    os_veg_mat.setConductivityofDrySoil(@hash[:conductivity])
  else
    os_veg_mat.setConductivityofDrySoil(defaults[:conductivity][:default])
  end

  # assign density if it exists
  if @hash[:density]
    os_veg_mat.setDensityofDrySoil(@hash[:density])
  else
    os_veg_mat.setDensityofDrySoil(defaults[:density][:default])
  end

  # assign specific_heat if it exists
  if @hash[:specific_heat]
    os_veg_mat.setSpecificHeatofDrySoil(@hash[:specific_heat])
  else
    os_veg_mat.setSpecificHeatofDrySoil(defaults[:specific_heat][:default])
  end

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

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

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

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

  # assign plant_height if it exists
  if @hash[:plant_height]
    os_veg_mat.setHeightofPlants(@hash[:plant_height])
  else
    os_veg_mat.setHeightofPlants(defaults[:plant_height][:default])
  end

  # assign leaf_area_index if it exists
  if @hash[:leaf_area_index]
    os_veg_mat.setLeafAreaIndex(@hash[:leaf_area_index])
  else
    os_veg_mat.setLeafAreaIndex(defaults[:leaf_area_index][:default])
  end

  # assign leaf_reflectivity if it exists
  if @hash[:leaf_reflectivity]
    os_veg_mat.setLeafReflectivity(@hash[:leaf_reflectivity])
  else
    os_veg_mat.setLeafReflectivity(defaults[:leaf_reflectivity][:default])
  end

  # assign leaf_emissivity if it exists
  if @hash[:leaf_emissivity]
    os_veg_mat.setLeafEmissivity(@hash[:leaf_emissivity])
  else
    os_veg_mat.setLeafEmissivity(defaults[:leaf_emissivity][:default])
  end

  # assign min_stomatal_resist if it exists
  if @hash[:min_stomatal_resist]
    os_veg_mat.setMinimumStomatalResistance(@hash[:min_stomatal_resist])
  else
    os_veg_mat.setMinimumStomatalResistance(defaults[:min_stomatal_resist][:default])
  end

  # assign sat_vol_moist_cont if it exists
  if @hash[:sat_vol_moist_cont]
    os_veg_mat.setSaturationVolumetricMoistureContentoftheSoilLayer(@hash[:sat_vol_moist_cont])
  else
    os_veg_mat.setSaturationVolumetricMoistureContentoftheSoilLayer(defaults[:sat_vol_moist_cont][:default])
  end

  # assign residual_vol_moist_cont if it exists
  if @hash[:residual_vol_moist_cont]
    os_veg_mat.setResidualVolumetricMoistureContentoftheSoilLayer(@hash[:residual_vol_moist_cont])
  else
    os_veg_mat.setResidualVolumetricMoistureContentoftheSoilLayer(defaults[:residual_vol_moist_cont][:default])
  end

  # assign init_vol_moist_cont if it exists
  if @hash[:init_vol_moist_cont]
    os_veg_mat.setInitialVolumetricMoistureContentoftheSoilLayer(@hash[:init_vol_moist_cont])
  else
    os_veg_mat.setInitialVolumetricMoistureContentoftheSoilLayer(defaults[:init_vol_moist_cont][:default])
  end

  # assign moist_diff_model if it exists
  if @hash[:moist_diff_model]
    os_veg_mat.setMoistureDiffusionCalculationMethod(@hash[:moist_diff_model])
  else
    os_veg_mat.setMoistureDiffusionCalculationMethod(defaults[:moist_diff_model][:default])
  end

  os_veg_mat
end