Skip to content

Commit

Permalink
Fix/simplify tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
shorowit committed Jan 6, 2024
1 parent 36cc3a1 commit 3805c70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 69 deletions.
36 changes: 0 additions & 36 deletions workflow/tests/resnet_hers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
43 changes: 10 additions & 33 deletions workflow/tests/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3805c70

Please sign in to comment.