Module: BTAP::Compliance::NECB2011

Defined in:
lib/openstudio-standards/btap/compliance.rb

Overview

Contains NECB relelvant methods and data.

Defined Under Namespace

Modules: Data Classes: SpacezoningData

Constant Summary collapse

SystemSpaceTypes =

this defines the system space types, from Table 8.4.4.8.A

[
  "None",
  #If greater than 4 stories

  "Assembly Area",[3,6],
  "Automotive Area",[4],
  #If colling cap > 20kW

  "Data Processing Area",[1,2],
  #if greater than 2 stories

  "General Area",[3,6],

  "Historical Collections Area",[2],
  "Hospital Area",[3],
  "Indoor Arena",[7],
  "Industrial Area",[3],
  #if heated and cooled use proposed.

  "Residential/Accomodation Area",[1],
  "Sleeping Area",[3],
  #food prep with a vented hood (add a new space type?)

  "Supermarket/Food Services Area",[3,4],
  #non_refridgerated spaces, refrigerated spaces.(New space types?)

  "Warehouse Area",[4,5]
]

Class Method Summary collapse

Class Method Details

.add_necb_building_types(model) ⇒ OpenStudio::model::Model

This method will add all the NECB building types to a model

Parameters:

  • model (OpenStudio::model::Model)

    A model object

Returns:

  • (OpenStudio::model::Model)

    A model object

Author:



954
955
956
957
# File 'lib/openstudio-standards/btap/compliance.rb', line 954

def self.add_necb_building_types( model )
  self.add_usage_types(model, BTAP::Compliance::NECB2011::Data::BuildingTypeData )
  return model
end

.add_necb_libraries_to_model(model) ⇒ Object

This method will add the schedules, building types and space types to the model.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

Author:



972
973
974
975
976
# File 'lib/openstudio-standards/btap/compliance.rb', line 972

def self.add_necb_libraries_to_model(model)
  self.add_necb_schedules(model)
  self.add_necb_building_types( model )
  self.add_necb_space_types( model )
end

.add_necb_schedules(model) ⇒ OpenStudio::model::Model

This method adds all the NECB 2011 schedules to the model. This was used to generate the NECB.osm file.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

Returns:

  • (OpenStudio::model::Model)

    A model object

Author:



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

def self.add_necb_schedules(model)

  #model.add_schedule_type_limits()

  counter = 0
  schedulesetname = ""
  schedule_set = ""
  cooling_sched = ""
  #why am I doing it in this primitive way? Ruby 1.8.6 does not support "step" method iterator.. :(

  while (NECB2011::Data::Schedules[counter] != nil)
    #Get Data from row.

    schedule_letter = BTAP::Compliance::NECB2011::Data::Schedules[counter][1]
    load_type = BTAP::Compliance::NECB2011::Data::Schedules[counter][2]
    schedule_type = BTAP::Compliance::NECB2011::Data::Schedules[counter][4]
    weekdayhourly = BTAP::Compliance::NECB2011::Data::Schedules[counter][5..28]
    sathourly = BTAP::Compliance::NECB2011::Data::Schedules[counter+1][5..28]
    sunhourly = BTAP::Compliance::NECB2011::Data::Schedules[counter+2][5..28]

    if schedulesetname != ("NECB-" + schedule_letter )
      schedulesetname =   ("NECB-" + schedule_letter )
      schedule_set = OpenStudio::Model::DefaultScheduleSet.new(model)
      schedule_set.setName(schedulesetname)
      schedule_set.setInfiltrationSchedule(Resources::Schedules::StandardSchedules::Fraction::always_on(model))
    end
    rulesetname = "NECB-" + schedule_letter + "-" + load_type

    #Add hourly schedule

    ruleset = BTAP::Resources::Schedules::create_annual_ruleset_schedule(model,rulesetname,schedule_type,[weekdayhourly,sathourly,sunhourly])


    #assign the ruleset to the correct type.

    case load_type
    when "Occ"
      schedule_set.setNumberofPeopleSchedule(ruleset)
    when "Ltg"
      schedule_set.setLightingSchedule(ruleset)
    when "Equ"
      schedule_set.setElectricEquipmentSchedule(ruleset)
    when "Fan"

      schedule_set.setHoursofOperationSchedule(ruleset)
    when "Proc"
      schedule_set.setOtherEquipmentSchedule(ruleset)
    when "Clg"
      cooling_sched = ruleset
    when "Htg"
      BTAP::Resources::Schedules::create_annual_thermostat_setpoint_dual_setpoint(model,schedulesetname,ruleset,cooling_sched)
    when "HW"

      schedule_set.setHotWaterEquipmentSchedule(ruleset)
    end
    counter = counter + 3
  end
  return model
end

.add_necb_space_types(model) ⇒ OpenStudio::model::Model

this method will add all the NECB space types to the model.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

Returns:

  • (OpenStudio::model::Model)

    A model object

Author:



963
964
965
966
# File 'lib/openstudio-standards/btap/compliance.rb', line 963

def self.add_necb_space_types( model )
  self.add_usage_types(model, BTAP::Compliance::NECB2011::Data::SpaceTypeData )
  return model
end

.add_usage_types(model, type_array) ⇒ Object

This will create space types from the type_array.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

  • type_array (array<String>)

Author:



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
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
# File 'lib/openstudio-standards/btap/compliance.rb', line 822

