Class: AddEMPDMaterialProperties

Inherits:
OpenStudio::Measure::ModelMeasure
  • Object
show all
Defined in:
lib/measures/add_empd_material_properties/measure.rb

Overview

start the measure

Instance Method Summary collapse

Instance Method Details

#arguments(model) ⇒ Object

define the arguments that the user will input



34
35
36
37
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
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
# File 'lib/measures/add_empd_material_properties/measure.rb', line 34

def arguments(model)
  args = OpenStudio::Measure::OSArgumentVector.new

  # find the available materials
  list_materials = model.getStandardOpaqueMaterials
  mat_names = []
  list_materials.each do |v|
    mat_names.append(v.name.to_s)
  end
  mat_names.sort!

  # Create arguments for material selection (Choice)
  selected_material = OpenStudio::Measure::OSArgument.makeChoiceArgument('selected_material',
                                                                         mat_names, true, true)
  selected_material.setDisplayName('Select Material')
  if !mat_names.empty?
    selected_material.setDefaultValue(mat_names[0])
  else
    selected_material.setDefaultValue('No Materials In Model!')
  end
  args << selected_material

  # create argument for Water Vapor Diffusion Resistance Factor
  water_diff_fact = OpenStudio::Measure::OSArgument.makeDoubleArgument('water_diff_fact', true)
  water_diff_fact.setDisplayName('Set value for Water Vapor Diffusion Resistance Factor')
  water_diff_fact.setDefaultValue(0)
  args << water_diff_fact

  # create argument for Coefficient A
  coef_a = OpenStudio::Measure::OSArgument.makeDoubleArgument('coef_a', true)
  coef_a.setDisplayName('Set value for Moisture Equation Coefficient A')
  coef_a.setDefaultValue(0)
  args << coef_a

  # create argument for Coefficient B
  coef_b = OpenStudio::Measure::OSArgument.makeDoubleArgument('coef_b', true)
  coef_b.setDisplayName('Set value for Moisture Equation Coefficient B')
  coef_b.setDefaultValue(0)
  args << coef_b

  # create argument for Coefficient C
  coef_c = OpenStudio::Measure::OSArgument.makeDoubleArgument('coef_c', true)
  coef_c.setDisplayName('Set value for Moisture Equation Coefficient C')
  coef_c.setDefaultValue(0)
  args << coef_c

  # create argument for Coefficient D
  coef_d = OpenStudio::Measure::OSArgument.makeDoubleArgument('coef_d', true)
  coef_d.setDisplayName('Set value for Moisture Equation Coefficient D')
  coef_d.setDefaultValue(0)
  args << coef_d

  # create argument for Surface Layer Penetration Depth
  surface_penetration = OpenStudio::Measure::OSArgument.makeStringArgument('surface_penetration', true)
  surface_penetration.setDisplayName('Set value for Surface Layer Penetration Depth')
  surface_penetration.setDefaultValue('Auto')
  args << surface_penetration

  # create argument for Deep Layer Penetration Depth
  deep_penetration = OpenStudio::Measure::OSArgument.makeStringArgument('deep_penetration', false)
  deep_penetration.setDisplayName('Set value for Deep Layer Penetration Depth')
  deep_penetration.setDefaultValue('Auto')
  args << deep_penetration

  # create argument for Coating layer Thickness
  coating = OpenStudio::Measure::OSArgument.makeDoubleArgument('coating', true)
  coating.setDisplayName('Set value for Coating Layer Thickness')
  coating.setDefaultValue(0)
  args << coating

  # create argument for Coating layer Resistance
  coating_res = OpenStudio::Measure::OSArgument.makeDoubleArgument('coating_res', true)
  coating_res.setDisplayName('Set value for Coating Layer Resistance Factor')
  coating_res.setDefaultValue(0)
  args << coating_res

  # create argument for heat balance algorithm
  algs = ['', 'MoisturePenetrationDepthConductionTransferFunction',
          'ConductionTransferFunction']
  algorithm = OpenStudio::Measure::OSArgument.makeChoiceArgument('algorithm', algs, false)
  algorithm.setDisplayName('Change heat balance algorithm?')
  algorithm.setDefaultValue(algs[0])
  args << algorithm

  return args
end

#descriptionObject

human readable description



24
25
26
# File 'lib/measures/add_empd_material_properties/measure.rb', line 24

def description
  return 'Adds the properties for the effective moisture penetration depth (EMPD) Heat Balance Model with inputs for penetration depths.'
end

#modeler_descriptionObject

human readable description of modeling approach



29
30
31
# File 'lib/measures/add_empd_material_properties/measure.rb', line 29

