Class: GeneralCalibrationMeasurePercentChange

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

Overview

start the measure

Instance Method Summary collapse

Instance Method Details

#arguments(model) ⇒ Object

define the arguments that the user will input



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

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

  # make a choice argument for model objects
  space_type_handles = OpenStudio::StringVector.new
  space_type_display_names = OpenStudio::StringVector.new

  # putting model object and names into hash
  space_type_args = model.getSpaceTypes
  space_type_args_hash = {}
  space_type_args.each do |space_type_arg|
    space_type_args_hash[space_type_arg.name.to_s] = space_type_arg
  end

  # looping through sorted hash of model objects
  space_type_args_hash.sort.map do |key, value|
    # only include if space type is used in the model
    unless value.spaces.empty?
      space_type_handles << value.handle.to_s
      space_type_display_names << key
    end
  end

  # add building to string vector with space type
  building = model.getBuilding
  space_type_handles << building.handle.to_s
  space_type_display_names << '*All SpaceTypes*'
  space_type_handles << '0'
  space_type_display_names << '*None*'

  # make a choice argument for space type
  space_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('space_type', space_type_handles, space_type_display_names)
  space_type.setDisplayName('Apply the Measure to a SINGLE SpaceType, ALL the SpaceTypes or NONE.')
  space_type.setDefaultValue('*All SpaceTypes*') # if no space type is chosen this will run on the entire building
  args << space_type

  # make a choice argument for model objects
  space_handles = OpenStudio::StringVector.new
  space_display_names = OpenStudio::StringVector.new

  # putting model object and names into hash
  space_args = model.getSpaces
  space_args_hash = {}
  space_args.each do |space_arg|
    space_args_hash[space_arg.name.to_s] = space_arg
  end

  # looping through sorted hash of model objects
  space_args_hash.sort.map do |key, value|
    space_handles << value.handle.to_s
    space_display_names << key
  end

  # add building to string vector with spaces
  building = model.getBuilding
  space_handles << building.handle.to_s
  space_display_names << '*All Spaces*'
  space_handles << '0'
  space_display_names << '*None*'

  # make a choice argument for space type
  space = OpenStudio::Measure::OSArgument.makeChoiceArgument('space', space_handles, space_display_names)
  space.setDisplayName('Apply the Measure to a SINGLE Space, ALL the Spaces or NONE.')
  space.setDefaultValue('*All Spaces*') # if no space type is chosen this will run on the entire building
  args << space

  # Lights multiplier
  lights_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('lights_perc_change', true)
  lights_perc_change.setDisplayName('Percent Change in the default Lights Definition.')
  lights_perc_change.setDescription('Percent Change in the default Lights Definition.')
  lights_perc_change.setDefaultValue(0.0)
  args << lights_perc_change

  # Luminaire multiplier
  luminaire_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('luminaire_perc_change', true)
  luminaire_perc_change.setDisplayName('Percent Change in the default Luminaire Definition.')
  luminaire_perc_change.setDescription('Percent Change in the default Luminaire Definition.')
  luminaire_perc_change.setDefaultValue(0.0)
  args << luminaire_perc_change

  # Electric Equipment multiplier
  electric_equip_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('ElectricEquipment_perc_change', true)
  electric_equip_perc_change.setDisplayName('Percent Change in the default Electric Equipment Definition.')
  electric_equip_perc_change.setDescription('Percent Change in the default Electric Equipment Definition.')
  electric_equip_perc_change.setDefaultValue(0.0)
  args << electric_equip_perc_change

  # Gas Equipment multiplier
  gas_equip_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('GasEquipment_perc_change', true)
  gas_equip_perc_change.setDisplayName('Percent Change in the default Gas Equipment Definition.')
  gas_equip_perc_change.setDescription('Percent Change in the default Gas Equipment Definition.')
  gas_equip_perc_change.setDefaultValue(0.0)
  args << gas_equip_perc_change

  # OtherEquipment multiplier
  other_equip_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('OtherEquipment_perc_change', true)
  other_equip_perc_change.setDisplayName('Percent Change in the default OtherEquipment Definition.')
  other_equip_perc_change.setDescription('Percent Change in the default OtherEquipment Definition.')
  other_equip_perc_change.setDefaultValue(0.0)
  args << other_equip_perc_change

  # occupancy % change
  people_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('people_perc_change', true)
  people_perc_change.setDisplayName('Percent Change in the default People Definition.')
  people_perc_change.setDescription('Percent Change in the default People Definition.')
  people_perc_change.setDefaultValue(0.0)
  args << people_perc_change

  # internalMass % change
  mass_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('mass_perc_change', true)
  mass_perc_change.setDisplayName('Percent Change in the default Internal Mass Definition.')
  mass_perc_change.setDescription('Percent Change in the default Internal Mass Definition.')
  mass_perc_change.setDefaultValue(0.0)
  args << mass_perc_change

  # infiltration % change
  infil_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('infil_perc_change', true)
  infil_perc_change.setDisplayName('Percent Change in the default Design Infiltration Outdoor Air.')
  infil_perc_change.setDescription('Percent Change in the default Design Infiltration Outdoor Air.')
  infil_perc_change.setDefaultValue(0.0)
  args << infil_perc_change

  # ventilation % change
  vent_perc_change = OpenStudio::Measure::OSArgument.makeDoubleArgument('vent_perc_change', true)
  vent_perc_change.setDisplayName('Percent Change in the default Design Specification Outdoor Air.')
  vent_perc_change.setDescription('Percent Change in the default Design Specification Outdoor Air.')
  vent_perc_change.setDefaultValue(0.0)
  args << vent_perc_change

  args
