Skip to content

Commit

Permalink
fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yardasol committed Jul 10, 2023
1 parent f7e8ce6 commit 950d0a0
Show file tree
Hide file tree
Showing 12 changed files with 39,167 additions and 39,115 deletions.
10 changes: 5 additions & 5 deletions saltproc/openmc_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,12 @@ def write_runtime_input(self, reactor, depletion_step, restart):
self.inactive_cycles = settings.inactive
self.active_cycles = settings.batches - self.inactive_cycles

diluted_model = openmc.Model(materials=materials, geometry=geometry, settings=settings)
reactions, diluted_materials = MicroXS._add_dilute_nuclides(self.chain_file_path,
diluted_model,
1e3)
#diluted_model = openmc.Model(materials=materials, geometry=geometry, settings=settings)
#reactions, diluted_materials = MicroXS._add_dilute_nuclides(self.chain_file_path,
# diluted_model,
# 1e3)

diluted_materials.export_to_xml(self.runtime_matfile)
#diluted_materials.export_to_xml(self.runtime_matfile)
geometry.export_to_xml(self.runtime_inputfile['geometry'])
settings.export_to_xml(self.runtime_inputfile['settings'])
self.write_depletion_settings(reactor, depletion_step)
Expand Down
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
from pathlib import Path
import pytest

from tests.integration_tests import config as integration_config

from saltproc.app import read_main_input, _create_depcode_object, _create_simulation_object, _create_reactor_object
from saltproc import Simulation


def pytest_addoption(parser):
parser.addoption('--update', action='store_true')


def pytest_configure(config):
opts = ['update']
for opt in opts:
if config.getoption(opt) is not None:
integration_config[opt] = config.getoption(opt)


@pytest.fixture(scope='session')
def cwd():
return Path(__file__).parents[0]
Expand Down
3 changes: 3 additions & 0 deletions tests/integration_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config = {
'update': False
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Run SaltProc with reprocessing"""
from tests.integration_tests import config

import os
import shutil
from pathlib import Path
Expand Down Expand Up @@ -37,6 +39,9 @@ def test_integration_2step_constant_ideal_removal_heavy(setup):
cwd=cwd,
stdout=sys.stdout,
stderr=subprocess.STDOUT)
if config['update']:
shutil.copyfile(test_db, ref_db)
return
np.testing.assert_allclose(read_keff(test_db), read_keff(ref_db), atol=atol)
assert_db_allclose(test_db, ref_db, atol, rtol)

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Run SaltProc with reprocessing"""
from tests.integration_tests import config

from pathlib import Path
import sys
import shutil
Expand Down Expand Up @@ -33,6 +35,10 @@ def test_integration_2step_constant_ideal_removal_heavy(setup):
cwd=cwd,
stdout=sys.stdout,
stderr=subprocess.STDOUT)
if config['update']:
shutil.copyfile(test_db, ref_db)
return

np.testing.assert_allclose(read_keff(test_db)[0], read_keff(ref_db)[0], rtol=5e-2)
np.testing.assert_allclose(read_keff(test_db)[1], read_keff(ref_db)[1], rtol=5e-1)
assert_db_allclose(test_db, ref_db, tol)
Expand Down
Binary file not shown.
17 changes: 14 additions & 3 deletions tests/integration_tests/run_no_reprocessing_openmc/test_openmc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Run SaltProc without reprocessing"""
from tests.integration_tests import config

import sys
import shutil
from pathlib import Path
Expand All @@ -22,15 +24,24 @@ def test_integration_2step_saltproc_no_reproc_heavy():
stdout=sys.stdout,
stderr=subprocess.STDOUT)

ref_results = tb.File('ref_saltproc_results.h5')
test_results = tb.File('saltproc_runtime/saltproc_results.h5')
ref_path = cwd + '/ref_saltproc_results.h5'
test_path = cwd + '/saltproc_runtime/saltproc_results.h5'
if config['update']:
shutil.copyfile(test_path, ref_path)

ref_mdens_error = np.loadtxt('reference_error')
ref_results = tb.File(ref_path)
test_results = tb.File(test_path)

ref_fuel_mdens = ref_results.root.materials.fuel.before_reproc.comp[-1]
test_fuel_mdens = test_results.root.materials.fuel.before_reproc.comp[-1]

test_mdens_error = np.array(ref_fuel_mdens) - np.array(test_fuel_mdens)
if config['update']:
with open('reference_error', mode='w') as f:
test_mdens_error.tofile(f, sep='\n')
return

ref_mdens_error = np.loadtxt('reference_error')
np.testing.assert_array_almost_equal(test_mdens_error, ref_mdens_error)

shutil.rmtree('saltproc_runtime')
Loading

0 comments on commit 950d0a0

Please sign in to comment.