Class: AdjustThermostatSetpointsByDegrees
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- AdjustThermostatSetpointsByDegrees
- Defined in:
- lib/measures/AdjustThermostatSetpointsByDegrees/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
define the name that a user will see.
-
#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
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/measures/AdjustThermostatSetpointsByDegrees/measure.rb', line 24 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # make an argument for adjustment to cooling setpoint cooling_adjustment = OpenStudio::Measure::OSArgument.makeDoubleArgument('cooling_adjustment', true) cooling_adjustment.setDisplayName('Degrees Fahrenheit to Adjust Cooling Setpoint By') cooling_adjustment.setDefaultValue(1.0) args << cooling_adjustment # make an argument for adjustment to heating setpoint heating_adjustment = OpenStudio::Measure::OSArgument.makeDoubleArgument('heating_adjustment', true) heating_adjustment.setDisplayName('Degrees Fahrenheit to Adjust heating Setpoint By') heating_adjustment.setDefaultValue(-1.0) args << heating_adjustment # make an argument for adjustment to heating setpoint alter_design_days = OpenStudio::Measure::OSArgument.makeBoolArgument('alter_design_days', true) alter_design_days.setDisplayName('Alter Design Day Thermostats') alter_design_days.setDefaultValue(false) args << alter_design_days return args end |
#description ⇒ Object
human readable description
14 15 16 |
# File 'lib/measures/AdjustThermostatSetpointsByDegrees/measure.rb', line 14 def description return 'This measure adjusts heating and cooling setpoints by a user specified number of degrees. This is applied throughout the entire building.' end |
#modeler_description ⇒ Object
human readable description of modeling approach
19 20 21 |
# File 'lib/measures/AdjustThermostatSetpointsByDegrees/measure.rb', line 19 def modeler_description return 'This measure will clone all of the schedules that are used as heating and cooling setpoints for thermal zones. The clones are hooked up to the thermostat in place of the original schedules. Then the schedules are adjusted by the specified values. There is a checkbox to determine if the thermostat for design days should be altered.' end |
#name ⇒ Object
define the name that a user will see
9 10 11 |
# File 'lib/measures/AdjustThermostatSetpointsByDegrees/measure.rb', line 9 def name return 'Adjust Thermostat Setpoints by Degrees' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
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 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 |
# File 'lib/measures/AdjustThermostatSetpointsByDegrees/measure.rb', line 49 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 cooling_adjustment = runner.getDoubleArgumentValue('cooling_adjustment', user_arguments) heating_adjustment = runner.getDoubleArgumentValue('heating_adjustment', user_arguments) alter_design_days = runner.getBoolArgumentValue('alter_design_days', user_arguments) # ruby test to see if first charter of string is uppercase letter if cooling_adjustment < 0 runner.registerWarning('Lowering the cooling setpoint will increase energy use.') elsif cooling_adjustment.abs > 500 runner.registerError("#{cooling_adjustment} is a larger than typical setpoint adjustment") return false elsif cooling_adjustment.abs > 50 runner.registerWarning("#{cooling_adjustment} is a larger than typical setpoint adjustment") end if heating_adjustment > 0 runner.registerWarning('Raising the heating setpoint will increase energy use.') elsif heating_adjustment.abs > 500 runner.registerError("#{heating_adjustment} is a larger than typical setpoint adjustment") return false elsif heating_adjustment.abs > 50 runner.registerWarning("#{heating_adjustment} is a larger than typical setpoint adjustment") end # setup OpenStudio units that we will need temperature_ip_unit = OpenStudio.createUnit('F').get temperature_si_unit = OpenStudio.createUnit('C').get # define starting units cooling_adjustment_ip = OpenStudio::Quantity.new(cooling_adjustment, temperature_ip_unit) heating_adjustment_ip = OpenStudio::Quantity.new(heating_adjustment, temperature_ip_unit) # push schedules to hash to avoid making unnecessary duplicates clg_set_schs = {} htg_set_schs = {} # get thermostats and setpoint schedules thermostats = model.getThermostatSetpointDualSetpoints thermostats.each do |thermostat| # setup new cooling setpoint schedule clg_set_sch = thermostat.coolingSetpointTemperatureSchedule if !clg_set_sch.empty? # clone of not alredy in hash if clg_set_schs.key?(clg_set_sch.get.name.to_s) new_clg_set_sch = clg_set_schs[clg_set_sch.get.name.to_s] else new_clg_set_sch = clg_set_sch.get.clone(model) new_clg_set_sch = new_clg_set_sch.to_Schedule.get new_clg_set_sch_name = new_clg_set_sch.setName("#{new_clg_set_sch.name} adjusted by #{cooling_adjustment_ip}") # add to the hash clg_set_schs[clg_set_sch.get.name.to_s] = new_clg_set_sch end # hook up clone to thermostat thermostat.setCoolingSetpointTemperatureSchedule(new_clg_set_sch) else runner.registerWarning("Thermostat '#{thermostat.name}' doesn't have a cooling setpoint schedule") end # setup new heating setpoint schedule htg_set_sch = thermostat.heatingSetpointTemperatureSchedule if !htg_set_sch.empty? # clone of not already in hash if htg_set_schs.key?(htg_set_sch.get.name.to_s) new_htg_set_sch = htg_set_schs[htg_set_sch.get.name.to_s] else new_htg_set_sch = htg_set_sch.get.clone(model) new_htg_set_sch = new_htg_set_sch.to_Schedule.get new_htg_set_sch_name = new_htg_set_sch.setName("#{new_htg_set_sch.name} adjusted by #{heating_adjustment_ip}") # add to the hash htg_set_schs[htg_set_sch.get.name.to_s] = new_htg_set_sch end # hook up clone to thermostat thermostat.setHeatingSetpointTemperatureSchedule(new_htg_set_sch) else runner.registerWarning("Thermostat '#{thermostat.name}' doesn't have a heating setpoint schedule.") end end # setting up variables to use for initial and final condition clg_sch_set_values = [] # may need to flatten this htg_sch_set_values = [] # may need to flatten this final_clg_sch_set_values = [] final_htg_sch_set_values = [] # consider issuing a warning if the model has un-conditioned thermal zones (no ideal air loads or hvac) zones = model.getThermalZones zones.each do |zone| # if you have a thermostat but don't have ideal air loads or zone equipment then issue a warning if !zone.thermostatSetpointDualSetpoint.empty? && !zone.useIdealAirLoads && (zone.equipment.size <= 0) runner.registerWarning("Thermal zone '#{zone.name}' has a thermostat but does not appear to be conditioned.") end end # make cooling schedule adjustments and rename. Put in check to skip and warn if schedule not ruleset clg_set_schs.each do |k, v| # old name and new object for schedule if !v.to_ScheduleRuleset.empty? # array to store profiles in profiles = [] schedule = v.to_ScheduleRuleset.get # push default profiles to array default_rule = schedule.defaultDaySchedule profiles << default_rule # push profiles to array rules = schedule.scheduleRules rules.each do |rule| day_sch = rule.daySchedule profiles << day_sch end # add design days to array if alter_design_days == true summer_design = schedule.summerDesignDaySchedule winter_design = schedule.winterDesignDaySchedule profiles << summer_design # profiles << winter_design end profiles.each do |sch_day| day_time_vector = sch_day.times day_value_vector = sch_day.values clg_sch_set_values << day_value_vector sch_day.clearValues for i in 0..(day_time_vector.size - 1) v_si = OpenStudio::Quantity.new(day_value_vector[i], temperature_si_unit) v_ip = OpenStudio.convert(v_si, temperature_ip_unit).get target_v_ip = v_ip + cooling_adjustment_ip target_temp_si = OpenStudio.convert(target_v_ip, temperature_si_unit).get sch_day.addValue(day_time_vector[i], target_temp_si.value) end final_clg_sch_set_values << sch_day.values end else runner.registerWarning("Schedule '#{k}' isn't a ScheduleRuleset object and won't be altered by this measure.") v.remove # remove un-used clone end end # make heating schedule adjustments and rename. Put in check to skip and warn if schedule not ruleset htg_set_schs.each do |k, v| # old name and new object for schedule if !v.to_ScheduleRuleset.empty? # array to store profiles in profiles = [] schedule = v.to_ScheduleRuleset.get # push default profiles to array default_rule = schedule.defaultDaySchedule profiles << default_rule # push profiles to array rules = schedule.scheduleRules rules.each do |rule| day_sch = rule.daySchedule profiles << day_sch end # add design days to array if alter_design_days == true summer_design = schedule.summerDesignDaySchedule winter_design = schedule.winterDesignDaySchedule # profiles << summer_design profiles << winter_design end profiles.each do |sch_day| day_time_vector = sch_day.times day_value_vector = sch_day.values htg_sch_set_values << day_value_vector sch_day.clearValues for i in 0..(day_time_vector.size - 1) v_si = OpenStudio::Quantity.new(day_value_vector[i], temperature_si_unit) v_ip = OpenStudio.convert(v_si, temperature_ip_unit).get target_v_ip = v_ip + heating_adjustment_ip target_temp_si = OpenStudio.convert(target_v_ip, temperature_si_unit).get sch_day.addValue(day_time_vector[i], target_temp_si.value) end final_htg_sch_set_values << sch_day.values end else runner.registerWarning("Schedule '#{k}' isn't a ScheduleRuleset object and won't be altered by this measure.") v.remove # remove un-used clone end end # get min and max heating and cooling and convert to IP clg_sch_set_values = clg_sch_set_values.flatten htg_sch_set_values = htg_sch_set_values.flatten # set NA flag if can't get values for schedules (e.g. if all compact) applicable_flag = false # get min and max if values exist if !clg_sch_set_values.empty? min_clg_si = OpenStudio::Quantity.new(clg_sch_set_values.min, temperature_si_unit) max_clg_si = OpenStudio::Quantity.new(clg_sch_set_values.max, temperature_si_unit) min_clg_ip = OpenStudio.convert(min_clg_si, temperature_ip_unit).get max_clg_ip = OpenStudio.convert(max_clg_si, temperature_ip_unit).get applicable_flag = true else min_clg_ip = 'NA' max_clg_ip = 'NA' end # get min and max if values exist if !htg_sch_set_values.empty? min_htg_si = OpenStudio::Quantity.new(htg_sch_set_values.min, temperature_si_unit) max_htg_si = OpenStudio::Quantity.new(htg_sch_set_values.max, temperature_si_unit) min_htg_ip = OpenStudio.convert(min_htg_si, temperature_ip_unit).get max_htg_ip = OpenStudio.convert(max_htg_si, temperature_ip_unit).get applicable_flag = true else min_htg_ip = 'NA' max_htg_ip = 'NA' end # not applicable if no schedules can be altered if applicable_flag == false runner.registerAsNotApplicable('No thermostat schedules in the models could be altered.') end # reporting initial condition of model starting_spaces = model.getSpaces runner.registerInitialCondition("Initial cooling setpoints used in the model range from #{min_clg_ip} to #{max_clg_ip}. Initial heating setpoints used in the model range from #{min_htg_ip} to #{max_htg_ip}.") # get min and max heating and cooling and convert to IP for final final_clg_sch_set_values = final_clg_sch_set_values.flatten final_htg_sch_set_values = final_htg_sch_set_values.flatten if !clg_sch_set_values.empty? final_min_clg_si = OpenStudio::Quantity.new(final_clg_sch_set_values.min, temperature_si_unit) final_max_clg_si = OpenStudio::Quantity.new(final_clg_sch_set_values.max, temperature_si_unit) final_min_clg_ip = OpenStudio.convert(final_min_clg_si, temperature_ip_unit).get final_max_clg_ip = OpenStudio.convert(final_max_clg_si, temperature_ip_unit).get else final_min_clg_ip = 'NA' final_max_clg_ip = 'NA' end # get min and max if values exist if !htg_sch_set_values.empty? final_min_htg_si = OpenStudio::Quantity.new(final_htg_sch_set_values.min, temperature_si_unit) final_max_htg_si = OpenStudio::Quantity.new(final_htg_sch_set_values.max, temperature_si_unit) final_min_htg_ip = OpenStudio.convert(final_min_htg_si, temperature_ip_unit).get final_max_htg_ip = OpenStudio.convert(final_max_htg_si, temperature_ip_unit).get else final_min_htg_ip = 'NA' final_max_htg_ip = 'NA' end # reporting final condition of model finishing_spaces = model.getSpaces runner.registerFinalCondition("Final cooling setpoints used in the model range from #{final_min_clg_ip} to #{final_max_clg_ip}. Final heating setpoints used in the model range from #{final_min_htg_ip} to #{final_max_htg_ip}.") return true end |