Class: XcelEDATariffSelectionandModelSetup

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

Overview

start the measure

Instance Method Summary collapse

Instance Method Details

#arguments(workspace) ⇒ Object

define the arguments that the user will input



26
27
28
29
30
31
32
33
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
# File 'lib/measures/XcelEDATariffSelectionandModelSetup/measure.rb', line 26

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

  # make an argument for the electric tariff
  elec_chs = OpenStudio::StringVector.new
  elec_chs << 'Residential General'
  elec_chs << 'Commercial'
  elec_chs << 'Primary General'
  elec_chs << 'Secondary General Low Load Factor'
  elec_chs << 'Secondary General'
  elec_chs << 'Secondary Photovoltaic Time-of-Use'
  elec_chs << 'Transmission General'
  elec_chs << 'Non-Xcel Commercial'
  elec_chs << 'Non-Xcel Primary General'
  elec_chs << 'Non-Xcel Secondary General Low Load Factor'
  elec_chs << 'Non-Xcel Secondary General'
  elec_chs << 'Non-Xcel Transmission General'
  elec_tar = OpenStudio::Measure::OSArgument.makeChoiceArgument('elec_tar', elec_chs, true)
  elec_tar.setDisplayName('Select an Electricity Tariff.')
  elec_tar.setDefaultValue('Secondary General')
  args << elec_tar

  # make an argument for the gas tariff
  gas_chs = OpenStudio::StringVector.new
  gas_chs << 'Residential Gas'
  gas_chs << 'Small CG'
  gas_chs << 'Large CG'
  gas_chs << 'Interruptible Industrial G'
  gas_chs << 'Non-Xcel Gas Firm'
  gas_chs << 'Non-Xcel Gas Interruptible'
  gas_tar = OpenStudio::Measure::OSArgument.makeChoiceArgument('gas_tar', gas_chs, true)
  gas_tar.setDisplayName('Select a Gas Tariff.')
  gas_tar.setDefaultValue('Large CG')
  args << gas_tar

  return args
end

#nameObject

define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml



21
22
23
# File 'lib/measures/XcelEDATariffSelectionandModelSetup/measure.rb', line 21

def name
  return 'XcelEDATariffSelectionandModelSetup'
end

#run(workspace, runner, user_arguments) ⇒ Object

