Skip to content

Commit

Permalink
Merge pull request #710 from NREL/ansi_301_2022_lighting_appl
Browse files Browse the repository at this point in the history
ANSI 301-2022: load profile schedules
  • Loading branch information
shorowit authored Feb 7, 2024
2 parents 67f1c43 + 9fbd169 commit 35d0c3a
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rulesets/tests/test_appliances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ def _check_clothes_washer(hpxml_bldg, mef:, imef:, annual_kwh:, elec_rate:, gas_
assert_in_epsilon(agc, clothes_washer.label_annual_gas_cost, 0.01)
assert_in_epsilon(cap, clothes_washer.capacity, 0.01)
assert_in_epsilon(label_usage, clothes_washer.label_usage, 0.01)
assert_equal('0.009, 0.007, 0.004, 0.004, 0.007, 0.011, 0.022, 0.049, 0.073, 0.086, 0.084, 0.075, 0.067, 0.060, 0.049, 0.051, 0.050, 0.049, 0.049, 0.049, 0.049, 0.047, 0.032, 0.017', clothes_washer.weekday_fractions)
assert_equal('0.009, 0.007, 0.004, 0.004, 0.007, 0.011, 0.022, 0.049, 0.073, 0.086, 0.084, 0.075, 0.067, 0.060, 0.049, 0.051, 0.050, 0.049, 0.049, 0.049, 0.049, 0.047, 0.032, 0.017', clothes_washer.weekend_fractions)
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', clothes_washer.monthly_multipliers)
end

def _check_clothes_dryer(hpxml_bldg, fuel_type:, ef:, cef:, control: nil, location:)
Expand All @@ -367,6 +370,9 @@ def _check_clothes_dryer(hpxml_bldg, fuel_type:, ef:, cef:, control: nil, locati
end
assert_equal(true, clothes_dryer.is_vented)
assert_equal(0.0, clothes_dryer.vented_flow_rate)
assert_equal('0.010, 0.006, 0.004, 0.002, 0.004, 0.006, 0.016, 0.032, 0.048, 0.068, 0.078, 0.081, 0.074, 0.067, 0.058, 0.061, 0.055, 0.054, 0.051, 0.051, 0.052, 0.054, 0.044, 0.024', clothes_dryer.weekday_fractions)
assert_equal('0.010, 0.006, 0.004, 0.002, 0.004, 0.006, 0.016, 0.032, 0.048, 0.068, 0.078, 0.081, 0.074, 0.067, 0.058, 0.061, 0.055, 0.054, 0.051, 0.051, 0.052, 0.054, 0.044, 0.024', clothes_dryer.weekend_fractions)
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', clothes_dryer.monthly_multipliers)
end

def _check_dishwasher(hpxml_bldg, ef:, annual_kwh:, cap:, elec_rate:, gas_rate:, agc:, label_usage:, location:)
Expand All @@ -388,13 +394,21 @@ def _check_dishwasher(hpxml_bldg, ef:, annual_kwh:, cap:, elec_rate:, gas_rate:,
assert_in_epsilon(gas_rate, dishwasher.label_gas_rate, 0.01)
assert_in_epsilon(agc, dishwasher.label_annual_gas_cost, 0.01)
assert_in_epsilon(label_usage, dishwasher.label_usage, 0.01)
assert_equal('0.015, 0.007, 0.005, 0.003, 0.003, 0.010, 0.020, 0.031, 0.058, 0.065, 0.056, 0.048, 0.042, 0.046, 0.036, 0.038, 0.038, 0.049, 0.087, 0.111, 0.090, 0.067, 0.044, 0.031', dishwasher.weekday_fractions)
assert_equal('0.015, 0.007, 0.005, 0.003, 0.003, 0.010, 0.020, 0.031, 0.058, 0.065, 0.056, 0.048, 0.042, 0.046, 0.036, 0.038, 0.038, 0.049, 0.087, 0.111, 0.090, 0.067, 0.044, 0.031', dishwasher.weekend_fractions)
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', dishwasher.monthly_multipliers)
end

def _check_refrigerator(hpxml_bldg, annual_kwh:, location:)
assert_equal(1, hpxml_bldg.refrigerators.size)
refrigerator = hpxml_bldg.refrigerators[0]
assert_equal(location, refrigerator.location)
assert_equal(annual_kwh, refrigerator.rated_annual_kwh)
assert_nil(refrigerator.weekday_fractions)
assert_nil(refrigerator.weekend_fractions)
assert_nil(refrigerator.monthly_multipliers)
assert_equal('-0.487, -0.340, -0.370, -0.361, -0.515, -0.684, -0.471, -0.159, -0.079, -0.417, -0.411, -0.386, -0.240, -0.314, -0.160, -0.121, -0.469, -0.412, -0.091, 0.077, -0.118, -0.247, -0.445, -0.544', refrigerator.constant_coefficients)
assert_equal('0.019, 0.016, 0.017, 0.016, 0.018, 0.021, 0.019, 0.015, 0.015, 0.019, 0.018, 0.018, 0.016, 0.017, 0.015, 0.015, 0.020, 0.020, 0.017, 0.014, 0.016, 0.017, 0.019, 0.020', refrigerator.temperature_coefficients)
end

def _check_cooking_range(hpxml_bldg, fuel_type:, cook_is_induction:, oven_is_convection:, location:)
Expand All @@ -403,6 +417,9 @@ def _check_cooking_range(hpxml_bldg, fuel_type:, cook_is_induction:, oven_is_con
assert_equal(location, cooking_range.location)
assert_equal(fuel_type, cooking_range.fuel_type)
assert_equal(cook_is_induction, cooking_range.is_induction)
assert_equal('0.008, 0.008, 0.008, 0.008, 0.008, 0.015, 0.023, 0.039, 0.046, 0.046, 0.046, 0.054, 0.062, 0.046, 0.039, 0.054, 0.076, 0.134, 0.114, 0.058, 0.039, 0.031, 0.023, 0.015', cooking_range.weekday_fractions)
assert_equal('0.008, 0.008, 0.008, 0.008, 0.008, 0.015, 0.023, 0.039, 0.046, 0.046, 0.046, 0.054, 0.062, 0.046, 0.039, 0.054, 0.076, 0.134, 0.114, 0.058, 0.039, 0.031, 0.023, 0.015', cooking_range.weekend_fractions)
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', cooking_range.monthly_multipliers)
assert_equal(1, hpxml_bldg.ovens.size)
oven = hpxml_bldg.ovens[0]
assert_equal(oven_is_convection, oven.is_convection)
Expand Down
18 changes: 18 additions & 0 deletions rulesets/tests/test_lighting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ def _check_lighting(hpxml_bldg, f_int_cfl: nil, f_ext_cfl: nil, f_grg_cfl: nil,
assert_in_epsilon(f_grg_led, lg.fraction_of_units_in_location, 0.01)
end
end

assert_equal('0.012, 0.010, 0.010, 0.010, 0.011, 0.018, 0.030, 0.038, 0.041, 0.041, 0.039, 0.037, 0.036, 0.035, 0.037, 0.041, 0.050, 0.065, 0.086, 0.106, 0.110, 0.079, 0.040, 0.018', hpxml_bldg.lighting.interior_weekday_fractions)
assert_equal('0.012, 0.010, 0.010, 0.010, 0.011, 0.018, 0.030, 0.038, 0.041, 0.041, 0.039, 0.037, 0.036, 0.035, 0.037, 0.041, 0.050, 0.065, 0.086, 0.106, 0.110, 0.079, 0.040, 0.018', hpxml_bldg.lighting.interior_weekend_fractions)
assert_equal('1.19, 1.11, 1.02, 0.93, 0.84, 0.80, 0.82, 0.88, 0.98, 1.07, 1.16, 1.20', hpxml_bldg.lighting.interior_monthly_multipliers)
assert_equal('0.040, 0.037, 0.037, 0.035, 0.035, 0.039, 0.044, 0.041, 0.031, 0.025, 0.024, 0.024, 0.025, 0.028, 0.030, 0.035, 0.044, 0.056, 0.064, 0.068, 0.070, 0.065, 0.056, 0.047', hpxml_bldg.lighting.exterior_weekday_fractions)
assert_equal('0.040, 0.037, 0.037, 0.035, 0.035, 0.039, 0.044, 0.041, 0.031, 0.025, 0.024, 0.024, 0.025, 0.028, 0.030, 0.035, 0.044, 0.056, 0.064, 0.068, 0.070, 0.065, 0.056, 0.047', hpxml_bldg.lighting.exterior_weekend_fractions)
assert_equal('1.19, 1.11, 1.02, 0.93, 0.84, 0.80, 0.82, 0.88, 0.98, 1.07, 1.16, 1.20', hpxml_bldg.lighting.exterior_monthly_multipliers)
if hpxml_bldg.has_location(HPXML::LocationGarage)
assert_equal('0.023, 0.019, 0.015, 0.017, 0.021, 0.031, 0.042, 0.041, 0.034, 0.029, 0.027, 0.025, 0.021, 0.021, 0.021, 0.026, 0.031, 0.044, 0.084, 0.117, 0.113, 0.096, 0.063, 0.039', hpxml_bldg.lighting.garage_weekday_fractions)
assert_equal('0.023, 0.019, 0.015, 0.017, 0.021, 0.031, 0.042, 0.041, 0.034, 0.029, 0.027, 0.025, 0.021, 0.021, 0.021, 0.026, 0.031, 0.044, 0.084, 0.117, 0.113, 0.096, 0.063, 0.039', hpxml_bldg.lighting.garage_weekend_fractions)
assert_equal('1.19, 1.11, 1.02, 0.93, 0.84, 0.80, 0.82, 0.88, 0.98, 1.07, 1.16, 1.20', hpxml_bldg.lighting.garage_monthly_multipliers)
end
end

def _check_ceiling_fans(hpxml_bldg, cfm_per_w: nil, count: nil)
Expand All @@ -203,5 +215,11 @@ def _check_ceiling_fans(hpxml_bldg, cfm_per_w: nil, count: nil)
end
assert_equal(0.5, hpxml_bldg.hvac_controls[0].ceiling_fan_cooling_setpoint_temp_offset)
end

hpxml_bldg.ceiling_fans.each do |ceiling_fan|
assert_equal('0.057, 0.057, 0.057, 0.057, 0.057, 0.057, 0.057, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.052, 0.057, 0.057, 0.057, 0.057, 0.057', ceiling_fan.weekday_fractions)
assert_equal('0.057, 0.057, 0.057, 0.057, 0.057, 0.057, 0.057, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.052, 0.057, 0.057, 0.057, 0.057, 0.057', ceiling_fan.weekend_fractions)
assert_equal('0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0', ceiling_fan.monthly_multipliers)
end
end
end
5 changes: 5 additions & 0 deletions rulesets/tests/test_misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,17 @@ def _check_misc(hpxml_bldg, misc_kwh:, misc_sens:, misc_lat:, tv_kwh:, tv_sens:,
assert_in_epsilon(misc_kwh, plug_load.kwh_per_year, 0.01)
assert_in_epsilon(misc_sens, plug_load.frac_sensible, 0.01)
assert_in_epsilon(misc_lat, plug_load.frac_latent, 0.01)
assert_equal('0.036, 0.036, 0.036, 0.036, 0.036, 0.036, 0.038, 0.041, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.044, 0.047, 0.050, 0.051, 0.050, 0.048, 0.044, 0.040, 0.037', plug_load.weekday_fractions)
assert_equal('0.036, 0.036, 0.036, 0.036, 0.036, 0.036, 0.038, 0.041, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.044, 0.047, 0.050, 0.051, 0.050, 0.048, 0.044, 0.040, 0.037', plug_load.weekend_fractions)
elsif plug_load.plug_load_type == HPXML::PlugLoadTypeTelevision
num_pls += 1
assert_in_epsilon(tv_kwh, plug_load.kwh_per_year, 0.01)
assert_in_epsilon(tv_sens, plug_load.frac_sensible, 0.01)
assert_in_epsilon(tv_lat, plug_load.frac_latent, 0.01)
assert_equal('0.014, 0.007, 0.004, 0.003, 0.004, 0.006, 0.010, 0.015, 0.020, 0.025, 0.028, 0.031, 0.033, 0.038, 0.042, 0.046, 0.054, 0.062, 0.080, 0.110, 0.132, 0.125, 0.077, 0.034', plug_load.weekday_fractions)
assert_equal('0.014, 0.007, 0.004, 0.003, 0.004, 0.006, 0.010, 0.015, 0.020, 0.025, 0.028, 0.031, 0.033, 0.038, 0.042, 0.046, 0.054, 0.062, 0.080, 0.110, 0.132, 0.125, 0.077, 0.034', plug_load.weekend_fractions)
end
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', plug_load.monthly_multipliers)
end
assert_equal(2, num_pls)
end
Expand Down
69 changes: 69 additions & 0 deletions rulesets/tests/test_occupancy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: true

require_relative '../../hpxml-measures/HPXMLtoOpenStudio/resources/minitest_helper'
require 'openstudio'
require_relative '../main.rb'
require 'fileutils'
require_relative 'util.rb'

class ERIOccupancyTest < Minitest::Test
def setup
@root_path = File.absolute_path(File.join(File.dirname(__FILE__), '..', '..'))
@sample_files_path = File.join(@root_path, 'workflow', 'sample_files')
@tmp_hpxml_path = File.join(@sample_files_path, 'tmp.xml')
@schema_validator = XMLValidator.get_schema_validator(File.join(@root_path, 'hpxml-measures', 'HPXMLtoOpenStudio', 'resources', 'hpxml_schema', 'HPXML.xsd'))
@epvalidator = OpenStudio::XMLValidator.new(File.join(@root_path, 'hpxml-measures', 'HPXMLtoOpenStudio', 'resources', 'hpxml_schematron', 'EPvalidator.xml'))
@erivalidator = OpenStudio::XMLValidator.new(File.join(@root_path, 'rulesets', 'resources', '301validator.xml'))
end

def teardown
File.delete(@tmp_hpxml_path) if File.exist? @tmp_hpxml_path
FileUtils.rm_rf(@results_path) if Dir.exist? @results_path
end

def test_building
hpxml_name = 'base.xml'

_all_calc_types.each do |calc_type|
_hpxml, hpxml_bldg = _test_ruleset(hpxml_name, calc_type)
_check_occupancy(hpxml_bldg)
_check_general_water_use(hpxml_bldg)
end
end

def _test_ruleset(hpxml_name, calc_type)
require_relative '../../workflow/design'
designs = [Design.new(calc_type: calc_type,
output_dir: @sample_files_path)]

hpxml_input_path = File.join(@sample_files_path, hpxml_name)
success, errors, _, _, hpxml = run_rulesets(hpxml_input_path, designs, @schema_validator, @erivalidator)

errors.each do |s|
puts "Error: #{s}"
end

# assert that it ran correctly
assert_equal(true, success)

# validate against OS-HPXML schematron
assert_equal(true, @epvalidator.validate(designs[0].hpxml_output_path))
@results_path = File.dirname(designs[0].hpxml_output_path)

return hpxml, hpxml.buildings[0]
end

def _check_occupancy(hpxml_bldg)
building_occupancy = hpxml_bldg.building_occupancy
assert_equal('0.035, 0.035, 0.035, 0.035, 0.035, 0.059, 0.082, 0.055, 0.027, 0.014, 0.014, 0.014, 0.014, 0.014, 0.019, 0.027, 0.041, 0.055, 0.068, 0.082, 0.082, 0.070, 0.053, 0.035', building_occupancy.weekday_fractions)
assert_equal('0.035, 0.035, 0.035, 0.035, 0.035, 0.059, 0.082, 0.055, 0.027, 0.014, 0.014, 0.014, 0.014, 0.014, 0.019, 0.027, 0.041, 0.055, 0.068, 0.082, 0.082, 0.070, 0.053, 0.035', building_occupancy.weekend_fractions)
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', building_occupancy.monthly_multipliers)
end

def _check_general_water_use(hpxml_bldg)
building_occupancy = hpxml_bldg.building_occupancy
assert_equal('0.023, 0.021, 0.021, 0.025, 0.027, 0.038, 0.044, 0.039, 0.037, 0.037, 0.034, 0.035, 0.035, 0.035, 0.039, 0.043, 0.051, 0.064, 0.065, 0.072, 0.073, 0.063, 0.045, 0.034', building_occupancy.general_water_use_weekday_fractions)
assert_equal('0.023, 0.021, 0.021, 0.025, 0.027, 0.038, 0.044, 0.039, 0.037, 0.037, 0.034, 0.035, 0.035, 0.035, 0.039, 0.043, 0.051, 0.064, 0.065, 0.072, 0.073, 0.063, 0.045, 0.034', building_occupancy.general_water_use_weekend_fractions)
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', building_occupancy.general_water_use_monthly_multipliers)
end
end
18 changes: 18 additions & 0 deletions rulesets/tests/test_water_heating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,21 @@ def _check_hot_water_distribution(hpxml_bldg, disttype:, pipe_r:, pipe_l: nil, r
else
assert_equal(shared_recirc_control_type, hot_water_distribution.shared_recirculation_control_type)
end

if hot_water_distribution.system_type == HPXML::DHWDistTypeRecirc || hot_water_distribution.has_shared_recirculation
recirc_control_type = hot_water_distribution.has_shared_recirculation ? hot_water_distribution.shared_recirculation_control_type : hot_water_distribution.recirculation_control_type
if [HPXML::DHWRecircControlTypeNone, HPXML::DHWRecircControlTypeTimer].include?(recirc_control_type)
assert_equal('0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042', hot_water_distribution.recirculation_pump_weekday_fractions)
assert_equal('0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042, 0.042', hot_water_distribution.recirculation_pump_weekend_fractions)
elsif [HPXML::DHWRecircControlTypeSensor, HPXML::DHWRecircControlTypeManual].include?(recirc_control_type)
assert_equal('0.012, 0.006, 0.004, 0.005, 0.010, 0.034, 0.078, 0.086, 0.080, 0.067, 0.056, 0.047, 0.040, 0.035, 0.033, 0.031, 0.038, 0.051, 0.060, 0.060, 0.055, 0.048, 0.038, 0.026', hot_water_distribution.recirculation_pump_weekday_fractions)
assert_equal('0.012, 0.006, 0.004, 0.005, 0.010, 0.034, 0.078, 0.086, 0.080, 0.067, 0.056, 0.047, 0.040, 0.035, 0.033, 0.031, 0.038, 0.051, 0.060, 0.060, 0.055, 0.048, 0.038, 0.026', hot_water_distribution.recirculation_pump_weekend_fractions)
elsif [HPXML::DHWRecircControlTypeTemperature].include?(recirc_control_type)
assert_equal('0.067, 0.072, 0.074, 0.073, 0.069, 0.048, 0.011, 0.003, 0.009, 0.020, 0.030, 0.037, 0.043, 0.047, 0.050, 0.051, 0.044, 0.034, 0.026, 0.026, 0.030, 0.036, 0.045, 0.055', hot_water_distribution.recirculation_pump_weekday_fractions)
assert_equal('0.067, 0.072, 0.074, 0.073, 0.069, 0.048, 0.011, 0.003, 0.009, 0.020, 0.030, 0.037, 0.043, 0.047, 0.050, 0.051, 0.044, 0.034, 0.026, 0.026, 0.030, 0.036, 0.045, 0.055', hot_water_distribution.recirculation_pump_weekend_fractions)
end
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', hot_water_distribution.recirculation_pump_monthly_multipliers)
end
end

def _check_water_fixtures(hpxml_bldg, low_flow_shower:, low_flow_faucet:)
Expand All @@ -647,6 +662,9 @@ def _check_water_fixtures(hpxml_bldg, low_flow_shower:, low_flow_faucet:)
assert_equal(low_flow_faucet, water_fixture.low_flow)
end
end
assert_equal('0.012, 0.006, 0.004, 0.005, 0.010, 0.034, 0.078, 0.086, 0.080, 0.067, 0.056, 0.047, 0.040, 0.035, 0.033, 0.031, 0.038, 0.051, 0.060, 0.060, 0.055, 0.048, 0.038, 0.026', hpxml_bldg.water_heating.water_fixtures_weekday_fractions)
assert_equal('0.012, 0.006, 0.004, 0.005, 0.010, 0.034, 0.078, 0.086, 0.080, 0.067, 0.056, 0.047, 0.040, 0.035, 0.033, 0.031, 0.038, 0.051, 0.060, 0.060, 0.055, 0.048, 0.038, 0.026', hpxml_bldg.water_heating.water_fixtures_weekend_fractions)
assert_equal('1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0', hpxml_bldg.water_heating.water_fixtures_monthly_multipliers)
end

def _check_drain_water_heat_recovery(hpxml_bldg, facilities_connected: nil, equal_flow: nil, efficiency: nil)
Expand Down

0 comments on commit 35d0c3a

Please sign in to comment.