Class: BTAP::Measures::CSV_OS_Measures

Inherits:
CSV_Measures show all
Defined in:
lib/openstudio-standards/btap/measures.rb

Instance Method Summary collapse

Methods inherited from CSV_Measures

#are_all_instance_variables_nil?, #initialize, #set_instance_variables

Constructor Details

This class inherits a constructor from BTAP::Measures::CSV_Measures

Instance Method Details

#apply_ecms(model, row_data) ⇒ Object



602
603
604
605
606
607
608
609
610
611
612
# File 'lib/openstudio-standards/btap/measures.rb', line 602

def apply_ecms(model,row_data)
  log = ""
  @csv_data = row_data
  self.methods.select{ |i| i[/^ecm_.*$/] }.each do |ecm_method_name|
    log << "**********#{ecm_method_name}\n"
    raise ("model is nil") if model.nil?
    raise ("name is nil") if ecm_method_name.nil?
    log << self.method(ecm_method_name).call(model)
  end
  return model,log
end

#create_cold_lake_vintages(output_folder = nil) ⇒ Object

Helper methods



552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
# File 'lib/openstudio-standards/btap/measures.rb', line 552

def create_cold_lake_vintages(output_folder = nil)
  # check if only a single vintage was requested or a full set.
  baseline_models = Hash.new()
  prototype_models = Hash.new()

  puts "Creating Baseline models"
  CSV.foreach( @csv_file_path, :headers => true, :converters => :all ) do |row|
    @csv_data = row
    unless @csv_data["measure_id"] == "NA"
      model = self.load_base_model_building()
      self.set_weather_file(model)
      self.set_hourly_output(model)
    
      model,log = self.apply_ecms(model,@csv_data)
      BTAP::FileIO::save_osm( model, "#{output_folder}/#{BTAP::FileIO::get_name(model)}.osm") unless output_folder.nil?
      File.open("#{output_folder}/#{BTAP::FileIO::get_name(model)}.log", 'w') { |file| file.write(log) }  unless output_folder.nil?
      baseline_models[BTAP::FileIO::get_name(model)] = model
    end
  end

  #create ECM models.
  puts "Creating ECM models"
  counter = 0
  baseline_models.each do |name,model|
    #Scan folder and get the ecm csv files.
    ecm_csv_files = Dir.glob( "#{@script_root_folder_path}/**/ecm_*.csv" )
    #iterate through each csv file.
    ecm_csv_files.each do |ecm_csv_file|
      puts "evaluating #{ecm_csv_file}"

      # iterate through each row
      CSV.foreach( ecm_csv_file, :headers => true, :converters => :all ) do |row|

        #  If row baseline matches current baseline name then
        if name == "#{row["building_type"]}~#{row["vintage_name"]}~baseline"
          #Skip row if measure_id is NA
          counter = counter + 1
          if row["measure_id"].nil? or row["measure_id"].upcase.strip == "NA" or row["measure_id"].upcase.strip == ""
          else
            new_model = BTAP::FileIO::deep_copy(model)
            new_model,log = self.apply_ecms(new_model,row)
            BTAP::FileIO::save_osm( new_model, "#{output_folder}/#{BTAP::FileIO::get_name(new_model)}.osm") unless output_folder.nil?
            File.open("#{output_folder}/#{BTAP::FileIO::get_name(new_model)}.log", 'w') { |file| file.write(log) }  unless output_folder.nil?
          end
        end
      end
    end
  end
  puts "ECM generation completed."
end

#ecm_capital_costs(model) ⇒ Object

ecms



615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
# File 'lib/openstudio-standards/btap/measures.rb', line 615

def ecm_capital_costs(model)
  log = ""
  measure_values =
    [
    "measure_id",
    "cost_per_floor_m2",
    "cost_per_building"
  ]
  self.set_instance_variables( measure_values )
  
  #cost per building and building area
  building = model.building.get
  raise ("you did not enter a cost for measure #{@measure_id}. All measures must have a cost of at least 0.0 .  Please add a cost_per_building field.") if @cost_per_building.nil?
  unless @cost_per_building.nil?
    BTAP::Resources::Economics::object_cost(building,"#{@measure_id} Capital Cost per building",@cost_per_building.to_f,"CostPerEach")
    log << "added cost of #{@measure_id} per building for #{@measure_id}"
    puts log
  end
  return log
end

#ecm_cold_deck_reset_control(model) ⇒ Object



1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
# File 'lib/openstudio-standards/btap/measures.rb', line 1383

def ecm_cold_deck_reset_control( model )
  log = ""
  measure_values = [
    "cold_deck_reset_enabled",
    "cold_deck_reset_max_supply_air_temp",
    "cold_deck_reset_min_supply_air_temp",
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)

  if @cold_deck_reset_enabled.to_bool == true

    model.getAirLoopHVACs.sort.each do |iairloop|
      cooling_present = false
      set_point_manager = nil
      iairloop.components.each do |icomponent|
        if icomponent.to_CoilCoolingDXSingleSpeed.is_initialized or
            icomponent.to_CoilCoolingDXTwoSpeed.is_initialized   or
            icomponent.to_CoilCoolingWater.is_initialized or
            icomponent.to_CoilCoolingCooledBeam.is_initialized  or
            icomponent.to_CoilCoolingDXMultiSpeed.is_initialized  or
            icomponent.to_CoilCoolingDXVariableRefrigerantFlow.is_initialized  or
            icomponent.to_CoilCoolingLowTempRadiantConstFlow.is_initialized  or
            icomponent.to_CoilCoolingLowTempRadiantVarFlow.is_initialized
          cooling_present = true
          log << "found cooling."
        end
      end
      #check if setpoint manager is present at supply outlet.
      model.getSetpointManagerSingleZoneReheats.sort.each do |manager|
        if iairloop.supplyOutletNode == manager.setpointNode.get
          set_point_manager = manager
        end
      end

      if set_point_manager.nil? and cooling_present == true
        set_point_manager = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)
        set_point_manager.addToNode(iairloop.supplyOutletNode)
      end



      if cooling_present == true and not set_point_manager.nil?
        set_point_manager.setMaximumSupplyAirTemperature(@cold_deck_reset_max_supply_air_temp)
        set_point_manager.setMinimumSupplyAirTemperature(@cold_deck_reset_min_supply_air_temp)
        log << "to_SetpointManagerSingleZoneReheat set to 20.0 and 13.0"
      end
    end
  end
  return log