define what happens when the measure is run



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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/measures/XcelEDATariffSelectionandModelSetup/measure.rb', line 65

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

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

  # assign the user inputs to variables
  elec_tar = runner.getStringArgumentValue('elec_tar', user_arguments)
  gas_tar = runner.getStringArgumentValue('gas_tar', user_arguments)

  # import the tariffs
  [elec_tar, gas_tar].each do |tar|
    # load the idf file containing the electric tariff
    tar_path = OpenStudio::Path.new("#{File.dirname(__FILE__)}/resources/#{tar}.idf")
    tar_file = OpenStudio::IdfFile.load(tar_path)

    # in OpenStudio PAT in 1.1.0 and earlier all resource files are moved up a directory.
    # below is a temporary workaround for this before issuing an error.
    if tar_file.empty?
      tar_path = OpenStudio::Path.new("#{File.dirname(__FILE__)}/#{tar}.idf")
      tar_file = OpenStudio::IdfFile.load(tar_path)
    end

    if tar_file.empty?
      runner.registerError("Unable to find the file #{tar}.idf")
      return false
    else
      tar_file = tar_file.get
    end

    # add the schedule type limits
    workspace.addObjects(tar_file.getObjectsByType('ScheduleTypeLimits'.to_IddObjectType))

    # add the schedules
    workspace.addObjects(tar_file.getObjectsByType('Schedule:Compact'.to_IddObjectType))

    # add the tariffs
    workspace.addObjects(tar_file.getObjectsByType('UtilityCost:Tariff'.to_IddObjectType))

    # add the simple charges
    workspace.addObjects(tar_file.getObjectsByType('UtilityCost:Charge:Simple'.to_IddObjectType))

    # add the block charges
    workspace.addObjects(tar_file.getObjectsByType('UtilityCost:Charge:Block'.to_IddObjectType))

    # let the user know what happened
    runner.registerInfo("added a tariff named #{tar}")
  end

  # set the simulation timestep to 15min (4 per hour) to match the demand window of the tariffs
  if !workspace.getObjectsByType('Timestep'.to_IddObjectType).empty?
    workspace.getObjectsByType('Timestep'.to_IddObjectType)[0].setString(0, '4')
    runner.registerInfo('set the simulation timestep to 15 min to match the demand window of the tariffs')
  else
    runner.registerError('there was no timestep object to alter')
  end

  # remove any existing lifecycle cost parameters
  workspace.getObjectsByType('LifeCycleCost:Parameters'.to_IddObjectType).each do |object|
    runner.registerInfo("removed existing lifecycle parameters named #{object.name}")
    workspace.removeObjects([object.handle])
  end

  # and replace with the FEMP ones
  life_cycle_params_string = "
  LifeCycleCost:Parameters,
    FEMP LifeCycle Cost Parameters,         !- Name
    EndOfYear,                              !- Discounting Convention
    ConstantDollar,                         !- Inflation Approach
    0.03,                                   !- Real Discount Rate
    ,                                       !- Nominal Discount Rate
    ,                                       !- Inflation
    ,                                       !- Base Date Month
    2011,                                   !- Base Date Year
    ,                                       !- Service Date Month
    2011,                                   !- Service Date Year
    25,                                     !- Length of Study Period in Years
    ,                                       !- Tax rate
    None;                                   !- Depreciation Method
  "
  life_cycle_params = OpenStudio::IdfObject.load(life_cycle_params_string).get
  workspace.addObject(life_cycle_params)
  runner.registerInfo("added lifecycle cost parameters named #{life_cycle_params.name}")

  # remove any existing lifecycle cost parameters
  workspace.getObjectsByType('LifeCycleCost:UsePriceEscalation'.to_IddObjectType).each do |object|
    runner.registerInfo("removed existing fuel escalation rates named #{object.name}")
    workspace.removeObjects([object.handle])
  end

  elec_escalation_string = "
  LifeCycleCost:UsePriceEscalation,
    U.S. Avg  Commercial-Electricity,       !- Name
    Electricity,                            !- Resource
    2011,                                   !- Escalation Start Year
    January,                                !- Escalation Start Month
    0.9838,                                 !- Year Escalation 1
    0.9730,                                 !- Year Escalation 2
    0.9632,                                 !- Year Escalation 3
    0.9611,                                 !- Year Escalation 4
    0.9571,                                 !- Year Escalation 5
    0.9553,                                 !- Year Escalation 6
    0.9539,                                 !- Year Escalation 7
    0.9521,                                 !- Year Escalation 8
    0.9546,                                 !- Year Escalation 9
    0.9550,                                 !- Year Escalation 10
    0.9553,                                 !- Year Escalation 11
    0.9564,                                 !- Year Escalation 12
    0.9575,                                 !- Year Escalation 13
    0.9596,                                 !- Year Escalation 14
    0.9618,                                 !- Year Escalation 15
    0.9614,                                 !- Year Escalation 16
    0.9618,                                 !- Year Escalation 17
    0.9618,                                 !- Year Escalation 18
    0.9593,                                 !- Year Escalation 19
    0.9589,                                 !- Year Escalation 20
    0.9607,                                 !- Year Escalation 21
    0.9625,                                 !- Year Escalation 22
    0.9650,                                 !- Year Escalation 23
    0.9708,                                 !- Year Escalation 24
    0.9751,                                 !- Year Escalation 25
    0.9762,                                 !- Year Escalation 26
    0.9766,                                 !- Year Escalation 27
    0.9766,                                 !- Year Escalation 28
    0.9769,                                 !- Year Escalation 29
    0.9773;                                 !- Year Escalation 30
  "
  elec_escalation = OpenStudio::IdfObject.load(elec_escalation_string).get
  workspace.addObject(elec_escalation)
  runner.registerInfo("added fuel escalation rates named #{elec_escalation.name}")

  fuel_oil_1_escalation_string = "
  LifeCycleCost:UsePriceEscalation,
    U.S. Avg  Commercial-Distillate Oil,    !- Name
    FuelOilNo1,                              !- Resource
    2011,                                   !- Escalation Start Year
    January,                                !- Escalation Start Month
    0.9714,                                 !- Year Escalation 1
    0.9730,                                 !- Year Escalation 2
    0.9942,                                 !- Year Escalation 3
    1.0164,                                 !- Year Escalation 4
    1.0541,                                 !- Year Escalation 5
    1.0928,                                 !- Year Escalation 6
    1.1267,                                 !- Year Escalation 7
    1.1580,                                 !- Year Escalation 8
    1.1792,                                 !- Year Escalation 9
    1.1967,                                 !- Year Escalation 10
    1.2200,                                 !- Year Escalation 11
    1.2333,                                 !- Year Escalation 12
    1.2566,                                 !- Year Escalation 13
    1.2709,                                 !- Year Escalation 14
    1.2826,                                 !- Year Escalation 15
    1.2985,                                 !- Year Escalation 16
    1.3102,                                 !- Year Escalation 17
    1.3250,                                 !- Year Escalation 18
    1.3261,                                 !- Year Escalation 19
    1.3282,                                 !- Year Escalation 20
    1.3324,                                 !- Year Escalation 21
    1.3356,                                 !- Year Escalation 22
    1.3431,                                 !- Year Escalation 23
    1.3510,                                 !- Year Escalation 24
    1.3568,                                 !- Year Escalation 25
    1.3606,                                 !- Year Escalation 26
    1.3637,                                 !- Year Escalation 27
    1.3674,                                 !- Year Escalation 28
    1.3706,                                 !- Year Escalation 29
    1.3743;                                 !- Year Escalation 30
  "
  fuel_oil_1_escalation = OpenStudio::IdfObject.load(fuel_oil_1_escalation_string).get
  workspace.addObject(fuel_oil_1_escalation)
  runner.registerInfo("added fuel escalation rates named #{fuel_oil_1_escalation.name}")

  fuel_oil_2_escalation_string = "
  LifeCycleCost:UsePriceEscalation,
    U.S. Avg  Commercial-Residual Oil,      !- Name
    FuelOilNo2,                              !- Resource
    2011,                                   !- Escalation Start Year
    January,                                !- Escalation Start Month
    0.8469,                                 !- Year Escalation 1
    0.8257,                                 !- Year Escalation 2
    0.8681,                                 !- Year Escalation 3
    0.8988,                                 !- Year Escalation 4
    0.9289,                                 !- Year Escalation 5
    0.9604,                                 !- Year Escalation 6
    0.9897,                                 !- Year Escalation 7
    1.0075,                                 !- Year Escalation 8
    1.0314,                                 !- Year Escalation 9
    1.0554,                                 !- Year Escalation 10
    1.0861,                                 !- Year Escalation 11
    1.1278,                                 !- Year Escalation 12
    1.1497,                                 !- Year Escalation 13
    1.1620,                                 !- Year Escalation 14
    1.1743,                                 !- Year Escalation 15
    1.1852,                                 !- Year Escalation 16
    1.1948,                                 !- Year Escalation 17
    1.2037,                                 !- Year Escalation 18
    1.2071,                                 !- Year Escalation 19
    1.2119,                                 !- Year Escalation 20
    1.2139,                                 !- Year Escalation 21
    1.2194,                                 !- Year Escalation 22
    1.2276,                                 !- Year Escalation 23
    1.2365,                                 !- Year Escalation 24
    1.2420,                                 !- Year Escalation 25
    1.2461,                                 !- Year Escalation 26
    1.2509,                                 !- Year Escalation 27
    1.2550,                                 !- Year Escalation 28
    1.2591,                                 !- Year Escalation 29
    1.2638;                                 !- Year Escalation 30
  "
  fuel_oil_2_escalation = OpenStudio::IdfObject.load(fuel_oil_2_escalation_string).get
  workspace.addObject(fuel_oil_2_escalation)
  runner.registerInfo("added fuel escalation rates named #{fuel_oil_2_escalation.name}")

  nat_gas_escalation_string = "
  LifeCycleCost:UsePriceEscalation,
    U.S. Avg  Commercial-Natural gas,       !- Name
    NaturalGas,                             !- Resource
    2011,                                   !- Escalation Start Year
    January,                                !- Escalation Start Month
    0.9823,                                 !- Year Escalation 1
    0.9557,                                 !- Year Escalation 2
    0.9279,                                 !- Year Escalation 3
    0.9257,                                 !- Year Escalation 4
    0.9346,                                 !- Year Escalation 5
    0.9412,                                 !- Year Escalation 6
    0.9512,                                 !- Year Escalation 7
    0.9645,                                 !- Year Escalation 8
    0.9856,                                 !- Year Escalation 9
    1.0067,                                 !- Year Escalation 10
    1.0222,                                 !- Year Escalation 11
    1.0410,                                 !- Year Escalation 12
    1.0610,                                 !- Year Escalation 13
    1.0787,                                 !- Year Escalation 14
    1.0942,                                 !- Year Escalation 15
    1.1098,                                 !- Year Escalation 16
    1.1220,                                 !- Year Escalation 17
    1.1308,                                 !- Year Escalation 18
    1.1386,                                 !- Year Escalation 19
    1.1486,                                 !- Year Escalation 20
    1.1619,                                 !- Year Escalation 21
    1.1763,                                 !- Year Escalation 22
    1.1918,                                 !- Year Escalation 23
    1.2118,                                 !- Year Escalation 24
    1.2284,                                 !- Year Escalation 25
    1.2439,                                 !- Year Escalation 26
    1.2605,                                 !- Year Escalation 27
    1.2772,                                 !- Year Escalation 28
    1.2938,                                 !- Year Escalation 29
    1.3115;                                 !- Year Escalation 30
  "
  nat_gas_escalation = OpenStudio::IdfObject.load(nat_gas_escalation_string).get
  workspace.addObject(nat_gas_escalation)
  runner.registerInfo("added fuel escalation rates named #{nat_gas_escalation.name}")

  coal_escalation_string = "
  LifeCycleCost:UsePriceEscalation,
    U.S. Avg  Commercial-Coal,              !- Name
    Coal,                                   !- Resource
    2011,                                   !- Escalation Start Year
    January,                                !- Escalation Start Month
    0.9970,                                 !- Year Escalation 1
    1.0089,                                 !- Year Escalation 2
    1.0089,                                 !- Year Escalation 3
    0.9941,                                 !- Year Escalation 4
    0.9941,                                 !- Year Escalation 5
    1.0000,                                 !- Year Escalation 6
    1.0030,                                 !- Year Escalation 7
    1.0059,                                 !- Year Escalation 8
    1.0089,                                 !- Year Escalation 9
    1.0119,                                 !- Year Escalation 10
    1.0148,                                 !- Year Escalation 11
    1.0178,                                 !- Year Escalation 12
    1.0208,                                 !- Year Escalation 13
    1.0267,                                 !- Year Escalation 14
    1.0297,                                 !- Year Escalation 15
    1.0356,                                 !- Year Escalation 16
    1.0415,                                 !- Year Escalation 17
    1.0534,                                 !- Year Escalation 18
    1.0564,                                 !- Year Escalation 19
    1.0593,                                 !- Year Escalation 20
    1.0653,                                 !- Year Escalation 21
    1.0712,                                 !- Year Escalation 22
    1.0742,                                 !- Year Escalation 23
    1.0801,                                 !- Year Escalation 24
    1.0831,                                 !- Year Escalation 25
    1.0831,                                 !- Year Escalation 26
    1.0861,                                 !- Year Escalation 27
    1.0890,                                 !- Year Escalation 28
    1.0920,                                 !- Year Escalation 29
    1.0950;                                 !- Year Escalation 30
   "
  coal_escalation = OpenStudio::IdfObject.load(coal_escalation_string).get
  workspace.addObject(coal_escalation)
  runner.registerInfo("added fuel escalation rates named #{coal_escalation.name}")

  return true
end