def self.add_usage_types(model, type_array )
  
  people = nil 
  lighting = nil 
  electric = nil 
  hotwater = nil 
  oa_load = nil 
  infiltration = nil   
  
  type_array.each do |array|
    #  ["Name","IsSpaceType?","ScheduleType",OccupantDensity,Plug Loads,DHW,LightingPowerDensity,AirChanges,Absence of,4.2.2.2.(2).a,infiltration_rate m3/s/m2]

    name, is_space_type, schedule_type,occupancy_density,plug_loads,dhw,lpd,oa_rate,absence,other,infiltration_rate  = array
    space_type_name = "NECB-" + name.strip
    if schedule_type != "*"
      default_schedule_set = OpenStudio::Model::getDefaultScheduleSetByName(model,"NECB-" + schedule_type).get

      #create loads

      people_name = "NECB-" + name + "-sched-"  + schedule_type + "-people"
      occupancy_density == 0.0 ? people = nil : people = BTAP::Resources::SpaceLoads::create_people_load(model,people_name,occupancy_density)
        
      light_name = "NECB-" + name + "-sched-"  + schedule_type + "-lights" 
      lpd == 0.0 ? lighting = nil : lighting = BTAP::Resources::SpaceLoads::create_lighting_load(model,light_name,lpd)

      elec_name = "NECB-" + name + "-sched-"  + schedule_type + "-elec"
      plug_loads == 0.0 ? electric = nil : electric = BTAP::Resources::SpaceLoads::create_electric_load(model,elec_name,plug_loads)
         
      hotwater_name = "NECB-" + name + "-sched-"  + schedule_type + "-dhw"
      dhw == 0.0 ? hotwater = nil : hotwater = BTAP::Resources::SpaceLoads::create_hotwater_load(model,hotwater_name,dhw)
       
      oa_name = "NECB-" + name + "-sched-"  + schedule_type + "-oa"
      oa_rate == 0.0 ? oa_load = nil : oa_load = BTAP::Resources::SpaceLoads::create_oa_load(model,oa_name,occupancy_density * oa_rate,0,0,0,"Maximum", BTAP::Resources::Schedules::StandardSchedules::Fraction::always_on(model) )
      
      infiltration_name = "NECB-" + name + "-sched-"  + schedule_type + "-inf"
      infiltration_rate == 0.0 ? infiltration = nil : infiltration = BTAP::Resources::SpaceLoads::create_infiltration_load(model, infiltration_name, infiltration_rate, "Flow/ExteriorArea", BTAP::Resources::Schedules::StandardSchedules::Fraction::always_on(model))
        
      BTAP::Resources::SpaceTypes::create_space_type(model,space_type_name,default_schedule_set,people,lighting,electric,hotwater,oa_load,infiltration)
    else
      ["*","A","B","C","D","E","F","G","H","I"].each do |schedule_type|

        default_schedule_set = OpenStudio::Model::getDefaultScheduleSetByName(model,"NECB-" + schedule_type).get unless schedule_type == "*"
        new_space_type_name = space_type_name
        new_space_type_name = space_type_name + "-" + schedule_type unless schedule_type == "*"
        #create loads

        people_name = "NECB-" + name + "-sched-"  + schedule_type + "-people"
        occupancy_density == 0.0 ? people = nil : people = BTAP::Resources::SpaceLoads::create_people_load(model,people_name,occupancy_density)
        
        light_name = "NECB-" + name + "-sched-"  + schedule_type + "-lights" 
        lpd == 0.0 ? lighting = nil : lighting = BTAP::Resources::SpaceLoads::create_lighting_load(model,light_name,lpd)

        elec_name = "NECB-" + name + "-sched-"  + schedule_type + "-elec"
        plug_loads == 0.0 ? electric = nil : electric = BTAP::Resources::SpaceLoads::create_electric_load(model,elec_name,plug_loads)
         
        hotwater_name = "NECB-" + name + "-sched-"  + schedule_type + "-dhw"
        dhw == 0.0 ? hotwater = nil : hotwater = BTAP::Resources::SpaceLoads::create_hotwater_load(model,hotwater_name,dhw)
       
        oa_name = "NECB-" + name + "-sched-"  + schedule_type + "-oa"
        oa_rate == 0.0 ? oa_load = nil : oa_load = BTAP::Resources::SpaceLoads::create_oa_load(model,oa_name,occupancy_density * oa_rate,0,0,0,"Maximum", BTAP::Resources::Schedules::StandardSchedules::Fraction::always_on(model) )
      
        infiltration_name = "NECB-" + name + "-sched-"  + schedule_type + "-inf"
        infiltration_rate == 0.0 ? infiltration = nil : infiltration = BTAP::Resources::SpaceLoads::create_infiltration_load(model, infiltration_name, infiltration_rate, "Flow/ExteriorArea", BTAP::Resources::Schedules::StandardSchedules::Fraction::always_on(model))
        
        BTAP::Resources::SpaceTypes::create_space_type(model,new_space_type_name,default_schedule_set,people,lighting,electric,hotwater,oa_load,infiltration)
      end
    end
  end
end

.check_all_spacetypes_are_valid_necb_names(model, runner = nil) ⇒ String

This method determines if all the spacetype names match the NECB spacetypes. This is a prerequisite for NECB zoning and system assignment

Parameters:

Returns:

Author:



1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
# File 'lib/openstudio-standards/btap/compliance.rb', line 1196

def self.check_all_spacetypes_are_valid_necb_names(model,runner = nil)
  #collect space type and building type names. 

  spacetypenames = []
  found = false
  BTAP::Compliance::NECB2011::Data::SpaceTypeData.each    {  |item| spacetypenames << item[0]}
  BTAP::Compliance::NECB2011::Data::BuildingTypeData.each {  |item| spacetypenames << item[0]}
  non_necb_spacetype_names = []
  model.getSpaceTypes.each do |model_spacetype|
    found = false
    spacetypenames.each do |valid_spacetype_name|
      # The optional suffix allows for for defined "wildcard" spacetypes to pass through. 

      if model_spacetype.name =~ /NECB-#{valid_spacetype_name}(\-[ABCDEFGHI])?/
        found = true
      end
    end
    non_necb_spacetype_names << model_spacetype.name unless found == true
  end
  if non_necb_spacetype_names.size > 0
    BTAP::runner_register("ERROR","The following spacetypes are not NECB space types.", runner)
    non_necb_spacetype_names.each {|item| BTAP::runner_register("ERROR","-#{item}", runner) }
    BTAP::runner_register("ERROR","Please edit model and assign valid space types.", runner)
    return false
  end
  BTAP::runner_register("INFO","All spacetypes conform to NECB naming.", runner)
  return true
end

.convert_all_doe_to_necb_reference_building(idf_folder, output_folder = 'C:/test/', construction_library_file = nil, construction_set_name = nil, weather_file = nil, set_necb_fdwr = true) ⇒ OpenStudio::model::Model

This model converts all DOE to NECB reference building.

Parameters:

Returns:

  • (OpenStudio::model::Model)

    model_array

Author:



1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
# File 'lib/openstudio-standards/btap/compliance.rb', line 1009

def self.convert_all_doe_to_necb_reference_building(idf_folder, output_folder = 'C:/test/', construction_library_file = nil , construction_set_name = nil , weather_file = nil , set_necb_fdwr = true)
  #iterate through all idf file in Original folder.

  filenames = Array.new()
  idf_filenames = BTAP::FileIO::get_find_files_from_folder_by_extension(idf_folder, "idf")
  puts idf_folder
  puts "filenames: #{idf_filenames}"
  BTAP::FileIO::get_find_files_from_folder_by_extension(idf_folder, ".idf").each do |idf_filename|
    puts idf_filename
    #Convert doe E+ file to NECB space types and create osm model.

    model = BTAP::Compliance::NECB2011::convert_doe_to_necb_reference_building(idf_filename, construction_library_file , construction_set_name , weather_file, set_necb_fdwr )
    #determine climate zone. 

    #set default to nil. 

    weather = nil
    #set weather file        

    unless weather_file == nil
      #Set weather file.

      weather = BTAP::Environment::WeatherFile.new(weather_file)
      weather.set_weather_file(model)
    end
    new_filename = "#{output_folder}#{File.basename(idf_filename,'.idf')}_#{weather.state_province_region}_#{weather.city}_CZ-#{ BTAP::Compliance::NECB2011::get_climate_zone_name(weather.hdd18)}.osm"
    BTAP::FileIO::save_osm(model, new_filename)
    filenames << new_filename
  end
  return filenames
end

.convert_idf_to_osm_and_map_doe_zones_to_necb_space_types(idf_filename, runner = nil) ⇒ OpenStudio::model::Model

Set all zones to NECB space types as provided by the space type map file (doors, windows, skylights) to NECB values. This model will be bare and only have ideal hvac installed. All previous space librairies will be removed and only NECB libraries will remain. Constructions will remain, even if flawed.