def modeler_description
  return ['Adds', 'the', 'properties', 'for', 'the', 'MoisturePenetrationDepthConductionTransferFunction', 'or', 'effective', 'moisture', 'penetration', 'depth', '(EMPD)', 'Heat', 'Balance', 'Model', 'with', 'inputs', 'for', 'penetration', 'depths.', "\n\n", 'Leaving', 'Change', 'heat', 'balance', 'algorithm?', 'blank', 'will', 'use', 'the', 'current', 'OpenStudio', 'heat', 'balance', 'algorithm', 'setting.', "\n\n", 'At', 'least', '1', 'interior', 'material', 'needs', 'to', 'have', 'moisture', 'penetration', 'depth', 'properties', 'set', 'to', 'use', 'the', 'EMPD', 'heat', 'balance', 'algorithm.'].join(' ')
end

#nameObject

human readable name



18
19
20
21
# File 'lib/measures/add_empd_material_properties/measure.rb', line 18

def name
  # Measure name should be the title case of the class name.
  return 'Add EMPD Material Properties'
end

#run(model, runner, user_arguments) ⇒ Object

define what happens when the measure is run



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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/measures/add_empd_material_properties/measure.rb', line 122

def run(model, runner, user_arguments)
  super(model, runner, user_arguments)

  # use the built-in error checking
  if !runner.validateUserArguments(arguments(model), user_arguments)
    return false
  end

  # assign the user inputs to variables
  selected_material = runner.getStringArgumentValue('selected_material', user_arguments)
  water_diff_fact = runner.getDoubleArgumentValue('water_diff_fact', user_arguments)
  coef_a = runner.getDoubleArgumentValue('coef_a', user_arguments)
  coef_b = runner.getDoubleArgumentValue('coef_b', user_arguments)
  coef_c = runner.getDoubleArgumentValue('coef_c', user_arguments)
  coef_d = runner.getDoubleArgumentValue('coef_d', user_arguments)
  surface_penetration = runner.getStringArgumentValue('surface_penetration', user_arguments)
  surface_penetration = surface_penetration.to_f
  deep_penetration = runner.getStringArgumentValue('deep_penetration', user_arguments)
  deep_penetration = deep_penetration.to_f
  coating = runner.getDoubleArgumentValue('coating', user_arguments)
  coating_res = runner.getDoubleArgumentValue('coating_res', user_arguments)
  algorithm = runner.getStringArgumentValue('algorithm', user_arguments)

  #---------------------------------------------------------------------------
  # Validate arguments
  if water_diff_fact == 0
    runner.registerError('The Water Vapor Diffusion Resistance Factor needs to be greater than 0.')
    return false
  end
  if coef_a == 0
    runner.registerWarning('The Moisture Equation Coefficient A has been left as 0. This is usally a non-zero value.')
  end
  if coef_b == 0
    runner.registerWarning('The Moisture Equation Coefficient B has been left as 0. This is usally a non-zero value.')
  end
  if coef_c == 0
    runner.registerWarning('The Moisture Equation Coefficient C has been left as 0. This is usally a non-zero value.')
  end
  if coef_d == 0
    runner.registerWarning('The Moisture Equation Coefficient D has been left as 0. This is usally a non-zero value.')
  end
  #---------------------------------------------------------------------------

  # Get os object for selected material
  mats = model.getStandardOpaqueMaterials
  mat = ''
  mats.each do |m|
    if m.name.to_s == selected_material
      mat = m
    end
  end

  # report initial condition of model
  runner.registerInitialCondition("The building has #{mats.size} materials.")

  #---------------------------------------------------------------------------
  # Set algorithm and report to users
  if algorithm != ''
    alg = model.getHeatBalanceAlgorithm
    alg.setAlgorithm(algorithm)
    runner.registerInfo("Heat Balance Algorithm Set to : #{algorithm}")
  end
  #---------------------------------------------------------------------------

  # Add moisture properties object and make changes to model
  n = OpenStudio::Model::MaterialPropertyMoisturePenetrationDepthSettings.new(
    mat, water_diff_fact, coef_a, coef_b, coef_c, coef_d, coating, coating_res
  )

  # check if the surface penetration is being autocalculated, and if not set the depth
  if surface_penetration > 0
    n.setSurfaceLayerPenetrationDepth(surface_penetration)
    runner.registerInfo("Surface layer penetration depth set to: #{surface_penetration}")
  else
    n.autocalculateSurfaceLayerPenetrationDepth
    runner.registerInfo('Surface layer penetration depth set to: AutoCalculate')
  end

  # check if the deep penetration is being autocalculated, and if not set the depth
  if deep_penetration > 0
    n.setDeepLayerPenetrationDepth(deep_penetration)
    runner.registerInfo("Deep layer penetration depth set to: #{surface_penetration}")
  else
    n.autocalculateDeepLayerPenetrationDepth
    runner.registerInfo('Deep layer penetration depth set to: AutoCalculate')
  end

  # report final condition of model
  runner.registerFinalCondition("Moisture properties were added to #{selected_material}.")

  return true
end