Class: AddZoneVentilationDesignFlowRateObject
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- AddZoneVentilationDesignFlowRateObject
- Defined in:
- lib/measures/add_zone_ventilation_design_flow_rate_object/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ 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(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Method Details
#arguments(model) ⇒ 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 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 |
# File 'lib/measures/add_zone_ventilation_design_flow_rate_object/measure.rb', line 27 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # populate choice argument for thermal zones in the model zone_handles = OpenStudio::StringVector.new zone_display_names = OpenStudio::StringVector.new # putting zone names into hash zone_hash = {} model.getThermalZones.each do |zone| zone_hash[zone.name.to_s] = zone end # looping through sorted hash of zones zone_hash.sort.map do |zone_name, zone| zone_handles << zone.handle.to_s zone_display_names << zone_name end # make an argument for zones zone = OpenStudio::Measure::OSArgument.makeChoiceArgument('zone', zone_handles, zone_display_names, true) zone.setDisplayName('Choose Thermal Zones to add zone ventilation to') args << zone # populate choice argument for schedules in the model sch_handles = OpenStudio::StringVector.new sch_display_names = OpenStudio::StringVector.new # putting schedule names into hash sch_hash = {} model.getSchedules.each do |sch| sch_hash[sch.name.to_s] = sch end # looping through sorted hash of schedules sch_hash.sort.map do |sch_name, sch| if !sch.scheduleTypeLimits.empty? # unitType = sch.scheduleTypeLimits.get.unitType # puts "#{sch.name}, #{unitType}" # if unitType == "Temperature" # todo - what is correct type for fractional sch_handles << sch.handle.to_s sch_display_names << sch_name # end end end # add empty handle to string vector with schedules sch_handles << OpenStudio.toUUID('').to_s # make an argument for cooling schedule vent_sch = OpenStudio::Measure::OSArgument.makeChoiceArgument('vent_sch', sch_handles, sch_display_names, true) vent_sch.setDisplayName('Choose Schedulew') args << vent_sch # make choice argument for vent_type choices = OpenStudio::StringVector.new choices << 'Natural' choices << 'Exhaust' choices << 'Intake' choices << 'Balanced' vent_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('vent_type', choices, true) vent_type.setDisplayName('Ventilation Type') vent_type.setDefaultValue('Natural') args << vent_type # make double argument for sillHeight design_flow_rate = OpenStudio::Measure::OSArgument.makeDoubleArgument('design_flow_rate', true) design_flow_rate.setDisplayName('Design Flow Rate') design_flow_rate.setUnits('cfm') args << design_flow_rate return args end |
#description ⇒ Object
human readable description
17 18 19 |
# File 'lib/measures/add_zone_ventilation_design_flow_rate_object/measure.rb', line 17 def description return 'This will allow you to add a ZoneVentilation:DesignFlowRate object into your model in a specified zone. The ventilation type is exposed as an argument but the design flow rate calculation method is set to design flow rate. A number of other object inputs are exposed as arguments' end |
#modeler_description ⇒ Object
human readable description of modeling approach
22 23 24 |
# File 'lib/measures/add_zone_ventilation_design_flow_rate_object/measure.rb', line 22 def modeler_description return 'This is simple implementation ment to expose the object to users. More complex use case specific versions will likely be developed in the future that may add multiple zone ventilation objects as well as zone mixing objects' end |
#name ⇒ Object
human readable name
12 13 14 |
# File 'lib/measures/add_zone_ventilation_design_flow_rate_object/measure.rb', line 12 def name return 'Add Zone Ventilation Design Flow Rate Object' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
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 |
# File 'lib/measures/add_zone_ventilation_design_flow_rate_object/measure.rb', line 102 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 zone = runner.getOptionalWorkspaceObjectChoiceValue('zone', user_arguments, model) # model is passed in because of argument type vent_sch = runner.getOptionalWorkspaceObjectChoiceValue('vent_sch', user_arguments, model) # model is passed in because of argument type vent_type = runner.getStringArgumentValue('vent_type', user_arguments) design_flow_rate = runner.getDoubleArgumentValue('design_flow_rate', user_arguments) design_flow_rate_si = OpenStudio.convert(design_flow_rate, 'cfm', 'm^3/s').get # check the zone selection for reasonableness if zone.empty? handle = runner.getStringArgumentValue('zone', user_arguments) if handle.empty? runner.registerError('No thermal zone was chosen.') return false else runner.registerError("The selected thermal zone with handle '#{handle}' was not found in the model. It may have been removed by another measure.") return false end else if !zone.get.to_ThermalZone.empty? zone = zone.get.to_ThermalZone.get else runner.registerError('Script Error - argument not showing up as thermal zone.') return false end end if vent_sch.empty? handle = runner.getStringArgumentValue('vent_sch', user_arguments) if handle.empty? runner.registerError('No schedule was chosen.') return false else runner.registerError("The selected schedule with handle '#{handle}' was not found in the model. It may have been removed by another measure.") return false end else if !vent_sch.get.to_Schedule.empty? vent_sch = vent_sch.get.to_Schedule.get else runner.registerError('Script Error - argument not showing up as schedule.') return false end end # report initial condition of model runner.registerInitialCondition("The building started with #{model.getZoneVentilationDesignFlowRates.size} zone ventilation design flow rate objects.") # add zone ventilation object zone_ventilation = OpenStudio::Model::ZoneVentilationDesignFlowRate.new(model) zone_ventilation.addToThermalZone(zone) zone_ventilation.setVentilationType(vent_type) zone_ventilation.setDesignFlowRate(design_flow_rate_si) if OpenStudio::VersionString.new(OpenStudio.openStudioVersion) < OpenStudio::VersionString.new('3.5.0') # Design Flow Rate Calculation Method is automatically set in 3.5.0+ zone_ventilation.setDesignFlowRateCalculationMethod('Flow/Zone') end zone_ventilation.setSchedule(vent_sch) runner.registerInfo('Creating zone ventilation design flow rate object with ventilation type of ') # report final condition of model runner.registerFinalCondition("The building finished with #{model.getZoneVentilationDesignFlowRates.size} zone ventilation design flow rate objects.") return true end |