Class: CoilHeatingGasMultiplier

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

Overview

start the measure

Instance Method Summary collapse

Instance Method Details

#arguments(model) ⇒ Object

define the arguments that the user will input



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
# File 'lib/measures/CoilHeatingGasMultiplier/measure.rb', line 48

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

  # populate choice argument for constructions that are applied to surfaces in the model
  loop_handles = OpenStudio::StringVector.new
  loop_display_names = OpenStudio::StringVector.new

  # putting air loops and names into hash
  loop_args = model.getAirLoopHVACs
  loop_args_hash = {}
  loop_args.each do |loop_arg|
    loop_args_hash[loop_arg.name.to_s] = loop_arg
  end

  # looping through sorted hash of air loops
  loop_args_hash.sort.map do |_key, value|
    show_loop = false
    components = value.supplyComponents
    components.each do |component|
      next if component.to_CoilHeatingGas.empty?

      show_loop = true
      loop_handles << component.handle.to_s
      loop_display_names << component.name.to_s
    end

    # if loop as object of correct type then add to hash.
    # if show_loop == true
    # loop_handles << value.handle.to_s
    # loop_display_names << key
    # end
  end

  # add building to string vector with space type
  building = model.getBuilding
  loop_handles << building.handle.to_s
  loop_display_names << '*All Gas Heating Coils*'
  loop_handles << '0'
  loop_display_names << '*None*'

  # make a choice argument for space type
  coil_arg = OpenStudio::Measure::OSArgument.makeChoiceArgument('coil', loop_handles, loop_display_names)
  coil_arg.setDisplayName('Apply the Measure to a SINGLE Gas Heating Coil, ALL the Gas Heating Coils or NONE.')
  coil_arg.setDefaultValue('*All Gas Heating Coils*') # if no space type is chosen this will run on the entire building
  args << coil_arg

  # coil_efficiency_multiplier
  coil_efficiency_multiplier = OpenStudio::Measure::OSArgument.makeDoubleArgument('coil_efficiency_multiplier', true)
  coil_efficiency_multiplier.setDisplayName('Multiplier for coil Efficiency.')
  coil_efficiency_multiplier.setDescription('Multiplier for coil Efficiency.')
  coil_efficiency_multiplier.setDefaultValue(1.0)
  args << coil_efficiency_multiplier

  # coil_capacity_multiplier
  coil_capacity_multiplier = OpenStudio::Measure::OSArgument.makeDoubleArgument('coil_capacity_multiplier', true)
  coil_capacity_multiplier.setDisplayName('Multiplier for coil Capacity.')
  coil_capacity_multiplier.setDescription('Multiplier for coil Capacity.')
  coil_capacity_multiplier.setDefaultValue(1.0)
  args << coil_capacity_multiplier

  # coil_parasitic_electric_multiplier
  coil_parasitic_electric_multiplier = OpenStudio::Measure::OSArgument.makeDoubleArgument('coil_parasitic_electric_multiplier', true)
  coil_parasitic_electric_multiplier.setDisplayName('Multiplier for coil parasitic electric load.')
  coil_parasitic_electric_multiplier.setDescription('Multiplier for coil parasitic electric load.')
  coil_parasitic_electric_multiplier.setDefaultValue(1.0)
  args << coil_parasitic_electric_multiplier

  # coil_parasitic_gas_multiplier
  coil_parasitic_gas_multiplier = OpenStudio::Measure::OSArgument.makeDoubleArgument('coil_parasitic_gas_multiplier', true)
  coil_parasitic_gas_multiplier.setDisplayName('Multiplier for coil parasitic gas load.')
  coil_parasitic_gas_multiplier.setDescription('Multiplier for coil parasitic gas load.')
  coil_parasitic_gas_multiplier.setDefaultValue(1.0)
  args << coil_parasitic_gas_multiplier

  args
end

#change_name(object, coil_parasitic_gas_multiplier, coil_efficiency_multiplier, coil_parasitic_electric_multiplier, coil_capacity_multiplier) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/measures/CoilHeatingGasMultiplier/measure.rb', line 23

def change_name(object, coil_parasitic_gas_multiplier, coil_efficiency_multiplier, coil_parasitic_electric_multiplier, coil_capacity_multiplier)
  nameString = object.name.get.to_s
  if coil_parasitic_gas_multiplier != 1.0
    nameString += " #{coil_parasitic_gas_multiplier.round(2)}x gasPara"
  end
  if coil_parasitic_electric_multiplier != 1.0
    nameString += " #{coil_parasitic_electric_multiplier.round(2)}x elecPara"
  end
  if coil_efficiency_multiplier != 1.0
    nameString += " #{coil_efficiency_multiplier.round(2)}x coilEff"
  end
  if coil_capacity_multiplier != 1.0
    nameString += " #{coil_capacity_multiplier.round(2)}x coilCap"
  end
  object.setName(nameString)
end

#check_multiplier(runner, multiplier) ⇒ Object



40
41
42
43
44
45
# File 'lib/measures/CoilHeatingGasMultiplier/measure.rb', line 40

def check_multiplier(runner, multiplier)
  if multiplier < 0
    runner.registerError("Multiplier #{multiplier} cannot be negative.")
    false
  end
end

#descriptionObject

human readable description



14
15
16
# File 'lib/measures/CoilHeatingGasMultiplier/measure.rb', line 14

def description
  'This is a general purpose measure to calibrate Gas Heating Coils with a Multiplier.'
end

#modeler_descriptionObject

human readable description of modeling approach



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

def modeler_description
  'It will be used for calibration of rated capacity and efficiency and parasitic loads. User can choose between a SINGLE coil or ALL the Coils.'
