Class: UnmetLoadHoursTroubleshooting
- Inherits:
-
OpenStudio::Measure::ReportingMeasure
- Object
- OpenStudio::Measure::ReportingMeasure
- UnmetLoadHoursTroubleshooting
- Defined in:
- lib/measures/UnmetLoadHoursTroubleshooting/measure.rb
Overview
start the measure
Instance Method Summary collapse
- #air_loop_vs_schedule_temp(zoneMetrics) ⇒ Object
- #airloop_reasonable_setting(measureMetrics) ⇒ Object
- #arguments(model = nil) ⇒ Object
- #compare_weather_to_dsn_days ⇒ Object
- #energyPlusOutputRequests(runner, user_arguments) ⇒ Object
- #get_unmet_hours_matrix(zoneMetrics) ⇒ Object
- #getAbruptScheduleChanges(schedule) ⇒ Object
- #getMinMaxForSchedule(schedule) ⇒ Object
- #getResourceFileData(fileName) ⇒ Object
- #getTimeSeries(name, index, envperiod, rate) ⇒ Object
- #getTimesForSeries(name, index, envperiod, rate) ⇒ Object
- #initZoneMetrics(thermalZone) ⇒ Object
- #name ⇒ Object
- #plant_loop_temp_vs_setpoints(zoneMetrics) ⇒ Object
-
#run(runner, user_arguments) ⇒ Object
define what happens when the measure is run.
- #thermostat_setpoints_for_underperforming(thermalZone, zoneMetrics) ⇒ Object
- #time_series_setpoint_vs_temp(zoneMetrics) ⇒ Object
-
#to_JSTime(os_time) ⇒ Object
Method to translate from OpenStudio’s time formatting to Javascript time formatting OpenStudio time 2009-May-14 00:10:00 Raw string Javascript time 2009/07/12 12:34:56.
- #unmet_hrs_from_slave_zones(thermalZone, zoneMetrics) ⇒ Object
- #writeResourceFileData(fileName, data) ⇒ Object
Instance Method Details
#air_loop_vs_schedule_temp(zoneMetrics) ⇒ Object
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 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 330 def air_loop_vs_schedule_temp(zoneMetrics) zoneMetrics[:test_eight_state] = nil if @model.getAirLoopHVACs.count == 0 zoneMetrics[:test_eight_state] = :no_airloops else zoneMetrics[:air_loop_vs_schedule_temp] = {} @model.getAirLoopHVACs.sort.each do |airloop| loop_name = airloop.name.to_s zoneMetrics[:air_loop_vs_schedule_temp][loop_name] = {} is_unitary_system = false airloop.supplyComponents.each do |component| obj_type = component.iddObjectType.valueName.to_s case obj_type when 'OS_AirLoopHVAC_UnitarySystem', 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir', 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeed', 'OS_AirLoopHVAC_UnitaryHeatCool_VAVChangeoverBypass' is_unitary_system = true end end if is_unitary_system zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:status] = :no_scheduled_manager next end supplyOutletNode = airloop.supplyOutletNode setPointManagers = supplyOutletNode.setpointManagers type = setPointManagers[0].iddObjectType.valueDescription if type == 'OS:SetpointManager:Scheduled' schedule = setPointManagers[0].to_SetpointManagerScheduled.get.schedule # get schedule name for the setPointManager scheduleName = schedule.name.get.to_s sizingSystem = airloop.sizingSystem centralHeatingTemp = OpenStudio.convert(sizingSystem.centralHeatingDesignSupplyAirTemperature, 'C', 'F').get centralCoolingTemp = OpenStudio.convert(sizingSystem.centralCoolingDesignSupplyAirTemperature, 'C', 'F').get rawMin, rawMax = getMinMaxForSchedule(schedule) maxSetpointValue = OpenStudio.convert(rawMax, 'C', 'F').get minSetpointValue = OpenStudio.convert(rawMin, 'C', 'F').get zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:centralHeatingTemp] = centralHeatingTemp zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:centralCoolingTemp] = centralCoolingTemp zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:maxSetpointValue] = maxSetpointValue zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:minSetpointValue] = minSetpointValue zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:scheduleName] = scheduleName if centralHeatingTemp < (maxSetpointValue - 1) || centralHeatingTemp > (maxSetpointValue + 1) zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:heating_status] = :failed else zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:heating_status] = :passed end if centralCoolingTemp < (minSetpointValue - 1) || centralCoolingTemp > (minSetpointValue + 1) zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:cooling_status] = :failed else zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:cooling_status] = :passed end else zoneMetrics[:air_loop_vs_schedule_temp][loop_name][:status] = :no_scheduled_manager end end end end |
#airloop_reasonable_setting(measureMetrics) ⇒ Object
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 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 296 def airloop_reasonable_setting(measureMetrics) measureMetrics[:test_seven_state] = nil if @model.getAirLoopHVACs.count == 0 measureMetrics[:test_seven_state] = :no_airloops else measureMetrics[:airloop_reasonable_setting] = {} @model.getAirLoopHVACs.sort.each do |airloop| loop_name = airloop.name.to_s measureMetrics[:airloop_reasonable_setting][loop_name] = {} sizingSystem = airloop.sizingSystem centralHeatingTempF = OpenStudio.convert(sizingSystem.centralHeatingDesignSupplyAirTemperature, 'C', 'F').get centralCoolingTempF = OpenStudio.convert(sizingSystem.centralCoolingDesignSupplyAirTemperature, 'C', 'F').get measureMetrics[:airloop_reasonable_setting][loop_name][:centralHeatingTempF] = centralHeatingTempF measureMetrics[:airloop_reasonable_setting][loop_name][:centralCoolingTempF] = centralCoolingTempF # Determine whether the system is a reheat system or not if !airloop.demandComponents('OS:AirTerminal:SingleDuct:ConstantVolume:Reheat'.to_IddObjectType).empty? || !airloop.demandComponents('OS:AirTerminal:SingleDuct:ParallelPIU:Reheat'.to_IddObjectType).empty? || !airloop.demandComponents('OS:AirTerminal:SingleDuct:SeriesPIU:Reheat'.to_IddObjectType).empty? || !airloop.demandComponents('OS:AirTerminal:SingleDuct:VAV:HeatAndCool:Reheat'.to_IddObjectType).empty? || !airloop.demandComponents('OS:AirTerminal:SingleDuct:VAV:Reheat'.to_IddObjectType).empty? measureMetrics[:airloop_reasonable_setting][loop_name][:reheat] = true else measureMetrics[:airloop_reasonable_setting][loop_name][:reheat] = false end end end end |
#arguments(model = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 31 def arguments(model = nil) args = OpenStudio::Measure::OSArgumentVector.new # Future functionality # zone_titles = [] # model.getThermalZones.each do |thermalZone| # zone_name = thermalZone.name.empty? ? thermalZone.name.get : '' # zone_titles.push( zone_name ) # end # Choice list of measure_zones measure_zones = ['All Zones'] measure_zone = OpenStudio::Measure::OSArgument.makeChoiceArgument('measure_zone', measure_zones, measure_zones, true) measure_zone.setDefaultValue('All Zones') measure_zone.setDisplayName('Pick a Zone (or all Zones)') args << measure_zone return args end |
#compare_weather_to_dsn_days ⇒ Object
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 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 81 def compare_weather_to_dsn_days # design day name vs run period weather file # lastEpwFile = @runner.lastEpwFilePath.empty? ? "" : @runner.lastEpwFilePath.get.to_s # Get the city name from the weather file epw_city_name = '' weather_file_name = @model.getWeatherFile.url if weather_file_name.is_initialized weather_file_name = weather_file_name.get weather_file_name = File.basename(weather_file_name, '.*') match = weather_file_name.match(/.*_.*_(\w*)\W/i) if match puts "Weather File City Initial = #{match}" if match[1] epw_city_name = match[1] puts "Weather File City = #{epw_city_name}" end end end # Get the city names from each design day dsn_day_city_names = [] @model.getDesignDays.each do |dsn_day| dsn_day_name = dsn_day.name.get match = dsn_day_name.match(/(\w*) /i) if match if match[1] dsn_day_city_name = match[1] puts "Design Day City = #{dsn_day_city_name}" dsn_day_city_names << dsn_day_city_name end end end # Compare the weather file city against the dsn day city all_match = true dsn_day_city_names.each do |dsn_day_city_name| unless dsn_day_city_name.casecmp(epw_city_name) all_match = false end end if dsn_day_city_names.empty? @metrics[:fileMatch] = :no_design_days elsif epw_city_name == '' @metrics[:fileMatch] = :no_weather_file elsif all_match == true @metrics[:fileMatch] = :matching_design_day_file else @metrics[:fileMatch] = :unmatched_design_day_file end end |
#energyPlusOutputRequests(runner, user_arguments) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 14 def energyPlusOutputRequests(runner, user_arguments) super(runner, user_arguments) requested_args = OpenStudio::IdfObjectVector.new if !runner.validateUserArguments(arguments, user_arguments) return requested_args end requested_args << OpenStudio::IdfObject.load('Output:Variable,,Zone Mean Air Temperature,Hourly;').get requested_args << OpenStudio::IdfObject.load('Output:Variable,,Zone Thermostat Heating Setpoint Temperature,Hourly;').get requested_args << OpenStudio::IdfObject.load('Output:Variable,,Zone Thermostat Cooling Setpoint Temperature,Hourly;').get requested_args << OpenStudio::IdfObject.load('Output:Variable,,Zone People Occupant Count,Hourly;').get return requested_args end |
#get_unmet_hours_matrix(zoneMetrics) ⇒ Object
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 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 51 def get_unmet_hours_matrix(zoneMetrics) @metrics[:toleranceTimeHeatSetUnmet] = 0.2 @metrics[:toleranceTimeCoolSetUnmet] = 0.2 @model.getObjectsByType('OS:OutputControl:ReportingTolerances'.to_IddObjectType).each do |d| @metrics[:toleranceTimeHeatSetUnmet] = d.getDouble(1).empty? ? 0.2 : d.getDouble(1).get @metrics[:toleranceTimeCoolSetUnmet] = d.getDouble(2).empty? ? 0.2 : d.getDouble(2).get end # We must use Kelvin -> Rankine conversion instead of Celsius -> Farenheit because the latter conversion adds the 32 degree offset @metrics[:toleranceTimeHeatSetUnmetF] = OpenStudio.convert(@metrics[:toleranceTimeHeatSetUnmet], 'K', 'R').get @metrics[:toleranceTimeCoolSetUnmetF] = OpenStudio.convert(@metrics[:toleranceTimeCoolSetUnmet], 'K', 'R').get for i in 0..(zoneMetrics[:zone_mean_air_temp_vals].size - 1) if zoneMetrics[:zone_heat_setpoint_vals][i] > zoneMetrics[:zone_mean_air_temp_vals][i] + @metrics[:toleranceTimeHeatSetUnmetF] zoneMetrics[:TimeSetpointNotMet][:dur_heating] += 1 zoneMetrics[:unmet_heating_hrs] += 1 if zoneMetrics[:zone_occupant_vals][i] > 0 zoneMetrics[:TimeSetpointNotMet][:dur_heating_occ] += 1 end end if zoneMetrics[:zone_cool_setpoint_vals][i] < zoneMetrics[:zone_mean_air_temp_vals][i] - @metrics[:toleranceTimeCoolSetUnmetF] zoneMetrics[:TimeSetpointNotMet][:dur_cooling] += 1 zoneMetrics[:unmet_cooling_hrs] += 1 if zoneMetrics[:zone_occupant_vals][i] > 0 zoneMetrics[:TimeSetpointNotMet][:dur_cooling_occ] += 1 end end end end |
#getAbruptScheduleChanges(schedule) ⇒ Object
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 668 def getAbruptScheduleChanges(schedule) profiles = [] defaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule profiles << defaultProfile rules = schedule.to_ScheduleRuleset.get.scheduleRules rules.each do |rule| profiles << rule.daySchedule end changesOut = {} profiles.each do |profile| name = profile.name.get.to_s last_val = -1 for s in 0..profile.values.count - 1 do if s == 0 curr = s last = profile.values.count - 1 else curr = s last = s - 1 end currVal = OpenStudio.convert(profile.values[curr], 'C', 'F').get lastVal = OpenStudio.convert(profile.values[last], 'C', 'F').get change = (currVal - lastVal).abs if change > 3 changesOut[name] = changesOut[name].nil? ? 0 : changesOut[name] + 1 end end end return changesOut end |
#getMinMaxForSchedule(schedule) ⇒ Object
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 614 def getMinMaxForSchedule(schedule) if schedule.to_ScheduleConstant.is_initialized schedule = schedule.to_ScheduleConstant.get max = schedule.value min = schedule.value elsif schedule.to_ScheduleCompact.is_initialized schedule = schedule.toScheduleCompact.get vals = [] prev_str = '' schedule.extensibleGroups.each do |eg| if prev_str.include?('until') val = eg.getDouble(0) if val.is_initialized vals << eg.getDouble(0).get end end str = eg.getString(0) if str.is_initialized prev_str = str.get.downcase end end max = vals.max min = vals.min elsif schedule.to_ScheduleRuleset.is_initialized schedule = schedule.to_ScheduleRuleset.get profiles = [] profiles << schedule.defaultDaySchedule rules = schedule.scheduleRules rules.each do |rule| profiles << rule.daySchedule end # test profiles min = nil max = nil profiles.each do |profile| profile.values.each do |value| if min.nil? min = value else if value < min then min = value end end if max.nil? max = value else if value > max then max = value end end end end end return min, max end |
#getResourceFileData(fileName) ⇒ Object
766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 766 def getResourceFileData(fileName) data_in_path = "#{File.dirname(__FILE__)}/resources/#{fileName}" if !File.exist?(data_in_path) data_in_path = "#{File.dirname(__FILE__)}/#{fileName}" end html_in = '' File.open(data_in_path, 'r') do |file| html_in = file.read end html_in end |
#getTimeSeries(name, index, envperiod, rate) ⇒ Object
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 709 def getTimeSeries(name, index, envperiod, rate) series = @sqlFile.timeSeries(envperiod, rate, name, index) if series.empty? @runner.registerWarning("No data found for '#{name}' '#{index}'") return nil else series = series.get end series_collection = series.values series_vals = [] for i in 0..(series_collection.size - 1) series_vals << series_collection[i] end series_vals end |
#getTimesForSeries(name, index, envperiod, rate) ⇒ Object
727 728 729 730 731 732 733 734 735 736 737 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 727 def getTimesForSeries(name, index, envperiod, rate) series = @sqlFile.timeSeries(envperiod, rate, name, index) if series.empty? @runner.registerWarning("No data found for '#{name}' '#{index}'") return nil else series = series.get end series.dateTimes end |
#initZoneMetrics(thermalZone) ⇒ Object
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 566 def initZoneMetrics(thermalZone) zoneMetrics = {} zone_name = !thermalZone.name.empty? ? thermalZone.name.get : '' puts("Zone:#{zone_name}") zoneMetrics[:name] = zone_name zoneMetrics[:TimeSetpointNotMet] = {} zoneMetrics[:TimeSetpointNotMet][:dur_heating] = 0 # is this occupied only, or both occupied and unoccupied? zoneMetrics[:TimeSetpointNotMet][:dur_cooling] = 0 zoneMetrics[:TimeSetpointNotMet][:dur_heating_occ] = 0 zoneMetrics[:TimeSetpointNotMet][:dur_cooling_occ] = 0 zoneMetrics[:singleZoneHeatWarningLoop] = nil zoneMetrics[:singleZoneCoolWarningLoop] = nil zoneMetrics[:singleZoneHeatControlZoneName] = '' zoneMetrics[:singleZoneCoolControlZoneName] = '' zoneMetrics[:unmet_heating_hrs] = 0 # is this the same as dur_heating? zoneMetrics[:unmet_cooling_hrs] = 0 puts('Getting mean air temps') zoneMetrics[:zone_mean_air_temp_vals] = getTimeSeries('Zone Mean Air Temperature', zone_name.upcase, @annEnvPd, 'Hourly') zoneMetrics[:zone_mean_air_temp_vals].map! { |v| OpenStudio.convert(v, 'C', 'F').get } @times = getTimesForSeries('Zone Mean Air Temperature', zone_name.upcase, @annEnvPd, 'Hourly') puts('Getting heating setpoints') zoneMetrics[:zone_heat_setpoint_vals] = getTimeSeries('Zone Thermostat Heating Setpoint Temperature', zone_name.upcase, @annEnvPd, 'Hourly') zoneMetrics[:zone_heat_setpoint_vals].map! { |v| OpenStudio.convert(v, 'C', 'F').get } puts('Getting cooling setpoints') zoneMetrics[:zone_cool_setpoint_vals] = getTimeSeries('Zone Thermostat Cooling Setpoint Temperature', zone_name.upcase, @annEnvPd, 'Hourly') zoneMetrics[:zone_cool_setpoint_vals].map! { |v| OpenStudio.convert(v, 'C', 'F').get } puts('Getting occupancy') zoneMetrics[:zone_occupant_vals] = getTimeSeries('Zone People Occupant Count', zone_name.upcase, @annEnvPd, 'Hourly') zoneMetrics[:zone_occupant_max] = !zoneMetrics[:zone_occupant_vals].nil? ? zoneMetrics[:zone_occupant_vals].max : 0 if zoneMetrics[:zone_occupant_vals].nil? zoneMetrics[:zone_occupant_vals] = Array.new(8760, 0) end return zoneMetrics end |
#name ⇒ Object
10 11 12 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 10 def name return 'Unmet Load Hours Troubleshooting' end |
#plant_loop_temp_vs_setpoints(zoneMetrics) ⇒ Object
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 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 235 def plant_loop_temp_vs_setpoints(zoneMetrics) zoneMetrics[:test_six_state] = nil if @model.getPlantLoops.count == 0 zoneMetrics[:test_six_state] = :no_plant_loops else zoneMetrics[:plant_loop_temp_vs_setpoints] = {} @model.getPlantLoops.sort.each do |plantloop| loop_name = plantloop.name.to_s loop_type = plantloop.sizingPlant.loopType zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name] = {} zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:loop_type] = loop_type supplyOutletNode = plantloop.supplyOutletNode setPointManagers = supplyOutletNode.setpointManagers managerType = setPointManagers[0].iddObjectType.valueDescription if managerType == 'OS:SetpointManager:Scheduled' schedule = setPointManagers[0].to_SetpointManagerScheduled.get.schedule rawMin, rawMax = getMinMaxForSchedule(schedule) exit_temp = plantloop.sizingPlant.getDesignLoopExitTemperature.value exit_temp = OpenStudio.convert(exit_temp, 'C', 'F').get maxSetpointValue = OpenStudio.convert(rawMax, 'C', 'F').get minSetpointValue = OpenStudio.convert(rawMin, 'C', 'F').get zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:schedule_name] = schedule.name.get.to_s zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:set_min] = minSetpointValue zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:set_max] = maxSetpointValue zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:exit_temp] = exit_temp if loop_type == 'Heating' if exit_temp < (maxSetpointValue - 5) || exit_temp > (maxSetpointValue + 5) zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:state] = :failed else zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:state] = :passed end end if loop_type == 'Cooling' if exit_temp > (minSetpointValue + 2) || exit_temp < (minSetpointValue - 2) zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:state] = :failed else zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:state] = :passed end end else zoneMetrics[:plant_loop_temp_vs_setpoints][loop_name][:state] = :no_scheduled_manager end end end end |
#run(runner, user_arguments) ⇒ Object
define what happens when the measure is run
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 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 448 def run(runner, user_arguments) super(runner, user_arguments) @runner = runner # use the built-in error checking if !@runner.validateUserArguments(arguments, user_arguments) return false end # get the last model and sql file @model = @runner.lastOpenStudioModel if @model.empty? @runner.registerError('Cannot find last model.') return false end @model = @model.get if @model.getThermalZones.empty? @runner.registerAsNotApplicable('This model has no thermal zones. This measure will not be run.') return true end @sqlFile = @runner.lastEnergyPlusSqlFile if @sqlFile.empty? @runner.registerError('Cannot find last sql file.') return false end @sqlFile = @sqlFile.get @model.setSqlFile(@sqlFile) # Get the weather file (as opposed to design day) run period @annEnvPd = nil @sqlFile.availableEnvPeriods.each do |envPd| envType = @sqlFile.environmentType(envPd) if !envType.empty? if envType.get == 'WeatherRunPeriod'.to_EnvironmentType @annEnvPd = envPd end else puts('Could not get weather file info') end end @test_nine_data = [] puts('Unmet Load Hours QAQC') # put data into variables, these are available in the local scope binding zone_collection = [] @metrics = {} # this is run once for the entire measure compare_weather_to_dsn_days @measureMetrics = { plant_loop_temp_vs_setpoints: {}, airloop_reasonable_setting: {}, air_loop_vs_schedule_temp: {} } # Test 2 see report markup # Test 3 see above @model.getThermalZones.sort.each do |thermalZone| zoneMetrics = initZoneMetrics(thermalZone) get_unmet_hours_matrix(zoneMetrics) unmet_hrs_from_slave_zones(thermalZone, zoneMetrics) thermostat_setpoints_for_underperforming(thermalZone, zoneMetrics) time_series_setpoint_vs_temp(zoneMetrics) zone_collection.push(zoneMetrics) end @measureMetrics[:zone_collection] = zone_collection plant_loop_temp_vs_setpoints(@measureMetrics) airloop_reasonable_setting(@measureMetrics) air_loop_vs_schedule_temp(@measureMetrics) # OUTPUT output = '' # Convert the graph data to JSON # This measure requires ruby 2.0.0 to create the JSON for the report graph if RUBY_VERSION >= '2.0.0' require 'json' @test_nine_data = @test_nine_data.to_json else runner.registerInfo("This Measure needs Ruby 2.0.0 to generate timeseries graphs on the report. You have Ruby #{RUBY_VERSION}. OpenStudio 1.4.2 and higher user Ruby 2.0.0.") end web_asset_path = OpenStudio.getSharedResourcesPath / OpenStudio::Path.new('web_assets') html_in = getResourceFileData('report.html.in') # configure template with variable values renderer = ERB.new(html_in) html_out = renderer.result(binding) writeResourceFileData('report.html', html_out) # closing the sql file @sqlFile.close # reporting final condition @runner.registerFinalCondition('Goodbye.') return true end |
#thermostat_setpoints_for_underperforming(thermalZone, zoneMetrics) ⇒ Object
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 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 189 def thermostat_setpoints_for_underperforming(thermalZone, zoneMetrics) zoneMetrics[:test_five_state] = nil if thermalZone.thermostatSetpointDualSetpoint.empty? setpoint = nil else setpoint = thermalZone.thermostatSetpointDualSetpoint.get unless setpoint.heatingSetpointTemperatureSchedule.is_initialized && setpoint.heatingSetpointTemperatureSchedule.is_initialized setpoint = nil end end if !setpoint.nil? # will have to correlate schedules by overlapping period zoneMetrics[:thermostat_setpoints_for_underperforming] = {} if zoneMetrics[:unmet_heating_hrs] > 50 heatingSchedule = setpoint.getHeatingSchedule.get abruptHeat = getAbruptScheduleChanges(heatingSchedule) if !abruptHeat.empty? zoneMetrics[:test_five_state] = :failed zoneMetrics[:heating_schedule_name] = heatingSchedule.name.get.to_s zoneMetrics[:thermostat_setpoints_for_underperforming][:heatChanges] = abruptHeat end end if zoneMetrics[:unmet_cooling_hrs] > 50 coolingSchedule = setpoint.getCoolingSchedule.get abruptCool = getAbruptScheduleChanges(coolingSchedule) if !abruptCool.empty? zoneMetrics[:test_five_state] = :failed zoneMetrics[:cooling_schedule_name] = coolingSchedule.name.get.to_s zoneMetrics[:thermostat_setpoints_for_underperforming][:coolChanges] = abruptCool end end else zoneMetrics[:test_five_state] = :no_setpoint end end |
#time_series_setpoint_vs_temp(zoneMetrics) ⇒ Object
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 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 405 def time_series_setpoint_vs_temp(zoneMetrics) heating_setpoint_tolerance = @metrics[:toleranceTimeHeatSetUnmet] cooling_setpoint_tolerance = @metrics[:toleranceTimeCoolSetUnmet] missed_heat = zoneMetrics[:zone_mean_air_temp_vals].map.with_index do |val, i| diff = zoneMetrics[:zone_heat_setpoint_vals][i] - val if diff > heating_setpoint_tolerance diff - heating_setpoint_tolerance else 0 end end missed_cool = zoneMetrics[:zone_mean_air_temp_vals].map.with_index do |val, i| diff = val - zoneMetrics[:zone_cool_setpoint_vals][i] if diff > cooling_setpoint_tolerance diff + cooling_setpoint_tolerance else 0 end end js_date_times = @times.map { |t| to_JSTime(t) } hourly_vals = js_date_times.zip(zoneMetrics[:zone_mean_air_temp_vals], zoneMetrics[:zone_heat_setpoint_vals], zoneMetrics[:zone_cool_setpoint_vals], missed_heat, missed_cool) # Add the hourly load data to JSON for the report.html graph = {} graph['title'] = (zoneMetrics[:name]).to_s graph['xaxislabel'] = 'Time' graph['yaxislabel'] = 'Temp F' graph['yaxis2label'] = 'Temp Difference' graph['labels'] = ['Date', 'Air Temp', 'Heat Setpoint', 'Cool Setpoint', 'Missed Heat', 'Missed Cool'] graph['colors'] = ['#888888', '#FF8833', '#3388FF', '#FF8833', '#3388FF'] graph['timeseries'] = hourly_vals # This measure requires ruby 2.0.0 to create the JSON for the report graph if RUBY_VERSION >= '2.0.0' @test_nine_data << graph end end |
#to_JSTime(os_time) ⇒ Object
Method to translate from OpenStudio’s time formatting to Javascript time formatting OpenStudio time 2009-May-14 00:10:00 Raw string Javascript time 2009/07/12 12:34:56
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 745 def to_JSTime(os_time) js_time = os_time.to_s # Replace the '-' with '/' js_time = js_time.tr('-', '/') # Replace month abbreviations with numbers js_time = js_time.gsub('Jan', '01') js_time = js_time.gsub('Feb', '02') js_time = js_time.gsub('Mar', '03') js_time = js_time.gsub('Apr', '04') js_time = js_time.gsub('May', '05') js_time = js_time.gsub('Jun', '06') js_time = js_time.gsub('Jul', '07') js_time = js_time.gsub('Aug', '08') js_time = js_time.gsub('Sep', '09') js_time = js_time.gsub('Oct', '10') js_time = js_time.gsub('Nov', '11') js_time = js_time.gsub('Dec', '12') return js_time end |
#unmet_hrs_from_slave_zones(thermalZone, zoneMetrics) ⇒ Object
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 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 134 def unmet_hrs_from_slave_zones(thermalZone, zoneMetrics) airloop = nil @model.getAirLoopHVACs.sort.each do |loop| airloop = loop break if airloop.thermalZones.include? thermalZone end zoneMetrics[:test_four_state] = nil if airloop.nil? zoneMetrics[:test_four_state] = :no_airloops else is_unitary_system = false airloop.supplyComponents.each do |component| obj_type = component.iddObjectType.valueName.to_s case obj_type when 'OS_AirLoopHVAC_UnitarySystem', 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir', 'OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeed', 'OS_AirLoopHVAC_UnitaryHeatCool_VAVChangeoverBypass' is_unitary_system = true end end if is_unitary_system zoneMetrics[:test_four_state] = :no_airloops return true end loopName = airloop.name.to_s supplyOutletNode = airloop.supplyOutletNode setPointManagers = supplyOutletNode.setpointManagers type = setPointManagers[0].iddObjectType.valueDescription if type == 'OS:SetpointManager:SingleZone:Reheat' manager = setPointManagers[0].to_SetpointManagerSingleZoneReheat.get managerControlledZoneName = !manager.controlZone.empty? ? manager.controlZone.get.name.to_s : '' if zoneMetrics[:name] != managerControlledZoneName if zoneMetrics[:unmet_heating_hrs] > 50 || zoneMetrics[:unmet_cooling_hrs] > 50 zoneMetrics[:test_four_state] = :failed zoneMetrics[:loopName] = loopName zoneMetrics[:managerControlledZoneName] = managerControlledZoneName end end else zoneMetrics[:test_four_state] = :not_single_zone_reheat end end end |
#writeResourceFileData(fileName, data) ⇒ Object
780 781 782 783 784 785 786 787 788 789 790 |
# File 'lib/measures/UnmetLoadHoursTroubleshooting/measure.rb', line 780 def writeResourceFileData(fileName, data) File.open("./#{fileName}", 'w') do |file| file << data # make sure data is written to the disk one way or the other begin file.fsync rescue StandardError file.flush end end end |