Class: Honeybee::EnergyWindowMaterialGasCustom

Inherits:
ModelObject
  • Object
show all
Defined in:
lib/honeybee/material/window_gas_custom.rb,
lib/to_openstudio/material/window_gas_custom.rb,
lib/from_openstudio/material/window_gas_custom.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
87
88
89
90
91
92
93
94
# File 'lib/from_openstudio/material/window_gas_custom.rb', line 38

def self.from_material(material)
    # create an empty hash
    hash = {}
    hash[:type] = 'EnergyWindowMaterialGasCustom'
    # 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
    # check if boost optional object is empty
    unless material.customConductivityCoefficientA.empty?
        hash[:conductivity_coeff_a] = material.customConductivityCoefficientA.get
    end
    # check if boost optional object is empty
    unless material.customConductivityCoefficientB.empty?
        hash[:conductivity_coeff_b] = material.customConductivityCoefficientB.get
    end
    # check if boost optional object is empty
    unless material.customConductivityCoefficientC.empty?
        hash[:conductivity_coeff_c] = material.customConductivityCoefficientC.get
    end
    # check if boost optional object is empty
    unless material.viscosityCoefficientA.empty?
        hash[:viscosity_coeff_a] = material.viscosityCoefficientA.get
    end
    # check if boost optional object is empty
    unless material.viscosityCoefficientB.empty?
        hash[:viscosity_coeff_b] = material.viscosityCoefficientB.get
    end
    # check if boost optional object is empty
    unless material.viscosityCoefficientC.empty?
        hash[:viscosity_coeff_c] = material.viscosityCoefficientC.get
    end
    # check if boost optional object is empty
    unless material.specificHeatCoefficientA.empty?
        hash[:specific_heat_coeff_a] = material.specificHeatCoefficientA.get
    end
    # check if boost optional object is empty
    unless material.specificHeatCoefficientB.empty?
        hash[:specific_heat_coeff_b] = material.specificHeatCoefficientB.get
    end
    # check if boost optional object is empty
    unless material.specificHeatCoefficientC.empty?
        hash[:specific_heat_coeff_c] = material.specificHeatCoefficientC.get
    end
    # check if boost optional object is empty
    unless material.specificHeatRatio.empty?
        hash[:specific_heat_ratio] = material.specificHeatRatio.get
    end
    # check if boost optional object is empty
    unless material.molecularWeight.empty?
        hash[:molecular_weight] = material.molecularWeight.get
    end

    hash
end

Instance Method Details

#defaultsObject



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

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

#find_existing_openstudio_object(openstudio_model) ⇒ Object



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

def find_existing_openstudio_object(openstudio_model)
  object = openstudio_model.getGasByName(@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
# File 'lib/to_openstudio/material/window_gas_custom.rb', line 45

def to_openstudio(openstudio_model)
  # create window gas openstudio object
  os_gas_custom = OpenStudio::Model::Gas.new(openstudio_model)
  os_gas_custom.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_gas_custom.setDisplayName(@hash[:display_name])
  end
  os_gas_custom.setGasType('Custom')
  os_gas_custom.setConductivityCoefficientA(@hash[:conductivity_coeff_a])
  os_gas_custom.setViscosityCoefficientA(@hash[:viscosity_coeff_a])
  os_gas_custom.setSpecificHeatCoefficientA(@hash[:specific_heat_coeff_a])
  os_gas_custom.setSpecificHeatRatio(@hash[:specific_heat_ratio])
  os_gas_custom.setMolecularWeight(@hash[:molecular_weight])

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

  # assign conductivity coefficient b
  if @hash[:conductivity_coeff_b]
    os_gas_custom.setConductivityCoefficientB(@hash[:conductivity_coeff_b])
  else
    os_gas_custom.setConductivityCoefficientB(defaults[:conductivity_coeff_b][:default])
  end

  # assign conductivity coeffient c
  if @hash[:conductivity_coeff_c]
    os_gas_custom.setConductivityCoefficientC(@hash[:conductivity_coeff_c])
  else
    os_gas_custom.setConductivityCoefficientC(defaults[:conductivity_coeff_c][:default])
  end

  # assign viscosity coefficient b
  if @hash[:viscosity_coeff_b]
    os_gas_custom.setViscosityCoefficientB(@hash[:viscosity_coeff_b])
  else
    os_gas_custom.setViscosityCoefficientB(defaults[:viscosity_coeff_b][:default])
  end

  # assign viscosity coefficient c
  if @hash[:viscosity_coeff_c]
    os_gas_custom.setViscosityCoefficientC(@hash[:viscosity_coeff_c])
  else
    os_gas_custom.setViscosityCoefficientC(defaults[:viscosity_coeff_c][:default])
  end

  # assign specific heat coefficient b
  if @hash[:specific_heat_coeff_b]
    os_gas_custom.setSpecificHeatCoefficientB(@hash[:specific_heat_coeff_b])
  else
    os_gas_custom.setSpecificHeatCoefficientB(defaults[:specific_heat_coeff_b][:default])
  end

  # assign specific heat coefficient c
  if @hash[:specific_heat_coeff_c]
    os_gas_custom.setSpecificHeatCoefficientC(@hash[:specific_heat_coeff_c])
  else
    os_gas_custom.setSpecificHeatCoefficientC(defaults[:specific_heat_coeff_c][:default])
  end

  os_gas_custom
end