end

#change_name(object, perc_change) ⇒ Object



23
24
25
26
27
# File 'lib/measures/GeneralCalibrationMeasurePercentChange/measure.rb', line 23

def change_name(object, perc_change)
  if perc_change != 0
    object.setName("#{object.name.get} (#{perc_change.round(2)} percent change)")
  end
end

#descriptionObject

human readable description



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

def description
  'This is a general purpose measure to calibrate space and space type elements with a percent change.'
end

#modeler_descriptionObject

human readable description of modeling approach



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

def modeler_description
  'It will be used for calibration of space and spaceType loads as well as infiltration, and outdoor air. User can choose between a SINGLE SpaceType or ALL the SpaceTypes as well as a SINGLE Space or ALL the Spaces.'
end

#nameObject

human readable name



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

def name
  'General Calibration Measure Percent Change'
end

#run(model, runner, user_arguments) ⇒ Object

define what happens when the measure is run



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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
# File 'lib/measures/GeneralCalibrationMeasurePercentChange/measure.rb', line 163

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
  space_type_object = runner.getOptionalWorkspaceObjectChoiceValue('space_type', user_arguments, model)
  space_type_handle = runner.getStringArgumentValue('space_type', user_arguments)
  space_object = runner.getOptionalWorkspaceObjectChoiceValue('space', user_arguments, model)
  space_handle = runner.getStringArgumentValue('space', user_arguments)
  people_perc_change = runner.getDoubleArgumentValue('people_perc_change', user_arguments)
  infil_perc_change = runner.getDoubleArgumentValue('infil_perc_change', user_arguments)
  vent_perc_change = runner.getDoubleArgumentValue('vent_perc_change', user_arguments)
  mass_perc_change = runner.getDoubleArgumentValue('mass_perc_change', user_arguments)
  electric_equip_perc_change = runner.getDoubleArgumentValue('ElectricEquipment_perc_change', user_arguments)
  gas_equip_perc_change = runner.getDoubleArgumentValue('GasEquipment_perc_change', user_arguments)
  other_equip_perc_change = runner.getDoubleArgumentValue('OtherEquipment_perc_change', user_arguments)
  lights_perc_change = runner.getDoubleArgumentValue('lights_perc_change', user_arguments)
  luminaire_perc_change = runner.getDoubleArgumentValue('luminaire_perc_change', user_arguments)

  # find objects to change
  space_types = []
  spaces = []
  building = model.getBuilding
  building_handle = building.handle.to_s
  runner.registerInfo("space_type_handle: #{space_type_handle}")
  runner.registerInfo("space_handle: #{space_handle}")
  # setup space_types
  if space_type_handle == building_handle
    # Use ALL SpaceTypes
    runner.registerInfo('Applying change to ALL SpaceTypes')
    space_types = model.getSpaceTypes
  elsif space_type_handle == 0.to_s
    # SpaceTypes set to NONE so do nothing
    runner.registerInfo('Applying change to NONE SpaceTypes')
  elsif !space_type_handle.empty?
    # Single SpaceType handle found, check if object is good
    if !space_type_object.get.to_SpaceType.empty?
      runner.registerInfo("Applying change to #{space_type_object.get.name} SpaceType")
      space_types << space_type_object.get.to_SpaceType.get
    else
      runner.registerError("SpaceType with handle #{space_type_handle} could not be found.")
    end
  else
    runner.registerError('SpaceType handle is empty.')
    return false
  end

  # setup spaces
  if space_handle == building_handle
    # Use ALL Spaces
    runner.registerInfo('Applying change to ALL Spaces')
    spaces = model.getSpaces
  elsif space_handle == 0.to_s
    # Spaces set to NONE so do nothing
    runner.registerInfo('Applying change to NONE Spaces')
  elsif !space_handle.empty?
    # Single Space handle found, check if object is good
    if !space_object.get.to_Space.empty?
      runner.registerInfo("Applying change to #{space_object.get.name} Space")
      spaces << space_object.get.to_Space.get
    else
      runner.registerError("Space with handle #{space_handle} could not be found.")
    end
  else
    runner.registerError('Space handle is empty.')
    return false
  end

  altered_people_definitions = []
  altered_infiltration_objects = []
  altered_outdoor_air_objects = []
  altered_internalmass_definitions = []
  altered_lights_definitions = []
  altered_luminaires_definitions = []
  altered_electric_equip_definitions = []
  altered_gas_equip_definitions = []
  altered_other_equip_definitions = []

  # report initial condition of model
  runner.registerInitialCondition("Applying Variable % Changes to #{space_types.size} space types and #{spaces.size} spaces.")
  runner.registerInfo("Applying Variable % Changes to #{space_types.size} space types.")

  # loop through space types
  space_types.each do |space_type|
    # modify lights
    space_type.lights.each do |light|
      equip_def = light.lightsDefinition
      # get and alter multiplier
      if !altered_lights_definitions.include? equip_def.handle.to_s
        if equip_def.lightingLevel.is_initialized
          runner.registerInfo("Applying #{lights_perc_change} % Change to #{equip_def.name.get} LightingLevel.")
          equip_def.setLightingLevel(equip_def.lightingLevel.get + equip_def.lightingLevel.get * lights_perc_change * 0.01)
        end
        if equip_def.wattsperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{lights_perc_change} % Change to #{equip_def.name.get} wattsperSpaceFloorArea.")
          equip_def.setWattsperSpaceFloorArea(equip_def.wattsperSpaceFloorArea.get + equip_def.wattsperSpaceFloorArea.get * lights_perc_change * 0.01)
        end
        if equip_def.wattsperPerson.is_initialized
          runner.registerInfo("Applying #{lights_perc_change} % Change to #{equip_def.name.get} wattsperPerson.")
          equip_def.setWattsperPerson(equip_def.wattsperPerson.get + equip_def.wattsperPerson.get * lights_perc_change * 0.01)
        end
        # update hash and change name
        change_name(equip_def, lights_perc_change)
        altered_lights_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify luminaire
    space_type.luminaires.each do |light|
      equip_def = light.luminaireDefinition
      # get and alter multiplier
      if !altered_luminaires_definitions.include? equip_def.handle.to_s
        runner.registerInfo("Applying #{luminaire_perc_change} % Change to #{equip_def.name.get} LightingPower.")
        equip_def.setLightingPower(equip_def.lightingPower + equip_def.lightingPower * luminaire_perc_change * 0.01)
        # update hash and change name
        change_name(equip_def, luminaire_perc_change)
        altered_luminaires_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify electric equip
    space_type.electricEquipment.each do |equip|
      # get and alter definition
      equip_def = equip.electricEquipmentDefinition
      if !altered_electric_equip_definitions.include? equip_def.handle.to_s
        if equip_def.designLevel.is_initialized
          runner.registerInfo("Applying #{electric_equip_perc_change} % Change to #{equip_def.name.get} DesignLevel.")
          equip_def.setDesignLevel(equip_def.designLevel.get + equip_def.designLevel.get * electric_equip_perc_change * 0.01)
        end
        if equip_def.wattsperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{electric_equip_perc_change} % Change to #{equip_def.name.get} wattsperSpaceFloorArea.")
          equip_def.setWattsperSpaceFloorArea(equip_def.wattsperSpaceFloorArea.get + equip_def.wattsperSpaceFloorArea.get * electric_equip_perc_change * 0.01)
        end
        if equip_def.wattsperPerson.is_initialized
          runner.registerInfo("Applying #{electric_equip_perc_change} % Change to #{equip_def.name.get} wattsperPerson.")
          equip_def.setWattsperPerson(equip_def.wattsperPerson.get + equip_def.wattsperPerson.get * electric_equip_perc_change * 0.01)
        end
        # update hash and change name
        change_name(equip_def, electric_equip_perc_change)
        altered_electric_equip_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify gas equip
    space_type.gasEquipment.each do |equip|
      # get and alter definition
      equip_def = equip.gasEquipmentDefinition
      if !altered_gas_equip_definitions.include? equip_def.handle.to_s
        if equip_def.designLevel.is_initialized
          runner.registerInfo("Applying #{gas_equip_perc_change} % Change to  #{equip_def.name.get} designlevel.")
          equip_def.setDesignLevel(equip_def.designLevel.get + equip_def.designLevel.get * gas_equip_perc_change * 0.01)
        end
        if equip_def.wattsperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{gas_equip_perc_change} % Change to  #{equip_def.name.get} WattsperSpaceFloorArea.")
          equip_def.setWattsperSpaceFloorArea(equip_def.wattsperSpaceFloorArea.get + equip_def.wattsperSpaceFloorArea.get * gas_equip_perc_change * 0.01)
        end
        if equip_def.wattsperPerson.is_initialized
          runner.registerInfo("Applying #{gas_equip_perc_change} % Change to  #{equip_def.name.get} WattsperPerson.")
          equip_def.setWattsperPerson(equip_def.wattsperPerson.get + equip_def.wattsperPerson.get * gas_equip_perc_change * 0.01)
        end
        # update hash and change name
        change_name(equip_def, gas_equip_perc_change)
        altered_gas_equip_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify other equip
    space_type.otherEquipment.each do |equip|
      # get and alter definition
      equip_def = equip.otherEquipmentDefinition
      if !altered_other_equip_definitions.include? equip_def.handle.to_s
        if equip_def.designLevel.is_initialized
          runner.registerInfo("Applying #{other_equip_perc_change} % Change to #{equip_def.name.get} designLevel.")
          equip_def.setDesignLevel(equip_def.designLevel.get + equip_def.designLevel.get * other_equip_perc_change * 0.01)
        end
        if equip_def.wattsperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{other_equip_perc_change} % Change to #{equip_def.name.get} wattsperSpaceFloorArea.")
          equip_def.setWattsperSpaceFloorArea(equip_def.wattsperSpaceFloorArea.get + equip_def.wattsperSpaceFloorArea.get * other_equip_perc_change * 0.01)
        end
        if equip_def.wattsperPerson.is_initialized
          runner.registerInfo("Applying #{other_equip_perc_change} % Change to #{equip_def.name.get} wattsperPerson.")
          equip_def.setWattsperPerson(equip_def.wattsperPerson.get + equip_def.wattsperPerson.get * other_equip_perc_change * 0.01)
        end
        # update hash and change name
        change_name(equip_def, other_equip_perc_change)
        altered_other_equip_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify occupancy
    space_type.people.each do |people_inst|
      # get and alter definition
      people_def = people_inst.peopleDefinition
      if !altered_people_definitions.include? people_def.handle.to_s
        if people_def.peopleperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{people_perc_change} % Change to #{people_def.name.get} PeopleperSpaceFloorArea.")
          people_def.setPeopleperSpaceFloorArea(people_def.peopleperSpaceFloorArea.get + people_def.peopleperSpaceFloorArea.get * people_perc_change * 0.01)
        end
        if people_def.numberofPeople.is_initialized
          runner.registerInfo("Applying #{people_perc_change} % Change to #{people_def.name.get} numberofPeople.")
          people_def.setNumberofPeople(people_def.numberofPeople.get + people_def.numberofPeople.get * people_perc_change * 0.01)
        end
        if people_def.spaceFloorAreaperPerson.is_initialized
          runner.registerInfo("Applying #{people_perc_change} % Change to #{people_def.name.get} spaceFloorAreaperPerson.")
          people_def.setSpaceFloorAreaperPerson(people_def.spaceFloorAreaperPerson.get + people_def.spaceFloorAreaperPerson.get * people_perc_change * 0.01)
        end
        # update hash and change name
        change_name(people_def, people_perc_change)
        altered_people_definitions << people_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{people_def.name.get}")
      end
    end

    # modify infiltration
    space_type.spaceInfiltrationDesignFlowRates.each do |infiltration|
      if !altered_infiltration_objects.include? infiltration.handle.to_s
        if infiltration.flowperExteriorSurfaceArea.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} FlowperExteriorSurfaceArea.")
          infiltration.setFlowperExteriorSurfaceArea(infiltration.flowperExteriorSurfaceArea.get + infiltration.flowperExteriorSurfaceArea.get * infil_perc_change * 0.01)
        end
        if infiltration.airChangesperHour.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} AirChangesperHour.")
          infiltration.setAirChangesperHour(infiltration.airChangesperHour.get + infiltration.airChangesperHour.get * infil_perc_change * 0.01)
        end
        if infiltration.designFlowRate.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} designFlowRate.")
          infiltration.setDesignFlowRate(infiltration.designFlowRate.get + infiltration.designFlowRate.get * infil_perc_change * 0.01)
        end
        if infiltration.flowperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} flowperSpaceFloorArea.")
          infiltration.setFlowperSpaceFloorArea(infiltration.flowperSpaceFloorArea.get + infiltration.flowperSpaceFloorArea.get * infil_perc_change * 0.01)
        end
        if infiltration.flowperExteriorWallArea.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} flowperExteriorWallArea.")
          infiltration.setFlowperExteriorWallArea(infiltration.flowperExteriorWallArea.get + infiltration.flowperExteriorWallArea.get * infil_perc_change * 0.01)
        end
        # add to hash and change name
        change_name(infiltration, infil_perc_change)
        altered_infiltration_objects << infiltration.handle.to_s
      else
        runner.registerInfo("Skipping change to #{infiltration.name.get}")
      end
    end

    # modify outdoor air
    if space_type.designSpecificationOutdoorAir.is_initialized
      outdoor_air = space_type.designSpecificationOutdoorAir.get
      # alter values if not already done
      if !altered_outdoor_air_objects.include? outdoor_air.handle.to_s
        runner.registerInfo("Applying #{vent_perc_change} % Change to #{outdoor_air.name.get} OutdoorAirFlowperPerson.")
        outdoor_air.setOutdoorAirFlowperPerson(outdoor_air.outdoorAirFlowperPerson + outdoor_air.outdoorAirFlowperPerson * vent_perc_change * 0.01)
        runner.registerInfo("Applying #{vent_perc_change} % Change to #{outdoor_air.name.get} OutdoorAirFlowperFloorArea.")
        outdoor_air.setOutdoorAirFlowperFloorArea(outdoor_air.outdoorAirFlowperFloorArea + outdoor_air.outdoorAirFlowperFloorArea * vent_perc_change * 0.01)
        runner.registerInfo("Applying #{vent_perc_change} % Change to #{outdoor_air.name.get} OutdoorAirFlowAirChangesperHour.")
        outdoor_air.setOutdoorAirFlowAirChangesperHour(outdoor_air.outdoorAirFlowAirChangesperHour + outdoor_air.outdoorAirFlowAirChangesperHour * vent_perc_change * 0.01)
        runner.registerInfo("Applying #{vent_perc_change} % Change to #{outdoor_air.name.get} OutdoorAirFlowRate.")
        outdoor_air.setOutdoorAirFlowRate(outdoor_air.outdoorAirFlowRate + outdoor_air.outdoorAirFlowRate * vent_perc_change * 0.01)
        # add to hash and change name
        change_name(outdoor_air, vent_perc_change)
        altered_outdoor_air_objects << outdoor_air.handle.to_s
      else
        runner.registerInfo("Skipping change to #{outdoor_air.name.get}")
      end
    end

    # modify internal mass
    space_type.internalMass.each do |internalmass|
      # get and alter definition
      internalmass_def = internalmass.internalMassDefinition
      if !altered_internalmass_definitions.include? internalmass_def.handle.to_s
        if internalmass_def.surfaceAreaperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{mass_perc_change} % Change to #{internalmass_def.name.get} surfaceAreaperSpaceFloorArea.")
          internalmass_def.setSurfaceAreaperSpaceFloorArea(internalmass_def.surfaceAreaperSpaceFloorArea.get + internalmass_def.surfaceAreaperSpaceFloorArea.get * mass_perc_change * 0.01)
        end
        if internalmass_def.surfaceArea.is_initialized
          runner.registerInfo("Applying #{mass_perc_change} % Change to #{internalmass_def.name.get} surfaceArea.")
          internalmass_def.setSurfaceArea(internalmass_def.surfaceArea.get + internalmass_def.surfaceArea.get * mass_perc_change * 0.01)
        end
        if internalmass_def.surfaceAreaperPerson.is_initialized
          runner.registerInfo("Applying #{mass_perc_change} % Change to #{internalmass_def.name.get} surfaceAreaperPerson.")
          internalmass_def.setSurfaceAreaperPerson(internalmass_def.surfaceAreaperPerson.get + internalmass_def.surfaceAreaperPerson.get * mass_perc_change * 0.01)
        end
        # update hash and change name
        change_name(internalmass_def, mass_perc_change)
        altered_internalmass_definitions << internalmass_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{internalmass_def.name.get}")
      end
    end
  end

  runner.registerInfo("altered_lights_definitions: #{altered_lights_definitions}")
  runner.registerInfo("altered_luminaires_definitions: #{altered_luminaires_definitions}")
  runner.registerInfo("altered_electric_equip_definitions: #{altered_electric_equip_definitions}")
  runner.registerInfo("altered_gas_equip_definitions: #{altered_gas_equip_definitions}")
  runner.registerInfo("altered_other_equip_definitions: #{altered_other_equip_definitions}")
  runner.registerInfo("altered_people_definitions: #{altered_people_definitions}")
  runner.registerInfo("altered_infiltration_objects: #{altered_infiltration_objects}")
  runner.registerInfo("altered_outdoor_air_objects: #{altered_outdoor_air_objects}")
  runner.registerInfo("altered_internalmass_definitions: #{altered_internalmass_definitions}")

  # report initial condition of model
  runner.registerInfo("Applying Variable % Changes to #{spaces.size} spaces.")

  # loop through space types
  spaces.each do |space|
    # modify lights
    space.lights.each do |light|
      equip_def = light.lightsDefinition
      # get and alter definition
      if !altered_lights_definitions.include? equip_def.handle.to_s
        if equip_def.lightingLevel.is_initialized
          runner.registerInfo("Applying #{lights_perc_change} % Change to #{equip_def.name.get} LightingLevel.")
          equip_def.setLightingLevel(equip_def.lightingLevel.get + equip_def.lightingLevel.get * lights_perc_change * 0.01)
        end
        if equip_def.wattsperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{lights_perc_change} % Change to #{equip_def.name.get} wattsperSpaceFloorArea.")
          equip_def.setWattsperSpaceFloorArea(equip_def.wattsperSpaceFloorArea.get + equip_def.wattsperSpaceFloorArea.get * lights_perc_change * 0.01)
        end
        if equip_def.wattsperPerson.is_initialized
          runner.registerInfo("Applying #{lights_perc_change} % Change to #{equip_def.name.get} wattsperPerson.")
          equip_def.setWattsperPerson(equip_def.wattsperPerson.get + equip_def.wattsperPerson.get * lights_perc_change * 0.01)
        end
        # update hash and change name
        change_name(equip_def, lights_perc_change)
        altered_lights_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify luminaire
    space.luminaires.each do |light|
      equip_def = light.luminaireDefinition
      # get and alter definition
      if !altered_luminaires_definitions.include? equip_def.handle.to_s
        runner.registerInfo("Applying #{luminaire_perc_change} % Change to #{equip_def.name.get} LightingPower.")
        equip_def.setLightingPower(equip_def.lightingPower + equip_def.lightingPower * luminaire_perc_change * 0.01)
        # update hash and change name
        change_name(equip_def, luminaire_perc_change)
        altered_luminaires_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify electric equip
    space.electricEquipment.each do |equip|
      # get and alter definition
      equip_def = equip.electricEquipmentDefinition
      if !altered_electric_equip_definitions.include? equip_def.handle.to_s
        if equip_def.designLevel.is_initialized
          runner.registerInfo("Applying #{electric_equip_perc_change} % Change to #{equip_def.name.get} DesignLevel.")
          equip_def.setDesignLevel(equip_def.designLevel.get + equip_def.designLevel.get * electric_equip_perc_change * 0.01)
        end
        if equip_def.wattsperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{electric_equip_perc_change} % Change to #{equip_def.name.get} wattsperSpaceFloorArea.")
          equip_def.setWattsperSpaceFloorArea(equip_def.wattsperSpaceFloorArea.get + equip_def.wattsperSpaceFloorArea.get * electric_equip_perc_change * 0.01)
        end
        if equip_def.wattsperPerson.is_initialized
          runner.registerInfo("Applying #{electric_equip_perc_change} % Change to #{equip_def.name.get} wattsperPerson.")
          equip_def.setWattsperPerson(equip_def.wattsperPerson.get + equip_def.wattsperPerson.get * electric_equip_perc_change * 0.01)
        end
        # update hash and change name
        change_name(equip_def, electric_equip_perc_change)
        altered_electric_equip_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify gas equip
    space.gasEquipment.each do |equip|
      # get and alter definition
      equip_def = equip.gasEquipmentDefinition
      if !altered_gas_equip_definitions.include? equip_def.handle.to_s
        if equip_def.designLevel.is_initialized
          runner.registerInfo("Applying #{gas_equip_perc_change} % Change to  #{equip_def.name.get} designlevel.")
          equip_def.setDesignLevel(equip_def.designLevel.get + equip_def.designLevel.get * gas_equip_perc_change * 0.01)
        end
        if equip_def.wattsperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{gas_equip_perc_change} % Change to  #{equip_def.name.get} WattsperSpaceFloorArea.")
          equip_def.setWattsperSpaceFloorArea(equip_def.wattsperSpaceFloorArea.get + equip_def.wattsperSpaceFloorArea.get * gas_equip_perc_change * 0.01)
        end
        if equip_def.wattsperPerson.is_initialized
          runner.registerInfo("Applying #{gas_equip_perc_change} % Change to  #{equip_def.name.get} WattsperPerson.")
          equip_def.setWattsperPerson(equip_def.wattsperPerson.get + equip_def.wattsperPerson.get * gas_equip_perc_change * 0.01)
        end
        # update hash and change name
        change_name(equip_def, gas_equip_perc_change)
        altered_gas_equip_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify other equip
    space.otherEquipment.each do |equip|
      # get and alter definition
      equip_def = equip.otherEquipmentDefinition
      if !altered_other_equip_definitions.include? equip_def.handle.to_s
        if equip_def.designLevel.is_initialized
          runner.registerInfo("Applying #{other_equip_perc_change} % Change to #{equip_def.name.get} designLevel.")
          equip_def.setDesignLevel(equip_def.designLevel.get + equip_def.designLevel.get * other_equip_perc_change * 0.01)
        end
        if equip_def.wattsperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{other_equip_perc_change} % Change to #{equip_def.name.get} wattsperSpaceFloorArea.")
          equip_def.setWattsperSpaceFloorArea(equip_def.wattsperSpaceFloorArea.get + equip_def.wattsperSpaceFloorArea.get * other_equip_perc_change * 0.01)
        end
        if equip_def.wattsperPerson.is_initialized
          runner.registerInfo("Applying #{other_equip_perc_change} % Change to #{equip_def.name.get} wattsperPerson.")
          equip_def.setWattsperPerson(equip_def.wattsperPerson.get + equip_def.wattsperPerson.get * other_equip_perc_change * 0.01)
        end
        # update hash and change name
        change_name(equip_def, other_equip_perc_change)
        altered_other_equip_definitions << equip_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{equip_def.name.get}")
      end
    end

    # modify occupancy
    space.people.each do |people_inst|
      # get and alter definition
      people_def = people_inst.peopleDefinition
      if !altered_people_definitions.include? people_def.handle.to_s
        if people_def.peopleperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{people_perc_change} % Change to #{people_def.name.get} PeopleperSpaceFloorArea.")
          people_def.setPeopleperSpaceFloorArea(people_def.peopleperSpaceFloorArea.get + people_def.peopleperSpaceFloorArea.get * people_perc_change * 0.01)
        end
        if people_def.numberofPeople.is_initialized
          runner.registerInfo("Applying #{people_perc_change} % Change to #{people_def.name.get} numberofPeople.")
          people_def.setNumberofPeople(people_def.numberofPeople.get + people_def.numberofPeople.get * people_perc_change * 0.01)
        end
        if people_def.spaceFloorAreaperPerson.is_initialized
          runner.registerInfo("Applying #{people_perc_change} % Change to #{people_def.name.get} spaceFloorAreaperPerson.")
          people_def.setSpaceFloorAreaperPerson(people_def.spaceFloorAreaperPerson.get + people_def.spaceFloorAreaperPerson.get * people_perc_change * 0.01)
        end
        # update hash and change name
        change_name(people_def, people_perc_change)
        altered_people_definitions << people_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{people_def.name.get}")
      end
    end

    # modify infiltration
    space.spaceInfiltrationDesignFlowRates.each do |infiltration|
      if !altered_infiltration_objects.include? infiltration.handle.to_s
        if infiltration.flowperExteriorSurfaceArea.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} FlowperExteriorSurfaceArea.")
          infiltration.setFlowperExteriorSurfaceArea(infiltration.flowperExteriorSurfaceArea.get + infiltration.flowperExteriorSurfaceArea.get * infil_perc_change * 0.01)
        end
        if infiltration.airChangesperHour.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} AirChangesperHour.")
          infiltration.setAirChangesperHour(infiltration.airChangesperHour.get + infiltration.airChangesperHour.get * infil_perc_change * 0.01)
        end
        if infiltration.designFlowRate.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} designFlowRate.")
          infiltration.setDesignFlowRate(infiltration.designFlowRate.get + infiltration.designFlowRate.get * infil_perc_change * 0.01)
        end
        if infiltration.flowperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} flowperSpaceFloorArea.")
          infiltration.setFlowperSpaceFloorArea(infiltration.flowperSpaceFloorArea.get + infiltration.flowperSpaceFloorArea.get * infil_perc_change * 0.01)
        end
        if infiltration.flowperExteriorWallArea.is_initialized
          runner.registerInfo("Applying #{infil_perc_change} % Change to #{infiltration.name.get} flowperExteriorWallArea.")
          infiltration.setFlowperExteriorWallArea(infiltration.flowperExteriorWallArea.get + infiltration.flowperExteriorWallArea.get * infil_perc_change * 0.01)
        end
        # add to hash and change name
        change_name(infiltration, infil_perc_change)
        altered_infiltration_objects << infiltration.handle.to_s
      else
        runner.registerInfo("Skipping change to #{infiltration.name.get}")
      end
    end

    # modify outdoor air
    if space.designSpecificationOutdoorAir.is_initialized
      outdoor_air = space.designSpecificationOutdoorAir.get
      # alter values if not already done
      if !altered_outdoor_air_objects.include? outdoor_air.handle.to_s
        runner.registerInfo("Applying #{vent_perc_change} % Change to #{outdoor_air.name.get} OutdoorAirFlowperPerson.")
        outdoor_air.setOutdoorAirFlowperPerson(outdoor_air.outdoorAirFlowperPerson + outdoor_air.outdoorAirFlowperPerson * vent_perc_change * 0.01)
        runner.registerInfo("Applying #{vent_perc_change} % Change to #{outdoor_air.name.get} OutdoorAirFlowperFloorArea.")
        outdoor_air.setOutdoorAirFlowperFloorArea(outdoor_air.outdoorAirFlowperFloorArea + outdoor_air.outdoorAirFlowperFloorArea * vent_perc_change * 0.01)
        runner.registerInfo("Applying #{vent_perc_change} % Change to #{outdoor_air.name.get} OutdoorAirFlowAirChangesperHour.")
        outdoor_air.setOutdoorAirFlowAirChangesperHour(outdoor_air.outdoorAirFlowAirChangesperHour + outdoor_air.outdoorAirFlowAirChangesperHour * vent_perc_change * 0.01)
        runner.registerInfo("Applying #{vent_perc_change} % Change to #{outdoor_air.name.get} OutdoorAirFlowRate.")
        outdoor_air.setOutdoorAirFlowRate(outdoor_air.outdoorAirFlowRate + outdoor_air.outdoorAirFlowRate * vent_perc_change * 0.01)
        # add to hash and change name
        change_name(outdoor_air, vent_perc_change)
        altered_outdoor_air_objects << outdoor_air.handle.to_s
      else
        runner.registerInfo("Skipping change to #{outdoor_air.name.get}")
      end
    end

    # modify internal mass
    space.internalMass.each do |internalmass|
      # get and alter definition
      internalmass_def = internalmass.internalMassDefinition
      if !altered_internalmass_definitions.include? internalmass_def.handle.to_s
        if internalmass_def.surfaceAreaperSpaceFloorArea.is_initialized
          runner.registerInfo("Applying #{mass_perc_change} % Change to #{internalmass_def.name.get} surfaceAreaperSpaceFloorArea.")
          internalmass_def.setSurfaceAreaperSpaceFloorArea(internalmass_def.surfaceAreaperSpaceFloorArea.get + internalmass_def.surfaceAreaperSpaceFloorArea.get * mass_perc_change * 0.01)
        end
        if internalmass_def.surfaceArea.is_initialized
          runner.registerInfo("Applying #{mass_perc_change} % Change to #{internalmass_def.name.get} surfaceArea.")
          internalmass_def.setSurfaceArea(internalmass_def.surfaceArea.get + internalmass_def.surfaceArea.get * mass_perc_change * 0.01)
        end
        if internalmass_def.surfaceAreaperPerson.is_initialized
          runner.registerInfo("Applying #{mass_perc_change} % Change to #{internalmass_def.name.get} surfaceAreaperPerson.")
          internalmass_def.setSurfaceAreaperPerson(internalmass_def.surfaceAreaperPerson.get + internalmass_def.surfaceAreaperPerson.get * mass_perc_change * 0.01)
        end
        # update hash and change name
        change_name(internalmass_def, mass_perc_change)
        altered_internalmass_definitions << internalmass_def.handle.to_s
      else
        runner.registerInfo("Skipping change to #{internalmass_def.name.get}")
      end
    end
  end

  runner.registerInfo("altered_lights_definitions: #{altered_lights_definitions}")
  runner.registerInfo("altered_luminaires_definitions: #{altered_luminaires_definitions}")
  runner.registerInfo("altered_electric_equip_definitions: #{altered_electric_equip_definitions}")
  runner.registerInfo("altered_gas_equip_definitions: #{altered_gas_equip_definitions}")
  runner.registerInfo("altered_other_equip_definitions: #{altered_other_equip_definitions}")
  runner.registerInfo("altered_people_definitions: #{altered_people_definitions}")
  runner.registerInfo("altered_infiltration_objects: #{altered_infiltration_objects}")
  runner.registerInfo("altered_outdoor_air_objects: #{altered_outdoor_air_objects}")
  runner.registerInfo("altered_internalmass_definitions: #{altered_internalmass_definitions}")

  # na if nothing in model to look at
  if altered_lights_definitions.size + altered_luminaires_definitions.size + altered_electric_equip_definitions.size + altered_gas_equip_definitions.size + altered_other_equip_definitions.size + altered_people_definitions.size + altered_infiltration_objects.size + altered_outdoor_air_objects.size + altered_internalmass_definitions.size == 0
    runner.registerAsNotApplicable('No objects to alter were found in the model')
    return true
  end

  # report final condition of model
  runner.registerFinalCondition("#{altered_lights_definitions.size} light objects were altered. #{altered_luminaires_definitions.size} luminaire objects were altered. #{altered_electric_equip_definitions.size} electric Equipment objects were altered. #{altered_gas_equip_definitions.size} gas Equipment objects were altered. #{altered_other_equip_definitions.size} otherEquipment objects were altered. #{altered_people_definitions.size} people definitions were altered. #{altered_infiltration_objects.size} infiltration objects were altered. #{altered_outdoor_air_objects.size} ventilation objects were altered. #{altered_internalmass_definitions.size} internal mass objects were altered.")

  true
end