Top Level Namespace

Defined Under Namespace

Modules: ASHRAE9012010CoolingTower, ASHRAE9012013CoolingTower, ASHRAE9012016CoolingTower, ASHRAE9012019CoolingTower, ASHRAE901PRMFan, ASHRAEPRMCoilDX, BTAP, BTAPMeasureHelper, BTAPMeasureTestHelper, CoilDX, College, CoolingTower, Courthouse, Fan, FullServiceRestaurant, HighriseApartment, Hospital, Laboratory, LargeDataCenterHighITE, LargeDataCenterLowITE, LargeHotel, LargeOffice, LargeOfficeDetailed, MediumOffice, MediumOfficeDetailed, MidriseApartment, NRELZNEReady2017CoolingTower, OpenstudioStandards, Outpatient, PrimarySchool, PrototypeFan, PrototypePump, Pump, QuickServiceRestaurant, References, RetailStandalone, RetailStripmall, SecondarySchool, SmallDataCenterHighITE, SmallDataCenterLowITE, SmallHotel, SmallOffice, SmallOfficeDetailed, SuperMarket, SuperTallBuilding, TallBuilding, Warehouse, ZEAEDGMultifamilyCoolingTower Classes: ASHRAE901, ASHRAE9012004, ASHRAE9012004College, ASHRAE9012004Courthouse, ASHRAE9012004FullServiceRestaurant, ASHRAE9012004HighriseApartment, ASHRAE9012004Hospital, ASHRAE9012004Laboratory, ASHRAE9012004LargeDataCenterHighITE, ASHRAE9012004LargeDataCenterLowITE, ASHRAE9012004LargeHotel, ASHRAE9012004LargeOffice, ASHRAE9012004LargeOfficeDetailed, ASHRAE9012004MediumOffice, ASHRAE9012004MediumOfficeDetailed, ASHRAE9012004MidriseApartment, ASHRAE9012004Outpatient, ASHRAE9012004PrimarySchool, ASHRAE9012004QuickServiceRestaurant, ASHRAE9012004RetailStandalone, ASHRAE9012004RetailStripmall, ASHRAE9012004SecondarySchool, ASHRAE9012004SmallDataCenterHighITE, ASHRAE9012004SmallDataCenterLowITE, ASHRAE9012004SmallHotel, ASHRAE9012004SmallOffice, ASHRAE9012004SmallOfficeDetailed, ASHRAE9012004SuperMarket, ASHRAE9012004SuperTallBuilding, ASHRAE9012004TallBuilding, ASHRAE9012004Warehouse, ASHRAE9012004_Prototype, ASHRAE9012007, ASHRAE9012007College, ASHRAE9012007Courthouse, ASHRAE9012007FullServiceRestaurant, ASHRAE9012007HighriseApartment, ASHRAE9012007Hospital, ASHRAE9012007Laboratory, ASHRAE9012007LargeDataCenterHighITE, ASHRAE9012007LargeDataCenterLowITE, ASHRAE9012007LargeHotel, ASHRAE9012007LargeOffice, ASHRAE9012007LargeOfficeDetailed, ASHRAE9012007MediumOffice, ASHRAE9012007MediumOfficeDetailed, ASHRAE9012007MidriseApartment, ASHRAE9012007Outpatient, ASHRAE9012007PrimarySchool, ASHRAE9012007QuickServiceRestaurant, ASHRAE9012007RetailStandalone, ASHRAE9012007RetailStripmall, ASHRAE9012007SecondarySchool, ASHRAE9012007SmallDataCenterHighITE, ASHRAE9012007SmallDataCenterLowITE, ASHRAE9012007SmallHotel, ASHRAE9012007SmallOffice, ASHRAE9012007SmallOfficeDetailed, ASHRAE9012007SuperMarket, ASHRAE9012007SuperTallBuilding, ASHRAE9012007TallBuilding, ASHRAE9012007Warehouse, ASHRAE9012007_Prototype, ASHRAE9012010, ASHRAE9012010College, ASHRAE9012010Courthouse, ASHRAE9012010FullServiceRestaurant, ASHRAE9012010HighriseApartment, ASHRAE9012010Hospital, ASHRAE9012010Laboratory, ASHRAE9012010LargeDataCenterHighITE, ASHRAE9012010LargeDataCenterLowITE, ASHRAE9012010LargeHotel, ASHRAE9012010LargeOffice, ASHRAE9012010LargeOfficeDetailed, ASHRAE9012010MediumOffice, ASHRAE9012010MediumOfficeDetailed, ASHRAE9012010MidriseApartment, ASHRAE9012010Outpatient, ASHRAE9012010PrimarySchool, ASHRAE9012010QuickServiceRestaurant, ASHRAE9012010RetailStandalone, ASHRAE9012010RetailStripmall, ASHRAE9012010SecondarySchool, ASHRAE9012010SmallDataCenterHighITE, ASHRAE9012010SmallDataCenterLowITE, ASHRAE9012010SmallHotel, ASHRAE9012010SmallOffice, ASHRAE9012010SmallOfficeDetailed, ASHRAE9012010SuperMarket, ASHRAE9012010SuperTallBuilding, ASHRAE9012010TallBuilding, ASHRAE9012010Warehouse, ASHRAE9012010_Prototype, ASHRAE9012013, ASHRAE9012013College, ASHRAE9012013Courthouse, ASHRAE9012013FullServiceRestaurant, ASHRAE9012013HighriseApartment, ASHRAE9012013Hospital, ASHRAE9012013Laboratory, ASHRAE9012013LargeDataCenterHighITE, ASHRAE9012013LargeDataCenterLowITE, ASHRAE9012013LargeHotel, ASHRAE9012013LargeOffice, ASHRAE9012013LargeOfficeDetailed, ASHRAE9012013MediumOffice, ASHRAE9012013MediumOfficeDetailed, ASHRAE9012013MidriseApartment, ASHRAE9012013Outpatient, ASHRAE9012013PrimarySchool, ASHRAE9012013QuickServiceRestaurant, ASHRAE9012013RetailStandalone, ASHRAE9012013RetailStripmall, ASHRAE9012013SecondarySchool, ASHRAE9012013SmallDataCenterHighITE, ASHRAE9012013SmallDataCenterLowITE, ASHRAE9012013SmallHotel, ASHRAE9012013SmallOffice, ASHRAE9012013SmallOfficeDetailed, ASHRAE9012013SuperMarket, ASHRAE9012013SuperTallBuilding, ASHRAE9012013TallBuilding, ASHRAE9012013Warehouse, ASHRAE9012013_Prototype, ASHRAE9012016, ASHRAE9012016College, ASHRAE9012016Courthouse, ASHRAE9012016FullServiceRestaurant, ASHRAE9012016HighriseApartment, ASHRAE9012016Hospital, ASHRAE9012016Laboratory, ASHRAE9012016LargeDataCenterHighITE, ASHRAE9012016LargeDataCenterLowITE, ASHRAE9012016LargeHotel, ASHRAE9012016LargeOffice, ASHRAE9012016LargeOfficeDetailed, ASHRAE9012016MediumOffice, ASHRAE9012016MediumOfficeDetailed, ASHRAE9012016MidriseApartment, ASHRAE9012016Outpatient, ASHRAE9012016PrimarySchool, ASHRAE9012016QuickServiceRestaurant, ASHRAE9012016RetailStandalone, ASHRAE9012016RetailStripmall, ASHRAE9012016SecondarySchool, ASHRAE9012016SmallDataCenterHighITE, ASHRAE9012016SmallDataCenterLowITE, ASHRAE9012016SmallHotel, ASHRAE9012016SmallOffice, ASHRAE9012016SmallOfficeDetailed, ASHRAE9012016SuperMarket, ASHRAE9012016SuperTallBuilding, ASHRAE9012016TallBuilding, ASHRAE9012016Warehouse, ASHRAE9012016_Prototype, ASHRAE9012019, ASHRAE9012019College, ASHRAE9012019Courthouse, ASHRAE9012019FullServiceRestaurant, ASHRAE9012019HighriseApartment, ASHRAE9012019Hospital, ASHRAE9012019Laboratory, ASHRAE9012019LargeDataCenterHighITE, ASHRAE9012019LargeDataCenterLowITE, ASHRAE9012019LargeHotel, ASHRAE9012019LargeOffice, ASHRAE9012019LargeOfficeDetailed, ASHRAE9012019MediumOffice, ASHRAE9012019MediumOfficeDetailed, ASHRAE9012019MidriseApartment, ASHRAE9012019Outpatient, ASHRAE9012019PrimarySchool, ASHRAE9012019QuickServiceRestaurant, ASHRAE9012019RetailStandalone, ASHRAE9012019RetailStripmall, ASHRAE9012019SecondarySchool, ASHRAE9012019SmallDataCenterHighITE, ASHRAE9012019SmallDataCenterLowITE, ASHRAE9012019SmallHotel, ASHRAE9012019SmallOffice, ASHRAE9012019SmallOfficeDetailed, ASHRAE9012019SuperMarket, ASHRAE9012019SuperTallBuilding, ASHRAE9012019TallBuilding, ASHRAE9012019Warehouse, ASHRAE9012019_Prototype, ASHRAE901PRM, ASHRAE901PRM2019, ASHRAE901PRM2019College, ASHRAE901PRM2019Courthouse, ASHRAE901PRM2019FullServiceRestaurant, ASHRAE901PRM2019HighriseApartment, ASHRAE901PRM2019Hospital, ASHRAE901PRM2019Laboratory, ASHRAE901PRM2019LargeDataCenterHighITE, ASHRAE901PRM2019LargeDataCenterLowITE, ASHRAE901PRM2019LargeHotel, ASHRAE901PRM2019LargeOffice, ASHRAE901PRM2019LargeOfficeDetailed, ASHRAE901PRM2019MediumOffice, ASHRAE901PRM2019MediumOfficeDetailed, ASHRAE901PRM2019MidriseApartment, ASHRAE901PRM2019Outpatient, ASHRAE901PRM2019PrimarySchool, ASHRAE901PRM2019QuickServiceRestaurant, ASHRAE901PRM2019RetailStandalone, ASHRAE901PRM2019RetailStripmall, ASHRAE901PRM2019SecondarySchool, ASHRAE901PRM2019SmallDataCenterHighITE, ASHRAE901PRM2019SmallDataCenterLowITE, ASHRAE901PRM2019SmallHotel, ASHRAE901PRM2019SmallOffice, ASHRAE901PRM2019SmallOfficeDetailed, ASHRAE901PRM2019SuperMarket, ASHRAE901PRM2019SuperTallBuilding, ASHRAE901PRM2019TallBuilding, ASHRAE901PRM2019Warehouse, ASHRAE901PRM2019_Prototype, Add_template_field_to_json, Array, BTAP1980TO2010, BTAPData, BTAPDatapoint, BTAPModelMeasure, BTAPModelMeasure_Test, BTAPPRE1980, CBES, CBESPre1978, CBEST241978, CBEST241992, CBEST242001, CBEST242005, CBEST242008, ComStockASHRAE9012004, ComStockASHRAE9012007, ComStockASHRAE9012010, ComStockASHRAE9012013, ComStockASHRAE9012016, ComStockASHRAE9012019, ComStockDEER1985, ComStockDEER1996, ComStockDEER2003, ComStockDEER2007, ComStockDEER2011, ComStockDEER2014, ComStockDEER2015, ComStockDEER2017, ComStockDEER2020, ComStockDEER2025, ComStockDEER2030, ComStockDEER2035, ComStockDEER2040, ComStockDEER2045, ComStockDEER2050, ComStockDEER2055, ComStockDEER2060, ComStockDEER2065, ComStockDEER2070, ComStockDEER2075, ComStockDEERPRE1975, ComStockDOERef1980to2004, ComStockDOERefPre1980, DEER, DEER1985, DEER1996, DEER2003, DEER2007, DEER2011, DEER2014, DEER2015, DEER2017, DEER2020, DEER2025, DEER2030, DEER2035, DEER2040, DEER2045, DEER2050, DEER2055, DEER2060, DEER2065, DEER2070, DEER2075, DEERPRE1975, DOERef1980to2004, DOERef1980to2004College, DOERef1980to2004Courthouse, DOERef1980to2004FullServiceRestaurant, DOERef1980to2004HighriseApartment, DOERef1980to2004Hospital, DOERef1980to2004Laboratory, DOERef1980to2004LargeDataCenterHighITE, DOERef1980to2004LargeDataCenterLowITE, DOERef1980to2004LargeHotel, DOERef1980to2004LargeOffice, DOERef1980to2004LargeOfficeDetailed, DOERef1980to2004MediumOffice, DOERef1980to2004MediumOfficeDetailed, DOERef1980to2004MidriseApartment, DOERef1980to2004Outpatient, DOERef1980to2004PrimarySchool, DOERef1980to2004QuickServiceRestaurant, DOERef1980to2004RetailStandalone, DOERef1980to2004RetailStripmall, DOERef1980to2004SecondarySchool, DOERef1980to2004SmallDataCenterHighITE, DOERef1980to2004SmallDataCenterLowITE, DOERef1980to2004SmallHotel, DOERef1980to2004SmallOffice, DOERef1980to2004SmallOfficeDetailed, DOERef1980to2004SuperMarket, DOERef1980to2004SuperTallBuilding, DOERef1980to2004TallBuilding, DOERef1980to2004Warehouse, DOERef1980to2004_Prototype, DOERefPre1980, DOERefPre1980College, DOERefPre1980Courthouse, DOERefPre1980FullServiceRestaurant, DOERefPre1980HighriseApartment, DOERefPre1980Hospital, DOERefPre1980Laboratory, DOERefPre1980LargeDataCenterHighITE, DOERefPre1980LargeDataCenterLowITE, DOERefPre1980LargeHotel, DOERefPre1980LargeOffice, DOERefPre1980LargeOfficeDetailed, DOERefPre1980MediumOffice, DOERefPre1980MediumOfficeDetailed, DOERefPre1980MidriseApartment, DOERefPre1980Outpatient, DOERefPre1980PrimarySchool, DOERefPre1980QuickServiceRestaurant, DOERefPre1980RetailStandalone, DOERefPre1980RetailStripmall, DOERefPre1980SecondarySchool, DOERefPre1980SmallDataCenterHighITE, DOERefPre1980SmallDataCenterLowITE, DOERefPre1980SmallHotel, DOERefPre1980SmallOffice, DOERefPre1980SmallOfficeDetailed, DOERefPre1980SuperMarket, DOERefPre1980SuperTallBuilding, DOERefPre1980TallBuilding, DOERefPre1980Warehouse, DOERefPre1980_Prototype, ECMS, FalseClass, ForStruct, Hash, ICCIECC, ICCIECC2015, Integer, NECB2011, NECB2011College, NECB2011Courthouse, NECB2011FullServiceRestaurant, NECB2011HighriseApartment, NECB2011Hospital, NECB2011Laboratory, NECB2011LargeDataCenterHighITE, NECB2011LargeDataCenterLowITE, NECB2011LargeHotel, NECB2011LargeOffice, NECB2011LargeOfficeDetailed, NECB2011MediumOffice, NECB2011MediumOfficeDetailed, NECB2011MidriseApartment, NECB2011Outpatient, NECB2011PrimarySchool, NECB2011QuickServiceRestaurant, NECB2011RetailStandalone, NECB2011RetailStripmall, NECB2011SecondarySchool, NECB2011SmallDataCenterHighITE, NECB2011SmallDataCenterLowITE, NECB2011SmallHotel, NECB2011SmallOffice, NECB2011SmallOfficeDetailed, NECB2011SuperMarket, NECB2011SuperTallBuilding, NECB2011TallBuilding, NECB2011Warehouse, NECB2011_Prototype, NECB2015, NECB2015College, NECB2015Courthouse, NECB2015FullServiceRestaurant, NECB2015HighriseApartment, NECB2015Hospital, NECB2015Laboratory, NECB2015LargeDataCenterHighITE, NECB2015LargeDataCenterLowITE, NECB2015LargeHotel, NECB2015LargeOffice, NECB2015LargeOfficeDetailed, NECB2015MediumOffice, NECB2015MediumOfficeDetailed, NECB2015MidriseApartment, NECB2015Outpatient, NECB2015PrimarySchool, NECB2015QuickServiceRestaurant, NECB2015RetailStandalone, NECB2015RetailStripmall, NECB2015SecondarySchool, NECB2015SmallDataCenterHighITE, NECB2015SmallDataCenterLowITE, NECB2015SmallHotel, NECB2015SmallOffice, NECB2015SmallOfficeDetailed, NECB2015SuperMarket, NECB2015SuperTallBuilding, NECB2015TallBuilding, NECB2015Warehouse, NECB2015_Prototype, NECB2017, NECB2017College, NECB2017Courthouse, NECB2017FullServiceRestaurant, NECB2017HighriseApartment, NECB2017Hospital, NECB2017Laboratory, NECB2017LargeDataCenterHighITE, NECB2017LargeDataCenterLowITE, NECB2017LargeHotel, NECB2017LargeOffice, NECB2017LargeOfficeDetailed, NECB2017MediumOffice, NECB2017MediumOfficeDetailed, NECB2017MidriseApartment, NECB2017Outpatient, NECB2017PrimarySchool, NECB2017QuickServiceRestaurant, NECB2017RetailStandalone, NECB2017RetailStripmall, NECB2017SecondarySchool, NECB2017SmallDataCenterHighITE, NECB2017SmallDataCenterLowITE, NECB2017SmallHotel, NECB2017SmallOffice, NECB2017SmallOfficeDetailed, NECB2017SuperMarket, NECB2017SuperTallBuilding, NECB2017TallBuilding, NECB2017Warehouse, NECB2017_Prototype, NECB2020, NRELZNEReady2017, NRELZNEReady2017College, NRELZNEReady2017Courthouse, NRELZNEReady2017FullServiceRestaurant, NRELZNEReady2017HighriseApartment, NRELZNEReady2017Hospital, NRELZNEReady2017Laboratory, NRELZNEReady2017LargeDataCenterHighITE, NRELZNEReady2017LargeDataCenterLowITE, NRELZNEReady2017LargeHotel, NRELZNEReady2017LargeOffice, NRELZNEReady2017LargeOfficeDetailed, NRELZNEReady2017MediumOffice, NRELZNEReady2017MediumOfficeDetailed, NRELZNEReady2017MidriseApartment, NRELZNEReady2017Outpatient, NRELZNEReady2017PrimarySchool, NRELZNEReady2017QuickServiceRestaurant, NRELZNEReady2017RetailStandalone, NRELZNEReady2017RetailStripmall, NRELZNEReady2017SecondarySchool, NRELZNEReady2017SmallDataCenterHighITE, NRELZNEReady2017SmallDataCenterLowITE, NRELZNEReady2017SmallHotel, NRELZNEReady2017SmallOffice, NRELZNEReady2017SmallOfficeDetailed, NRELZNEReady2017SuperMarket, NRELZNEReady2017SuperTallBuilding, NRELZNEReady2017TallBuilding, NRELZNEReady2017Warehouse, NRELZNEReady2017_Prototype, NilClass, OEESC, OEESC2014, OS_sim_extract, PRMError, Sched_create, ScheduleTranslator, Standard, StandardsData, String, SystemFuels, TestNECBSurfaces8426Custom, ThroughStruct, TrueClass, UntilStruct, UserData, UserDataBoolean, UserDataCSV, UserDataCSVAirLoopHVAC, UserDataCSVAirLoopHVACDOAS, UserDataCSVBuilding, UserDataCSVElectricEquipment, UserDataCSVExteriorLights, UserDataCSVGasEquipment, UserDataCSVLights, UserDataCSVOutdoorAir, UserDataCSVSpace, UserDataCSVSpaceTypes, UserDataCSVThermalZone, UserDataCSVZoneHvac, UserDataFiles, UserDataHVACBldgType, UserDataNonTradableLightsCategory, UserDataSHWBldgType, UserDataWWRBldgType, UserDataWaterUseConnection, UserDataWaterUseEquipment, UserDataWaterUseEquipmentDefinition, Vintagizer, ZEAEDGMultifamily