Parameters:

  • idf_filename (String)

    a idf file

  • runner (Object) (defaults to: nil)

Returns:

  • (OpenStudio::model::Model)

    A model object

Author:



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
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
# File 'lib/openstudio-standards/btap/compliance.rb', line 726

def self.convert_idf_to_osm_and_map_doe_zones_to_necb_space_types(idf_filename, runner = nil)
          
  
  #spacetype map file should be in IDF folder.

  space_type_csv_file = File.dirname(idf_filename) + "/SpaceTypeConversions.csv"
  BTAP::runner_register("ERROR","Spacemap file #{space_type_csv_file} could not be found", runner) unless File.exist?(space_type_csv_file)
  
  #Load IDF file

  model = BTAP::FileIO.load_idf(idf_filename)
  

  #Set building name to match archetype name.

  BTAP::FileIO::set_name(model,"#{File.basename(idf_filename,'.idf')}")
    

  
  #Set Building Stories

  BTAP::Geometry::BuildingStoreys::auto_assign_spaces_to_stories( model )

  #Add NECB Libraries

  BTAP::runner_register("INFO", "Adding NECB default spacetype libs to model... (this may take a while)....", runner)
  BTAP::Compliance::NECB2011::add_necb_schedules( model )
  BTAP::Compliance::NECB2011::add_necb_space_types( model )
  BTAP::Compliance::NECB2011::add_necb_building_types( model )
  BTAP::runner_register("INFO", "Done!.", runner)
  
  
  #iterate thourgh all spaces.

  BTAP::runner_register("INFO", "Mapping NECB space types.",runner)
  #Open CSV Map file.. this contains the map from DOE spacenames to NECB space types.

  found_idf_file_in_space_type_csv = false  
  idf_base_filename = Pathname.new(idf_filename).basename.to_s
  BTAP::runner_register("INFO", "Loaded CSV DOE Space name to NECB SpaceType map file #{space_type_csv_file}.",runner)
  CSV.foreach( space_type_csv_file, :headers => true, :converters => :all ) do |row|
    #puts "Checking #{row['idf_file']} for map."

    if row['idf_file'] == idf_base_filename
      #puts "Found #{row['idf_file']} for map."

      #flag that the idf file was found in the csv file. 

      found_idf_file_in_space_type_csv = true  
      #check if the spacetype is a valid NECB space type. 

      if is_proper_spacetype(row['necb_space_type']) != false
        #get space as named in csv file.

        space_name  = row['zone_name'].gsub(/\bThermal Zone\b/, '').strip
        #get space by space name

        if model.getSpaceTypeByName("NECB-#{row['necb_space_type']}").empty?
          BTAP::runner_register("ERROR","Missing spacetype: #{row['necb_space_type']}", runner) 
        end
        space = model.getSpaceByName(space_name).get
    
        #Get NECB spacetype

        if model.getSpaceTypeByName("NECB-#{row['necb_space_type']}").empty?
          BTAP::runner_register("ERROR","Space name #{space_name} not found in model.", runner)
          return false
        end
        necb_spacetype = model.getSpaceTypeByName("NECB-#{row['necb_space_type']}").get
        #set space type

        space.setSpaceType(necb_spacetype)
        puts "**space #{space.name} has been set to spacetype #{necb_spacetype.name}"
      else
        BTAP::runner_register("ERROR","#{row['necb_space_type']} is not a proper NECB space type",runner)
      end
    else
      if found_idf_file_in_space_type_csv == true
        break
      else
        next
      end
    end
  end
  unless found_idf_file_in_space_type_csv == true
    BTAP::runner_register("ERROR","#{Pathname.new(idf_filename).basename.to_s} not found in spacetype csv mapping in #{space_type_csv_file}.") 
  end
  return model
end

.convert_idf_to_osm_with_necb_space_types(idf_filename, model = nil, runner = nil) ⇒ OpenStudio::model::Model

This model converts all DOE to NECB reference building.

Parameters:

Returns:

  • (OpenStudio::model::Model)

    model

Author:



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

def self.convert_idf_to_osm_with_necb_space_types(idf_filename,model = nil,runner = nil)
  
  #Load up idf as OSM file and convert spacetypes based on map contained in File.dirname(idf_filename) + "/SpaceTypeConversions.csv"

  model = BTAP::Compliance::NECB2011::convert_idf_to_osm_and_map_doe_zones_to_necb_space_types(idf_filename,runner)
  
  #Taking care of wildcard spacetypes. 

  BTAP::Compliance::NECB2011::set_wildcard_schedules_to_dominant_building_schedule(model, runner)
  
  #set weather file        

  BTAP::Environment::WeatherFile.new(weather_file).set_weather_file(model,runner)
  
  #set Construction set.

  BTAP::Resources::Envelope::ConstructionSets::set_construction_set_by_file(model, construction_library_file, construction_set_name, runner)

  #set NECB u-values to construction. 

  BTAP::Compliance::NECB2011::set_all_construction_sets_to_necb!( model, runner ) 
  
  #Set FWDR

  BTAP::Compliance::NECB2011::set_necb_fwdr( model, true, runner)
  
  # Set Surface if they are out of wack.

  BTAP::Geometry::match_surfaces( model )
  
  #*** HVAC ***

  BTAP::Compliance::NECB2011::necb_autozoner(model)
  
  BTAP::Compliance::NECB2011::set_zones_thermostat_schedule_based_on_space_type_schedules(model,runner)



 

  #*** HVAC ***

  BTAP::Compliance::NECB2011::necb_autozoner(model)
  
  
  #Set output for Raymond 

  #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)
  puts  "added output variables ..." << output_variable_array.to_s << "\n"
  
  #Purge unused objects and return osm model object. 

  model.purgeUnusedResourceObjects
  return model
end

.create_necb_librariesObject

This method will write all the NECB libraries to the NECB model.



980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
# File 'lib/openstudio-standards/btap/compliance.rb', line 980

def self.create_necb_libraries()

  puts "Creating necb_libraries in #{BTAP::TESTING_FOLDER} "
  necb_schedules = OpenStudio::Model::Model.new()
  self.add_necb_schedules(necb_schedules)
  FileUtils.rm_rf(BTAP::TESTING_FOLDER + "/necb_schedules.osm")
  necb_schedules.save(OpenStudio::Path.new(BTAP::TESTING_FOLDER + "/necb_schedules.osm"))

  necb_space_types = OpenStudio::Model::Model.new()
  self.add_necb_space_types(self.add_necb_schedules(necb_space_types))
  FileUtils.rm_rf(BTAP::TESTING_FOLDER + "/necb_space_types.osm")
  necb_space_types.save(OpenStudio::Path.new(BTAP::TESTING_FOLDER + "/necb_space_types.osm"))

  necb_building_types = OpenStudio::Model::Model.new()
  self.add_necb_building_types(self.add_necb_schedules(necb_building_types))
  FileUtils.rm_rf(BTAP::TESTING_FOLDER + "/necb_building_types.osm")
  necb_building_types.save(OpenStudio::Path.new(BTAP::TESTING_FOLDER + "/necb_building_types.osm"))

  necb_full = OpenStudio::Model::Model.new()
  self.add_necb_building_types( self.add_necb_space_types( self.add_necb_schedules(necb_full) ) )
  FileUtils.rm_rf(BTAP::TESTING_FOLDER + "/necb_full.osm")
  necb_full.save(OpenStudio::Path.new(BTAP::TESTING_FOLDER + "/necb_full.osm"))