end

#nameObject

human readable name



9
10
11
# File 'lib/measures/CoilHeatingGasMultiplier/measure.rb', line 9

def name
  'Heating Coils Gas Multiplier'
end

#run(model, runner, user_arguments) ⇒ Object

define what happens when the measure is run



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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/measures/CoilHeatingGasMultiplier/measure.rb', line 126

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

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

  # assign the user inputs to variables
  coil_object = runner.getOptionalWorkspaceObjectChoiceValue('coil', user_arguments, model)
  coil_handle = runner.getStringArgumentValue('coil', user_arguments)

  coil_capacity_multiplier = runner.getDoubleArgumentValue('coil_capacity_multiplier', user_arguments)
  check_multiplier(runner, coil_capacity_multiplier)
  coil_efficiency_multiplier = runner.getDoubleArgumentValue('coil_efficiency_multiplier', user_arguments)
  check_multiplier(runner, coil_efficiency_multiplier)
  coil_parasitic_electric_multiplier = runner.getDoubleArgumentValue('coil_parasitic_electric_multiplier', user_arguments)
  check_multiplier(runner, coil_parasitic_electric_multiplier)
  coil_parasitic_gas_multiplier = runner.getDoubleArgumentValue('coil_parasitic_gas_multiplier', user_arguments)
  check_multiplier(runner, coil_parasitic_gas_multiplier)

  # find objects to change
  coils = []
  building = model.getBuilding
  building_handle = building.handle.to_s
  runner.registerInfo("coil_handle: #{coil_handle}")
  # setup coils
  if coil_handle == building_handle
    # Use ALL coils
    runner.registerInfo('Applying change to ALL Coils')
    loops = model.getAirLoopHVACs
    # loop through air loops
    loops.each do |loop|
      supply_components = loop.supplyComponents
      # find coils on loops
      supply_components.each do |supply_component|
        unless supply_component.to_CoilHeatingGas.empty?
          coils << supply_component.to_CoilHeatingGas.get
        end
      end
    end
  elsif coil_handle == 0.to_s
    # coils set to NONE so do nothing
    runner.registerInfo('Applying change to NONE Coils')
  elsif !coil_handle.empty?
    # Single coil handle found, check if object is good
    if !coil_object.get.to_CoilHeatingGas.empty?
      runner.registerInfo("Applying change to #{coil_object.get.name} coil")
      coils << coil_object.get.to_CoilHeatingGas.get
    else
      runner.registerError("coil with handle #{coil_handle} could not be found.")
    end
  else
    runner.registerError('coil handle is empty.')
    return false
  end

  # report initial condition of model
  runner.registerInitialCondition("Coils to change: #{coils.size}")
  runner.registerInfo("Coils to change: #{coils.size}")
  altered_coils = []
  altered_capacity = []
  altered_parasiteelectric = []
  altered_coilefficiency = []
  altered_parasitegas = []
  # loop through coils
  coils.each do |coil|
    altered_coil = false
    # coil_capacity_multiplier
    if coil_capacity_multiplier != 1.0 && coil.nominalCapacity.is_initialized
      runner.registerInfo("Applying nominalCapacity #{coil_capacity_multiplier}x multiplier to #{coil.name.get}.")
      coil.setNominalCapacity(coil.nominalCapacity.get * coil_capacity_multiplier)
      altered_capacity << coil.handle.to_s
      altered_coil = true
    end

    # modify coil_efficiency_multiplier
    if coil_efficiency_multiplier != 1.0
      runner.registerInfo("Applying gasBurnerEfficiency #{coil_efficiency_multiplier}x multiplier to #{coil.name.get}.")
      if coil.gasBurnerEfficiency * coil_efficiency_multiplier <= 1
        coil.setGasBurnerEfficiency(coil.gasBurnerEfficiency * coil_efficiency_multiplier)
      else
        coil.setGasBurnerEfficiency(1.0)
        runner.registerWarning("#{coil_efficiency_multiplier}x multiplier results in Efficiency greater than 1.")
      end
      altered_coilefficiency << coil.handle.to_s
      altered_coil = true
    end

    # coil_parasitic_electric_multiplier
    if coil_parasitic_electric_multiplier != 1.0
      runner.registerInfo("Applying parasiticElectricLoad #{coil_parasitic_electric_multiplier}x multiplier to #{coil.name.get}.")
      coil.setParasiticElectricLoad(coil.parasiticElectricLoad * coil_parasitic_electric_multiplier)
      altered_parasiteelectric << coil.handle.to_s
      altered_coil = true
    end

    # coil_parasitic_gas_multiplier
    if coil_parasitic_gas_multiplier != 1.0
      runner.registerInfo("Applying parasiticGasLoad #{coil_parasitic_gas_multiplier}x multiplier to #{coil.name.get}.")
      coil.setParasiticGasLoad(coil.parasiticGasLoad * coil_parasitic_gas_multiplier)
      altered_parasitegas << coil.handle.to_s
      altered_coil = true
    end

    next unless altered_coil

    altered_coils << coil.handle.to_s
    change_name(coil, coil_parasitic_gas_multiplier, coil_efficiency_multiplier, coil_parasitic_electric_multiplier, coil_capacity_multiplier)
    runner.registerInfo("coil name changed to: #{coil.name.get}")
  end

  # na if nothing in model to look at
  if altered_coils.empty?
    runner.registerAsNotApplicable('No Coils were altered in the model')
    return true
  end

  # report final condition of model
  runner.registerFinalCondition("#{altered_coils.size} Coils objects were altered.")

  true
end