Instance Method Summary collapse

Instance Method Details

#calculate_max_delta_t(adj_DaySchedule, cur_DaySchedule) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/openstudio-standards/btap/utilities/convert_surfaces_to_adiabatic_necb_8426.rb', line 27

def calculate_max_delta_t(adj_DaySchedule, cur_DaySchedule)
  max = -999
  #  #if either one of schedule does not exist then it will return the max of the existing schedule
  #  if adj_DaySchedule.nil?
  #    0.upto(23) do |hour|
  #      time = OpenStudio::Time.new(0,hour,0,0)
  #      max = cur_DaySchedule.getValue(time) if cur_DaySchedule.getValue(time) > max
  #    end
  #  elsif cur_DaySchedule.nil?
  #    0.upto(23) do |hour|
  #      time = OpenStudio::Time.new(0,hour,0,0)
  #      max = adj_DaySchedule.getValue(time) if adj_DaySchedule.getValue(time) > max
  #    end
  #  elsif (cur_DaySchedule.nil? and cur_DaySchedule.nil?)
  #    return nil
  #  end
  if cur_DaySchedule.nil? || adj_DaySchedule.nil?
    raise 'cur_DaySchedule or adj_DaySchedule is nil'
    return nil
  end

  0.upto(23) do |hour|
    time = OpenStudio::Time.new(0, hour, 0, 0)
    difference = (cur_DaySchedule.getValue(time) - adj_DaySchedule.getValue(time)).abs
    max = difference if difference > max
  end
  return max
end

#check_boolean_value(value, varname) ⇒ Object



718
719
720
721
722
723
# File 'lib/openstudio-standards/btap/btap_result.rb', line 718

def check_boolean_value (value,varname)
  return true if value =~ (/^(true|t|yes|y|1)$/i)
  return false if value.empty? || value =~ (/^(false|f|no|n|0)$/i)

  raise ArgumentError.new "invalid value for #{varname}: #{value}"
end

#create_cbes_class_arrayObject



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

def create_cbes_class_array
  prototype_buildings = [
    'MediumOffice',
    'RetailStandalone',
    'SmallOffice'
  ]

  templates = {
    'CBESPre1978' => 'CBES Pre-1978',
    'CBEST241978' => 'CBES T24 1978',
    'CBEST241992' => 'CBES T24 1992',
    'CBEST242001' => 'CBES T24 2001',
    'CBEST242005' => 'CBES T24 2005',
    'CBEST242008' => 'CBES T24 2008'
  }

  class_array = []
  templates.each_pair do |template, template_string|
    # Create Prototype base class (May not be needed...)
    # Ex: class CBESPre1978_Prototype < CBESPre1978
    class_array << "
  class #{template}_Prototype < #{template}
  attr_reader :instvarbuilding_type
  def initialize
    super()
  end