end

.determine_dominant_necb_schedule_type(model) ⇒ Object

This model determines the dominant NECB schedule type return s.each [String]

Parameters:

  • model (OpenStudio::model::Model)

    A model object



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

def self.determine_dominant_necb_schedule_type( model )
  # Here is a hash to keep track of the m2 running total of spacetypes for each

  # sched type.

  s = Hash[
    "A",0,
    "B",0,
    "C",0,
    "D",0,
    "E",0,
    "F",0,
    "G",0,
    "H",0,
    "I",0
  ]
  #iterate through spaces in building.

  model.getSpaces.each do |space|
    raise ("Space #{space.name} does not have a spacetype defined!") if space.spaceType.empty?
    spacetype_name = space.spaceType.get.name
    #iterate throught the NECB spacetypes

    found_space_type = false
    BTAP::Compliance::NECB2011::Data::SpaceTypeData.each do |spacetype|

      #puts "compare #{spacetype_name.to_s}  == #{("NECB-" + spacetype[0]).to_s}"

      if (spacetype_name.to_s  == ("NECB-" + spacetype[0]).to_s ) 
        s[ spacetype[2] ] = s[ spacetype[2] ] + space.floorArea() if "*" != spacetype[2]
        #puts "Found #{space.spaceType.get.name} schedule #{spacetype[2]} match with floor area of #{space.floorArea()}"

        found_space_type = true
      elsif spacetype_name.to_s =~ /NECB-#{spacetype[0].to_s}(\-[ABCDEFGHI])?/
        #found wildcard..will not count to total. 

        found_space_type = true
      end

    end
    raise ("Did not find #{space.spaceType.get.name} in NECB space types.") if found_space_type == false
  end
  #finds max value and returns NECB schedule letter.

  puts s
  raise("default necb schedule could not be determined for . ") if 0.0 == s.values.max
  return s.each { |k, v| return k.to_s if v == s.values.max }
end

.determine_necb_schedule_type(space) ⇒ String

This method determines the spacetype schedule type. This will re

Parameters:

Returns:

  • (String)

    :[“A”,“B”,“C”,“D”,“E”,“F”,“G”,“H”,“I”] spacetype

Author:



1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
# File 'lib/openstudio-standards/btap/compliance.rb', line 1293

def self.determine_necb_schedule_type(space)
  BTAP::Compliance::NECB2011::Data::SpaceTypeData.each do |spacetype|
    spacetype_name = space.spaceType.get.name  unless space.spaceType.empty?
    #If it is a regular space type.

    if spacetype_name.to_s  == ("NECB-" + spacetype[0]).to_s
      return spacetype[2]
    end
    #if it is a wildcard space type the schedule is in the name ensure that 

    if spacetype_name.to_s =~ /#{"NECB-" + spacetype[0]}-(\S)$/i
      return $1
    end
  end
  raise ("Could not find space type #{space.spaceType.get.name  unless space.spaceType.empty?} as a valid NECB spacetype")
end

.get_climate_zone_index(hdd) ⇒ Fixnum

This model gets the climate zone column index from tables 3.2.2.x

Parameters:

  • hdd (Float)

Returns:

  • (Fixnum)

    climate zone 4-8

Author:



628
629
630
631
632
633
634
635
636
637
638
# File 'lib/openstudio-standards/btap/compliance.rb', line 628

def self.get_climate_zone_index(hdd)
  #check for climate zone index from NECB 3.2.2.X

  case hdd
  when 0..2999        then return 0    #climate zone 4

  when 3000..3999     then return 1    #climate zone 5

  when 4000..4999     then return 2    #climate zone 6

  when 5000..5999     then return 3    #climate zone 7a

  when 6000..6999     then return 4    #climate zone 7b

  when 7000..1000000  then return 5    #climate zone 8

  end
end

.get_climate_zone_name(hdd) ⇒ Fixnum

This model gets the climate zone name and returns the climate zone string.

Parameters:

  • hdd (Float)

Returns:

  • (Fixnum)

    climate zone 4-8

Author:



644
645
646
647
648
649
650
651
652
653
# File 'lib/openstudio-standards/btap/compliance.rb', line 644

def self.get_climate_zone_name(hdd)
  case self.get_climate_zone_index(hdd)
  when 0    then return "4"
  when 1    then return "5"    #climate zone 5

  when 2    then return "6"    #climate zone 6

  when 3    then return "7a"    #climate zone 7a

  when 4    then return "7b"    #climate zone 7b

  when 5    then return "8"    #climate zone 8

  end
end

.get_spacetype_names_by_necb_schedule_type(type) ⇒ String

Get Wildcard SpaceTypes

Parameters:

Returns:

  • (String)

    wildcard_space_types

Author:



807
808
809
810
811
812
813
814
815
# File 'lib/openstudio-standards/btap/compliance.rb', line 807

def self.get_spacetype_names_by_necb_schedule_type(type)
  wildcard_space_types = Array.new()
  BTAP::Compliance::NECB2011::Data::SpaceTypeData.each do |spacetype_data|
    if spacetype_data[2] == type
      wildcard_space_types << ("NECB-" + spacetype_data[0]).to_s
    end
  end
  return wildcard_space_types
end

.is_proper_spacetype(type) ⇒ String

This method confirms if the type is the proper space type

Parameters:

Returns:

Author:



1182
1183
1184
1185
1186
1187
1188
1189
# File 'lib/openstudio-standards/btap/compliance.rb', line 1182

def self.is_proper_spacetype(type)
  BTAP::Compliance::NECB2011::Data::SpaceTypeData.each do |item|
    if item[0] == type
      return item
    end
  end
  return false
end

.lookup_spacetype_info(type) ⇒ String

This model gets the building space type info from lookup table.

Parameters:

Returns:

Author:



1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
# File 'lib/openstudio-standards/btap/compliance.rb', line 1229

def self.lookup_spacetype_info(type)
  BTAP::Compliance::NECB2011::Data::SpaceTypeData.each do |item|
    # The optional suffix allows for for defined "wildcard" spacetypes to pass through. 

    if type.strip =~ /NECB-#{item[0]}(\-[ABCDEFGHI])?/
      return item
    end
    
  end
  BTAP::Compliance::NECB2011::Data::BuildingTypeData.each do |item|
    if type.strip =~ /NECB-#{item[0]}(\-[ABCDEFGHI])?/
      return item
    end
  end
  raise ("#{type} is not a NECB space type, Cannot use NECB system definitions!!")
end

.max_fwdr(hdd) ⇒ Double

This method ???.

Parameters:

  • hdd (Float)

Returns:

  • (Double)

    a constant float

Author:



437
438
439
440
441
442
443
444
445
446
447
# File 'lib/openstudio-standards/btap/compliance.rb', line 437

