class NECB2017

This class holds methods that apply NECB2017 rules. @ref [References::NECB2017]

Public Class Methods

new() click to toggle source
Calls superclass method NECB2015::new
# File lib/openstudio-standards/standards/necb/NECB2017/necb_2017.rb, line 7
def initialize
  super()
  @standards_data = load_standards_database_new
  corrupt_standards_database
end

Public Instance Methods

air_loop_hvac_energy_recovery_ventilator_required?(air_loop_hvac, climate_zone) click to toggle source

Check if ERV is required on this airloop.

@return [Boolean] Returns true if required, false if not.

# File lib/openstudio-standards/standards/necb/NECB2017/hvac_systems.rb, line 5
def air_loop_hvac_energy_recovery_ventilator_required?(air_loop_hvac, climate_zone)
  erv_required = nil

  # ERV Not Applicable for AHUs that have no OA intake.
  oa_system = nil
  controller_oa = nil
  if air_loop_hvac.airLoopHVACOutdoorAirSystem.is_initialized
    oa_system = air_loop_hvac.airLoopHVACOutdoorAirSystem.get
    controller_oa = oa_system.getControllerOutdoorAir
  else
    OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name}, ERV not applicable because it has no OA intake.")
    return false
  end

  # Get the AHU design supply air flow rate
  dsn_flow_m3_per_s = nil
  if air_loop_hvac.designSupplyAirFlowRate.is_initialized
    dsn_flow_m3_per_s = air_loop_hvac.designSupplyAirFlowRate.get
  elsif air_loop_hvac.autosizedDesignSupplyAirFlowRate.is_initialized
    dsn_flow_m3_per_s = air_loop_hvac.autosizedDesignSupplyAirFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{air_loop_hvac.name} design supply air flow rate is not available, cannot apply efficiency standard.")
    return false
  end

  # Get the minimum OA flow rate
  min_oa_flow_m3_per_s = nil
  if controller_oa.minimumOutdoorAirFlowRate.is_initialized
    min_oa_flow_m3_per_s = controller_oa.minimumOutdoorAirFlowRate.get
  elsif controller_oa.autosizedMinimumOutdoorAirFlowRate.is_initialized
    min_oa_flow_m3_per_s = controller_oa.autosizedMinimumOutdoorAirFlowRate.get
  else
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.AirLoopHVAC', "For #{controller_oa.name}: minimum OA flow rate is not available, cannot apply efficiency standard.")
    return false
  end

  weather_file_path = air_loop_hvac.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)
  hdd = stat_file.hdd18
  flow = min_oa_flow_m3_per_s
  oaf = min_oa_flow_m3_per_s / dsn_flow_m3_per_s
  erv_required = eval(get_standards_formula('heat_recovery_requirement_formula'))

  return erv_required
end
load_standards_database_new() click to toggle source
Calls superclass method NECB2015#load_standards_database_new
# File lib/openstudio-standards/standards/necb/NECB2017/necb_2017.rb, line 13
def load_standards_database_new
  # load NECB2011 data.
  super()

  if __dir__[0] == ':' # Running from OpenStudio CLI
    embedded_files_relative('data/', /.*\.json/).each do |file|
      data = JSON.parse(EmbeddedScripting.getFileAsString(file))
      if !data['tables'].nil?
        @standards_data['tables'] = [*@standards_data['tables'], *data['tables']].to_h
      elsif !data['constants'].nil?
        @standards_data['constants'] = [*@standards_data['constants'], *data['constants']].to_h
      elsif !data['constants'].nil?
        @standards_data['formulas'] = [*@standards_data['formulas'], *data['formulas']].to_h
      end
    end
  else
    files = Dir.glob("#{File.dirname(__FILE__)}/data/*.json").select { |e| File.file? e }
    files.each do |file|
      data = JSON.parse(File.read(file))
      if !data['tables'].nil?
        @standards_data['tables'] = [*@standards_data['tables'], *data['tables']].to_h
      elsif !data['constants'].nil?
        @standards_data['constants'] = [*@standards_data['constants'], *data['constants']].to_h
      elsif !data['formulas'].nil?
        @standards_data['formulas'] = [*@standards_data['formulas'], *data['formulas']].to_h
      end
    end
  end
  # Write test report file.
  # Write database to file.
  # File.open(File.join(File.dirname(__FILE__), '..', 'NECB2017.json'), 'w') {|f| f.write(JSON.pretty_generate(@standards_data))}
  return @standards_data
end
set_lighting_per_area_led_lighting(space_type:, definition:, lighting_per_area_led_lighting:, lights_scale:) click to toggle source
# File lib/openstudio-standards/standards/necb/NECB2017/necb_2017.rb, line 47
def set_lighting_per_area_led_lighting(space_type:, definition:, lighting_per_area_led_lighting:, lights_scale:)
  # puts "#{space_type.name.to_s} - 'space_height' - #{space_height.to_s}"
  # @todo Note that 'occ_sens_lpd_frac' in this function has been removed for NECB2015 and 2017.
  # ##### Since Atrium's LPD for LED lighting depends on atrium's height, the height of the atrium (if applicable) should be found.
  standards_space_type = space_type.standardsSpaceType.is_initialized ? space_type.standardsSpaceType.get : nil # Sara
  if standards_space_type.include? 'Atrium' # @todo Note that since none of the archetypes has Atrium, this was tested for 'Dining'. #Atrium
    puts "#{standards_space_type} - has atrium" # space_type.name.to_s
    # puts space_height
    if get_max_space_height_for_space_type(space_type: space_type) < 12.0
      # @todo Regarding the below equations, identify which version of ASHRAE 90.1 was used in NECB2017.
      atrium_lpd_eq_smaller_12_intercept = 0
      atrium_lpd_eq_smaller_12_slope = 1.06
      atrium_lpd_eq_larger_12_intercept = 4.3
      atrium_lpd_eq_larger_12_slope = 0.71
      lighting_per_area_led_lighting_atrium = (atrium_lpd_eq_smaller_12_intercept + atrium_lpd_eq_smaller_12_slope * space_height) * 0.092903 # W/ft2
    else # i.e. get_max_space_height_for_space_type >= 12.0
      lighting_per_area_led_lighting_atrium = (atrium_lpd_eq_larger_12_intercept + atrium_lpd_eq_larger_12_slope * space_height) * 0.092903 # W/ft2
    end
    puts "#{standards_space_type} - has lighting_per_area_led_lighting_atrium - #{lighting_per_area_led_lighting_atrium}"
    lighting_per_area_led_lighting = lighting_per_area_led_lighting_atrium
  end
  lighting_per_area_led_lighting *= lights_scale

  definition.setWattsperSpaceFloorArea(OpenStudio.convert(lighting_per_area_led_lighting.to_f, 'W/ft^2', 'W/m^2').get)

  OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set LPD to #{lighting_per_area_led_lighting} W/ft^2.")
end