end
"

    # Create Building Specific classes for each building.
    # Example class CBESPre1978_MediumOffice
    prototype_buildings.each do |building_type|
      class_array << "
  # This class represents a prototypical #{template} #{building_type}.
  class #{template}#{building_type} < #{template}
  @@building_type = \"#{building_type}\"
  register_standard (\"#{template_string}_\#{@@building_type}\")
  attr_accessor :prototype_database
  attr_accessor :prototype_input
  attr_accessor :lookup_building_type
  attr_accessor :space_type_map
  attr_accessor :geometry_file
  attr_accessor :building_story_map
  attr_accessor :system_to_space_map

  def initialize
    super()
    @instvarbuilding_type = @@building_type
    @prototype_input = self.model_find_object(standards_data['prototype_inputs'], {'template' => @template,'building_type' => @@building_type}, nil)
    if @prototype_input.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', \"Could not find prototype inputs for \#{{'template' => @template,'building_type' => @@building_type}}, cannot create model.\")
      raise(\"Could not find prototype inputs for #{template}#{building_type}, cannot create model.\")
      return false
    end
    @lookup_building_type = self.model_get_lookup_name(@building_type)
    #ideally we should map the data required to a instance variable.
    @geometry_file = 'geometry/' + @prototype_input['geometry_osm']
    hvac_map_file =  'geometry/' + @prototype_input['hvac_json']
    @system_to_space_map = load_hvac_map(hvac_map_file)
    self.set_variables()
  end

  # This method is used to extend the class with building-type-specific
  # methods, as defined in Prototype.SomeBuildingType.rb.  Each building type
  # has its own set of methods that change things which are not
  # common across all prototype buildings, even within a given Standard.
  def set_variables()
    # Will be overwritten in class reopen file.
    # add all building methods for now.
  end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the space types
  # available for this particular Standard.
  def define_space_type_map(building_type, climate_zone)
    return @space_type_map
  end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the HVAC system that will
  # be applied to those spaces.
  def define_hvac_system_map(building_type, climate_zone)
    return @system_to_space_map
  end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the building story
  # that they are located on.
  def define_building_story_map(building_type, climate_zone)
     return @building_story_map
  end

  # Does nothing unless implmented by the specific standard
  def model_modify_oa_controller(model)
  end

  # Does nothing unless implmented by the specific standard
  def model_reset_or_room_vav_minimum_damper(prototype_input, model)
  end

  # update exhuast fan efficiency
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @return [Boolean] returns true if successful, false if not
  def model_update_exhaust_fan_efficiency(model)
    return true
  end

  # Does nothing unless implmented by the specific standard
  def model_update_fan_efficiency(model)
  end

  # Get the name of the building type used in lookups.
  # For CBES, this lookup matches the DOE prototype building types.
  #
  # @param building_type [String] the building type
  # @return [String] returns the lookup name as a string
  def model_get_lookup_name(building_type)
    lookup_name = building_type
    case building_type
      when 'SmallOffice'
        lookup_name = 'Office'
      when 'MediumOffice'
        lookup_name = 'Office'
      when 'LargeOffice'
        lookup_name = 'Office'
      when 'LargeOfficeDetailed'
        lookup_name = 'Office'
      when 'RetailStandalone'
        lookup_name = 'Retail'
      when 'RetailStripmall'
        lookup_name = 'StripMall'
      when 'Office'
        lookup_name = 'Office'
    end
    return lookup_name
  end

  # hvac adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_hvac_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end

  # swh adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_swh_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end

  # geometry adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_geometry_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end

  # daylighting adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_daylighting_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end
end
"
    end
  end
  return class_array
end

#create_class_arrayObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/openstudio-standards/prototypes/common/prototype_metaprogramming.rb', line 6

def create_class_array
  prototype_buildings = ['FullServiceRestaurant',
                         'Hospital',
                         'HighriseApartment',
                         'LargeHotel',
                         'LargeOffice',
                         'MediumOffice',
                         'MidriseApartment',
                         'Outpatient',
                         'PrimarySchool',
                         'QuickServiceRestaurant',
                         'RetailStandalone',
                         'SecondarySchool',
                         'SmallHotel',
                         'SmallOffice',
                         'RetailStripmall',
                         'Warehouse',
                         'SuperMarket',
                         'SmallDataCenterLowITE',
                         'SmallDataCenterHighITE',
                         'LargeDataCenterLowITE',
                         'LargeDataCenterHighITE',
                         'SmallOfficeDetailed',
                         'MediumOfficeDetailed',
                         'LargeOfficeDetailed',
                         'Laboratory',
                         'College',
                         'Courthouse',
                         'TallBuilding',
                         'SuperTallBuilding']

  templates = {
    'ASHRAE9012004' => '90.1-2004',
    'ASHRAE9012007' => '90.1-2007',
    'ASHRAE9012010' => '90.1-2010',
    'ASHRAE9012013' => '90.1-2013',
    'ASHRAE901PRM2019' => '90.1-PRM-2019',
    'ASHRAE9012016' => '90.1-2016',
    'ASHRAE9012019' => '90.1-2019',
    'DOERef1980to2004' => 'DOE Ref 1980-2004',
    'DOERefPre1980' => 'DOE Ref Pre-1980',
    'NRELZNEReady2017' => 'NREL ZNE Ready 2017'
  }
  class_array = []
  templates.each_pair do |template, template_string|
    # Create Prototype base class (May not be needed...)
    # Ex: class NECB2011_Prototype < NECB2011
    class_array << "
  class #{template}_Prototype < #{template}
  attr_reader :instvarbuilding_type
  def initialize
    super()
  end
end
"

    # Create Building Specific classes for each building.
    # Example class NECB2011Hospital
    prototype_buildings.each do |name|
      class_array << "
  # This class represents a prototypical #{template} #{name}.
  class #{template}#{name} < #{template}
  @@building_type = \"#{name}\"
  register_standard (\"#{template_string}_\#{@@building_type}\")
  attr_accessor :prototype_database
  attr_accessor :prototype_input
  attr_accessor :lookup_building_type
  attr_accessor :space_type_map
  attr_accessor :geometry_file
  attr_accessor :building_story_map
  attr_accessor :system_to_space_map
  def initialize
    super()
    @instvarbuilding_type = @@building_type
    @prototype_input = self.standards_lookup_table_first(table_name: 'prototype_inputs',search_criteria: {'template' => @template,'building_type' => @@building_type })
    if @prototype_input.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', \"Could not find prototype inputs for \#{{'template' => @template,'building_type' => @@building_type }}, cannot create model.\")
      raise(\"Could not find prototype inputs for #{template}#{name}, cannot create model.\")
      return false
    end
    @lookup_building_type = self.model_get_lookup_name(@@building_type)
    #ideally we should map the data required to a instance variable.
    @geometry_file = 'geometry/' + @prototype_input['geometry_osm']
    hvac_map_file =  'geometry/' + @prototype_input['hvac_json']
    @system_to_space_map = load_hvac_map(hvac_map_file)
    self.set_variables()
  end
  # This method is used to extend the class with building-type-specific
  # methods, as defined in Prototype.SomeBuildingType.rb.  Each building type
  # has its own set of methods that change things which are not
  # common across all prototype buildings, even within a given Standard.
  def set_variables()
    # Will be overwritten in class reopen file.
    # add all building methods for now.
    self.extend(#{name}) unless @template == 'NECB 2011'
  end
  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the space types
  # available for this particular Standard.
  def define_space_type_map(building_type, climate_zone)
    return @space_type_map
  end
  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the HVAC system that will
  # be applied to those spaces.
  def define_hvac_system_map(building_type, climate_zone)
    return @system_to_space_map
  end
  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the building story
  # that they are located on.
  def define_building_story_map(building_type, climate_zone)
     return @building_story_map
  end
  # Does nothing unless implmented by the specific standard
  def model_modify_oa_controller(model)
  end
  # Does nothing unless implmented by the specific standard
  def model_reset_or_room_vav_minimum_damper(prototype_input, model)
  end

  # update exhuast fan efficiency
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @return [Boolean] returns true if successful, false if not
  def model_update_exhaust_fan_efficiency(model)
    return true
  end

  # Does nothing unless implmented by the specific standard
  def model_update_fan_efficiency(model)
  end
  # Get the name of the building type used in lookups
  #
  # @param building_type [String] the building type
  # @return [String] returns the lookup name as a string
  # @todo Unify the lookup names and eliminate this method
  def model_get_lookup_name(building_type)
    lookup_name = building_type
    case building_type
      when 'SmallOffice'
        lookup_name = 'Office'
      when 'MediumOffice'
        lookup_name = 'Office'
      when 'LargeOffice'
        lookup_name = 'Office'
      when 'SmallOfficeDetailed'
        lookup_name = 'Office'
      when 'MediumOfficeDetailed'
        lookup_name = 'Office'
	  when 'LargeOfficeDetailed'
        lookup_name = 'Office'
      when 'RetailStandalone'
        lookup_name = 'Retail'
      when 'RetailStripmall'
        lookup_name = 'StripMall'
      when 'Office'
        lookup_name = 'Office'
    end
    return lookup_name
  end

  # daylighting adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_daylighting_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end
end
"
    end
  end

  ['NECB2011',
   'NECB2015',
   'NECB2017'].each do |template|
    # Create Prototype base class (May not be needed...)
    # Ex: class NECB2011_Prototype < NECB2011
    class_array << "
  class #{template}_Prototype < #{template}
  attr_reader :instvarbuilding_type
  def initialize
    super()
  end
end
"

    # Create Building Specific classes for each building.
    # Example class NECB2011Hospital
    prototype_buildings.each do |name|
      class_array << "
  # This class represents a prototypical #{template} #{name}.
  class #{template}#{name} < #{template}
    BUILDING_TYPE = \"#{name}\"
    TEMPLATE =  \"#{template}\"
    register_standard (\"\#{TEMPLATE}_\#{BUILDING_TYPE}\")
    attr_accessor :prototype_database
    attr_accessor :prototype_input
    attr_accessor :lookup_building_type
    attr_accessor :space_type_map
    attr_accessor :geometry_file
    attr_accessor :building_story_map
    attr_accessor :system_to_space_map

    def initialize
      super()
      @building_type = BUILDING_TYPE
      @template = TEMPLATE
      @instvarbuilding_type = @building_type
      @prototype_input = self.standards_lookup_table_first(table_name: 'prototype_inputs', search_criteria: {'template' => \"#{template}\",'building_type' => \"#{name}\" })
      if @prototype_input.nil?
        OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', \"Could not find prototype inputs for \#{{'template' => \"#{template}\",'building_type' => \"#{name}\" }}, cannot create model.\")
        #puts JSON.pretty_generate(standards_data['prototype_inputs'])
        raise(\"Could not find prototype inputs for #{template} #{name}, cannot create model.\")
        return false
      end
      @lookup_building_type = self.model_get_lookup_name(@building_type)
      #ideally we should map the data required to a instance variable.
      @geometry_file = 'geometry/' + self.class.name + '.osm'
      hvac_map_file =  'geometry/' + self.class.name + '.hvac_map.json'
      # @system_to_space_map = load_hvac_map(hvac_map_file) # No HVAC map json files for NECB
      self.set_variables()
    end

  # This method is used to extend the class with building-type-specific
  # methods, as defined in Prototype.SomeBuildingType.rb.  Each building type
  # has its own set of methods that change things which are not
  # common across all prototype buildings, even within a given Standard.
    def set_variables()
    end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the space types
  # available for this particular Standard.
    def define_space_type_map(building_type, climate_zone)
      return @space_type_map
    end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the HVAC system that will
  # be applied to those spaces.
    def define_hvac_system_map(building_type, climate_zone)
      return @system_to_space_map
    end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the building story
  # that they are located on.
  def define_building_story_map(building_type, climate_zone)
     return @building_story_map
  end

  # Does nothing unless implmented by the specific standard
  def model_modify_oa_controller(model)
  end

  # Does nothing unless implmented by the specific standard
  def model_reset_or_room_vav_minimum_damper(prototype_input, model)
  end

  # update exhuast fan efficiency
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @return [Boolean] returns true if successful, false if not
  def model_update_exhaust_fan_efficiency(model)
    return true
  end

  # Does nothing unless implmented by the specific standard
  def model_update_fan_efficiency(model)
  end

end
"
    end
  end

  return class_array
end

#create_deer_class_arrayObject



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
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
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
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
# File 'lib/openstudio-standards/prototypes/common/prototype_metaprogramming.rb', line 290

def create_deer_class_array
  prototype_buildings = [
    'Asm',
    'ECC',
    'EPr',
    'ERC',
    'ESe',
    'EUn',
    'Gro',
    'Hsp',
    'Nrs',
    'Htl',
    'Mtl',
    'MBT',
    'MLI',
    'OfL',
    'OfS',
    'RFF',
    'RSD',
    'Rt3',
    'RtL',
    'RtS',
    'SCn',
    'SUn',
    'WRf',
    'GHs',
    'DMo',
    'MFm',
    'SFm'
  ]

  # Only a subset of building type and HVAC type combinations are valid
  building_to_hvac_systems = {
    'Asm' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'ECC' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG',
      'WLHP'
    ],
    'EPr' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'WLHP'
    ],
    'ERC' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'ESe' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG',
      'WLHP'
    ],
    'EUn' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG'
    ],
    'Gro' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'Hsp' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG'
    ],
    'Nrs' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'FPFC',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG'
    ],
    'Htl' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG',
      'WLHP'
    ],
    'Mtl' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'MBT' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG',
      'WLHP'
    ],
    'MFm' => [
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'MLI' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'OfL' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG',
      'WLHP'
    ],
    'OfS' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG',
      'WLHP'
    ],
    'RFF' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'RSD' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'Rt3' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF',
      'PVVE',
      'PVVG',
      'SVVE',
      'SVVG',
      'WLHP'
    ],
    'RtL' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'RtS' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'SCn' => [
      'DXEH',
      'DXGF',
      'DXHP',
      'NCEH',
      'NCGF'
    ],
    'SUn' => ['Unc'],
    'WRf' => ['DXGF']
  }

  templates = {
    'DEERPRE1975' => 'DEER Pre-1975',
    'DEER1985' => 'DEER 1985',
    'DEER1996' => 'DEER 1996',
    'DEER2003' => 'DEER 2003',
    'DEER2007' => 'DEER 2007',
    'DEER2011' => 'DEER 2011',
    'DEER2014' => 'DEER 2014',
    'DEER2015' => 'DEER 2015',
    'DEER2017' => 'DEER 2017'
  }

  class_array = []
  templates.each_pair do |template, template_string|
    # Create Prototype base class (May not be needed...)
    # Ex: class DEER_Prototype < DEER1985
    class_array << "
  class #{template}_Prototype < #{template}
  attr_reader :instvarbuilding_type
  def initialize
    super()
  end