def self.max_fwdr(hdd)
  #NECB 3.2.1.4


  if hdd < 4000
    return 0.40
  elsif hdd >= 4000 and hdd <=7000
    return  (2000-0.2 * hdd)/3000
  elsif hdd >7000
    return 0.20
  end
end

.necb_autozone_and_autosystem(model, runner, use_ideal_air_loads = false, boiler_fueltype = "NaturalGas", mau_type = true, mau_heating_coil_type = "Hot Water", baseboard_type = "Hot Water", chiller_type = "Scroll", mua_cooling_type = "DX", heating_coil_types_sys3 = "Gas", heating_coil_types_sys4 = "Gas", heating_coil_types_sys6 = "Hot Water", fan_type = "AF_or_BI_rdg_fancurve") ⇒ String

This method will take a model that uses NECB 2011 spacetypes , and..

  1. Create a building story schema.

  2. Remove all existing Thermal Zone defintions.

  3. Create new thermal zones based on the following definitions.

Rule1 all zones must contain only the same schedule / occupancy schedule. Rule2 zones must cater to similar solar gains (N,E,S,W) Rule3 zones must not pass from floor to floor. They must be contained to a single floor or level. Rule4 Wildcard spaces will be associated with the nearest zone of similar schedule type in which is shared most of it’s internal surface with.

Rule5 For NECB zones must contain spaces of similar system type only.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

Returns:

  • (String)

    system_zone_array

Author:



1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
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
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
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
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
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
# File 'lib/openstudio-standards/btap/compliance.rb', line 1330

def self.necb_autozone_and_autosystem(
    model,
    runner,
    use_ideal_air_loads = false,
    boiler_fueltype = "NaturalGas",
    mau_type = true,
    mau_heating_coil_type = "Hot Water",
    baseboard_type = "Hot Water",
    chiller_type = "Scroll",
    mua_cooling_type = "DX",
    heating_coil_types_sys3 = "Gas",
    heating_coil_types_sys4 = "Gas",
    heating_coil_types_sys6 = "Hot Water",
    fan_type = "AF_or_BI_rdg_fancurve" )
  
  #system assignment. 

  unless  ["NaturalGas","Electricity","PropaneGas","FuelOil#1","FuelOil#2","Coal","Diesel","Gasoline","OtherFuel1"].include?(boiler_fueltype)
    BTAP::runner_register("ERROR","boiler_fueltype = #{boiler_fueltype}",runner)
    return
  end
    
  unless [true, false].include?(mau_type) 
    BTAP::runner_register("ERROR","mau_type = #{mau_type}",runner)
    return 
  end
      
  unless ["Hot Water", "Electric"].include?(mau_heating_coil_type)
    BTAP::runner_register("ERROR","mau_heating_coil_type = #{mau_heating_coil_type}",runner)
    return false
  end
  
  unless ["Hot Water" , "Electric"].include?(baseboard_type)
    BTAP::runner_register("ERROR","baseboard_type = #{baseboard_type}",runner)
    return false
  end
  
  
  unless ["Scroll","Centrifugal","Rotary Screw","Reciprocating"].include?(chiller_type)
    BTAP::runner_register("ERROR","chiller_type = #{chiller_type}",runner)
    return false
  end
  unless ["DX","Hydronic"].include?(mua_cooling_type)
    BTAP::runner_register("ERROR","mua_cooling_type = #{mua_cooling_type}",runner)
    return false
  end
  
  unless ["Electric", "Gas", "DX"].include?(heating_coil_types_sys3)
    BTAP::runner_register("ERROR","heating_coil_types_sys3 = #{heating_coil_types_sys3}",runner)
    return false
  end
  
  unless ["Electric", "Gas", "DX"].include?(heating_coil_types_sys3)
    BTAP::runner_register("ERROR","heating_coil_types_sys4and6 = #{heating_coil_types_sys4and6}",runner)
    return false
  end
  
  unless ["AF_or_BI_rdg_fancurve","AF_or_BI_inletvanes","fc_inletvanes","var_speed_drive"].include?(fan_type)
    BTAP::runner_register("ERROR","fan_type = #{fan_type}",runner)
    return false
  end

  unless ["Electric", "Hot Water"].include?(heating_coil_types_sys6)
    BTAP::runner_register("ERROR","heating_coil_types_sys6 = #{heating_coil_types_sys6}",runner)
    return false
  end
  
  unless ["Electric", "Gas"].include?(heating_coil_types_sys4)
    BTAP::runner_register("ERROR","heating_coil_types_sys4 = #{heating_coil_types_sys4}",runner)
    return false
  end

  #some defaults until we figure out how to handle them. (TODO) 

  vented = true
  heated_only = true
  refrigerated = false
  cooling_capacity = 19.0 #only after sizing run is completed. 

  # Reassign / set floors if required. 

  BTAP::Geometry::BuildingStoreys::auto_assign_stories(model)
  
  
  #Array to store schedule objects

  schedule_type_array = []
  
  
  #This remove all ThermalZones in model just in case

  model.getThermalZones.each do |zone|
    zone.remove
  end
  
  #this method replaces all the "*" space types with concrete "A-I" schedule based shedules. 

  BTAP::Compliance::NECB2011::set_wildcard_schedules_to_dominant_building_schedule(model, runner)
  
  #find the number of stories in the model. 

  number_of_stories = model.getBuildingStorys.size
  
  #set up system array containers. These will contain the spaces associated with the system types. 

  space_zoning_data_array = []
  
  #First pass of spaces to collect information into the space_zoning_data_array . 

  model.getSpaces.each do |space|
    #initialize building story variable. 

    building_story = nil
    #check to see if the space is already set to a story. 

    if not space.buildingStory.empty?
      building_story = space.buildingStory.get
    end
      
    #this will get the spacetype system index 8.4.4.8A  from the SpaceTypeData and BuildingTypeData in  (1-12)

    space_system_index = nil
    if space.spaceType.empty?
      space_system_index = nil
    else
      space_system_index = self.lookup_spacetype_info(space.spaceType.get.name.get)[11]
    end
    
    #identify space-system_index and assign the right NECB system type 1-7. 

    system = nil
    case space_system_index
    when nil
    when 0
      #These are spaces are undefined...so they are unconditioned and have no loads other than infiltration and no systems

      system = 0
    when 1 #Assembly Area.

      if number_of_stories <= 4
        system = 3
      else
        system = 6
      end
      
    when 2 #"Automotive Area",[4]

      system = 4
      
    when 3 #"Data Processing Area",[1,2]

      if cooling_capacity > 20 #KW...need a sizing run. 

        system = 2
      else
        system = 1
      end

    when 4 #"General Area",[3,6]

      if number_of_stories <= 2 
        system = 3
      else
        system = 6
      end
      
    when 5 #"Historical Collections Area",[2],

      system = 2
      
    when 6 # "Hospital Area",[3],

      system = 6
      
    when 7 # "Indoor Arena",[7],

      system = 7
      
    when 8 # "Industrial Area [3] this need some thought. 

      system = 3
      
    when 9 # "Residential/Accomodation Area",[1], this needs some thought. 

      if heated_only
        system = 1
      else 
        system = 1
      end
      
    when 10 #"Sleeping Area",[3],

      system = 3
      
    when 11 #"Supermarket/Food Services Area",[3,4],

      if vented
        system = 3
      else
        system = 4
      end
      
    when 12 # Warehouse

      if refrigerated
        system = 3
      else
        system = 3
      end
    end 
    #get placement on floor, core or perimeter and if a top, bottom, middle or single story. 

    horizontal_placement, vertical_placement =  BTAP::Geometry::Spaces::get_space_placement( space )
    #dump all info into an array for debugging and iteration. 

    unless space.spaceType.empty? or space.spaceType.get.name.to_s.include?("undefined")
      space_zoning_data_array << SpacezoningData.new( space,system,building_story, horizontal_placement,vertical_placement,space.spaceType.get.people )
      schedule_type_array <<  BTAP::Compliance::NECB2011::determine_necb_schedule_type( space ).to_s
    end
  end
  #remove duplicates

  schedule_type_array.uniq!
  
  #now lets apply the rules. 

  # Rule1 all zones must contain only the same schedule / occupancy schedule. 

  # Rule2 zones must cater to similar solar gains (N,E,S,W) 

  # Rule3 zones must not pass from floor to floor. They must be contained to a single floor or level. 

  # Rule4 Wildcard spaces will be associated with the nearest zone of similar schedule type in which is shared most of it's internal surface with.  

  # Rule5 NECB zones must contain spaces of similar system type only. 


  #Thermal zone hash


  system_zone_array = []
  #Lets iterate by system

  (0..7).each do |system_number|
    system_zone_array[system_number] = []
    #iterate by story

    story_counter = 0
    model.getBuildingStorys.each do |story|
      #puts "Story:#{story}"

      story_counter = story_counter + 1
      #iterate by operation schedule type. 

      schedule_type_array.each do |schedule_type|
        #iterate by horizontal location

        ["north","east","west","south","core"].each do |horizontal_placement|
          #puts "horizontal_placement:#{horizontal_placement}"

          space_array = Array.new
          space_zoning_data_array.each do |space_info|
            #puts "Spacename: #{space_info.space.name}:#{space_info.space.spaceType.get.name}"

            if space_info.system_number == system_number and 
                space_info.space.spaceType.get.name.get.include?("- undefined -") == false and
                space_info.story == story and
                BTAP::Compliance::NECB2011::determine_necb_schedule_type(space_info.space).to_s == schedule_type and
                space_info.horizontal_placement == horizontal_placement

              space_array << space_info.space
            end
          end
          #create Thermal Zone if space_array is not empty.

          if space_array.size > 0
            #create new zone and add the spaces to it. 

            name = "Sys-#{system_number.to_s} Flr-#{story_counter.to_s} Sch-#{schedule_type.to_s} HPlcmt-#{horizontal_placement}"
            thermal_zone = BTAP::Geometry::Zones::create_thermal_zone(model, space_array)
            thermal_zone.setAttribute("name",name)
            BTAP::runner_register("INFO", "ThermalZone:#{name} Created with the following spaces:", runner)
            space_array.each do |space|
              BTAP::runner_register("DEBUG","space name/type:#{space.name}:#{space.spaceType.get.name}" , runner)
            end
            
            #default it to ideal air system. 

            thermal_zone.setUseIdealAirLoads(true)
            #store zone in 

            system_zone_array[system_number] << thermal_zone

          end
        end
      end
    end
  end #system iteration

  
  BTAP::Compliance::NECB2011::set_zones_thermostat_schedule_based_on_space_type_schedules(model,runner)

  unless use_ideal_air_loads == true
    

    puts boiler_fueltype

    system_zone_array.each_with_index do |zones,system_index|
      #skip if no thermal zones for this system.

      next if zones.size == 0
      puts "Zone Names for System #{system_index}"
      case system_index
      when 1
        BTAP::Resources::HVAC::HVACTemplates::NECB2011::assign_zones_sys1(model, zones, boiler_fueltype, mau_type, mau_heating_coil_type, baseboard_type)
      when 2
        BTAP::Resources::HVAC::HVACTemplates::NECB2011::assign_zones_sys2(model, zones, boiler_fueltype, chiller_type, mua_cooling_type)
      when 3
        BTAP::Resources::HVAC::HVACTemplates::NECB2011::assign_zones_sys3(model, zones, boiler_fueltype, heating_coil_types_sys3, baseboard_type)
      when 4
        BTAP::Resources::HVAC::HVACTemplates::NECB2011::assign_zones_sys4(model, zones, boiler_fueltype, heating_coil_types_sys4and6, baseboard_type)
      when 5
        BTAP::Resources::HVAC::HVACTemplates::NECB2011::assign_zones_sys5(model, zones, boiler_fueltype, chiller_type, mua_cooling_type)
      when 6
        BTAP::Resources::HVAC::HVACTemplates::NECB2011::assign_zones_sys6(model, zones, boiler_fueltype, heating_coil_types_sys6, baseboard_type, chiller_type, fan_type)
      when 7
        BTAP::Resources::HVAC::HVACTemplates::NECB2011::assign_zones_sys2(model, zones, boiler_fueltype, chiller_type, mua_cooling_type)
      end
    end
  end
