From 3805c70087e9ce334d24dc6b34b9c761d01087cd Mon Sep 17 00:00:00 2001 From: Scott Horowitz Date: Fri, 5 Jan 2024 23:02:15 -0700 Subject: [PATCH] Fix/simplify tests. --- workflow/tests/resnet_hers_test.rb | 36 ------------------------- workflow/tests/util.rb | 43 +++++++----------------------- 2 files changed, 10 insertions(+), 69 deletions(-) diff --git a/workflow/tests/resnet_hers_test.rb b/workflow/tests/resnet_hers_test.rb index bc181e06d..85167b389 100644 --- a/workflow/tests/resnet_hers_test.rb +++ b/workflow/tests/resnet_hers_test.rb @@ -77,42 +77,6 @@ def test_resnet_hers_reference_home_auto_generation end end - def test_resnet_hers_iad_home_auto_generation - test_name = 'RESNET_Test_Other_HERS_AutoGen_IAD_Home' - test_results_csv = File.absolute_path(File.join(@test_results_dir, "#{test_name}.csv")) - File.delete(test_results_csv) if File.exist? test_results_csv - - # Run simulations - all_results = {} - xmldir = File.join(File.dirname(__FILE__), 'RESNET_Tests/Other_HERS_AutoGen_IAD_Home') - Dir["#{xmldir}/*.xml"].sort.each do |xml| - out_xml = File.join(@test_files_dir, test_name, File.basename(xml), File.basename(xml)) - _run_ruleset(Constants.CalcTypeERIIndexAdjustmentDesign, xml, out_xml) - test_num = File.basename(xml)[0, 2].to_i - all_results[File.basename(xml)] = _get_iad_home_components(out_xml, test_num) - end - assert(all_results.size > 0) - - # Write results to csv - CSV.open(test_results_csv, 'w') do |csv| - csv << ['Component', 'Test 1 Results', 'Test 2 Results', 'Test 3 Results', 'Test 4 Results'] - all_results['01-L100.xml'].keys.each do |component| - csv << [component, - all_results['01-L100.xml'][component], - all_results['02-L100.xml'][component], - all_results['03-L304.xml'][component], - all_results['04-L324.xml'][component]] - end - end - puts "Wrote results to #{test_results_csv}." - - # Check results - all_results.each do |xml, results| - test_num = File.basename(xml)[0, 2].to_i - _check_iad_home_components(results, test_num) - end - end - def test_resnet_hers_method all_results = _test_resnet_hers_method('RESNET_Test_4.3_HERS_Method', 'RESNET_Tests/4.3_HERS_Method') diff --git a/workflow/tests/util.rb b/workflow/tests/util.rb index fed81fa38..83ba93f5f 100644 --- a/workflow/tests/util.rb +++ b/workflow/tests/util.rb @@ -869,26 +869,12 @@ def _check_reference_home_components(results, test_num, version) # Mechanical ventilation mv_kwh_yr = nil - if version == '2014' - if test_num == 1 - mv_kwh_yr = 0.0 - elsif test_num == 2 - mv_kwh_yr = 77.9 - elsif test_num == 3 - mv_kwh_yr = 140.4 - else - mv_kwh_yr = 379.1 - end - else - if test_num == 1 - mv_kwh_yr = 0.0 - elsif test_num == 2 - mv_kwh_yr = 223.9 - elsif test_num == 3 - mv_kwh_yr = 288.1 - else - mv_kwh_yr = 763.4 - end + if version == '2022' + mv_kwh_yr = { 1 => 0.0, 2 => 223.9, 3 => 288.1, 4 => 763.4 }[test_num] + elsif version == '2019' + mv_kwh_yr = { 1 => 0.0, 2 => 222.1, 3 => 288.1, 4 => 763.4 }[test_num] + elsif version == '2014' + mv_kwh_yr = { 1 => 0.0, 2 => 77.9, 3 => 140.4, 4 => 379.1 }[test_num] end assert_in_epsilon(mv_kwh_yr, results['Mechanical ventilation (kWh/y)'], epsilon) @@ -950,19 +936,10 @@ def _check_iad_home_components(results, test_num) end # Mechanical Ventilation - if test_num == 1 - assert_in_delta(66.4, results['Mechanical ventilation rate'], 0.2) - assert_in_delta(407, results['Mechanical ventilation'], 1.0) - elsif test_num == 2 - assert_in_delta(64.2, results['Mechanical ventilation rate'], 0.2) - assert_in_delta(394, results['Mechanical ventilation'], 1.0) - elsif test_num == 3 - assert_in_delta(53.3, results['Mechanical ventilation rate'], 0.2) - assert_in_delta(327, results['Mechanical ventilation'], 1.0) - elsif test_num == 4 - assert_in_delta(57.1, results['Mechanical ventilation rate'], 0.2) - assert_in_delta(350, results['Mechanical ventilation'], 1.0) - end + mv_cfm = { 1 => 66.4, 2 => 64.2, 3 => 53.3, 4 => 57.1 }[test_num] + mv_kwh = { 1 => 407, 2 => 394, 3 => 327, 4 => 350 }[test_num] + assert_in_delta(mv_cfm, results['Mechanical ventilation rate'], 0.2) + assert_in_delta(mv_kwh, results['Mechanical ventilation'], 1.0) # HVAC if (test_num == 1) || (test_num == 4)