Class: PredictedMeanVote
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- PredictedMeanVote
- Defined in:
- lib/measures/PredictedMeanVote/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ Object
define the arguments that the user will input.
-
#description ⇒ Object
description.
-
#modeler_description ⇒ Object
modeler description.
-
#name ⇒ Object
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.
-
#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
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 |
# File 'lib/measures/PredictedMeanVote/measure.rb', line 31 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # make a bool argument for ASHRAE 55 Comfort Warnings comfortWarnings = OpenStudio::Measure::OSArgument.makeBoolArgument('comfortWarnings', true) comfortWarnings.setDisplayName('Enable ASHRAE 55 Comfort Warnings?') comfortWarnings.setDefaultValue(false) args << comfortWarnings # make a choice argument for Mean Radiant Temperature Calculation Type chs = OpenStudio::StringVector.new chs << 'ZoneAveraged' chs << 'SurfaceWeighted' # chs << "AngleFactor" # I disabled this choice unless we expose the Surface Name/Angle Factor List Name field. meanRadiantCalcType = OpenStudio::Measure::OSArgument.makeChoiceArgument('meanRadiantCalcType', chs, true) meanRadiantCalcType.setDisplayName('Mean Radiant Temperature Calculation Type') meanRadiantCalcType.setDefaultValue('ZoneAveraged') args << meanRadiantCalcType # populate raw choice argument for schedules schedule_handles = OpenStudio::StringVector.new schedule_display_names = OpenStudio::StringVector.new # putting raw schedules and names into hash schedule_args = model.getSchedules schedule_args_hash = {} schedule_args.each do |schedule_arg| schedule_args_hash[schedule_arg.name.to_s] = schedule_arg end # populate choice argument for fractional schedules fractional_schedule_handles = OpenStudio::StringVector.new fractional_schedule_display_names = OpenStudio::StringVector.new # looping through sorted hash of schedules to find fractional schedules schedule_args_hash.sort.map do |key, value| next if value.scheduleTypeLimits.empty? if (value.scheduleTypeLimits.get.unitType == 'Dimensionless') && !value.scheduleTypeLimits.get.lowerLimitValue.empty? && !value.scheduleTypeLimits.get.upperLimitValue.empty? next if value.scheduleTypeLimits.get.lowerLimitValue.get != 0.0 next if value.scheduleTypeLimits.get.upperLimitValue.get != 1.0 fractional_schedule_handles << value.handle.to_s fractional_schedule_display_names << key end end # make a choice schedule for Work Efficiency Schedule workEfficiencySchedule = OpenStudio::Measure::OSArgument.makeChoiceArgument('workEfficiencySchedule', fractional_schedule_handles, fractional_schedule_display_names, true) workEfficiencySchedule.setDisplayName('Choose a Work Efficiency Schedule') # I don't offer a default here because there will be many fractional schedules. I want to user to choose args << workEfficiencySchedule # populate choice argument for clothing insulation schedules clothing_schedule_handles = OpenStudio::StringVector.new clothing_schedule_display_names = OpenStudio::StringVector.new # looping through sorted hash of schedules to find clothing insulation schedules schedule_args_hash.sort.map do |key, value| next if value.scheduleTypeLimits.empty? if value.scheduleTypeLimits.get.unitType == 'ClothingInsulation' clothing_schedule_handles << value.handle.to_s clothing_schedule_display_names << key end end # make a choice argument for Clothing Insulation Schedule Name clothingSchedule = OpenStudio::Measure::OSArgument.makeChoiceArgument('clothingSchedule', clothing_schedule_handles, clothing_schedule_display_names, true) clothingSchedule.setDisplayName('Choose a Clothing Insulation Schedule') if !clothing_schedule_display_names.empty? clothingSchedule.setDefaultValue(clothing_schedule_display_names[0]) # normally I don't default model choice list, but since often there might be just one I decided to default this. end args << clothingSchedule # populate choice argument for air velocity schedules airVelocity_schedule_handles = OpenStudio::StringVector.new airVelocity_schedule_display_names = OpenStudio::StringVector.new # looping through sorted hash of schedules to find air velocity schedules schedule_args_hash.sort.map do |key, value| next if value.scheduleTypeLimits.empty? if value.scheduleTypeLimits.get.unitType == 'Velocity' airVelocity_schedule_handles << value.handle.to_s airVelocity_schedule_display_names << key end end # make a choice argument for Air Velocity Schedule Name airVelocitySchedule = OpenStudio::Measure::OSArgument.makeChoiceArgument('airVelocitySchedule', airVelocity_schedule_handles, airVelocity_schedule_display_names, true) airVelocitySchedule.setDisplayName('Choose an Air Velocity Schedule') if !airVelocity_schedule_display_names.empty? airVelocitySchedule.setDefaultValue(airVelocity_schedule_display_names[0]) # normally I don't default model choice list, but since often there might be just one I decided to default this. end args << airVelocitySchedule # hard code Thermal Comfort Model Type to Fanger, but could add argument in the future. # make an argument for the frequency reporting_frequency_chs = OpenStudio::StringVector.new reporting_frequency_chs << 'Detailed' reporting_frequency_chs << 'Timestep' reporting_frequency_chs << 'Hourly' reporting_frequency_chs << 'Daily' reporting_frequency_chs << 'Monthly' reporting_frequency_chs << 'Runperiod' reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true) reporting_frequency.setDisplayName('Reporting Frequency') reporting_frequency.setDescription('The frequency at which to report timeseries output data.') reporting_frequency.setDefaultValue('Timestep') args << reporting_frequency return args end |
#description ⇒ Object
description
21 22 23 |
# File 'lib/measures/PredictedMeanVote/measure.rb', line 21 def description return 'This measure adds the necessary data to people objects to support Predicted Mean Vote output data. It also adds the variable request.' end |
#modeler_description ⇒ Object
modeler description
26 27 28 |
# File 'lib/measures/PredictedMeanVote/measure.rb', line 26 def modeler_description return 'This will not add new people objects, but rather just extend the ones that are in the model. It will rely on schedules already made in the model instead of creating new schedules.' end |
#name ⇒ Object
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
16 17 18 |
# File 'lib/measures/PredictedMeanVote/measure.rb', line 16 def name return 'Predicted Mean Vote' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
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 |
# File 'lib/measures/PredictedMeanVote/measure.rb', line 144 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 comfortWarnings = runner.getBoolArgumentValue('comfortWarnings', user_arguments) meanRadiantCalcType = runner.getStringArgumentValue('meanRadiantCalcType', user_arguments) workEfficiencySchedule = runner.getOptionalWorkspaceObjectChoiceValue('workEfficiencySchedule', user_arguments, model) # model is passed in because of argument type clothingSchedule = runner.getOptionalWorkspaceObjectChoiceValue('clothingSchedule', user_arguments, model) airVelocitySchedule = runner.getOptionalWorkspaceObjectChoiceValue('airVelocitySchedule', user_arguments, model) reporting_frequency = runner.getStringArgumentValue('reporting_frequency', user_arguments) # check the schedules for reasonableness if clothingSchedule.empty? || airVelocitySchedule.empty? || workEfficiencySchedule.empty? handle = runner.getStringArgumentValue('construction', user_arguments) if handle.empty? runner.registerError('One of the required schedules was not chosen.') else runner.registerError('One of the selected schedules was not found in the model. It may have been removed by another measure.') end return false else if clothingSchedule.get.to_Schedule.empty? || airVelocitySchedule.get.to_Schedule.empty? || workEfficiencySchedule.get.to_Schedule.empty? runner.registerError('Script Error - one of the schedule arguments is not showing up as an argument.') return false else workEfficiencySchedule = workEfficiencySchedule.get.to_Schedule.get clothingSchedule = clothingSchedule.get.to_Schedule.get airVelocitySchedule = airVelocitySchedule.get.to_Schedule.get end end # get people people_defs = model.getPeopleDefinitions people_instances = model.getPeoples # reporting initial condition of model starting_spaces = model.getSpaces runner.registerInitialCondition("The building started with #{people_defs.size} people definitions.") # loop through people people_def_counter = 0 people_defs.sort.each do |people_def| next if people_def.instances.size <= 0 people_def_counter += 1 runner.registerInfo("Editing '#{people_def.name}'") people_def.setEnableASHRAE55ComfortWarnings(comfortWarnings) people_def.setMeanRadiantTemperatureCalculationType(meanRadiantCalcType) people_def.setThermalComfortModelType(0, 'Fanger') end # loop through people instances people_instances.each do |people_instance| runner.registerInfo("Assigning Schedules for '#{people_instance.name}'") people_instance.setWorkEfficiencySchedule(workEfficiencySchedule) people_instance.setClothingInsulationSchedule(clothingSchedule) people_instance.setAirVelocitySchedule(airVelocitySchedule) end # array of output variables to use outputVariableArray = [] # these work on EnergyPlus 7.2 outputVariableArray << 'FangerPMV' outputVariableArray << 'FangerPPD' outputVariableArray << 'Time Not Comfortable Summer Clothes' outputVariableArray << 'Time Not Comfortable Winter Clothes' outputVariableArray << 'Time Not Comfortable Summer Or Winter Clothes' # these work on EnergyPlus 8.0 outputVariableArray << 'Zone Thermal Comfort Fanger Model PMV' outputVariableArray << 'Zone Thermal Comfort Fanger Model PPD' outputVariableArray << 'Zone Thermal Comfort ASHRAE 55 Simple Model Summer Clothes Not Comfortable Time' outputVariableArray << 'Zone Thermal Comfort ASHRAE 55 Simple Model Winter Clothes Not Comfortable Time' outputVariableArray << 'Zone Thermal Comfort ASHRAE 55 Simple Model Summer or Winter Clothes Not Comfortable Time' # add output variable objects runner.registerInfo('Adding zone output variables for Fanger PMV, Fanger PPD, and ASHRAE 55') outputVariableArray.each do |variable| outputVariable = OpenStudio::Model::OutputVariable.new(variable, model) outputVariable.setReportingFrequency(reporting_frequency.to_s) end # reporting final condition of model finishing_spaces = model.getSpaces runner.registerFinalCondition("#{people_def_counter} people definitions and #{people_instances.size} people instances were altered.") return true end |