end

.set_all_construction_sets_to_necb!(model, runner = nil, scale_wall = 1.0, scale_floor = 1.0, scale_roof = 1.0, scale_ground_wall = 1.0, scale_ground_floor = 1.0, scale_ground_roof = 1.0, scale_door = 1.0, scale_window = 1.0) ⇒ Object

This method will convert in place(over write) a construction set to necb conductances.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

  • scale_wall (Float) (defaults to: 1.0)
  • scale_floor (Float) (defaults to: 1.0)
  • scale_roof (Float) (defaults to: 1.0)
  • scale_ground_wall (Float) (defaults to: 1.0)
  • scale_ground_floor (Float) (defaults to: 1.0)
  • scale_ground_roof (Float) (defaults to: 1.0)
  • scale_door (Float) (defaults to: 1.0)
  • scale_window (Float) (defaults to: 1.0)

Author:



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

def self.set_all_construction_sets_to_necb!(model,
    runner = nil, 
    scale_wall = 1.0,
    scale_floor = 1.0 ,
    scale_roof = 1.0,
    scale_ground_wall = 1.0,
    scale_ground_floor = 1.0,
    scale_ground_roof = 1.0,
    scale_door = 1.0,
    scale_window = 1.0)

  model.getDefaultConstructionSets.each do |set|
    self.set_construction_set_to_necb!(model,
      set,
      runner,
      scale_wall,
      scale_floor ,
      scale_roof,
      scale_ground_wall,
      scale_ground_floor,
      scale_ground_roof,
      scale_door,
      scale_window)
  end
end

.set_construction_set_to_necb!(model, default_surface_construction_set, runner = nil, scale_wall = 1.0, scale_floor = 1.0, scale_roof = 1.0, scale_ground_wall = 1.0, scale_ground_floor = 1.0, scale_ground_roof = 1.0, scale_door = 1.0, scale_window = 1.0) ⇒ Boolean

this will create a copy and convert all construction sets to NECB reference conductances.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

  • default_surface_construction_set (String)

