diff --git a/tests/micro_xs_simple.csv b/tests/micro_xs_simple.csv index 40142f543..bc43600ba 100644 --- a/tests/micro_xs_simple.csv +++ b/tests/micro_xs_simple.csv @@ -1,13 +1,7 @@ -,fission,"(n,gamma)" -U234,0.1,0.0 -U235,0.1,0.0 -U238,0.9,0.0 -U236,0.4,0.0 -O16,0.0,0.0 -O17,0.0,0.0 -I135,0.0,0.1 -Xe135,0.0,0.9 -Xe136,0.0,0.0 -Cs135,0.0,0.0 -Gd157,0.0,0.1 -Gd156,0.0,0.1 +nuclide,"(n,gamma)",fission +U234,23.518634203050645,0.49531930067650976 +U235,10.621118186344665,49.10955932965905 +U238,0.8652742788116043,0.10579281644765708 +U236,9.095623870006154,0.32315392339237936 +O16,0.0029535689693132015,0.0 +O17,0.05980775766572907,0.0 diff --git a/tests/regression_tests/deplete/no_transport_deplete/test.py b/tests/regression_tests/deplete/no_transport_deplete/test.py new file mode 100644 index 000000000..3fb2bf7f2 --- /dev/null +++ b/tests/regression_tests/deplete/no_transport_deplete/test.py @@ -0,0 +1,106 @@ +""" Full system test suite. """ + +from math import floor +import shutil +from pathlib import Path + +from difflib import unified_diff +import numpy as np +import pytest +import openmc +from openmc.data import JOULE_PER_EV +import openmc.deplete +from openmc.deplete import FluxDepletionOperator + + +from tests.regression_tests import config + + +@pytest.fixture(scope="module") +def vol_nuc(): + fuel = openmc.Material(name="uo2") + fuel.add_element("U", 1, percent_type="ao", enrichment=4.25) + fuel.add_element("O", 2) + fuel.set_density("g/cc", 10.4) + + fuel.volume = np.pi * 0.42 ** 2 + + nuclides = {} + for nuc, t in fuel.get_nuclide_atom_densities().items(): + nuclides[nuc] = t[1] * 1e24 + + # Load geometry from example + return (fuel.volume, nuclides) + + +@pytest.mark.parametrize("multiproc", [True, False]) +def test_full(run_in_tmpdir, vol_nuc, multiproc): + """Full system test suite. + + Runs an OpenMC depletion calculation and verifies + that the outputs match a reference file. Sensitive to changes in + OpenMC. + + """ + + # Create operator + micro_xs_file = Path(__file__).parents[3] / 'micro_xs_simple.csv' + micro_xs = FluxDepletionOperator.create_micro_xs_from_csv(micro_xs_file) + chain_file = Path(__file__).parents[3] / 'chain_simple.xml' + flux = 1164719970082145.0 # flux from pincell example + op = FluxDepletionOperator(vol_nuc[0], vol_nuc[1], micro_xs, flux, chain_file, dilute_initial=0.0) + + # Power and timesteps + dt = [30] # single step + power = 174 # W/cm + + # Perform simulation using the predictor algorithm + openmc.deplete.pool.USE_MULTIPROCESSING = multiproc + openmc.deplete.PredictorIntegrator(op, dt, power, timestep_units='d').integrate() + + # Get path to test and reference results + path_test = op.output_dir / 'depletion_results.h5' + path_reference = Path(__file__).with_name('test_reference.h5') + + # If updating results, do so and return + if config['update']: + shutil.copyfile(str(path_test), str(path_reference)) + return + + # Load the reference/test results + res_test = openmc.deplete.Results(path_test) + res_ref = openmc.deplete.Results(path_reference) + + # Assert same mats + for mat in res_ref[0].mat_to_ind: + assert mat in res_test[0].mat_to_ind, \ + "Material {} not in new results.".format(mat) + for nuc in res_ref[0].nuc_to_ind: + assert nuc in res_test[0].nuc_to_ind, \ + "Nuclide {} not in new results.".format(nuc) + + for mat in res_test[0].mat_to_ind: + assert mat in res_ref[0].mat_to_ind, \ + "Material {} not in old results.".format(mat) + for nuc in res_test[0].nuc_to_ind: + assert nuc in res_ref[0].nuc_to_ind, \ + "Nuclide {} not in old results.".format(nuc) + + tol = 1.0e-6 + for mat in res_test[0].mat_to_ind: + for nuc in res_test[0].nuc_to_ind: + _, y_test = res_test.get_atoms(mat, nuc) + _, y_old = res_ref.get_atoms(mat, nuc) + + # Test each point + correct = True + for i, ref in enumerate(y_old): + if ref != y_test[i]: + if ref != 0.0: + correct = np.abs(y_test[i] - ref) / ref <= tol + else: + correct = False + + assert correct, "Discrepancy in mat {} and nuc {}\n{}\n{}".format( + mat, nuc, y_old, y_test) + diff --git a/tests/regression_tests/deplete/test_reference.h5 b/tests/regression_tests/deplete/test_reference.h5 deleted file mode 100644 index d478d628e..000000000 Binary files a/tests/regression_tests/deplete/test_reference.h5 and /dev/null differ diff --git a/tests/regression_tests/deplete/example_geometry.py b/tests/regression_tests/deplete/transport_deplete/example_geometry.py similarity index 100% rename from tests/regression_tests/deplete/example_geometry.py rename to tests/regression_tests/deplete/transport_deplete/example_geometry.py diff --git a/tests/regression_tests/deplete/last_step_reference_materials.xml b/tests/regression_tests/deplete/transport_deplete/last_step_reference_materials.xml similarity index 100% rename from tests/regression_tests/deplete/last_step_reference_materials.xml rename to tests/regression_tests/deplete/transport_deplete/last_step_reference_materials.xml diff --git a/tests/regression_tests/deplete/test.py b/tests/regression_tests/deplete/transport_deplete/test.py similarity index 98% rename from tests/regression_tests/deplete/test.py rename to tests/regression_tests/deplete/transport_deplete/test.py index 6c431fb33..caf292936 100644 --- a/tests/regression_tests/deplete/test.py +++ b/tests/regression_tests/deplete/transport_deplete/test.py @@ -52,7 +52,7 @@ def test_full(run_in_tmpdir, problem, multiproc): model = openmc.Model(geometry=geometry, settings=settings) # Create operator - chain_file = Path(__file__).parents[2] / 'chain_simple.xml' + chain_file = Path(__file__).parents[3] / 'chain_simple.xml' op = openmc.deplete.Operator(model, chain_file) op.round_number = True