end

#ecm_cooling_cop(model) ⇒ Object



963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
# File 'lib/openstudio-standards/btap/measures.rb', line 963

def ecm_cooling_cop( model )
  log = ""
  measure_values =[
    "cop"
  ]

  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)

  unless model.getCoilCoolingDXSingleSpeeds.empty?
    log = "coil_cooling_dx_single_speed_name,cop\n"
    model.getCoilCoolingDXSingleSpeeds.sort.each do |cooling_coil|
      cooling_coil.setRatedCOP( OpenStudio::OptionalDouble.new( @cop ) ) unless @cop.nil?
      cop = "NA"
      cop = cooling_coil.ratedCOP.get unless cooling_coil.ratedCOP.empty?
      log  << cooling_coil.name.get.to_s << ",#{cop}\n"

    end
  end

  unless model.getCoilCoolingDXTwoSpeeds.empty?
    log << "coil_cooling_dx_two_speed_name,cop\n"
    model.getCoilCoolingDXTwoSpeeds.sort.each do |cooling_coil|
      cooling_coil.setRatedHighSpeedCOP( @cop  ) unless @cop.nil?
      cooling_coil.setRatedLowSpeedCOP(  @cop  ) unless @cop.nil?
      cop_high = "NA"
      cop_high = cooling_coil.ratedHighSpeedCOP.get unless cooling_coil.ratedHighSpeedCOP.empty?
      cop_low = "NA"
      cop_low = cooling_coil.ratedLowSpeedCOP.get unless cooling_coil.ratedLowSpeedCOP.empty?
      log  << cooling_coil.name.get.to_s << ",#{cop_high},#{cop_low}\n"
    end
  end
  return log
end

#ecm_dcv(model) ⇒ Object



1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
# File 'lib/openstudio-standards/btap/measures.rb', line 1189

def ecm_dcv( model )
  log = ""
  measure_values =[
    "dcv_enabled"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  unless @dcv_enabled.nil?
    log = BTAP::Resources::HVAC::enable_demand_control_ventilation(model,@dcv_enabled.to_bool)
  end
  return log
end

#ecm_dhw(model) ⇒ Object



1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
# File 'lib/openstudio-standards/btap/measures.rb', line 1053

def ecm_dhw( model )
  log = "shw_setpoint_sched,shw_heater_fuel_type,shw_thermal_eff\n"
  measure_values =[
    "shw_setpoint_sched_name",
    "shw_heater_fuel_type",
    "shw_thermal_eff"
  ]
  log = "*SHW Measures*\n"
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)

  #Create Schedule
  #schedule = BTAP::Resources::Schedules::create_annual_ruleset_schedule_detailed_json(model, @shw_setpoint_sched) unless @shw_setpoint_sched_name.nil? or @shw_setpoint_sched.nil?

  #iterate through water heaters.
  model.getWaterHeaterMixeds.sort.each do |item|
    unless @shw_setpoint_sched_name.nil? or @shw_setpoint_sched.nil?
      item.setSetpointTemperatureSchedule(schedule)
    end
    item.setHeaterFuelType(@shw_heater_fuel_type) unless @shw_heater_fuel_type.nil?
    item.setHeaterThermalEfficiency(@shw_thermal_eff) unless @shw_thermal_eff.nil?
    log  << item.name.get.to_s << ",#{item.setpointTemperatureSchedule},#{item.heaterFuelType},#{item.heaterThermalEfficiency}\n"
  end
  return log
end

#ecm_economizers(model) ⇒ Object



997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
# File 'lib/openstudio-standards/btap/measures.rb', line 997

def ecm_economizers( model )

  measure_values =[
    "economizer_control_type",
    "economizer_control_action_type",
    "economizer_maximum_limit_dry_bulb_temperature",
    "economizer_maximum_limit_enthalpy",
    "economizer_maximum_limit_dewpoint_temperature",
    "economizer_minimum_limit_dry_bulb_temperature"        ]

  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  log = ""
  unless @economizer_control_type.nil?
    log << BTAP::Resources::HVAC::enable_economizer(
      model,
      @economizer_control_type,
      @economizer_control_action_type,
      @economizer_maximum_limit_dry_bulb_temperature,
      @economizer_maximum_limit_enthalpy,
      @economizer_maximum_limit_dewpoint_temperature,
      @economizer_minimum_limit_dry_bulb_temperature
    )

  end
  return log
end

#ecm_envelope(model) ⇒ Object



649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
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
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
# File 'lib/openstudio-standards/btap/measures.rb', line 649