Returns:

  • (Boolean)

    returns true if sucessful, false if not

Author:



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

def self.set_construction_set_to_necb!(model,default_surface_construction_set,
    runner = nil,
    scale_wall = 1.0,
    scale_floor = 1.0 ,
    scale_roof = 1.0,
    scale_ground_wall = 1.0,
    scale_ground_floor = 1.0,
    scale_ground_roof = 1.0,
    scale_door = 1.0,
    scale_window = 1.0
  )
  BTAP::runner_register("Info","set_construction_set_to_necb!", runner) 
  if model.weatherFile.empty? or model.weatherFile.get.path.empty? or not File.exists?(model.weatherFile.get.path.get.to_s)
    
    BTAP::runner_register("Error","Weather file is not defined. Please ensure the weather file is defined and exists.", runner) 
    return false
  end
  hdd = BTAP::Environment::WeatherFile.new(model.weatherFile.get.path.get).hdd18
  
  old_name = ""
  unless default_surface_construction_set.getAttribute("name").empty? 
    old_name =  default_surface_construction_set.getAttribute("name").get.valueAsString
  end
  
   
  climate_zone_index = get_climate_zone_index(hdd)
  new_name = "#{old_name} at climate #{get_climate_zone_name(hdd)}"

  #convert conductance values to rsi values. (Note: we should really be only using conductances in)

  wall_rsi = 1.0 / ( scale_wall * BTAP::Compliance::NECB2011::Data::Conductances::Wall[climate_zone_index] )
  floor_rsi = 1.0 / ( scale_floor * BTAP::Compliance::NECB2011::Data::Conductances::Floor[climate_zone_index] )
  roof_rsi = 1.0 / ( scale_roof * BTAP::Compliance::NECB2011::Data::Conductances::Roof[climate_zone_index] )
  ground_wall_rsi = 1.0 / ( scale_ground_wall * BTAP::Compliance::NECB2011::Data::Conductances::GroundWall[climate_zone_index] )
  ground_floor_rsi = 1.0 / ( scale_ground_floor * BTAP::Compliance::NECB2011::Data::Conductances::GroundFloor[climate_zone_index] )
  ground_roof_rsi = 1.0 / ( scale_ground_roof * BTAP::Compliance::NECB2011::Data::Conductances::GroundRoof[climate_zone_index] )
  door_rsi = 1.0 / ( scale_door * BTAP::Compliance::NECB2011::Data::Conductances::Door[climate_zone_index] )
  window_rsi = 1.0 / ( scale_window * BTAP::Compliance::NECB2011::Data::Conductances::Window[climate_zone_index] )
  BTAP::Resources::Envelope::ConstructionSets::customize_default_surface_construction_set_rsi!(model,new_name,default_surface_construction_set,
    wall_rsi, floor_rsi, roof_rsi,
    ground_wall_rsi, ground_floor_rsi, ground_roof_rsi,
    window_rsi,  nil ,  nil,
    window_rsi, nil , nil,
    door_rsi,
    door_rsi, nil ,nil,
    door_rsi,
    window_rsi,  nil , nil,
    window_rsi,   nil , nil,
    window_rsi, nil , nil
  )
  BTAP::runner_register("Info","set_construction_set_to_necb! was sucessful.", runner)
  return true
end

.set_necb_envelope(model, hdd) ⇒ Object

This method will set the the envelope (wall, roof, glazings) to values to the default NECB 2011 values based on the heating degree day value (hdd) surface by surface.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

  • hdd (Float)

Author:



455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/openstudio-standards/btap/compliance.rb', line 455

def self.set_necb_envelope( model, hdd )

  #interate Through all surfaces

  model.getSurfaces.each do |surface|
    #set fenestration to wall ratio.

    BTAP::Compliance::NECB2011::set_fwdr(surface,hdd)

    #dig into the subsurface and change them as well.

    model.getSubSurfaces.each do |subsurface|
      BTAP::Compliance::NECB2011::set_necb_external_subsurface_conductance(subsurface,hdd)
    end
  end
end

.set_necb_external_subsurface_conductance(subsurface, hdd) ⇒ Object

Set all external subsurfaces (doors, windows, skylights) to NECB values.

Parameters:

  • subsurface (String)
  • hdd (Float)

Author:



704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/openstudio-standards/btap/compliance.rb', line 704

def self.set_necb_external_subsurface_conductance(subsurface,hdd)
  conductance_value = 0
  climate_zone_index = get_climate_zone_index(hdd)
  if subsurface.outsideBoundaryCondition.downcase.match("outdoors")
    case subsurface.subSurfaceType.downcase
    when /window/
      conductance_value =  BTAP::Compliance::NECB2011::Data::Conductances::Window[climate_zone_index]
    when /door/
      conductance_value = BTAP::Compliance::NECB2011::Data::Conductance::Door[climate_zone_index]
    end
    subsurface.setRSI(1/conductance_value)
  end
end

.set_necb_external_surface_conductance(surface, hdd, is_radiant = false, scaling_factor = 1.0) ⇒ String

Set all external surface conductances to NECB values.

Parameters:

  • surface (String)
  • hdd (Float)
  • is_radiant (Boolian) (defaults to: false)
  • scaling_factor (Float) (defaults to: 1.0)

Returns:

Author:



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

def self.set_necb_external_surface_conductance(surface,hdd,is_radiant = false,scaling_factor = 1.0)
  conductance_value = 0
  if surface.outsideBoundaryCondition.downcase == "outdoors"

    case surface.surfaceType.downcase
    when "wall"
      conductance_value =  BTAP::Compliance::NECB2011::Data::Conductances::Wall[BTAP::Compliance::NECB2011::get_climate_zone_index(@hdd)] * scaling_factor
    when "floor"
      conductance_value = BTAP::Compliance::NECB2011::Data::Conductances::Floor[BTAP::Compliance::NECB2011::get_climate_zone_index(@hdd)]  * scaling_factor
    when "roofceiling"
      conductance_value = BTAP::Compliance::NECB2011::Data::Conductances::Roof[BTAP::Compliance::NECB2011::get_climate_zone_index(@hdd)] 
    end
    if (is_radiant)
      conductance_value = conductance_value * 0.80
    end
    return surface.setRSI(1/conductance_value)
  end


  if surface.outsideBoundaryCondition.downcase.match(/ground/)
    case surface.surfaceType.downcase
    when "wall"
      conductance_value =  BTAP::Compliance::NECB2011::Data::Conductances::GroundWall[BTAP::Compliance::NECB2011::get_climate_zone_index(@hdd)]
    when "floor"
      conductance_value =  BTAP::Compliance::NECB2011::Data::Conductances::GroundFloor[BTAP::Compliance::NECB2011::get_climate_zone_index(@hdd)]
    when "roofceiling"
      conductance_value =  BTAP::Compliance::NECB2011::Data::Conductances::GroundRoof[BTAP::Compliance::NECB2011::get_climate_zone_index(@hdd)]
    end
    if (is_radiant)
      conductance_value = conductance_value * 0.80
    end
    return BTAP::Geometry::Surfaces::set_surfaces_construction_conductance( [surface], conductance_value )

  end
end

