Skip to content

Commit 4a96ad1

Browse files
authored
Merge branch 'master' into slab-hvac-sizing
2 parents f01773d + d2aa946 commit 4a96ad1

2 files changed

Lines changed: 22 additions & 18 deletions

File tree

tasks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5354,7 +5354,7 @@ def display_usage(command_list)
53545354
if not ENV['CI']
53555355
# Run ASHRAE 140 files
53565356
puts 'Running ASHRAE 140 tests (this will take a minute)...'
5357-
command = 'openstudio workflow/tests/hpxml_translator_test.rb --name=test_ashrae_140 > log.txt'
5357+
command = "#{OpenStudio.getOpenStudioCLI} workflow/tests/hpxml_translator_test.rb --name=test_ashrae_140 > log.txt"
53585358
system(command)
53595359
results_csv_path = 'workflow/tests/results/results_ashrae_140.csv'
53605360
if not File.exist? results_csv_path

workflow/tests/hpxml_translator_test.rb

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ class HPXMLTest < MiniTest::Test
2121
def before_setup
2222
@this_dir = File.dirname(__FILE__)
2323
@results_dir = File.join(@this_dir, 'results')
24-
rm_path(@results_dir)
25-
Dir.mkdir(@results_dir)
24+
FileUtils.mkdir_p @results_dir
2625
end
2726

2827
def test_simulations
2928
sample_files_dir = File.absolute_path(File.join(@this_dir, '..', 'sample_files'))
3029
autosize_dir = File.absolute_path(File.join(@this_dir, '..', 'sample_files', 'hvac_autosizing'))
30+
31+
results_out = File.join(@results_dir, 'results.csv')
32+
File.delete(results_out) if File.exist? results_out
33+
sizing_out = File.join(@results_dir, 'results_hvac_sizing.csv')
34+
File.delete(sizing_out) if File.exist? sizing_out
3135

3236
test_dirs = [sample_files_dir,
3337
autosize_dir]
@@ -47,15 +51,18 @@ def test_simulations
4751
all_results[xml], all_sizing_results[xml] = _run_xml(xml)
4852
end
4953

50-
_write_summary_results(all_results)
51-
_write_hvac_sizing_results(all_sizing_results)
54+
_write_summary_results(all_results, results_out)
55+
_write_hvac_sizing_results(all_sizing_results, sizing_out)
5256
end
5357

5458
def test_ashrae_140
55-
ashrae_140_dir = File.absolute_path(File.join(@this_dir, 'ASHRAE_Standard_140'))
59+
ashrae140_dir = File.absolute_path(File.join(@this_dir, 'ASHRAE_Standard_140'))
60+
61+
ashrae140_out = File.join(@results_dir, 'results_ashrae_140.csv')
62+
File.delete(ashrae140_out) if File.exist? ashrae140_out
5663

5764
xmls = []
58-
Dir["#{ashrae_140_dir}/*.xml"].sort.each do |xml|
65+
Dir["#{ashrae140_dir}/*.xml"].sort.each do |xml|
5966
xmls << File.absolute_path(xml)
6067
end
6168

@@ -67,7 +74,7 @@ def test_ashrae_140
6774
all_results[xml], all_sizing_results[xml] = _run_xml(xml)
6875
end
6976

70-
_write_ashrae_140_results(all_results, ashrae_140_dir)
77+
_write_ashrae_140_results(all_results, ashrae140_dir)
7178
end
7279

7380
def test_run_simulation_rb
@@ -269,15 +276,15 @@ def test_invalid
269276
def test_release_zips
270277
# Check release zips successfully created
271278
top_dir = File.join(@this_dir, '..', '..')
272-
command = "openstudio #{File.join(top_dir, 'tasks.rb')} create_release_zips"
279+
command = "#{OpenStudio.getOpenStudioCLI} #{File.join(top_dir, 'tasks.rb')} create_release_zips"
273280
system(command)
274281
assert_equal(2, Dir["#{top_dir}/*.zip"].size)
275282

276283
# Check successful running of simulation from release zips
277284
Dir["#{top_dir}/OpenStudio-HPXML*.zip"].each do |zip|
278285
unzip_file = OpenStudio::UnzipFile.new(zip)
279286
unzip_file.extractAllFiles(OpenStudio::toPath(top_dir))
280-
command = 'openstudio OpenStudio-HPXML/workflow/run_simulation.rb -x OpenStudio-HPXML/workflow/sample_files/base.xml'
287+
command = "#{OpenStudio.getOpenStudioCLI} OpenStudio-HPXML/workflow/run_simulation.rb -x OpenStudio-HPXML/workflow/sample_files/base.xml"
281288
system(command)
282289
assert(File.exist? 'OpenStudio-HPXML/workflow/sample_files/run/results_annual.csv')
283290
File.delete(zip)
@@ -1339,9 +1346,8 @@ def _verify_outputs(runner, rundir, hpxml_path, results)
13391346
sqlFile.close
13401347
end
13411348

1342-
def _write_summary_results(results)
1349+
def _write_summary_results(results, csv_out)
13431350
require 'csv'
1344-
csv_out = File.join(@results_dir, 'results.csv')
13451351

13461352
output_keys = []
13471353
results.each do |xml, xml_results|
@@ -1372,9 +1378,8 @@ def _write_summary_results(results)
13721378
puts "Wrote summary results to #{csv_out}."
13731379
end
13741380

1375-
def _write_hvac_sizing_results(all_sizing_results)
1381+
def _write_hvac_sizing_results(all_sizing_results, csv_out)
13761382
require 'csv'
1377-
csv_out = File.join(@results_dir, 'results_hvac_sizing.csv')
13781383

13791384
output_keys = nil
13801385
all_sizing_results.each do |xml, xml_results|
@@ -1397,16 +1402,15 @@ def _write_hvac_sizing_results(all_sizing_results)
13971402
puts "Wrote HVAC sizing results to #{csv_out}."
13981403
end
13991404

1400-
def _write_ashrae_140_results(all_results, ashrae_140_dir)
1405+
def _write_ashrae_140_results(all_results, ashrae140_dir, csv_out)
14011406
require 'csv'
1402-
csv_out = File.join(@results_dir, 'results_ashrae_140.csv')
14031407

14041408
htg_loads = {}
14051409
clg_loads = {}
14061410
CSV.open(csv_out, 'w') do |csv|
14071411
csv << ['Test Case', 'Annual Heating Load [MMBtu]', 'Annual Cooling Load [MMBtu]']
14081412
all_results.sort.each do |xml, xml_results|
1409-
next unless xml.include? ashrae_140_dir
1413+
next unless xml.include? ashrae140_dir
14101414
next unless xml.include? 'C.xml'
14111415

14121416
htg_load = xml_results['Load: Heating (MBtu)'].round(2)
@@ -1415,7 +1419,7 @@ def _write_ashrae_140_results(all_results, ashrae_140_dir)
14151419
htg_loads[test_name] = htg_load
14161420
end
14171421
all_results.sort.each do |xml, xml_results|
1418-
next unless xml.include? ashrae_140_dir
1422+
next unless xml.include? ashrae140_dir
14191423
next unless xml.include? 'L.xml'
14201424

14211425
clg_load = xml_results['Load: Cooling (MBtu)'].round(2)

0 commit comments

Comments
 (0)