end
"

    # Create Building Specific classes for each building.
    # Example class DEER1985AsmDXGF
    prototype_buildings.each do |building_type|
      next if building_to_hvac_systems[building_type].nil?

      building_to_hvac_systems[building_type].each do |hvac_system|
        class_array << "
  # This class represents a prototypical #{template} #{building_type} #{hvac_system}.
  class #{template}#{building_type}#{hvac_system} < #{template}
  @@building_type = \"#{building_type}\"
  @@hvac_system = \"#{hvac_system}\"
  register_standard (\"#{template_string}_\#{@@building_type}_\#{@@hvac_system}\")
  attr_accessor :prototype_database
  attr_accessor :prototype_input
  attr_accessor :lookup_building_type
  attr_accessor :space_type_map
  attr_accessor :geometry_file
  attr_accessor :building_story_map
  attr_accessor :system_to_space_map

  def initialize
    super()
    @instvarbuilding_type = @@building_type
    @prototype_input = self.standards_lookup_table_first(table_name: 'prototype_inputs', search_criteria: {'template' => @template,'building_type' => @@building_type, 'hvac_system' => @@hvac_system})
    if @prototype_input.nil?
      OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Model', \"Could not find prototype inputs for \#{{'template' => @template,'building_type' => @@building_type, 'hvac' => @@hvac_system}}, cannot create model.\")
      raise(\"Could not find prototype inputs for #{template}#{building_type}#{hvac_system}, cannot create model.\")
      return false
    end
    @lookup_building_type = @@building_type
    #ideally we should map the data required to a instance variable.
    @geometry_file = 'geometry/' + @prototype_input['geometry_osm']
    hvac_map_file =  'geometry/' + @prototype_input['hvac_json']
    @system_to_space_map = load_hvac_map(hvac_map_file)
    self.set_variables()
  end

  # This method is used to extend the class with building-type-specific
  # methods, as defined in Prototype.SomeBuildingType.rb.  Each building type
  # has its own set of methods that change things which are not
  # common across all prototype buildings, even within a given Standard.
  def set_variables()
    # Will be overwritten in class reopen file.
    # add all building methods for now.
  end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the space types
  # available for this particular Standard.
  def define_space_type_map(building_type, climate_zone)
    return @space_type_map
  end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the HVAC system that will
  # be applied to those spaces.
  def define_hvac_system_map(building_type, climate_zone)
    return @system_to_space_map
  end

  # Returns the mapping between the names of the spaces
  # in the geometry .osm file and the building story
  # that they are located on.
  def define_building_story_map(building_type, climate_zone)
     return @building_story_map
  end

  # Does nothing unless implmented by the specific standard
  def model_modify_oa_controller(model)
  end

  # Does nothing unless implmented by the specific standard
  def model_reset_or_room_vav_minimum_damper(prototype_input, model)
  end

  # update exhuast fan efficiency
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @return [Boolean] returns true if successful, false if not
  def model_update_exhaust_fan_efficiency(model)
    return true
  end

  # Does nothing unless implmented by the specific standard
  def model_update_fan_efficiency(model)
  end

  # Get the name of the building type used in lookups.
  # For DEER, this is the building type.
  #
  # @param building_type [String] the building type
  # @return [String] returns the lookup name as a string
  def model_get_lookup_name(building_type)
    return building_type
  end

  # hvac adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_hvac_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end

  # swh adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_swh_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end

  # geometry adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_geometry_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end

  # daylighting adjustments specific to the prototype model
  #
  # @param model [OpenStudio::Model::Model] OpenStudio model object
  # @param building_type [String] the building type
  # @param climate_zone [String] ASHRAE climate zone, e.g. 'ASHRAE 169-2013-4A'
  # @param prototype_input [Hash] hash of prototype inputs
  # @return [Boolean] returns true if successful, false if not
  def model_custom_daylighting_tweaks(model, building_type, climate_zone, prototype_input)
    return true
  end
end
"
      end
    end
  end
  return class_array
end

#create_meta_classesObject



889
890
891
892
893
# File 'lib/openstudio-standards/prototypes/common/prototype_metaprogramming.rb', line 889

def create_meta_classes
  create_class_array.each { |item| eval(item) } # rubocop:disable Security/Eval
  create_deer_class_array.each { |item| eval(item) } # rubocop:disable Security/Eval
  create_cbes_class_array.each { |item| eval(item) } # rubocop:disable Security/Eval
end

#distance(loc1, loc2) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/openstudio-standards/btap/utilities/necb_to_epw_map.rb', line 3

def distance(loc1, loc2)
  rad_per_deg = Math::PI / 180 # PI / 180
  rkm = 6371 # Earth radius in kilometers
  rm = rkm * 1000 # Radius in meters

  dlat_rad = (loc2[0] - loc1[0]) * rad_per_deg # Delta, converted to rad
  dlon_rad = (loc2[1] - loc1[1]) * rad_per_deg

  lat1_rad, lon1_rad = loc1.map { |i| i * rad_per_deg }
  lat2_rad, lon2_rad = loc2.map { |i| i * rad_per_deg }

  a = Math.sin(dlat_rad / 2)**2 + Math.cos(lat1_rad) * Math.cos(lat2_rad) * Math.sin(dlon_rad / 2)**2
  c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
  rm * c # Delta in meters
end

#get_additional_property_as_boolean(component, key, default = false) ⇒ Boolean

PRM get an additional property from an OpenStudio object as a boolean, if no such additional property, then return default value.

Parameters:

  • component (OpenStudio::Model:Component)

    the component to get the additional property from

  • key (String)

    key string

  • default (Boolean) (defaults to: false)

    the default to return when there is no matching key

Returns:

  • (Boolean)

    boolean value



67
68
69
70
71
72
73
74
75
# File 'lib/openstudio-standards/utilities/assertion.rb', line 67

def get_additional_property_as_boolean(component, key, default = false)
  value = default
  if component.additionalProperties.getFeatureAsBoolean(key).is_initialized
    value = component.additionalProperties.getFeatureAsBoolean(key).get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.utilities', "Cannot find the #{key} in component: #{component.name.get}, default value #{default} is used.")
  end
  return value
end

#get_additional_property_as_double(component, key, default = 0.0) ⇒ Double

PRM get an additional property from an OpenStudio object as a double, if no such additional property, then return default value.

Parameters:

  • component (OpenStudio::Model::Component)

    the component to get the additional property from

  • key (String)

    key string

  • default (Double) (defaults to: 0.0)

    the default to return when there is no matching key

Returns:

  • (Double)

    Double value



99
100
101
102
103
104
105
106
107
# File 'lib/openstudio-standards/utilities/assertion.rb', line 99

def get_additional_property_as_double(component, key, default = 0.0)
  value = default
  if component.additionalProperties.getFeatureAsDouble(key).is_initialized
    value = component.additionalProperties.getFeatureAsDouble(key).get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.utilities', "Cannot find the #{key} in component: #{component.name.get}, default value #{default} is used.")
  end
  return value
end

#get_additional_property_as_integer(component, key, default = 0.0) ⇒ Integer

PRM get an additional property from an OpenStudio object as a double, if no such additional property, then return default value.

Parameters:

  • component (OpenStudio::Model::Component)

    the component to get the additional property from

  • key (String)

    key string

  • default (Integer) (defaults to: 0.0)

    the default to return when there is no matching key

Returns:



83
84
85
86
87
88
89
90
91
# File 'lib/openstudio-standards/utilities/assertion.rb', line 83

def get_additional_property_as_integer(component, key, default = 0.0)
  value = default
  if component.additionalProperties.getFeatureAsInteger(key).is_initialized
    value = component.additionalProperties.getFeatureAsInteger(key).get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.utilities', "Cannot find the #{key} in component: #{component.name.get}, default value #{default} is used.")
  end
  return value
end

#get_additional_property_as_string(component, key, default = '') ⇒ String

PRM get an additional property from an OpenStudio object as a string, if no such additional property, then return default value.

Parameters:

  • component (OpenStudio::Model::Component)

    the component to get the additional property from

  • key (String)

    key string

  • default (String) (defaults to: '')

    the default to return when there is no matching key

Returns:



115
116
117
118
119
120
121
122
123
# File 'lib/openstudio-standards/utilities/assertion.rb', line 115

def get_additional_property_as_string(component, key, default = '')
  value = default
  if component.additionalProperties.getFeatureAsString(key).is_initialized
    value = component.additionalProperties.getFeatureAsString(key).get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.utilities', "Cannot find the #{key} in component: #{component.name.get}, default value #{default} is used.")
  end
  return value
end

#get_logs(log_type = OpenStudio::Error) ⇒ Array<String>

Get an array of all messages of a given type in the log

Parameters:

  • log_type (OpenStudio::Class) (defaults to: OpenStudio::Error)

    type of messages to return from the log, e.g. OpenStudio::Error

Returns:



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/openstudio-standards/utilities/logging.rb', line 138

def get_logs(log_type = OpenStudio::Error)
  errors = []

  $OPENSTUDIO_LOG.logMessages.each do |msg|
    if /openstudio.*/ =~ msg.logChannel
      # Skip certain messages that are irrelevant/misleading
      next if msg.logMessage.include?('UseWeatherFile') || # 'UseWeatherFile' is not yet a supported option for YearDescription
              msg.logMessage.include?('Skipping layer') || # Annoying/bogus "Skipping layer" warnings
              msg.logChannel.include?('runmanager') || # RunManager messages
              msg.logChannel.include?('setFileExtension') || # .ddy extension unexpected
              msg.logChannel.include?('Translator') || # Forward translator and geometry translator
              msg.logMessage.include?('Successive data points') || # Successive data points (2004-Jan-31 to 2001-Feb-01, ending on line 753) are greater than 1 day apart in EPW file
              msg.logMessage.include?('has multiple parents') || # Bogus errors about curves having multiple parents
              msg.logMessage.include?('does not have an Output') || # Warning from EMS translation
              msg.logMessage.include?('Prior to OpenStudio 2.6.2, this field was returning a double, it now returns an Optional double') # Warning about OS API change

      # Only fail on the errors
      if msg.logLevel == log_type
        errors << "[#{msg.logChannel}] #{msg.logMessage}"
      end
    end
  end

  return errors
end

#get_schedule_max_delta_t(model, surface) ⇒ Object

returns -999 if current surface does not have heating OR cooling schedule returns -997 if all adjacent surfaces does not have BOTH heating AND cooling returns nil if the surface does not have adjacent surface



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/openstudio-standards/btap/utilities/convert_surfaces_to_adiabatic_necb_8426.rb', line 59

def get_schedule_max_delta_t(model, surface)
  # find spaces that share that surface.
  # load the schedules for every day type of the year. for both spaces. If the space is does not have a heating schedule..assume the temperature is the -10C always for now.
  # iterate through every hour. and determine delta T
  # Store the max delta T.
  # end iteration
  # return max deltaT
  cur_space = nil
  delta_t = -998
  adjacent_surface_found = false
  atleast_one_adjacent_surface_has_schedule = false
  model.getSpaces.each do |space|
    if space == surface.space.get
      cur_space = space
    end
  end
  if cur_space.nil?
    raise "Surface: [#{surface.name}] does not belong to any space"
  end

  model.getSpaces.each do |space|
    if space == surface.space.get
      next
    end

    space.surfaces.each do |surf|
      unless surf.adjacentSurface.empty?
        adj_surface = surf.adjacentSurface.get
        if adj_surface == surface
          adjacent_surface_found = true
          unless space.thermalZone.empty?
            adj_surface_thermal_zone = space.thermalZone.get
            cur_surface_thermal_zone = cur_space.thermalZone.get
            unless adj_surface_thermal_zone.thermostatSetpointDualSetpoint.empty?
              adj_thermostat = adj_surface_thermal_zone.thermostatSetpointDualSetpoint.get
              cur_thermostat = cur_surface_thermal_zone.thermostatSetpointDualSetpoint.get
              # if current surface does not have a thermostat schedule, then it will return -999 instead of nil because nil is reserved for surfaces without adjacent surface
              if cur_thermostat.getHeatingSchedule.empty? || cur_thermostat.getCoolingSchedule.empty?
                return -999
              end
              # after this point current surface should have BOTH heating and cooling schedule
              # if adjacent surface does not have a heating OR cooling schedule it will be skipped
              if adj_thermostat.getHeatingSchedule.empty? || adj_thermostat.getCoolingSchedule.empty?
                next
              else
                atleast_one_adjacent_surface_has_schedule = true
              end

              startDate = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(1), 1, 2009)
              endDate = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(1), 7, 2009)

              adj_surface_heating_day_schedule_array = adj_thermostat.getHeatingSchedule.get.to_ScheduleRuleset.get.getDaySchedules(startDate, endDate) unless adj_thermostat.getHeatingSchedule.empty?
              adj_surface_cooling_day_schedule_array = adj_thermostat.getCoolingSchedule.get.to_ScheduleRuleset.get.getDaySchedules(startDate, endDate) unless adj_thermostat.getCoolingSchedule.empty?
              cur_surface_heating_day_schedule_array = cur_thermostat.getHeatingSchedule.get.to_ScheduleRuleset.get.getDaySchedules(startDate, endDate) unless cur_thermostat.getHeatingSchedule.empty?
              cur_surface_cooling_day_schedule_array = cur_thermostat.getCoolingSchedule.get.to_ScheduleRuleset.get.getDaySchedules(startDate, endDate) unless cur_thermostat.getCoolingSchedule.empty?
              delta_t = -998
              heating_delta_t = []
              cooling_delta_t = []
              1.upto(7) do |i|
                puts 'mee mee mee'
                puts calculate_max_delta_t(adj_surface_heating_day_schedule_array[i - 1], cur_surface_heating_day_schedule_array[i - 1])
                heating_delta_t << calculate_max_delta_t(adj_surface_heating_day_schedule_array[i - 1], cur_surface_heating_day_schedule_array[i - 1])
                cooling_delta_t << calculate_max_delta_t(adj_surface_cooling_day_schedule_array[i - 1], cur_surface_cooling_day_schedule_array[i - 1])
              end
              delta_t = [heating_delta_t.max, cooling_delta_t.max].max
              puts "delta_t: #{delta_t}"
            end
          end
        end
      end
    end
  end
  # adjacent_surface_found ? (atleast_one_adjacent_surface_has_schedule ? (return delta_t) : (return -997)) : (return nil)
  if adjacent_surface_found
    if atleast_one_adjacent_surface_has_schedule
      return delta_t
    else
      return -997
    end
  else
    return nil
  end