def ecm_envelope( model )
  log = ""
  #List of variables required by this measure that are to be extracted from CSV row.
  measure_values =
    [
    "library_file",
    "default_construction_set_name",
    "ext_wall_rsi",
    "ext_floor_rsi",
    "ext_roof_rsi",
    "ground_wall_rsi",
    "ground_floor_rsi",
    "ground_roof_rsi",
    "fixed_window_rsi",
    "fixed_wind_solar_trans",
    "fixed_wind_vis_trans",
    "operable_window_rsi",
    "operable_wind_solar_trans",
    "operable_wind_vis_trans",
    "door_construction_rsi",
    "glass_door_rsi",
    "glass_door_solar_trans",
    "glass_door_vis_trans",
    "overhead_door_rsi",
    "skylight_rsi",
    "skylight_solar_trans",
    "skylight_vis_trans",
    "tubular_daylight_dome_rsi",
    "tubular_daylight_dome_solar_trans",
    "tubular_daylight_dome_vis_trans",
    "tubular_daylight_diffuser_rsi",
    "tubular_daylight_diffuser_solar_trans",
    "tubular_daylight_diffuser_vis_trans",
    "ext_wall_cost_m3",
    "ext_floor_cost_m3",
    "ext_roof_cost_m3",
    "ground_wall_cost_m3",
    "ground_floor_cost_m3",
    "ground_roof_cost_m3",
    "fixed_window_cost_m3",
    "operable_window_cost_m3",
    "door_construction_cost_m3",
    "glass_door_cost_m3",
    "overhead_door_cost_m3",
    "skylight_cost_m3",
    "tubular_daylight_dome_cost_m3",
    "tubular_daylight_diffuser_cost_m3",
    "total_building_construction_set_cost"
  ]

  self.set_instance_variables(measure_values)
  unless @default_construction_set_name.nil? or @library_file.nil?

    #    #Remove all existing constructions from model.
    BTAP::Resources::Envelope::remove_all_envelope_information( model )

    #    #Load Contruction osm library.
    construction_lib = BTAP::FileIO::load_osm("#{@script_root_folder_path}/#{@library_file}")

    #Get construction set.. I/O expensive so doing it here.
    vintage_construction_set = construction_lib.getDefaultConstructionSetByName(@default_construction_set_name)
    if vintage_construction_set.empty?
      raise("#{@default_construction_set} does not exist in #{@script_root_folder_path}/#{@library_file} library ")
    else
      vintage_construction_set = construction_lib.getDefaultConstructionSetByName(@default_construction_set_name).get
    end


    new_construction_set =vintage_construction_set.clone(model).to_DefaultConstructionSet.get
    #Set conductances to needed values in construction set if possible.
    BTAP::Resources::Envelope::ConstructionSets::customize_default_surface_construction_set_rsi!( model, "#{@default_construction_set}-modified",new_construction_set,
      @ext_wall_rsi, @ext_floor_rsi, @ext_roof_rsi,
      @ground_wall_rsi, @ground_floor_rsi, @ground_roof_rsi,
      @fixed_window_rsi, @fixed_wind_solar_trans, @fixed_wind_vis_trans,
      @operable_window_rsi, @operable_wind_solar_trans, @operable_wind_vis_trans,
      @door_construction_rsi,
      @glass_door_rsi,  @glass_door_solar_trans, @glass_door_vis_trans,
      @overhead_door_rsi,
      @skylight_rsi,  @skylight_solar_trans, @skylight_vis_trans,
      @tubular_daylight_dome_rsi,  @tubular_daylight_dome_solar_trans, @tubular_daylight_dome_vis_trans,
      @tubular_daylight_diffuser_rsi, @tubular_daylight_diffuser_solar_trans, @tubular_daylight_diffuser_vis_trans
    )


    #Set as default to model.
    model.building.get.setDefaultConstructionSet( new_construction_set )

    #Set cost information.
    BTAP::Resources::Envelope::ConstructionSets::customize_default_surface_construction_set_costs(new_construction_set,
      @ext_wall_cost_m2,
      @ext_floor_cost_m2,
      @ext_roof_cost_m2,
      @ground_wall_cost_m2,
      @ground_floor_cost_m2,
      @ground_roof_cost_m2,
      @fixed_window_cost_m2,
      @operable_window_cost_m2,
      @door_construction_cost_m2,
      @glass_door_cost_m2,
      @overhead_door_cost_m2,
      @skylight_cost_m2,
      @tubular_daylight_dome_cost_m2,
      @tubular_daylight_diffuser_cost_m2,
      @total_building_construction_set_cost
    )

    #Give adiabatic surfaces a construction. Does not matter what. This is a bug in Openstudio that leave these surfaces unassigned by the default construction set.
    all_adiabatic_surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition(model.getSurfaces, "Adiabatic")
    unless all_adiabatic_surfaces.empty?
      BTAP::Geometry::Surfaces::set_surfaces_construction( all_adiabatic_surfaces, model.building.get.defaultConstructionSet.get.defaultInteriorSurfaceConstructions.get.wallConstruction.get)
    end
    #Create sample csv file.
    CSV.open("#{@script_root_folder_path}/sample_envelope_ecm.csv", 'w') { |csv| csv << measure_values.unshift("measure_id") }
    return BTAP::Resources::Envelope::ConstructionSets::get_construction_set_info( new_construction_set )
  end
  return "Constructions were unchanged.\n"
end

#ecm_erv(model) ⇒ Object



1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
# File 'lib/openstudio-standards/btap/measures.rb', line 1250

def ecm_erv( model )
  log = ""
  measure_values =[
    "erv_enabled",
    "erv_autosizeNominalSupplyAirFlowRate",
    "erv_NominalSupplyAirFlowRate",
    "erv_HeatExchangerType",
    "erv_SensibleEffectivenessat100CoolingAirFlow",
    "erv_SensibleEffectivenessat75CoolingAirFlow",
    "erv_LatentEffectiveness100Cooling",
    "erv_LatentEffectiveness75Cooling",
    "erv_SensibleEffectiveness100Heating",
    "erv_SensibleEffectiveness75Heating",
    "erv_LatentEffectiveness100Heating",
    "erv_LatentEffectiveness75Heating",
    "erv_SupplyAirOutletTemperatureControl",
    "erv_setFrostControlType",
    "erv_ThresholdTemperature",
    "erv_InitialDefrostTimeFraction",
    "erv_nominal_electric_power",
    "erv_economizer_lockout"
  ]

  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)


  unless  @erv_enabled.nil? or @erv_enabled.to_bool == false
    BTAP::Resources::HVAC::enable_erv(
      model,
      @erv_autosizeNominalSupplyAirFlowRate,
      @erv_NominalSupplyAirFlowRate,
      @erv_HeatExchangerType,
      @erv_SensibleEffectivenessat100CoolingAirFlow,
      @erv_SensibleEffectivenessat75CoolingAirFlow,
      @erv_LatentEffectiveness100Cooling,
      @erv_LatentEffectiveness75Cooling,
      @erv_SensibleEffectiveness100Heating,
      @erv_SensibleEffectiveness75Heating,
      @erv_LatentEffectiveness100Heating,
      @erv_LatentEffectiveness75Heating,
      @erv_SupplyAirOutletTemperatureControl.to_bool,
      @erv_setFrostControlType,
      @erv_ThresholdTemperature,
      @erv_InitialDefrostTimeFraction,
      @erv_nominal_electric_power,
      @erv_economizer_lockout.to_bool
    ).each { |erv| log << erv.to_s }
    
    
    #Add setpoint manager to all OA object in airloops.
    model.getHeatExchangerAirToAirSensibleAndLatents.sort.each do |erv|

      #needed to get the supply outlet node from the erv to place the setpoint manager.
      node =  erv.primaryAirOutletModelObject.get.to_Node.get if erv.primaryAirOutletModelObject.is_initialized
      new_set_point_manager = OpenStudio::Model::SetpointManagerWarmest.new(model)
      raise ("Could not add setpoint manager") unless new_set_point_manager.addToNode(node)
      log << "added warmest control to node #{node}"
      new_set_point_manager.setMaximumSetpointTemperature(16.0)
      new_set_point_manager.setMinimumSetpointTemperature(5.0)
      new_set_point_manager.setStrategy("MaximumTemperature")
      new_set_point_manager.setControlVariable("Temperature")
    end
    log << "ERV have been modified.\n"
  else
    log << "ERV not changed."
  end
  return log
