Class: TariffSelectionTimeAndDateDependant
- Inherits:
-
OpenStudio::Measure::EnergyPlusMeasure
- Object
- OpenStudio::Measure::EnergyPlusMeasure
- TariffSelectionTimeAndDateDependant
- Defined in:
- lib/measures/tariff_selection_time_and_date_dependant/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 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 |
# File 'lib/measures/tariff_selection_time_and_date_dependant/measure.rb', line 27 def arguments(workspace) args = OpenStudio::Measure::OSArgumentVector.new # make choice argument for facade choices = OpenStudio::StringVector.new choices << 'QuarterHour' choices << 'HalfHour' choices << 'FullHour' # don't want to offer Day or Week even though valid E+ options # choices << "Day" # choices << "Week" demand_window_length = OpenStudio::Measure::OSArgument.makeChoiceArgument('demand_window_length', choices, true) demand_window_length.setDisplayName('Demand Window Length.') demand_window_length.setDefaultValue('QuarterHour') args << demand_window_length # adding argument for summer_start_month summer_start_month = OpenStudio::Measure::OSArgument.makeIntegerArgument('summer_start_month', true) summer_start_month.setDisplayName('Month Summer Begins') summer_start_month.setDescription('1-12') summer_start_month.setDefaultValue(5) summer_start_month.setMinValue(1.0) summer_start_month.setMaxValue(12.0) args << summer_start_month # adding argument for summer_start_day summer_start_day = OpenStudio::Measure::OSArgument.makeIntegerArgument('summer_start_day', true) summer_start_day.setDisplayName('Day Summer Begins') summer_start_day.setDescription('1-31') summer_start_day.setDefaultValue(1) summer_start_day.setMinValue(1.0) summer_start_day.setMaxValue(31.0) args << summer_start_day # adding argument for summer_end_month summer_end_month = OpenStudio::Measure::OSArgument.makeIntegerArgument('summer_end_month', true) summer_end_month.setDisplayName('Month Summer Ends') summer_end_month.setDescription('1-12') summer_end_month.setDefaultValue(9) summer_end_month.setMinValue(1.0) summer_end_month.setMaxValue(12.0) args << summer_end_month # adding argument for summer_end_day summer_end_day = OpenStudio::Measure::OSArgument.makeIntegerArgument('summer_end_day', true) summer_end_day.setDisplayName('Day Summer Ends') summer_end_day.setDescription('1-31') summer_end_day.setDefaultValue(1) summer_end_day.setMinValue(1.0) summer_end_day.setMaxValue(31.0) args << summer_end_day # adding argument for peak_start_hour peak_start_hour = OpenStudio::Measure::OSArgument.makeDoubleArgument('peak_start_hour', true) peak_start_hour.setDisplayName('Hour Peak Begins') peak_start_hour.setDescription('1-24') peak_start_hour.setDefaultValue(12) peak_start_hour.setMinValue(0.0) peak_start_hour.setMaxValue(24.0) args << peak_start_hour # adding argument for peak_end_hour peak_end_hour = OpenStudio::Measure::OSArgument.makeDoubleArgument('peak_end_hour', true) peak_end_hour.setDisplayName('Hour Peak Ends') peak_end_hour.setDescription('1-24') peak_end_hour.setDefaultValue(18) peak_end_hour.setMinValue(0.0) peak_end_hour.setMaxValue(24.0) args << peak_end_hour # adding argument for elec_rate_sum_peak elec_rate_sum_peak = OpenStudio::Measure::OSArgument.makeDoubleArgument('elec_rate_sum_peak', true) elec_rate_sum_peak.setDisplayName('Electric Rate Summer On-Peak') elec_rate_sum_peak.setUnits('$/kWh') elec_rate_sum_peak.setDefaultValue(0.06) args << elec_rate_sum_peak # adding argument for elec_rate_sum_nonpeak elec_rate_sum_nonpeak = OpenStudio::Measure::OSArgument.makeDoubleArgument('elec_rate_sum_nonpeak', true) elec_rate_sum_nonpeak.setDisplayName('Electric Rate Summer Off-Peak') elec_rate_sum_nonpeak.setUnits('$/kWh') elec_rate_sum_nonpeak.setDefaultValue(0.04) args << elec_rate_sum_nonpeak # adding argument for elec_rate_nonsum_peak elec_rate_nonsum_peak = OpenStudio::Measure::OSArgument.makeDoubleArgument('elec_rate_nonsum_peak', true) elec_rate_nonsum_peak.setDisplayName('Electric Rate Not Summer On-Peak') elec_rate_nonsum_peak.setUnits('$/kWh') elec_rate_nonsum_peak.setDefaultValue(0.05) args << elec_rate_nonsum_peak # adding argument for elec_rate_nonsum_nonpeak elec_rate_nonsum_nonpeak = OpenStudio::Measure::OSArgument.makeDoubleArgument('elec_rate_nonsum_nonpeak', true) elec_rate_nonsum_nonpeak.setDisplayName('Electric Rate Not Summer Off-Peak') elec_rate_nonsum_nonpeak.setUnits('$/kWh') elec_rate_nonsum_nonpeak.setDefaultValue(0.03) args << elec_rate_nonsum_nonpeak # adding argument for elec_demand_sum elec_demand_sum = OpenStudio::Measure::OSArgument.makeDoubleArgument('elec_demand_sum', true) elec_demand_sum.setDisplayName('Electric Peak Demand Charge Summer') elec_demand_sum.setUnits('$/kW') elec_demand_sum.setDefaultValue(15.0) args << elec_demand_sum # adding argument for elec_demand_nonsum elec_demand_nonsum = OpenStudio::Measure::OSArgument.makeDoubleArgument('elec_demand_nonsum', true) elec_demand_nonsum.setDisplayName('Electric Peak Demand Charge Not Summer') elec_demand_nonsum.setUnits('$/kW') elec_demand_nonsum.setDefaultValue(10.0) args << elec_demand_nonsum # adding argument for gas_rate gas_rate = OpenStudio::Measure::OSArgument.makeDoubleArgument('gas_rate', true) gas_rate.setDisplayName('Gas Rate') gas_rate.setUnits('$/therm') gas_rate.setDefaultValue(0.5) args << gas_rate # adding argument for water_rate water_rate = OpenStudio::Measure::OSArgument.makeDoubleArgument('water_rate', true) water_rate.setDisplayName('Water Rate') water_rate.setUnits('$/gal') water_rate.setDefaultValue(0.005) args << water_rate # adding argument for disthtg_rate disthtg_rate = OpenStudio::Measure::OSArgument.makeDoubleArgument('disthtg_rate', true) disthtg_rate.setDisplayName('District Heating Rate') disthtg_rate.setUnits('$/therm') disthtg_rate.setDefaultValue(0.2) args << disthtg_rate # adding argument for distclg_rate distclg_rate = OpenStudio::Measure::OSArgument.makeDoubleArgument('distclg_rate', true) distclg_rate.setDisplayName('District Cooling Rate') distclg_rate.setUnits('$/therm') distclg_rate.setDefaultValue(0.2) args << distclg_rate return args end |
#description ⇒ Object
human readable description
17 18 19 |
# File 'lib/measures/tariff_selection_time_and_date_dependant/measure.rb', line 17 def description return 'This measure sets flat rates for gas, water, district heating, and district cooling but has on seasonal and off peak rates for electricity. It exposes inputs for the time of day and day of year where peak rates should be applied.' end |
#modeler_description ⇒ Object
human readable description of modeling approach
22 23 24 |
# File 'lib/measures/tariff_selection_time_and_date_dependant/measure.rb', line 22 def modeler_description return 'Will add the necessary UtilityCost objects and associated schedule into the model.' end |
#name ⇒ Object
human readable name
12 13 14 |
# File 'lib/measures/tariff_selection_time_and_date_dependant/measure.rb', line 12 def name return 'Tariff Selection-Time and Date Dependant' end |
#run(workspace, runner, user_arguments) ⇒ Object
define what happens when the measure is run
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 |
# File 'lib/measures/tariff_selection_time_and_date_dependant/measure.rb', line 171 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 args = runner.getArgumentValues(arguments(workspace), user_arguments) args = Hash[args.collect{ |k, v| [k.to_s, v] }] if !args then return false end # reporting initial condition of model starting_tariffs = workspace.getObjectsByType('UtilityCost:Tariff'.to_IddObjectType) runner.registerInitialCondition("The model started with #{starting_tariffs.size} tariff objects.") # map demand window length to integer demand_window_per_hour = nil if args['demand_window_length'] == 'QuarterHour' demand_window_per_hour = 4 elsif args['demand_window_length'] == 'HalfHour' demand_window_per_hour = 2 elsif args['demand_window_length'] == 'FullHour' demand_window_per_hour = 1 end # make sure demand window length is is divisible by timestep if !workspace.getObjectsByType('Timestep'.to_IddObjectType).empty? initial_timestep = workspace.getObjectsByType('Timestep'.to_IddObjectType)[0].getString(0).get if initial_timestep.to_f / demand_window_per_hour.to_f == (initial_timestep.to_f / demand_window_per_hour.to_f).truncate # checks if remainder of divided numbers is > 0 runner.registerInfo("The demand window length of a #{args['demand_window_length']} is compatible with the current setting of #{initial_timestep} timesteps per hour.") else workspace.getObjectsByType('Timestep'.to_IddObjectType)[0].setString(0, demand_window_per_hour.to_s) runner.registerInfo("Updating the timesteps per hour in the model from #{initial_timestep} to #{demand_window_per_hour} to be compatible with the demand window length of a #{args['demand_window_length']}") end else # add a timestep object to the workspace new_object_string = " Timestep, 4; !- Number of Timesteps per Hour " idfObject = OpenStudio::IdfObject.load(new_object_string) object = idfObject.get wsObject = workspace.addObject(object) new_object = wsObject.get runner.registerInfo('No timestep object found. Added a new timestep object set to 4 timesteps per hour') end # get variables for time of day and year ms = args['summer_start_month'] ds = args['summer_start_day'] mf = args['summer_end_month'] df = args['summer_end_day'] ps = args['peak_start_hour'] pf = args['peak_end_hour'] psh = ps.truncate pfh = pf.truncate psm = ((ps - ps.truncate) * 60).truncate pfm = ((pf - pf.truncate) * 60).truncate if args['elec_rate_sum_peak'].abs + args['elec_rate_sum_nonpeak'].abs + args['elec_rate_nonsum_peak'].abs + args['elec_rate_nonsum_nonpeak'].abs + args['elec_demand_sum'].abs + args['elec_demand_nonsum'].abs > 0 # make type limits object new_object_string = " ScheduleTypeLimits, number, !- Name 0, !- Lower Limit Value {BasedOnField A3} 4, !- Upper Limit Value {BasedOnField A3} DISCRETE; !- Numeric Type " type_limits = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get # make two season schedule if ms + ds / 100.0 < mf + ds / 100.0 new_object_string = " Schedule:Compact, TwoSeasonSchedule, !- Name number, !- Schedule Type Limits Name Through: #{ms}/#{ds}, !- Field 1 For: AllDays, !- Field 2 Until: 24:00, !- Field 3 1, !- Field 4 Through: #{mf}/#{df}, !- Field 5 For: AllDays, !- Field 6 Until: 24:00, !- Field 7 3, !- Field 8 Through: 12/31, !- Field 9 For: AllDays, !- Field 10 Until: 24:00, !- Field 11 1; " else new_object_string = " Schedule:Compact, TwoSeasonSchedule, !- Name number, !- Schedule Type Limits Name Through: #{mf}/#{df}, !- Field 1 For: AllDays, !- Field 2 Until: 24:00, !- Field 3 3, !- Field 4 Through: #{ms}/#{ds}, !- Field 5 For: AllDays, !- Field 6 Until: 24:00, !- Field 7 1, !- Field 8 Through: 12/31, !- Field 9 For: AllDays, !- Field 10 Until: 24:00, !- Field 11 3; " end two_season_schedule = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get # make time of day schedule if psh + psm / 100.0 < pfh + pfm / 100.0 new_object_string = " Schedule:Compact, TimeOfDaySchedule, !- Name number, !- Schedule Type Limits Name Through: 12/31, !- Field 1 For: AllDays, !- Field 2 Until: #{psh}:#{psm}, !- Field 3 3, !- Field 4 Until: #{pfh}:#{pfm}, !- Field 5 1, !- Field 6 Until: 24:00, !- Field 7 3; !- Field 8 " else new_object_string = " Schedule:Compact, TimeOfDaySchedule, !- Name number, !- Schedule Type Limits Name Through: 12/31, !- Field 1 For: AllDays, !- Field 2 Until: #{pfh}:#{pfm}, !- Field 3 1, !- Field 4 Until: #{psh}:#{psm}, !- Field 5 3, !- Field 6 Until: 24:00, !- Field 7 1; !- Field 8 " end time_of_day_schedule = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get # electric tariff object new_object_string = " UtilityCost:Tariff, Electricity Tariff, !- Name ElectricityPurchased:Facility, !- Output Meter Name kWh, !- Conversion Factor Choice , !- Energy Conversion Factor , !- Demand Conversion Factor #{time_of_day_schedule.getString(0)}, !- Time of Use Period Schedule Name #{two_season_schedule.getString(0)}, !- Season Schedule Name , !- Month Schedule Name #{args['demand_window_length']}, !- Demand Window Length 0.0; !- Monthly Charge or Variable Name " electric_tariff = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get # make UtilityCost:Charge:Simple objects for electricity new_object_string = " UtilityCost:Charge:Simple, ElectricityTariffSummerOnPeakEnergyCharge, !- Name Electricity Tariff, !- Tariff Name peakEnergy, !- Source Variable summer, !- Season EnergyCharges, !- Category Variable Name #{args['elec_rate_sum_peak']}; !- Cost per Unit Value or Variable Name " elec_utility_cost_sum_peak = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get new_object_string = " UtilityCost:Charge:Simple, ElectricityTariffSummerOffPeakEnergyCharge, !- Name Electricity Tariff, !- Tariff Name offPeakEnergy, !- Source Variable summer, !- Season EnergyCharges, !- Category Variable Name #{args['elec_rate_sum_nonpeak']}; !- Cost per Unit Value or Variable Name " elec_utility_cost_sum_nonpeak = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get new_object_string = " UtilityCost:Charge:Simple, ElectricityTariffWinterOnPeakEnergyCharge, !- Name Electricity Tariff, !- Tariff Name peakEnergy, !- Source Variable winter, !- Season EnergyCharges, !- Category Variable Name #{args['elec_rate_nonsum_peak']}; !- Cost per Unit Value or Variable Name " elec_utility_cost_nonsum_peak = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get new_object_string = " UtilityCost:Charge:Simple, ElectricityTariffWinterOffPeakEnergyCharge, !- Name Electricity Tariff, !- Tariff Name offPeakEnergy, !- Source Variable winter, !- Season EnergyCharges, !- Category Variable Name #{args['elec_rate_nonsum_nonpeak']}; !- Cost per Unit Value or Variable Name " elec_utility_cost_nonsum_nonpeak = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get new_object_string = " UtilityCost:Charge:Simple, ElectricityTariffSummerDemandCharge, !- Name Electricity Tariff, !- Tariff Name totalDemand, !- Source Variable summer, !- Season DemandCharges, !- Category Variable Name #{args['elec_demand_sum']}; !- Cost per Unit Value or Variable Name " elec_utility_cost_sum_demand = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get new_object_string = " UtilityCost:Charge:Simple, ElectricityTariffWinterDemandCharge, !- Name Electricity Tariff, !- Tariff Name totalDemand, !- Source Variable winter, !- Season DemandCharges, !- Category Variable Name #{args['elec_demand_nonsum']}; !- Cost per Unit Value or Variable Name " elec_utility_cost_nonsum_demand = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get end # gas tariff object if args['gas_rate'] > 0 new_object_string = " UtilityCost:Tariff, Gas Tariff, !- Name NaturalGas:Facility, !- Output Meter Name Therm, !- Conversion Factor Choice , !- Energy Conversion Factor , !- Demand Conversion Factor , !- Time of Use Period Schedule Name , !- Season Schedule Name , !- Month Schedule Name Day, !- Demand Window Length 0.0; !- Monthly Charge or Variable Name " gas_tariff = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get # make UtilityCost:Charge:Simple objects for gas new_object_string = " UtilityCost:Charge:Simple, GasTariffEnergyCharge, !- Name Gas Tariff, !- Tariff Name totalEnergy, !- Source Variable Annual, !- Season EnergyCharges, !- Category Variable Name #{args['gas_rate']}; !- Cost per Unit Value or Variable Name " gas_utility_cost = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get end # conversion for water tariff rate dollars_per_gallon = args['water_rate'] dollars_per_meter_cubed = OpenStudio.convert(dollars_per_gallon, '1/gal', '1/m^3').get # water tariff object if args['water_rate'] > 0 new_object_string = " UtilityCost:Tariff, Water Tariff, !- Name Water:Facility, !- Output Meter Name UserDefined, !- Conversion Factor Choice 1, !- Energy Conversion Factor , !- Demand Conversion Factor , !- Time of Use Period Schedule Name , !- Season Schedule Name , !- Month Schedule Name , !- Demand Window Length 0.0; !- Monthly Charge or Variable Name " water_tariff = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get # make UtilityCost:Charge:Simple objects for water new_object_string = " UtilityCost:Charge:Simple, WaterTariffEnergyCharge, !- Name Water Tariff, !- Tariff Name totalEnergy, !- Source Variable Annual, !- Season EnergyCharges, !- Category Variable Name #{dollars_per_meter_cubed}; !- Cost per Unit Value or Variable Name " water_utility_cost = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get end # disthtg tariff object if args['disthtg_rate'] > 0 new_object_string = " UtilityCost:Tariff, DistrictHeating Tariff, !- Name DistrictHeating:Facility, !- Output Meter Name Therm, !- Conversion Factor Choice , !- Energy Conversion Factor , !- Demand Conversion Factor , !- Time of Use Period Schedule Name , !- Season Schedule Name , !- Month Schedule Name Day, !- Demand Window Length 0.0; !- Monthly Charge or Variable Name " disthtg_tariff = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get # make UtilityCost:Charge:Simple objects for disthtg new_object_string = " UtilityCost:Charge:Simple, DistrictHeatingTariffEnergyCharge, !- Name DistrictHeating Tariff, !- Tariff Name totalEnergy, !- Source Variable Annual, !- Season EnergyCharges, !- Category Variable Name #{args['disthtg_rate']}; !- Cost per Unit Value or Variable Name " disthtg_utility_cost = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get end # distclg tariff object if args['distclg_rate'] > 0 new_object_string = " UtilityCost:Tariff, DistrictCooling Tariff, !- Name DistrictCooling:Facility, !- Output Meter Name Therm, !- Conversion Factor Choice , !- Energy Conversion Factor , !- Demand Conversion Factor , !- Time of Use Period Schedule Name , !- Season Schedule Name , !- Month Schedule Name Day, !- Demand Window Length 0.0; !- Monthly Charge or Variable Name " distclg_tariff = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get # make UtilityCost:Charge:Simple objects for distclg new_object_string = " UtilityCost:Charge:Simple, DistrictCoolingTariffEnergyCharge, !- Name DistrictCooling Tariff, !- Tariff Name totalEnergy, !- Source Variable Annual, !- Season EnergyCharges, !- Category Variable Name #{args['distclg_rate']}; !- Cost per Unit Value or Variable Name " distclg_utility_cost = workspace.addObject(OpenStudio::IdfObject.load(new_object_string).get).get end # report final condition of model finishing_tariffs = workspace.getObjectsByType('UtilityCost:Tariff'.to_IddObjectType) runner.registerFinalCondition("The model finished with #{finishing_tariffs.size} tariff objects.") return true end |