end

#get_total_nominal_capacity(model) ⇒ Object



726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/openstudio-standards/btap/btap_result.rb', line 726

def get_total_nominal_capacity (model)
  total_nominal_capacity = 0
  model.getSpaces.sort.each do |space|
    unless space.thermalZone.empty?
      zone_name = space.thermalZone.get.name.get.upcase
      area = model.sqlFile().get().execAndReturnFirstDouble("SELECT Value FROM TabularDataWithStrings WHERE ReportName='InputVerificationandResultsSummary' AND ReportForString='Entire Facility' AND TableName='Zone Summary' AND ColumnName='Area' AND RowName='#{zone_name}'")
      area = validate_optional(area, model, -1)
      multiplier = model.sqlFile().get().execAndReturnFirstDouble("SELECT Value FROM TabularDataWithStrings WHERE ReportName='InputVerificationandResultsSummary' AND ReportForString='Entire Facility' AND TableName='Zone Summary' AND ColumnName='Multipliers' AND RowName='#{zone_name}'")
      multiplier = validate_optional(multiplier, model, -1)
      area_per_person = model.sqlFile().get().execAndReturnFirstDouble("SELECT Value FROM TabularDataWithStrings WHERE ReportName='InputVerificationandResultsSummary' AND ReportForString='Entire Facility' AND TableName='Zone Summary' AND ColumnName='People' AND RowName='#{zone_name}'")
      area_per_person = validate_optional(area_per_person, model, -1)
      next if area_per_person == 0
      puts "area: #{area}  multiplier: #{multiplier}   area_per_person: #{area_per_person}"
      total_nominal_capacity += area*multiplier/area_per_person
    end
  end
  return total_nominal_capacity
end

#log_messages_to_file(file_path, debug = false) ⇒ Array<String>

Log the info, warning, and error messages to a file.

runner @param [file_path] The path to the log file debug @param [Boolean] If true, include the debug messages in the log

Returns:

  • (Array<String>)

    The array of messages, which can be used elsewhere.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/openstudio-standards/utilities/logging.rb', line 91

def log_messages_to_file(file_path, debug = false)
  messages = []

  File.open(file_path, 'w') do |file|
    $OPENSTUDIO_LOG.logMessages.each do |msg|
      # DLM: you can filter on log channel here for now
      if /openstudio.*/ =~ msg.logChannel # /openstudio\.model\..*/
        # Skip certain messages that are irrelevant/misleading
        next if msg.logMessage.include?('UseWeatherFile') || # 'UseWeatherFile' is not yet a supported option for YearDescription
                msg.logMessage.include?('Skipping layer') || # Annoying/bogus "Skipping layer" warnings
                msg.logChannel.include?('runmanager') || # RunManager messages
                msg.logChannel.include?('setFileExtension') || # .ddy extension unexpected
                msg.logChannel.include?('Translator') || # Forward translator and geometry translator
                msg.logMessage.include?('Successive data points') || # Successive data points (2004-Jan-31 to 2001-Feb-01, ending on line 753) are greater than 1 day apart in EPW file
                msg.logMessage.include?('has multiple parents') || # Bogus errors about curves having multiple parents
                msg.logMessage.include?('does not have an Output') || # Warning from EMS translation
                msg.logMessage.include?('Prior to OpenStudio 2.6.2, this field was returning a double, it now returns an Optional double') # Warning about OS API change

        # Report the message in the correct way
        if msg.logLevel == OpenStudio::Info
          s = "INFO  #{msg.logMessage}"
          file.puts(s)
          messages << s
        elsif msg.logLevel == OpenStudio::Warn
          s = "WARN  #{msg.logMessage}"
          file.puts(s)
          messages << s
        elsif msg.logLevel == OpenStudio::Error
          s = "ERROR #{msg.logMessage}"
          file.puts(s)
          messages << s
        elsif msg.logLevel == OpenStudio::Debug && debug
          s = "DEBUG #{msg.logMessage}"
          file.puts(s)
          messages << s
        end
      end
    end
  end

  return messages
end

#log_messages_to_file_prm(file_path, debug = false) ⇒ Array

A function to export log messages specific to PRM to a log file.

Parameters:

  • file_path (String)

    the file path to the log file

  • debug (Boolean) (defaults to: false)

    debug mode

Returns:

  • (Array)

    array of message strings



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/openstudio-standards/utilities/logging.rb', line 55

def log_messages_to_file_prm(file_path, debug = false)
  messages = []

  File.open(file_path, 'w') do |file|
    $OPENSTUDIO_LOG.logMessages.each do |msg|
      # only apply to prm
      if msg.logChannel.casecmp? 'prm.log'
        # Report the message in the correct way
        if msg.logLevel == OpenStudio::Info
          s = "[#{msg.logChannel}] INFO  #{msg.logMessage}"
          file.puts(s)
          messages << s
        elsif msg.logLevel == OpenStudio::Warn
          s = "[#{msg.logChannel}] WARN  #{msg.logMessage}"
          file.puts(s)
          messages << s
        elsif msg.logLevel == OpenStudio::Error
          s = "[#{msg.logChannel}] ERROR #{msg.logMessage}"
          file.puts(s)
          messages << s
        elsif msg.logLevel == OpenStudio::Debug && debug
          s = "[#{msg.logChannel}] DEBUG #{msg.logMessage}"
          file.puts(s)
          messages << s
        end
      end
    end
  end
  return messages
end

#log_messages_to_runner(runner, debug = false) ⇒ Runner

Log the info, warning, and error messages to a runner.

runner @param [Runner] The Measure runner to add the messages to debug @param [Boolean] If true, include the debug messages in the log