.set_necb_fwdr(model, use_max = false, runner = nil) ⇒ Object

This method will set the fwdr for a building. It will remove all glazings and hard set the FDWR.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

  • runner (Object) (defaults to: nil)
  • use_max (Boolean) (defaults to: false)

Author:



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

def self.set_necb_fwdr(model,use_max = false, runner = nil)
  BTAP::runner_register("Info","set_necb_fwdr", runner) 
  if model.weatherFile.empty? or model.weatherFile.get.path.empty? or not File.exists?(model.weatherFile.get.path.get.to_s)
    BTAP::runner_register("Error","Weather file is not defined. Please ensure the weather file is defined and exists.", runner) 
    return false
  end
  hdd = BTAP::Environment::WeatherFile.new(model.weatherFile.get.path.get).hdd18
  old_fwdr = BTAP::Geometry::get_fwdr(model)
  BTAP::runner_register("Info","old FWDR is #{old_fwdr}", runner) 
  outdoor_surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition(model.getSurfaces(), "Outdoors")
  outdoor_subsurfaces = BTAP::Geometry::Surfaces::get_subsurfaces_from_surfaces(outdoor_surfaces)
  outdoor_walls = BTAP::Geometry::Surfaces::filter_by_surface_types(outdoor_surfaces, "Wall")
  
  #Remove all windows

  BTAP::Geometry::Surfaces::filter_subsurfaces_by_types(outdoor_subsurfaces, ["FixedWindow" , "OperableWindow" ]).each {|door| door.remove}
  #Remove all doors

  BTAP::Geometry::Surfaces::filter_subsurfaces_by_types(outdoor_subsurfaces, ["Door" , "GlassDoor" ]).each {|door| door.remove}
  
  if use_max == true or old_fwdr > self.max_fwdr(hdd)
    ratio = self.max_fwdr(hdd)
  else
    ratio = old_fwdr
  end
  outdoor_walls.each {|wall| wall.setWindowToWallRatio(ratio) }
  
  BTAP::runner_register("Info","New FWDR is #{BTAP::Geometry::get_fwdr(model)} based on HDD of #{hdd}.", runner) 
  return model
end

.set_necb_srr(model, runner = nil) ⇒ Object

This method will set the fwdr for a building. It will remove all glazings and hard set the FDWR.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

  • runner (OpenStudio::Ruleset::OSRunner) (defaults to: nil)

Author:



605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# File 'lib/openstudio-standards/btap/compliance.rb', line 605

def self.set_necb_srr(model, runner = nil)
  BTAP::runner_register("Info","Setting NECB Skylight to Roof Ration to 0.05", runner) 
  ratio = 0.05
  old_srr = BTAP::Geometry::get_srr(model)
  BTAP::runner_register("InitialCondition","old Skylight to Roof Ratio is #{old_srr}", runner) 
  outdoor_surfaces = BTAP::Geometry::Surfaces::filter_by_boundary_condition(model.getSurfaces(), "Outdoors")
  outdoor_subsurfaces = BTAP::Geometry::Surfaces::get_subsurfaces_from_surfaces(outdoor_surfaces)
  outdoor_roofs = BTAP::Geometry::Surfaces::filter_by_surface_types(outdoor_surfaces, "RoofCeiling")
  skylights = BTAP::Geometry::Surfaces::filter_subsurfaces_by_types(outdoor_subsurfaces, ["Skylight", "TubularDaylightDiffuser","TubularDaylightDome" ])
  overhead_doors = BTAP::Geometry::Surfaces::filter_subsurfaces_by_types(outdoor_subsurfaces, ["OverheadDoor" ])
  skylights.each {|skylight| skylight.remove}
  overhead_doors.each {|overhead_door| overhead_door.remove}
  outdoor_roofs.each {|roof| roof.setWindowToWallRatio(ratio) }
  BTAP::runner_register("FinalCondition","old Skylight to Roof Ratio is #{BTAP::Geometry::get_srr(model)}", runner) 
end

.set_wildcard_schedules_to_dominant_building_schedule(model, runner = nil) ⇒ Object



1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
# File 'lib/openstudio-standards/btap/compliance.rb', line 1036

def self.set_wildcard_schedules_to_dominant_building_schedule(model, runner = nil)
  BTAP::runner_register("Info", "set_wildcard_schedules_to_dominant_building_schedule", runner)
  #Set wildcard schedules based on dominant schedule type in building.

  dominant_sched_type = BTAP::Compliance::NECB2011::determine_dominant_necb_schedule_type(model)
  model.getSpaces.each do |space|
    #check to see if space space type has a "*" wildcard schedule.

    spacetype_name = space.spaceType.get.name.to_s unless space.spaceType.empty?
    if determine_necb_schedule_type( space ).to_s == "*".to_s
      new_sched = (spacetype_name + "-" + dominant_sched_type).to_s
      optional_spacetype = model.getSpaceTypeByName(new_sched)
      if optional_spacetype.empty?
        BTAP::runner_register("Error", "Cannot find NECB spacetype #{new_sched}" , runner )
      else
        BTAP::runner_register("Info","Setting wildcard space #{spacetype_name} to concrete spacetype #{new_sched}",runner)
        space.setSpaceType(optional_spacetype.get)
      end
    end
  end
  return true
end

.set_zones_thermostat_schedule_based_on_space_type_schedules(model, runner = nil) ⇒ Object



1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
# File 'lib/openstudio-standards/btap/compliance.rb', line 1057

def self.set_zones_thermostat_schedule_based_on_space_type_schedules(model,runner = nil)
  BTAP::runner_register("DEBUG","Start-set_zones_thermostat_schedule_based_on_space_type_schedules" , runner)
  model.getThermalZones.each do |zone|
    BTAP::runner_register("DEBUG","\tThermalZone:#{zone.name}" , runner)
    array = []
    zone.spaces.each do |space|
      schedule_type = BTAP::Compliance::NECB2011::determine_necb_schedule_type( space ).to_s
      BTAP::runner_register("DEBUG","space name/type:#{space.name}/#{schedule_type}" , runner)
      array << schedule_type
    end
    array.uniq!
    if array.size > 1
      BTAP::runner_register("Error", "#{zone.name} has spaces with different schedule types. Please ensure that all the spaces are of the same schedule type A to I.",runner)  
      return false
    end

    if model.getThermostatSetpointDualSetpointByName("NECB-#{array[0]}").empty? == false
      ds = model.getThermostatSetpointDualSetpointByName("NECB-#{array[0]}").get
      zone.setThermostatSetpointDualSetpoint(ds)

      BTAP::runner_register("Info","Found DualSetpoint Schedule NECB-#{array[0]}",runner)
      BTAP::runner_register("Info","ThermalZone #{zone.name} set to DualSetpoint Schedule NECB-#{array[0]}",runner)
      BTAP::runner_register("DEBUG","END-set_zones_thermostat_schedule_based_on_space_type_schedules" , runner)
    else
      BTAP::runner_register("ERROR","set_zones_thermostat_schedule NECB-#{array[0]} does not exist" , runner)
      puts model.getThermostatSetpointDualSetpoints
      return false
    end
  end
  return true
end