Class: AddZoneMixingObject
- Inherits:
-
OpenStudio::Measure::EnergyPlusMeasure
- Object
- OpenStudio::Measure::EnergyPlusMeasure
- AddZoneMixingObject
- Defined in:
- lib/measures/add_zone_mixing_object/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(workspace) ⇒ Object
define the arguments that the user will input.
-
#description ⇒ Object
human readable description.
-
#modeler_description ⇒ Object
human readable description of modeling approach.
-
#name ⇒ Object
human readable name.
-
#run(workspace, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Method Details
#arguments(workspace) ⇒ Object
define the arguments that the user will input
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 |
# File 'lib/measures/add_zone_mixing_object/measure.rb', line 27 def arguments(workspace) args = OpenStudio::Measure::OSArgumentVector.new # the name of the zone to receive air zone_name = OpenStudio::Measure::OSArgument.makeStringArgument('zone_name', true) zone_name.setDisplayName('Zone with Exhaust') args << zone_name # the name of the schedule schedule_name = OpenStudio::Measure::OSArgument.makeStringArgument('schedule_name', true) schedule_name.setDisplayName('Schedule Name for Zone Mixing') args << schedule_name # design level for zone mixing design_level = OpenStudio::Measure::OSArgument.makeDoubleArgument('design_level', true) design_level.setDisplayName('Design Level for Zone Mixing') design_level.setUnits('cfm') args << design_level # the name of the zone to receive air source_zone_name = OpenStudio::Measure::OSArgument.makeStringArgument('source_zone_name', true) source_zone_name.setDisplayName('Source Zone for Zone Mixing') args << source_zone_name return args end |
#description ⇒ Object
human readable description
17 18 19 |
# File 'lib/measures/add_zone_mixing_object/measure.rb', line 17 def description return 'This adds a zone mixing object with a few inputs exposed, including source zone. You can add multiple copies of this to the workflow as needed.' end |
#modeler_description ⇒ Object
human readable description of modeling approach
22 23 24 |
# File 'lib/measures/add_zone_mixing_object/measure.rb', line 22 def modeler_description return 'Currently this is just setup for design level calculation method, but it could be extended as needed..' end |
#name ⇒ Object
human readable name
12 13 14 |
# File 'lib/measures/add_zone_mixing_object/measure.rb', line 12 def name return 'Add Zone Mixing Object' end |
#run(workspace, runner, user_arguments) ⇒ Object
define what happens when the measure is run
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 |
# File 'lib/measures/add_zone_mixing_object/measure.rb', line 55 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 zone_name = runner.getStringArgumentValue('zone_name', user_arguments) schedule_name = runner.getStringArgumentValue('schedule_name', user_arguments) design_level = runner.getDoubleArgumentValue('design_level', user_arguments) source_zone_name = runner.getStringArgumentValue('source_zone_name', user_arguments) # reporting initial condition of model zone_mixing_objects = workspace.getObjectsByType('ZoneMixing'.to_IddObjectType) runner.registerInitialCondition("The building started with #{zone_mixing_objects.size} zone mixing objects.") # get all thermal zones in the starting model zones = workspace.getObjectsByType('Zone'.to_IddObjectType) # validate input names and get zones zone_name_valid = false source_zone_name_valid = false zones.each do |zone| if zone_name == zone.getString(0).to_s zone_name_valid = true elsif source_zone_name == zone.getString(0).to_s source_zone_name_valid = true end end # error if didn't find zones if (zone_name_valid == false) || (source_zone_name_valid == false) runner.registerError('One or more of the expected zones could not be found..') return false end # TODO: - validate schedule name (multiple types to look at) # validate design level input if design_level < 0.0 runner.registerError('Choose a non negative number for design level.') return false end # variables for zone mixing object zm_calc_method = 'Flow/Zone' # at some point in the future could add more options and inputs for this design_level_si = OpenStudio.convert(design_level, 'cfm', 'm^3/s').get # add a new zone mixing to the model zone_mixing_string = " ZoneMixing, #{zone_name} Zone Mixing, !- Name #{zone_name}, !- Zone Name #{schedule_name}, !- Schedule Name #{zm_calc_method}, !- Design Flow Rate Calculation Method #{design_level_si}, !- Design Level , !- Volume Flow Rate per Area {m3/s/m2} , !- Volume Flow Rate Per Person {m3/s/person} , !- Air Changes per Hour {ACH} #{source_zone_name}, !- Source Zone Name 0.0; !- Delta Temperature " idfObject = OpenStudio::IdfObject.load(zone_mixing_string) object = idfObject.get wsObject = workspace.addObject(object) new_zone_mixing_object = wsObject.get # echo the new zone mixing objects name back to the user, using the index based getString method runner.registerInfo("A zone mixing object named '#{new_zone_mixing_object.getString(0)}' was added.") # report final condition of model zone_mixing_objects = workspace.getObjectsByType('ZoneMixing'.to_IddObjectType) runner.registerFinalCondition("The building finished with #{zone_mixing_objects.size} zone mixing objects.") return true end |