Returns:

  • (Runner)

    The same Measure runner, with messages from the openstudio-standards library added



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/openstudio-standards/utilities/logging.rb', line 10

def log_messages_to_runner(runner, debug = false)
  $OPENSTUDIO_LOG.logMessages.each do |msg|
    # DLM: you can filter on log channel here for now
    if /openstudio.*/ =~ msg.logChannel # /openstudio\.model\..*/
      # Skip certain messages that are irrelevant/misleading
      next if msg.logMessage.include?('UseWeatherFile') || # 'UseWeatherFile' is not yet a supported option for YearDescription
              msg.logMessage.include?('Skipping layer') || # Annoying/bogus "Skipping layer" warnings
              msg.logChannel.include?('runmanager') || # RunManager messages
              msg.logChannel.include?('setFileExtension') || # .ddy extension unexpected
              msg.logChannel.include?('Translator') || # Forward translator and geometry translator
              msg.logMessage.include?('Successive data points') || # Successive data points (2004-Jan-31 to 2001-Feb-01, ending on line 753) are greater than 1 day apart in EPW file
              msg.logMessage.include?('has multiple parents') || # Bogus errors about curves having multiple parents
              msg.logMessage.include?('does not have an Output') || # Warning from EMS translation
              msg.logMessage.include?('Prior to OpenStudio 2.6.2, this field was returning a double, it now returns an Optional double') # Warning about OS API change

      # Report the message in the correct way
      if msg.logLevel == OpenStudio::Info
        runner.registerInfo(msg.logMessage)
      elsif msg.logLevel == OpenStudio::Warn
        runner.registerWarning("[#{msg.logChannel}] #{msg.logMessage}")
      elsif msg.logLevel == OpenStudio::Error
        runner.registerError("[#{msg.logChannel}] #{msg.logMessage}")
      elsif msg.logLevel == OpenStudio::Debug && debug
        runner.registerInfo("DEBUG - #{msg.logMessage}")
      end
    end
  end
end

#look_up_csv_data(csv_fname, search_criteria) ⇒ Object



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

def look_up_csv_data(csv_fname, search_criteria)
  options = { :headers    => :first_row,
    :converters => [ :numeric ] }
  unless File.exist?(csv_fname)
    raise ("File: [#{csv_fname}] Does not exist")
  end
  # we'll save the matches here
  matches = nil
  # save a copy of the headers
  headers = nil
  CSV.open( csv_fname, "r", options ) do |csv|

    # Since CSV includes Enumerable we can use 'find_all'
    # which will return all the elements of the Enumerble for
    # which the block returns true

    matches = csv.find_all do |row|
      match = true
      search_criteria.keys.each do |key|
        match = match && ( row[key].strip == search_criteria[key].strip )
      end
      match
    end
    headers = csv.headers
  end
  #puts matches
  raise("More than one match") if matches.size > 1
  puts "Zero matches found for [#{search_criteria}]" if matches.size == 0
  #return matches[0]
  return matches[0]
end

#map_spacetypesObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/openstudio-standards/btap/utilities/space_type.rb', line 57

def map_spacetypes()

  map_list = CSV.open("cold_lake_map.csv", headers: :first_row).map(&:to_h)
  path = "/home/osdev/openstudio-standards/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/DND*.osm"
  Dir.glob(path) do |osm_file|
    model = BTAP::FileIO::load_osm(osm_file)
    model.getSpaceTypes.each do |st|
      map_item = map_list.select { |item| item["Original Spacetype Name"] == st.name.get }
      unless map_item.empty?
        new_name = map_item.first()['New-StandardsBuildingType'].to_s + '-'+map_item.first()['New-StandardSpaceType'].to_s
        st.setName(new_name)
        st.setStandardsBuildingType(map_item.first()["New-StandardsBuildingType"])
        st.setStandardsSpaceType(map_item.first()["New-StandardSpaceType"])
        puts st
      end
    end
    BTAP::FileIO::save_osm(model,File.join(__dir__,File.basename(osm_file)))
  end
end

#model_out_path(test_name) ⇒ Object



11
12
13
# File 'lib/openstudio-standards/btap/utilities/convert_surfaces_to_adiabatic_necb_8426.rb', line 11

def model_out_path(test_name)
  "#{run_dir(test_name)}/ExampleModel.osm"
end

#necb_2011_qaqc(qaqc, model) ⇒ Object



777
778
779
780
781
782
783
784
785
786
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
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
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
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
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
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
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
# File 'lib/openstudio-standards/btap/btap_result.rb', line 777