end

#ecm_exhaust_fans(model) ⇒ Object



1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
# File 'lib/openstudio-standards/btap/measures.rb', line 1319

def ecm_exhaust_fans( model )
  log = ""
  #Exhaust ECM
  measure_values =[
    "exhaust_fans_occ_control_enabled"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  unless @exhaust_fans_occ_control_enabled.nil? or @exhaust_fans_occ_control_enabled.to_bool == false
    fans = BTAP::Resources::Schedules::set_exhaust_fans_availability_to_building_default_occ_schedule(model)
    fans.each { |fan| log << fan.to_s}
  else
    log << "No changes to exhaust fans."
  end
  return log
end

#ecm_fans(model) ⇒ Object



787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
# File 'lib/openstudio-standards/btap/measures.rb', line 787

def ecm_fans( model )
  measure_values =
    [
    "fan_total_eff",
    "fan_motor_eff",
    "fan_volume_type"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  log = ""
  unless model.getFanVariableVolumes.empty?
    log = "fan_variable_volume_name,fan_total_eff,fan_motor_eff\n"
    model.getFanVariableVolumes.sort.each do |fan|
      fan.setFanEfficiency( @fan_total_eff  ) unless @fan_total_eff.nil?
      fan.setMotorEfficiency( @fan_motor_eff  ) unless @fan_motor_eff.nil?
      log  << fan.name.get.to_s << ",#{fan.fanEfficiency},#{fan.motorEfficiency}\n"
    end
  end

  unless model.getFanConstantVolumes.empty?
    log = "fan_constant_volume_name,fan_total_eff,fan_motor_eff\n"
    model.getFanConstantVolumes.sort.each do |fan|
      fan.setFanEfficiency(  @fan_total_eff ) unless @fan_total_eff.nil?
      fan.setMotorEfficiency( @fan_motor_eff ) unless @fan_motor_eff.nil?
      log  << fan.name.get.to_s << ",#{fan.fanEfficiency},#{fan.motorEfficiency}\n"
    end
    
  end

  case @fan_volume_type

  when "VariableVolume"
    model.getFanConstantVolumes.sort.each do |fan_const|
      #check that this is indeed connected to an airloop.
      log << "Found Const Vol Fan #{fan_const.name.get.to_s}"
      unless fan_const.loop.empty?
        fan_variable = OpenStudio::Model::FanVariableVolume.new(model,fan_const.availabilitySchedule)
        #pass information from old fan as much as possible.
        fan_variable.setFanEfficiency(fan_const.fanEfficiency)
        fan_variable.setPressureRise( fan_const.pressureRise() )
        fan_variable.autosizeMaximumFlowRate
        fan_variable.setFanPowerMinimumFlowRateInputMethod("FixedFlowRate")
        fan_variable.setFanPowerMinimumFlowFraction(0.25)
        fan_variable.setMotorInAirstreamFraction( fan_const.motorInAirstreamFraction() )
        fan_variable.setFanPowerCoefficient1(0.35071223)
        fan_variable.setFanPowerCoefficient2(0.30850535)
        fan_variable.setFanPowerCoefficient3(-0.54137364)
        fan_variable.setFanPowerCoefficient4(0.87198823)

        #get the airloop.
        air_loop = fan_const.loop.get
        #add the FanVariableVolume
        fan_variable.addToNode(air_loop.supplyOutletNode())
        #Remove FanConstantVolume
        fan_const.remove()
        log << "Replaced by Variable Vol Fan #{fan_variable.name.get.to_s}"
      end
    end
  when "ConstantVolume"
    model.getFanVariableVolumes.sort.each do |fan|
      #check that this is indeed connected to an airloop.
      log << "Found Const Vol Fan #{fan.name.get.to_s}"
      unless fan.loop.empty?
        new_fan = OpenStudio::Model::FanConstantVolume.new(model,fan.availabilitySchedule)
        #pass information from constant speed fan as much as possible.
        new_fan.setFanEfficiency(fan.fanEfficiency)
        new_fan.setPressureRise( fan.pressureRise() )
        new_fan.setMotorEfficiency(fan.motorEfficiency)
        new_fan.setMotorInAirstreamFraction( fan.motorInAirstreamFraction() )
        new_fan.autosizeMaximumFlowRate
        #get the airloop.
        air_loop = fan.loop.get
        #add the FanVariableVolume
        new_fan.addToNode(air_loop.supplyOutletNode())
        #Remove FanConstantVolume
        fan.remove()
        log << "Replaced by Constant Vol Fan #{new_fan.name.get.to_s}"
      end
    end
  when nil
    log << "No changes to Fan."
  else
    raise("fan_volume_type should be ConstantVolume or VariableVolume")
  end
  return log
end

#ecm_heating_cooling_setpoints(model) ⇒ Object



1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'lib/openstudio-standards/btap/measures.rb', line 1201

def ecm_heating_cooling_setpoints(model)

  log = ""
  measure_values =[
    "library_file",
    "heating_schedule_name",
    "cooling_schedule_name"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)

  library_file = @library_file
  heating_schedule_name = @heating_schedule_name
  cooling_schedule_name = @cooling_schedule_name

  unless @heating_schedule_name.nil? and @cooling_schedule_name.nil?
    #Load Contruction osm library.
    lib = BTAP::FileIO::load_osm("#{@script_root_folder_path}/#{library_file}")

    unless heating_schedule_name.nil?
      #Get heating schedule from library and clone it.
      heating_schedule = lib.getScheduleRulesetByName(heating_schedule_name)
      if heating_schedule.empty?
        raise("#{heating_schedule_name} does not exist in #{library_file} library ")
      else
        heating_schedule =  lib.getScheduleRulesetByName(heating_schedule_name).get.clone(model).to_ScheduleRuleset.get
      end
    end

    unless cooling_schedule_name.nil?
      #Get cooling schedule from library and clone it.
      cooling_schedule = lib.getScheduleRulesetByName(cooling_schedule_name)
      if cooling_schedule.empty?
        raise("#{cooling_schedule_name} does not exist in #{library_file} library ")
      else
        cooling_schedule =  lib.getScheduleRulesetByName(cooling_schedule_name).get.clone(model).to_ScheduleRuleset.get
      end
    end
    model.getThermostatSetpointDualSetpoints.sort.each do |dual_setpoint|
      unless heating_schedule_name.nil?
        raise ("Could not set heating Schedule") unless dual_setpoint.setHeatingSetpointTemperatureSchedule(heating_schedule)
      end
      unless cooling_schedule_name.nil?
        raise ("Could not set cooling Schedule") unless dual_setpoint.setCoolingSetpointTemperatureSchedule(cooling_schedule)
      end
    end
  end
  return log
end

#ecm_hotwater_boilers(model) ⇒ Object



1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
# File 'lib/openstudio-standards/btap/measures.rb', line 1078

def ecm_hotwater_boilers( model )
  measure_values = [
    "hw_boiler_design_water_outlet_temperature",
    "hw_boiler_fuel_type",
    "hw_boiler_thermal_eff",
    "hw_boiler_curve",
    "hw_boiler_flow_mode",#
    "hw_boiler_eff_curve_temp_eval_var",#
    "hw_boiler_reset_highsupplytemp" ,
    "hw_boiler_reset_outsidehighsupplytemp" ,
    "hw_boiler_reset_lowsupplytemp" ,
    "hw_boiler_reset_outsidelowsupplytemp" ,
  ]

  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  table = "name,boiler_design_water_outlet_temperature,boiler_fuel_type,boiler_thermal_eff\n"

  model.getPlantLoops.sort.each do |iplantloop|
    iplantloop.components.each do |icomponent|
      if icomponent.to_BoilerHotWater.is_initialized
        boiler = icomponent.to_BoilerHotWater.get

        #set design outlet temp
        if model.version < OpenStudio::VersionString.new('3.0.0')
          boiler.setDesignWaterOutletTemperature(@hw_boiler_design_water_outlet_temperature) unless @hw_boiler_design_water_outlet_temperature.nil?
        end
        #set fuel type
        boiler.setFuelType(@hw_boiler_fuel_type) unless @hw_boiler_fuel_type.nil?
        #set thermal eff
        boiler.setNominalThermalEfficiency(@hw_boiler_thermal_eff) unless @hw_boiler_thermal_eff.nil?
        #set boiler flow mode
        unless @hw_boiler_flow_mode.nil?
          ["ConstantFlow","LeavingSetpointModulated","NotModulated"].include?(@hw_boiler_flow_mode) ? boiler.setBoilerFlowMode(@hw_boiler_flow_mode) : raise("Boiler flow mode #{@hw_boiler_flow_mode} invalid.")
        end
        #set setDesignWaterOutletTemperature
        if model.version < OpenStudio::VersionString.new('3.0.0')
          boiler.setDesignWaterOutletTemperature(@hotwaterboiler_reset_highsupplytemp) unless @hotwaterboiler_reset_highsupplytemp.nil?
        end
        #set EfficiencyCurveTemperatureEvaluationVariable
        unless @hw_boiler_eff_curve_temp_eval_var.nil?
          ["LeavingBoiler","EnteringBoiler"].include?(@hw_boiler_eff_curve_temp_eval_var) ? boiler.setEfficiencyCurveTemperatureEvaluationVariable(@hw_boiler_eff_curve_temp_eval_var) : raise("EfficiencyCurveTemperatureEvaluationVariable  #{@hw_boiler_eff_curve_temp_eval_var} invalid.")
        end


        #Set boiler curve
        curve = boiler.normalizedBoilerEfficiencyCurve
        if not @hw_boiler_curve.nil? and curve.is_initialized and curve.get.to_CurveBiquadratic.is_initialized
          case @hw_boiler_curve.downcase
          when  "atmospheric"
            biqcurve = curve.get.to_CurveBiquadratic.get
            biqcurve.setCoefficient1Constant(1.057059)
            biqcurve.setCoefficient1Constant(1.057059)
            biqcurve.setCoefficient2x(-0.0774177)
            biqcurve.setCoefficient3xPOW2(0.07875142)
            biqcurve.setCoefficient4y(0.0003943856)
            biqcurve.setCoefficient5yPOW2(-0.000004074629)
            biqcurve.setCoefficient6xTIMESY(-0.002202606)
            biqcurve.setMinimumValueofx(0.3)
            biqcurve.setMaximumValueofx(1.0)
            biqcurve.setMinimumValueofy(40.0)
            biqcurve.setMaximumValueofy(90.0)
            biqcurve.setMinimumCurveOutput(0.0)
            biqcurve.setMaximumCurveOutput(1.1)
            biqcurve.setInputUnitTypeforX("Dimensionless")
            biqcurve.setInputUnitTypeforY("Temperature")
            biqcurve.setOutputUnitType("Dimensionless")
          when  "condensing"
            biqcurve = curve.get.to_CurveBiquadratic.get
            biqcurve.setCoefficient1Constant(0.4873)
            biqcurve.setCoefficient2x(1.1322)
            biqcurve.setCoefficient3xPOW2(-0.6425)
            biqcurve.setCoefficient4y(0.0)
            biqcurve.setCoefficient5yPOW2(0.0)
            biqcurve.setCoefficient6xTIMESY(0.0)
            biqcurve.setMinimumValueofx(0.1)
            biqcurve.setMaximumValueofx(1.0)
            biqcurve.setMinimumValueofy(0.0)
            biqcurve.setMaximumValueofy(0.0)
            biqcurve.setMinimumCurveOutput(0.0)
            biqcurve.setMaximumCurveOutput(1.0)
            biqcurve.setInputUnitTypeforX("Dimensionless")
            biqcurve.setInputUnitTypeforY("Temperature")
            biqcurve.setOutputUnitType("Dimensionless")
          else
            raise("#{@hotwaterboiler_curve} is not a valid boiler curve name (condensing_boiler_curve,atmospheric_boiler_curve")
          end
        end

        #boiler reset setpoint manager
        unless @hotwaterboiler_reset_lowsupplytemp.nil? and @hotwaterboiler_reset_outsidelowsupplytemp.nil? and @hotwaterboiler_reset_highsupplytemp.nil? and @hotwaterboiler_reset_outsidehighsupplytemp.nil?
          #check if setpoint manager is present at supply outlet
          #Find any setpoint manager if it exists and outlet node and remove it.
          iplantloop.supplyOutletNode.setpointManagers.each {|sm| sm.disconnect}

          #Add new setpoint manager
          oar_stpt_manager = OpenStudio::Model::SetpointManagerOutdoorAirReset.new(model)
          oar_stpt_manager.addToNode(iplantloop.supplyOutletNode)
          oar_stpt_manager.setSetpointatOutdoorHighTemperature(@hw_boiler_reset_lowsupplytemp) unless @hw_boiler_reset_lowsupplytemp.nil?
          oar_stpt_manager.setOutdoorHighTemperature(@hotwaterboiler_reset_outsidelowsupplytemp) unless @hw_boiler_reset_outsidelowsupplytemp.nil?
          oar_stpt_manager.setSetpointatOutdoorLowTemperature(@hw_boiler_reset_highsupplytemp) unless @hw_boiler_reset_highsupplytemp.nil?
          oar_stpt_manager.setOutdoorLowTemperature(@hw_boiler_reset_outsidehighsupplytemp) unless @hw_boiler_reset_outsidehighsupplytemp.nil?
        end
        table  << boiler.name.get.to_s << ","
        boiler.designWaterOutletTemperature.empty? ? dowt = "NA" : dowt = boiler.designWaterOutletTemperature.get
        table << "#{dowt},#{boiler.fuelType},#{boiler.nominalThermalEfficiency}\n"
      end
    end
  end #end boilers loop
  return table
end

#ecm_id(model) ⇒ Object



635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/openstudio-standards/btap/measures.rb', line 635

def ecm_id(model)
  log = ""
  measure_values =
    [
    "building_type",
    "vintage_name",
    "measure_id"
  ]
  self.set_instance_variables( measure_values )
  BTAP::FileIO::set_name(model,"#{@building_type}~#{@vintage_name}~#{@measure_id}")
  puts BTAP::FileIO::get_name(model)
  return "Changed name to #{BTAP::FileIO::get_name(model)}"

end

#ecm_infiltration(model) ⇒ Object



766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
# File 'lib/openstudio-standards/btap/measures.rb', line 766

def ecm_infiltration( model )
  measure_values =
    [
    "infiltration_design_flow_rate",
    "infiltration_flow_per_space",
    "infiltration_flow_per_exterior_area",
    "infiltration_air_changes_per_hour"
  ]
    
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)

  log = BTAP::Resources::SpaceLoads::ScaleLoads::set_inflitration_magnitude(
    model,
    @infiltration_design_flow_rate,
    @infiltration_flow_per_space,
    @infiltration_flow_per_exterior_area,
    @infiltration_air_changes_per_hour
  )
  return log
end

#ecm_lighting(model) ⇒ Object



1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
# File 'lib/openstudio-standards/btap/measures.rb', line 1335

def ecm_lighting( model )
  log = ""
  #Lighting ECM
  measure_values =[
    "lighting_scaling_factor",
    "lighting_fraction_radiant",
    "lighting_fraction_visible",
    "lighting_return_air_fraction"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  BTAP::Resources::SpaceLoads::ScaleLoads::scale_lighting_loads(
    model,
    @lighting_scaling_factor ) unless @lighting_scaling_factor.nil?
  #Set lighting variables
  model.getLightsDefinitions.sort.each do |lightsdef|
    lightsdef.setFractionRadiant(@lighting_fraction_radiant.to_f)
    lightsdef.setFractionVisible(@lighting_fraction_visible.to_f)
    lightsdef.setReturnAirFraction(@lighting_return_air_fraction.to_f)
  end
  return log
end

#ecm_plugs(model) ⇒ Object



1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
# File 'lib/openstudio-standards/btap/measures.rb', line 1357

def ecm_plugs( model )
  log = ""
  #Plug loads ECM
  measure_values = [
    "elec_equipment_scaling_factor",
    "elec_equipment_fraction_radiant",
    "elec_equipment_fraction_latent",
    "elec_equipment_fraction_lost"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)

  BTAP::Resources::SpaceLoads::ScaleLoads::scale_electrical_loads(
    model,
    @elec_equipment_scaling_factor) unless @elec_equipment_scaling_factor.nil?

  #Set plug loads variables
  model.getElectricEquipmentDefinitions.sort.each do |elec_equip_def|
    elec_equip_def.setFractionRadiant(@elec_equipment_fraction_radiant.to_f)
    elec_equip_def.setFractionLatent(@elec_equipment_fraction_latent.to_f)
    elec_equip_def.setFractionLost(@elec_equipment_fraction_lost.to_f)
  end

  CSV.open("#{@script_root_folder_path}/sample_scale_plug_loads_ecm.csv", 'w') { |csv| csv << measure_values.unshift("measure_id") }
  return log
end

#ecm_pumps(model) ⇒ Object



873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
# File 'lib/openstudio-standards/btap/measures.rb', line 873

def ecm_pumps( model )
  measure_values =
    [
    "pump_motor_eff",
    "pump_control_type",
    "pump_speed_type"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  log = ""
  unless model.getPumpVariableSpeeds.empty?
    log = "pump_variable_speed_name,@pump_motor_eff\n"
    model.getPumpVariableSpeeds.sort.each do |pump|
      pump.setMotorEfficiency( @pump_motor_eff.to_f ) unless @pump_motor_eff.nil?
      pump.setPumpControlType( @pump_control_type ) unless @pump_control_type.nil?
      log  << pump.name.get.to_s << ",#{pump.motorEfficiency}\n"
    end
  end
  unless model.getPumpConstantSpeeds.empty?
    log << "pump_variable_speed_name,@pump_motor_eff\n"
    model.getPumpConstantSpeeds.sort.each do |pump|
      pump.setMotorEfficiency( @pump_motor_eff.to_f  ) unless @pump_motor_eff.nil?
      pump.setPumpControlType( @pump_control_type ) unless @pump_control_type.nil?
      log  << pump.name.get.to_s << ",#{pump.motorEfficiency}\n"
    end
  end

  #set pump speed type based on existing pump.
  case @pump_speed_type
  when "VariableSpeed"
    model.getPumpConstantSpeeds.sort.each do |pump_const|
      log << "Found Const Vol Fan #{pump_const.name.get.to_s}"
      #check that this is indeed connected to an plant loop.
      unless pump_const.plantLoop.empty?
        pump_variable = OpenStudio::Model::PumpVariableSpeed.new(model)
        #pass information from constant speed fan as much as possible.
        pump_variable.setRatedFlowRate(pump_const.ratedFlowRate)
        pump_variable.setRatedPumpHead(pump_const.ratedPumpHead)
        pump_variable.setRatedPowerConsumption(pump_const.ratedPowerConsumption.to_f)
        pump_variable.setMotorEfficiency(pump_const.motorEfficiency.to_f)
        pump_variable.setPumpControlType(pump_const.pumpControlType)
        pump_variable.setFractionofMotorInefficienciestoFluidStream(pump_const.fractionofMotorInefficienciestoFluidStream.to_f)
        pump_variable.autosizeRatedFlowRate if pump_const.isRatedFlowRateAutosized
        pump_variable.autosizeRatedPowerConsumption if pump_const.isRatedPowerConsumptionAutosized

        #get the hot water loop.
        hw_loop = pump_const.plantLoop.get
        #Remove PumpConstantSpeed
        pump_const.remove()
        #add
        pump_variable.addToNode(hw_loop.supplyInletNode)
        log << "Replaced by Variable Vol Pump #{pump_variable.name.get.to_s}"
      end
    end #end loop PumpConstantSpeeds
  when "ConstantSpeed"
    model.getPumpVariableSpeeds.sort.each do |pump|
      log << "Found Variable Speed Pump #{pump.name.get.to_s}"
      #check that this is indeed connected to an plant loop.
      unless pump.plantLoop.empty?
        new_pump = OpenStudio::Model::PumpVariableSpeed.new(model)
        #pass information from constant speed fan as much as possible.

        new_pump.setRatedFlowRate(pump.ratedFlowRate.get)
        new_pump.setRatedPumpHead(pump.ratedPumpHead())
        new_pump.setRatedPowerConsumption(pump.ratedPowerConsumption.to_f)
        new_pump.setMotorEfficiency(pump.motorEfficiency().to_f)
        new_pump.setFractionofMotorInefficienciestoFluidStream(pump.fractionofMotorInefficienciestoFluidStream().to_f)
        new_pump.setPumpControlType( pump.pumpControlType )
        new_pump.autosizeRatedFlowRate if pump.isRatedFlowRateAutosized
        new_pump.autosizeRatedPowerConsumption if pump.isRatedPowerConsumptionAutosized
        #get the hot water loop.
        hw_loop = pump.plantLoop.get
        #Remove PumpVariableSpeed
        pump.remove()
        #add the pump to loop.
        new_pump.addToNode(hw_loop.supplyInletNode)

        log << "Replaced by constant speed Pump #{new_pump.name.get.to_s}"
      end
    end #end loop Pump variable Speeds
  when nil
    log << "No changes"
  else
    raise( "pump_speed_type field is not ConstantSpeed or VariableSpeed" )
  end

  #Create sample csv file.
  CSV.open("#{@script_root_folder_path}/sample_pump_eff_ecm.csv", 'w') { |csv| csv << measure_values.unshift("measure_id") }
  return log
end

#ecm_sat_reset(model) ⇒ Object



1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
# File 'lib/openstudio-standards/btap/measures.rb', line 1434

def ecm_sat_reset( model )
  log = ""
  measure_values = [
    "sat_reset_enabled",
    "sat_reset_outdoor_high_temperature",
    "sat_reset_outdoor_low_temperature",
    "sat_reset_setpoint_at_outdoor_high_temperature",
    "sat_reset_setpoint_at_outdoor_low_temperature"
  ]


  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  if @sat_reset_enabled.to_bool == true
    model.getAirLoopHVACs.sort.each do |iairloop|

      #check if setpoint manager is present at supply outlet
      model.getSetpointManagerSingleZoneReheats.sort.each do |manager|
        if iairloop.supplyOutletNode == manager.setpointNode.get
          manager.disconnect
        end
      end

      new_set_point_manager = OpenStudio::Model::SetpointManagerOutdoorAirReset.new(model)
      new_set_point_manager.addToNode(iairloop.supplyOutletNode)
      new_set_point_manager.setOutdoorHighTemperature(@sat_reset_outdoor_high_temperature)
      new_set_point_manager.setOutdoorLowTemperature(@sat_reset_outdoor_low_temperature)
      new_set_point_manager.setSetpointatOutdoorHighTemperature(@sat_reset_setpoint_at_outdoor_high_temperature)
      new_set_point_manager.setSetpointatOutdoorLowTemperature(@sat_reset_setpoint_at_outdoor_low_temperature)
      new_set_point_manager.setControlVariable("Temperature")
      log << "Replaced SingleZoneReheat with OA reset control."
    end
  end
  return log
end

#ecm_sizing(model) ⇒ Object



1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
# File 'lib/openstudio-standards/btap/measures.rb', line 1024

def ecm_sizing( model)
  measure_values =[
    "heating_sizing_factor",
    "cooling_sizing_factor",
    "zone_heating_sizing_factor",
    "zone_cooling_sizing_factor"
  ]

  table = "*Sizing Factor Measure*"
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  table = "handle,heating_sizing_factor,cooling_sizing_factor\n"
  #Sizing Parameters

  model.getSizingParameters.setHeatingSizingFactor(@heating_sizing_factor) unless @heating_sizing_factor.nil?
  model.getSizingParameters.setCoolingSizingFactor(@cooling_sizing_factor) unless @cooling_sizing_factor.nil?


  #SizingZone
  table << "handle,zone_heating_sizing_factor,zone_cooling_sizing_factor\n"
  model.getSizingZones.sort.each do |item|
    item.setZoneHeatingSizingFactor(@zone_heating_sizing_factor) unless @zone_heating_sizing_factor.nil?
    item.setZoneCoolingSizingFactor(@zone_cooling_sizing_factor) unless @zone_cooling_sizing_factor.nil?
    table  << "#{item.handle},#{item.zoneHeatingSizingFactor.get},#{item.zoneCoolingSizingFactor.get}\n"
  end
  #Create sample csv file.
  CSV.open("#{@script_root_folder_path}/sample_sizing_param_ecm.csv", 'w') { |csv| csv << measure_values.unshift("measure_id") }
  return table
end

#ecm_temp_setback(model) ⇒ Object



1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
# File 'lib/openstudio-standards/btap/measures.rb', line 1469

def ecm_temp_setback( model )
  log = ""
  measure_values = [
    "occ_stbck_enabled",
    "occ_stbck_tolerance",
    "occ_stbck_heat_setback",
    "occ_stbck_heat_setpoint",
    "occ_stbck_cool_setback",
    "occ_stbck_cool_setpoint"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  # get occupancy schedule if possible.
  unless @occ_stbck_enabled.nil? or @occ_stbck_enabled == false
    if  model.building.get.defaultScheduleSet.is_initialized and
        model.building.get.defaultScheduleSet.get.numberofPeopleSchedule.is_initialized and
        model.building.get.defaultScheduleSet.get.numberofPeopleSchedule.get.to_ScheduleRuleset.is_initialized
      occupancy_schedule = model.building.get.defaultScheduleSet.get.numberofPeopleSchedule.get
      heating_schedule,cooling_schedule  = BTAP::Resources::Schedules::create_setback_schedule_based_on_another_schedule(
        model,
        occupancy_schedule,
        @occ_stbck_tolerance.to_f,
        @occ_stbck_heat_setpoint.to_f,
        @occ_stbck_heat_setback.to_f,
        @occ_stbck_cool_setpoint.to_f,
        @occ_stbck_cool_setback.to_f)
      model.getThermostatSetpointDualSetpoints.sort.each do |dual_setpoint|
        raise ("Could not set setback heating Schedule") unless dual_setpoint.setHeatingSetpointTemperatureSchedule(heating_schedule)
        raise ("Could not set setback cooling Schedule") unless dual_setpoint.setCoolingSetpointTemperatureSchedule(cooling_schedule)
        log << "modified....#{dual_setpoint}"
      end
    end
  else
    log << "no change to setbacks."
  end
  return log
end

#load_base_model_buildingObject



489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/openstudio-standards/btap/measures.rb', line 489

def load_base_model_building()
  log_message = ""
  measure_values =[
    "base_model_rel_path"
  ]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  osm_model_full_path = "#{@script_root_folder_path}/#{@base_model_rel_path}"
  model = BTAP::FileIO::load_osm(osm_model_full_path,"-")
  log_message << "\nModel rloaded #{osm_model_full_path}.\n"
  return model
end

#set_hourly_output(model) ⇒ Object



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
# File 'lib/openstudio-standards/btap/measures.rb', line 508

def set_hourly_output(model)
  #create array of output variables strings from E+
  output_variable_array =
    [
    "Facility Total Electric Demand Power",
    "Water Heater Gas Rate",
    "Plant Supply Side Heating Demand Rate",
    "Heating Coil Gas Rate",
    "Cooling Coil Electric Power",
    "Boiler Gas Rate",
    "Heating Coil Air Heating Rate",
    "Heating Coil Electric Power",
    "Cooling Coil Total Cooling Rate",
    "Water Heater Heating Rate",
    #          "Facility Total HVAC Electric Demand Power",
    #          "Facility Total Electric Demand Power",
    "Zone Air Temperature",
    "Water Heater Electric Power"
    #          "Baseboard Air Inlet Temperature",
    #          "Baseboard Air Outlet Temperature",
    #          "Baseboard Water Inlet Temperature",
    #          "Baseboard Water Outlet Temperature",
    #          "Boiler Inlet Temperature",
    #          "Boiler Outlet Temperature",
    #          "Plant Supply Side Inlet Temperature",
    #          "Plant Supply Side Outlet Temperature",
    #          "People Radiant Heating Rate",
    #          "People Sensible Heating Rate",
    #          "People Latent Gain Rate",
    #          "People Total Heating Rate",
    #          "Lights Total Heating Rate",
    #          "Electric Equipment Total Heating Rate",
    #          "Other Equipment Total Heating Rate",
    #          "District Heating Hot Water Rate",
    #          "District Heating Rate",
    #          "Air System Outdoor Air Flow Fraction",
    #          "Air System Outdoor Air Minimum Flow Fraction",
    #          "Air System Fan Electric Energy"
  ]
  BTAP::Reports::set_output_variables(model,"Hourly", output_variable_array)
  return "added output variables ..." << output_variable_array.to_s << "\n"
end

#set_weather_file(model) ⇒ Object



501
502
503
504
505
506
507
# File 'lib/openstudio-standards/btap/measures.rb', line 501

def set_weather_file(model)
  measure_values =["weather_file_rel_path"]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  BTAP::Site::set_weather_file(model,"#{@script_root_folder_path}/#{@weather_file_rel_path}") unless @weather_file_rel_path.nil?
  return "Set weather file to #{@weather_file_rel_path}.\n"
end

#side_load_base_model_building(model) ⇒ Object

loading methods



479
480
481
482
483
484
485
486
487
488
# File 'lib/openstudio-standards/btap/measures.rb', line 479

def side_load_base_model_building( model  )
  log_message = ""
  measure_values =["base_model_rel_path"]
  #Set all the above instance variables to the @csv_data values or, if not set or == 'na', to nil.
  self.set_instance_variables(measure_values)
  puts osm_model_full_path = "#{@script_root_folder_path}/#{@base_model_rel_path}"
  newModel = BTAP::FileIO::load_osm(osm_model_full_path,"-")
  model.swap(newModel)
  log_message << "\nModel replaced with alternative model #{osm_model_full_path}.\n"
end