def necb_2011_qaqc(qaqc, model)
  #Now perform basic QA/QC on items for NECB2011
  qaqc[:information] = []
  qaqc[:warnings] =[]
  qaqc[:errors] = []
  qaqc[:unique_errors]=[]


  #    #Padmassun's Code Start
  csv_file_name ="#{File.dirname(__FILE__)}/necb_2011_spacetype_info.csv"
  puts csv_file_name
  qaqc[:spaces].each do |space|
    building_type =""
    space_type =""
    if space[:space_type_name].include? 'Space Function '
      space_type = (space[:space_type_name].to_s.rpartition('Space Function '))[2].strip
      building_type = 'Space Function'
    elsif space[:space_type_name].include? ' WholeBuilding'
      space_type = (space[:space_type_name].to_s.rpartition(' WholeBuilding'))[0].strip
      building_type = 'WholeBuilding'
    end
    row = look_up_csv_data(csv_file_name,{2 => space_type, 1 => building_type})
    if row.nil?
      #raise ("space type of [#{space_type}] and/or building type of [#{building_type}] was not found in the excel sheet for space: [#{space[:name]}]")
      qaqc[:ruby_warnings] << "space type of [#{space_type}] and/or building type of [#{building_type}] was not found in the excel sheet for space: [#{space[:name]}]"
      puts "space type of [#{space_type}] and/or building type of [#{building_type}] was not found in the excel sheet for space: [#{space[:name]}]"
    else
      #correct the data from the csv file to include a multiplier of 0.9 for specific space types.

      reduceLPDSpaces = ["Classroom/lecture/training", "Conf./meet./multi-purpose", "Lounge/recreation",
        "Washroom-sch-A", "Washroom-sch-B", "Washroom-sch-C", "Washroom-sch-D", "Washroom-sch-E",
        "Washroom-sch-F", "Washroom-sch-G", "Washroom-sch-H", "Washroom-sch-I", "Dress./fitt. - performance arts",
        "Locker room", "Retail - dressing/fitting","Locker room-sch-A","Locker room-sch-B","Locker room-sch-C",
        "Locker room-sch-D","Locker room-sch-E","Locker room-sch-F","Locker room-sch-G","Locker room-sch-H",
        "Locker room-sch-I", "Office - open plan - occsens", "Office - enclosed - occsens", "Storage area - occsens",
        "Hospital - medical supply - occsens", "Storage area - refrigerated - occsens"]

      if reduceLPDSpaces.include?(space_type)
        row[3] = row[3]*0.9
        puts "\n============================\nspace_type: #{space_type}\n============================\n"
      end

      # Start of Space Compliance
      necb_section_name = "NECB2011-Section 8.4.3.6"
      data = {}
      data[:lighting_per_area] 		        = [ row[3],'==',space[:lighting_w_per_m2] , "Table 4.2.1.6"     ,1 ] unless space[:lighting_w_per_m2].nil?
      data[:occupancy_per_area]           = [ row[4],'==',space[:occ_per_m2]        , "Table A-8.4.3.3.1" ,3 ] unless space[:occ_per_m2].nil?
      data[:occupancy_schedule]           = [ row[5],'==',space[:occupancy_schedule], "Table A-8.4.3.3.1" ,nil ] unless space[:occupancy_schedule].nil?
      data[:electric_equipment_per_area]  = [ row[6],'==',space[:electric_w_per_m2] , "Table A-8.4.3.3.1" ,1 ] unless space[:electric_w_per_m2].nil?
      data.each do |key,value|
        #puts key
        necb_section_test(
          qaqc,
          value[0],
          value[1],
          value[2],
          value[3],
          "[SPACE][#{space[:name]}]-[TYPE:][#{space_type}]#{key}",
          value[4]
        )
      end
    end#space Compliance
  end
  #Padmassun's Code End


  # Envelope
  necb_section_name = "NECB2011-Section 3.2.1.4"
  #store hdd in short form
  hdd = qaqc[:geography][:hdd]
  #calculate fdwr based on hdd.
  fdwr = 0
  if hdd < 4000
    fdwr = 0.40
  elsif hdd >= 4000 and hdd <=7000
    fdwr = (2000-0.2 * hdd)/3000
  elsif hdd >7000
    fdwr = 0.20
  end
  #hardset srr to 0.05
  srr = 0.05
  #create table of expected values and results.
  data = {}
  data[:fenestration_to_door_and_window_percentage]  = [ fdwr * 100,qaqc[:envelope][:fdwr].round(3)]
  data[:skylight_to_roof_percentage]  = [  srr * 100,qaqc[:envelope][:srr].round(3)]
  #perform test. result must be less than or equal to.
  data.each {|key,value| necb_section_test(
      qaqc,
      value[0],
      '>=',
      value[1],
      necb_section_name,
      "[ENVELOPE]#{key}",
      1 #padmassun added tollerance
    )
  }

  #Infiltration
  necb_section_name = "NECB2011-Section 8.4.3.6"
  qaqc[:spaces].each do |spaceinfo|
    data = {}
    data[:infiltration_method] 		= [ "Flow/ExteriorArea", spaceinfo[:infiltration_method] , nil ]
    data[:infiltration_flow_per_m2] = [ 0.00025,			 spaceinfo[:infiltration_flow_per_m2], 5 ]
    data.each do |key,value|
      #puts key
      necb_section_test(
        qaqc,
        value[0],
        '==',
        value[1],
        necb_section_name,
        "[SPACE][#{spaceinfo[:name]}]-#{key}",
        value[2]
      )
    end
  end
  #Exterior Opaque
  necb_section_name = "NECB2011-Section 3.2.2.2"
  climate_index = NECB2011.new().get_climate_zone_index(qaqc[:geography][:hdd])
  result_value_index = 6
  round_precision = 3
  data = {}
  data[:ext_wall_conductances]        =  [0.315,0.278,0.247,0.210,0.210,0.183,qaqc[:envelope][:outdoor_walls_average_conductance_w_per_m2_k]] unless qaqc[:envelope][:outdoor_walls_average_conductance_w_per_m2_k].nil?
  data[:ext_roof_conductances]        =  [0.227,0.183,0.183,0.162,0.162,0.142,qaqc[:envelope][:outdoor_roofs_average_conductance_w_per_m2_k]] unless qaqc[:envelope][:outdoor_roofs_average_conductance_w_per_m2_k].nil?
  data[:ext_floor_conductances]       =  [0.227,0.183,0.183,0.162,0.162,0.142,qaqc[:envelope][:outdoor_floors_average_conductance_w_per_m2_k]] unless qaqc[:envelope][:outdoor_floors_average_conductance_w_per_m2_k].nil?

  data.each {|key,value| necb_section_test(
      qaqc,
      value[result_value_index],
      '==',
      value[climate_index],
      necb_section_name,
      "[ENVELOPE]#{key}",
      round_precision
    )
  }
  #Exterior Fenestration
  necb_section_name = "NECB2011-Section 3.2.2.3"
  climate_index = NECB2011.new().get_climate_zone_index(qaqc[:geography][:hdd])
  result_value_index = 6
  round_precision = 3
  data = {}
  data[:ext_window_conductances]      =     [2.400,2.200,2.200,2.200,2.200,1.600,qaqc[:envelope][:windows_average_conductance_w_per_m2_k]] unless qaqc[:envelope][:windows_average_conductance_w_per_m2_k].nil?
  data[:ext_door_conductances]        =     [2.400,2.200,2.200,2.200,2.200,1.600,qaqc[:envelope][:doors_average_conductance_w_per_m2_k]]   unless qaqc[:envelope][:doors_average_conductance_w_per_m2_k].nil?
  data[:ext_overhead_door_conductances] =   [2.400,2.200,2.200,2.200,2.200,1.600,qaqc[:envelope][:overhead_doors_average_conductance_w_per_m2_k]] unless qaqc[:envelope][:overhead_doors_average_conductance_w_per_m2_k].nil?
  data[:ext_skylight_conductances]  =       [2.400,2.200,2.200,2.200,2.200,1.600,qaqc[:envelope][:skylights_average_conductance_w_per_m2_k]] unless qaqc[:envelope][:skylights_average_conductance_w_per_m2_k].nil?
  data.each do |key,value|

    #puts key
    necb_section_test(
      qaqc,
      value[result_value_index].round(round_precision),
      '==',
      value[climate_index].round(round_precision),
      necb_section_name,
      "[ENVELOPE]#{key}",
      round_precision
    )
  end
  #Exterior Ground surfaces
  necb_section_name = "NECB2011-Section 3.2.3.1"
  climate_index = NECB2011.new().get_climate_zone_index(qaqc[:geography][:hdd])
  result_value_index = 6
  round_precision = 3
  data = {}
  data[:ground_wall_conductances]  = [ 0.568,0.379,0.284,0.284,0.284,0.210, qaqc[:envelope][:ground_walls_average_conductance_w_per_m2_k] ]  unless qaqc[:envelope][:ground_walls_average_conductance_w_per_m2_k].nil?
  data[:ground_roof_conductances]  = [ 0.568,0.379,0.284,0.284,0.284,0.210, qaqc[:envelope][:ground_roofs_average_conductance_w_per_m2_k] ]  unless qaqc[:envelope][:ground_roofs_average_conductance_w_per_m2_k].nil?
  data[:ground_floor_conductances] = [ 0.757,0.757,0.757,0.757,0.757,0.379, qaqc[:envelope][:ground_floors_average_conductance_w_per_m2_k] ] unless qaqc[:envelope][:ground_floors_average_conductance_w_per_m2_k].nil?
  data.each {|key,value| necb_section_test(
      qaqc,
      value[result_value_index],
      '==',
      value[climate_index],
      necb_section_name,
      "[ENVELOPE]#{key}",
      round_precision
    )
  }
  #Zone Sizing and design supply temp tests
  necb_section_name = "NECB2011-?"
  qaqc[:thermal_zones].each do |zoneinfo|
    #    skipping undefined schedules
    if zoneinfo[:name].to_s.include?"- undefined -"
      next
    end
    data = {}
    data[:heating_sizing_factor] = [1.3 , zoneinfo[:heating_sizing_factor]]
    data[:cooling_sizing_factor] = [1.1 ,zoneinfo[:cooling_sizing_factor]]
    data[:heating_design_supply_air_temp] =   [43.0, zoneinfo[:zone_heating_design_supply_air_temperature] ] #unless zoneinfo[:zone_heating_design_supply_air_temperature].nil?
    data[:cooling_design_supply_temp] 	=   [13.0, zoneinfo[:zone_cooling_design_supply_air_temperature] ]
    data.each do |key,value|
      #puts key
      necb_section_test(
        qaqc,
        value[0],
        '==',
        value[1],
        necb_section_name,
        "[ZONE][#{zoneinfo[:name]}] #{key}",
        round_precision
      )
    end
  end
  #Air flow sizing check
  #determine correct economizer usage according to section 5.2.2.7 of NECB2011
  necb_section_name = "NECB2011-5.2.2.7"
  qaqc[:air_loops].each do |air_loop_info|
    #    air_loop_info[:name]
    #    air_loop_info[:thermal_zones]
    #    air_loop_info[:total_floor_area_served]
    #    air_loop_info[:cooling_coils][:dx_single_speed]
    #    air_loop_info[:cooling_coils][:dx_two_speed]
    #    air_loop_info[:supply_fan][:max_air_flow_rate]
    #
    #    air_loop_info[:heating_coils][:coil_heating_gas][:nominal_capacity]
    #    air_loop_info[:heating_coils][:coil_heating_electric][:nominal_capacity]
    #    air_loop_info[:heating_coils][:coil_heating_water][:nominal_capacity]
    #
    #    air_loop_info[:economizer][:control_type]

    capacity = -1.0

    if !air_loop_info[:cooling_coils][:dx_single_speed][0].nil?
      puts "air_loop_info[:heating_coils][:coil_heating_gas][0][:nominal_capacity]"
      capacity = air_loop_info[:cooling_coils][:dx_single_speed][0][:nominal_total_capacity_w]
    elsif !air_loop_info[:cooling_coils][:dx_two_speed][0].nil?
      puts "capacity = air_loop_info[:heating_coils][:coil_heating_electric]"
      capacity = air_loop_info[:cooling_coils][:dx_two_speed][0][:cop_high]
    end
    puts capacity
    if capacity == -1.0
      #This should not happen
      puts "air_loop_info[:heating_coils] does not have a capacity or the type is not gas/electric/water for #{air_loop_info[:name]}"
    else
      #check for correct economizer usage
      puts "air_loop_info[:supply_fan][:max_air_flow_rate]: #{air_loop_info[:supply_fan][:max_air_flow_rate]}"
      unless air_loop_info[:supply_fan][:max_air_flow_rate_m3_per_s] == -1.0
        #capacity should be in kW
        if capacity > 20000 or air_loop_info[:supply_fan][:max_air_flow_rate_m3_per_s]*1000 >1500
          #diff enth
          #puts "diff"
          necb_section_test(
            qaqc,
            "DifferentialEnthalpy",
            '==',
            air_loop_info[:economizer][:control_type],
            necb_section_name,
            "[AIR LOOP][#{air_loop_info[:name]}][:economizer][:control_type]"
          )
        else
          #no economizer
          #puts "no econ"
          necb_section_test(
            qaqc,
            'NoEconomizer',
            '==',
            air_loop_info[:economizer][:control_type],
            necb_section_name,
            "[AIR LOOP][#{air_loop_info[:name]}][:economizer][:control_type]"
          )
        end
      end
    end
  end

  # @todo ?
  necb_section_name = "NECB2011-5.2.10.1"
  qaqc[:air_loops].each do |air_loop_info|
    unless air_loop_info[:supply_fan][:max_air_flow_rate_m3_per_s] == -1.0
      weather_file_path = model.weatherFile.get.path.get.to_s
      stat_file_path = weather_file_path.gsub('.epw', '.stat')
      stat_file = OpenstudioStandards::Weather::StatFile.new(stat_file_path)
      db990 = stat_file.heating_design_info[2]
      hrv_calc = 0.00123 * air_loop_info[:outdoor_air_L_per_s] * (21 - db990) #=AP46*(21-O$1)
      hrv_reqd = hrv_calc > 150 ? true : false
      #qaqc[:information] << "[Info][TEST-PASS][#{necb_section_name}]:#{test_text} result value:#{result_value} #{bool_operator} expected value:#{expected_value}"
      hrv_present = false
      unless air_loop_info[:heat_exchanger].empty?
        hrv_present = true
      end
      necb_section_test(
        qaqc,
        hrv_reqd,
        '==',
        hrv_present,
        necb_section_name,
        "[AIR LOOP][:heat_exchanger] for [#{air_loop_info[:name]}] is present?"
      )

    end
  end

  necb_section_name = "NECB2011-5.2.3.3"
  qaqc[:air_loops].each do |air_loop_info|
    #necb_clg_cop = air_loop_info[:cooling_coils][:dx_single_speed][:cop] #*assuming that the cop is defined correctly*
    if air_loop_info[:supply_fan][:max_air_flow_rate_m3_per_s].nil?
      qaqc[:ruby_warnings] << "air_loop_info[:supply_fan][:max_air_flow_rate_m3_per_s] is nil"
      next
    end
    necb_supply_fan_w = (air_loop_info[:supply_fan][:max_air_flow_rate_m3_per_s]*1000*1.6).round(2)

    if air_loop_info[:name].include? "PSZ"
      necb_supply_fan_w = (air_loop_info[:supply_fan][:max_air_flow_rate_m3_per_s]*1000*1.6).round(2)
    elsif air_loop_info[:name].include? "VAV"
      necb_supply_fan_w = (air_loop_info[:supply_fan][:max_air_flow_rate_m3_per_s]*1000*2.65).round(2)
    end

    if air_loop_info[:supply_fan][:rated_electric_power_w].nil?
      qaqc[:ruby_warnings] << "air_loop_info[:supply_fan][:rated_electric_power_w] is nil"
      next
    end

    supply_fan_w = (air_loop_info[:supply_fan][:rated_electric_power_w]).round(3)
    absolute_diff = (necb_supply_fan_w - supply_fan_w).to_f.abs
    if absolute_diff < 10
      #This case should ALWAYS PASS
      necb_section_test(
        qaqc,
        10,
        '>=',
        absolute_diff,
        necb_section_name,
        "[AIR LOOP][#{air_loop_info[:name]}][:supply_fan][:rated_electric_power_w] [#{supply_fan_w}] Absolute Difference from NECB value [#{necb_supply_fan_w}]"
      )
      next
    else
      #The test should pass if and only if the percent difference is less than 10%
      percent_diff = ((necb_supply_fan_w - supply_fan_w).to_f.abs/necb_supply_fan_w * 100).round(3)
      necb_section_test(
        qaqc,
        10,
        '>=',
        percent_diff,
        necb_section_name,
        "[AIR LOOP][#{air_loop_info[:name]}][:supply_fan][:rated_electric_power_w] [#{supply_fan_w}] Percent Diff from NECB value [#{necb_supply_fan_w}]"
      )
    end
  end

  necb_section_name = "SANITY-??"
  qaqc[:plant_loops].each do |plant_loop_info|
    pump_head = plant_loop_info[:pumps][0][:head_pa]
    flow_rate = plant_loop_info[:pumps][0][:water_flow_m3_per_s]*1000
    hp_check = ((flow_rate*60*60)/1000*1000*9.81*pump_head*0.000101997)/3600000
    puts "\npump_head #{pump_head}"
    puts "name: #{qaqc[:building][:name]}"
    puts "name: #{plant_loop_info[:name]}"
    puts "flow_rate #{flow_rate}"
    puts "hp_check #{hp_check}\n"
    pump_power_hp = plant_loop_info[:pumps][0][:electric_power_w]/1000*0.746
    percent_diff = (hp_check - pump_power_hp).to_f.abs/hp_check * 100

    if percent_diff.nan?
      qaqc[:ruby_warnings] << "(hp_check - pump_power_hp).to_f.abs/hp_check * 100 for #{plant_loop_info[:name]} is NaN"
      next
    end

    necb_section_test(
      qaqc,
      20, #diff of 20%
      '>=',
      percent_diff,
      necb_section_name,
      "[PLANT LOOP][#{plant_loop_info[:name]}][:pumps][0][:electric_power_hp] [#{pump_power_hp}] Percent Diff from NECB value [#{hp_check}]"
    )

  end
end

#necb_section_test(qaqc, result_value, bool_operator, expected_value, necb_section_name, test_text, tolerance = nil) ⇒ Object



695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/openstudio-standards/btap/btap_result.rb', line 695

def necb_section_test(qaqc,result_value,bool_operator,expected_value,necb_section_name,test_text,tolerance = nil)
  test = "eval_failed"
  command = ''
  if tolerance.is_a?(Integer)
    command = "#{result_value}.round(#{tolerance}) #{bool_operator} #{expected_value}.round(#{tolerance})"
  elsif expected_value.is_a?(String) and result_value.is_a?(String)
    command = "'#{result_value}' #{bool_operator} '#{expected_value}'"
  else
    command = "#{result_value} #{bool_operator} #{expected_value}"
  end
  test = eval(command)
  test == 'true' ? true :false
  raise ("Eval command failed #{test}") if !!test != test
  if test
    qaqc[:information] << "[Info][TEST-PASS][#{necb_section_name}]:#{test_text} result value:#{result_value} #{bool_operator} expected value:#{expected_value}"
  else
    qaqc[:errors] << "[ERROR][TEST-FAIL][#{necb_section_name}]:#{test_text} expected value:#{expected_value} #{bool_operator} result value:#{result_value}"
    unless (expected_value == -1.0 or expected_value == 'N/A')
      qaqc[:unique_errors] << "[ERROR][TEST-FAIL][#{necb_section_name}]:#{test_text} expected value:#{expected_value} #{bool_operator} result value:#{result_value}"
    end
  end
end

#prm_get_component_name(component) ⇒ String

This is a PRM handler to get a name from an OpenStudio object instance If the object instance does not have a name, then it will return the object name.

Parameters:

  • component (OpenStudio::Model:Component)

    an OpenStudio object

Returns:

  • (String)

    the name of the instance or object name



51
52
53
54
55
56
57
58
59
# File 'lib/openstudio-standards/utilities/assertion.rb', line 51

def prm_get_component_name(component)
  return 'Model' if component.is_a?(OpenStudio::Model::Model)

  name = component.iddObjectType.valueName.to_s
  if component.name.is_initialized
    name = component.name.get
  end
  return name
end

#prm_get_optional_handler(component, log_dir, data_key, *remaining_keys) ⇒ OpenStudio::Model::Component

This is a PRM handler function handles the .get from an optional object The handler will try to access the OpenStudio Object data key And do it recursively until all the keys have been checked and final object get or raise exception for non_initialized objects.

Parameters:

  • component (OpenStudio::Model::Component)

    an OpenStudio object

  • log_dir (string)

    directory to save the log

  • data_key (string)

    The data key to retrieve the data from the OpenStudio object

  • remaining_keys (str)

    Any additional keys in the path

Returns:

  • (OpenStudio::Model::Component)

    the OpenStudio Object or exception raise



39
40
41
42
43
44
# File 'lib/openstudio-standards/utilities/assertion.rb', line 39

def prm_get_optional_handler(component, log_dir, data_key, *remaining_keys)
  target_data = component.send(data_key)
  prm_raise(target_data.is_initialized, log_dir, "Failed to retrieve data: #{data_key} from #{prm_get_component_name(component)}")
  target_data_get = target_data.get
  return remaining_keys.empty? ? target_data_get : prm_get_optional_handler(target_data_get, log_dir, remaining_keys[0], *remaining_keys[1...])
end

#prm_raise(bool, log_dir, err_msg) ⇒ Object

PRM assertion method Raise assertion if the test (bool) is failed

Before raise the exception, the method will generate the prm.log for debugging

Parameters:

  • bool (Boolean, Object)

    an object for truthy evaluation

  • log_dir (String)

    log file directory

  • err_msg (String)

    message raise the exception



12
13
14
15
16
17
18
# File 'lib/openstudio-standards/utilities/assertion.rb', line 12

def prm_raise(bool, log_dir, err_msg)
  unless bool
    # OpenStudio.logFree(OpenStudio::Debug, 'prm.log', log_msg)
    log_messages_to_file_prm("#{log_dir}/prm.log", true)
    raise PRMError, "#{err_msg} - Check debug log at #{log_dir}/prm.log for more information"
  end
end

#prm_read_user_data(user_data, key, default = nil) ⇒ String

PRM reading function reads user data from a hash map. Handles key existence, value is nil and value string is empty

Parameters:

  • user_data (Hash)

    a hash contains a user data

  • key (String)

    key string

  • default (Object) (defaults to: nil)

    values assigned if the data is not available.

Returns:



26
27
28
# File 'lib/openstudio-standards/utilities/assertion.rb', line 26

def prm_read_user_data(user_data, key, default = nil)
  return user_data.key?(key) && !user_data[key].nil? && !user_data[key].to_s.empty? ? user_data[key] : default
end

#read_space_typesObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/openstudio-standards/btap/utilities/space_type.rb', line 13

def read_space_types()
  path = "/home/osdev/openstudio-standards/lib/openstudio-standards/standards/necb/NECB2011/data/geometry/DND*.osm"
  spacetype_list = []
  Dir.glob(path) do |osm_file|
    model = BTAP::FileIO::load_osm(osm_file)
    standard = NECB2011.new()
    model.getSpaces.each do |space|
      unless space.spaceType.empty?
        name = space.spaceType.get.name.get
        bt = space.spaceType.get.standardsBuildingType.get unless space.spaceType.get.standardsBuildingType.empty?
        st = space.spaceType.get.standardsSpaceType.get unless space.spaceType.get.standardsSpaceType.empty?
        spacetype_list << {'name': name, 'Original-StandardsBuildingType': bt, 'Original-StandardSpaceType': st}

      end
    end

  end
  unique_list = spacetype_list.uniq.sort_by { |st| st[:name] }


  CSV.open("data.csv", "wb") do |csv|
    csv << unique_list.first.keys # adds the attributes name on the first line
    unique_list.each do |hash|
      csv << hash.values
    end
  end

  standard_space_type_list = Standard.build('NECB2011').standards_data['space_types'].map { |space_types| {'building_type': space_types['building_type'],
                                                                                                           'space_type': space_types['space_type'],
                                                                                                           "necb_hvac_system_selection_type": space_types['necb_hvac_system_selection_type'],
                                                                                                           "necb_schedule_type": space_types['necb_schedule_type']


  } }
  standards_space_type_list.s

  CSV.open("spacetypes.csv", "wb") do |csv|
    csv << standard_space_type_list.first.keys # adds the attributes name on the first line
    standard_space_type_list.each do |hash|
      csv << hash.values
    end
  end
end

#remove_meta_class_fileObject



900
901
902
903
# File 'lib/openstudio-standards/prototypes/common/prototype_metaprogramming.rb', line 900

def remove_meta_class_file
  filepath = "#{File.dirname(__FILE__)}/do_not_edit_metaclasses.rb"
  FileUtils.rm(filepath)
end

#report_path(test_name) ⇒ Object



23
24
25
# File 'lib/openstudio-standards/btap/utilities/convert_surfaces_to_adiabatic_necb_8426.rb', line 23

def report_path(test_name)
  "#{run_dir(test_name)}/report.html"
end

#reset_logObject

resets the log



165
166
167
# File 'lib/openstudio-standards/utilities/logging.rb', line 165

def reset_log
  $OPENSTUDIO_LOG.resetStringStream
end

#run_dir(test_name) ⇒ Object



6
7
8
9
# File 'lib/openstudio-standards/btap/utilities/convert_surfaces_to_adiabatic_necb_8426.rb', line 6

def run_dir(test_name)
  # always generate test output in specially named 'output' directory so result files are not made part of the measure
  "#{File.dirname(__FILE__)}/output/#{test_name}"
end

#sanity_check(qaqc) ⇒ Object



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

def sanity_check(qaqc)
  qaqc[:sanity_check] = {}
  qaqc[:sanity_check][:fail] = []
  qaqc[:sanity_check][:pass] = []
  #Padmassun's code for isConditioned start
  qaqc[:thermal_zones].each do |zoneinfo|
    zoneinfo[:spaces].each do |space|
      #skip plenums and undefined spaces/zones
      if zoneinfo[:name].to_s.include?"- undefined -"
        next
      end
      if zoneinfo[:space_type_name].to_s.include?"Space Function - undefined -"
        if zoneinfo[:is_conditioned].to_s == "No"
          qaqc[:sanity_check][:pass] << "[TEST-PASS][SANITY_CHECK-PASS] for [SPACE][#{space[:name]}] and [THERMAL ZONE] [#{zoneinfo[:name]}] where isConditioned is supposed to be [""No""] and found as #{zoneinfo[:is_conditioned]}"
        else
          qaqc[:sanity_check][:fail] << "[ERROR][SANITY_CHECK-FAIL] for [SPACE][#{space[:name]}] and [THERMAL ZONE] [#{zoneinfo[:name]}] where isConditioned is supposed to be [""No""] but found as #{zoneinfo[:is_conditioned]}"
        end
      else
        if zoneinfo[:is_conditioned].to_s == "Yes"
          qaqc[:sanity_check][:pass] << "[TEST-PASS][SANITY_CHECK-PASS] for [SPACE][#{space[:name]}] and [THERMAL ZONE] [#{zoneinfo[:name]}] where isConditioned is supposed to be [""Yes""] and found as #{zoneinfo[:is_conditioned]}"
        elsif zoneinfo[:name]
          qaqc[:sanity_check][:fail] << "[ERROR][SANITY_CHECK-FAIL] for [SPACE][#{space[:name]}] and [THERMAL ZONE] [#{zoneinfo[:name]}] where isConditioned is supposed to be [""Yes""] but found as #{zoneinfo[:is_conditioned]}"
        end
      end
    end
  end
  qaqc[:sanity_check][:fail] = qaqc[:sanity_check][:fail].sort
  qaqc[:sanity_check][:pass] = qaqc[:sanity_check][:pass].sort
  #Padmassun's code for isConditioned end
end

#save_meta_classes_to_fileObject



895
896
897
898
# File 'lib/openstudio-standards/prototypes/common/prototype_metaprogramming.rb', line 895

def save_meta_classes_to_file
  filepath = "#{File.dirname(__FILE__)}/do_not_edit_metaclasses.rb"
  File.open(filepath, 'w') { |f| create_class_array.each { |item| f << item } }
end

#sql_path(test_name) ⇒ Object



19
20
21
# File 'lib/openstudio-standards/btap/utilities/convert_surfaces_to_adiabatic_necb_8426.rb', line 19

def sql_path(test_name)
  "#{run_dir(test_name)}/ModelToIdf/EnergyPlusPreProcess-0/EnergyPlus-0/eplusout.sql"
end

#terminate_prm_write_log(msg, log_path, debug = false) ⇒ Object

A function that writes error message to log file and stop the execution.

Parameters:

  • msg (String)

    error message

  • log_path (String)

    the log file directory

  • debug (Boolean) (defaults to: false)

    debug mode



44
45
46
47
48
# File 'lib/openstudio-standards/utilities/logging.rb', line 44

def terminate_prm_write_log(msg, log_path, debug = false)
  OpenStudio.logFree(OpenStudio::Error, 'prm.log', msg)
  log_messages_to_file_prm("#{log_path}/prm.log", debug)
  raise msg
end

#validate_optional(var, model, return_value = "N/A") ⇒ Object



654
655
656
657
658
659
660
# File 'lib/openstudio-standards/btap/btap_result.rb', line 654

def validate_optional (var, model, return_value = "N/A")
  if var.empty?
    return return_value
  else
    return var.get
  end
end

#workspace_path(test_name) ⇒ Object



15
16
17
# File 'lib/openstudio-standards/btap/utilities/convert_surfaces_to_adiabatic_necb_8426.rb', line 15

def workspace_path(test_name)
  "#{run_dir(test_name)}/ModelToIdf/in.idf"
end