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 11, 2023
1 parent f7e8ce6 commit b38b2c2
Show file tree
Hide file tree
Showing 21 changed files with 2,157 additions and 2,300 deletions.
17 changes: 0 additions & 17 deletions doc/io_formats/depcode_input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,23 +366,6 @@ OpenMC-specific properties
``null``


``dilute_initial``
~~~~~~~~~~~~~~~~~~

:description:
Initial atom density to add for nuclides that are zero in initial
condition.

:type:
``number``

:minimum:
0

:default:
1000


``fission_yield_mode``
~~~~~~~~~~~~~~~~~~~~~~

Expand Down
5 changes: 0 additions & 5 deletions saltproc/input_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@
"description": "Path to fission Q values",
"type": ["string", "null"],
"default": null},
"dilute_initial": {
"description": "Initial atom density to add for nuclides that are zero in initial condition.",
"type": "number",
"minimum": 0,
"default": 1000},
"fission_yield_mode": {
"description": "Determine what fission energy helper is used",
"type": "string",
Expand Down
7 changes: 1 addition & 6 deletions saltproc/openmc_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,7 @@ 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_materials.export_to_xml(self.runtime_matfile)
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
52 changes: 39 additions & 13 deletions saltproc/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class Results():
Parameters
----------
path
path : str
Path of results file
load_in_out_streams : bool
Switch on whether or not to load waste streams.
Attributes
----------
Expand All @@ -28,15 +31,25 @@ class Results():
power_level : numpy.ndarray
Power in [W].
beta_eff : numpy.ndarray
...
Timeseries of delayed neutron fractions.
lambda_eff : numpy.ndarray
...
depcode_metadata : ...
depletion_step_metadata : ...
nuclide_ids : ...
material_composition : ...
material_parameters : ...
waste_streams : ...
Timesereis of delayed neutron precursor decay constants.
depcode_metadata : dict of str to object
Depletion code metadata, such as depletion code name, version, etc.
depletion_step_metadata : dict of str to object
Depletion step metadata, such as step runtime, memory usage, etc.
nuclide_idx : dict of str to int
A dictionary mapping nuclide name as a string to index.
material_composition : dict of str to numpy.ndarray
A dictionary mapping material name as a string to nuclide composition
over time.
material_parameters : dict of str to object
A dictionary mapping material name as a string to material parameters
(density, volume, burnup, etc.)
waste_streams : dict of str to dict
A dictionary mapping material name as a string to a dictionary mapping
waste stream names as a string to the waste streams mass [g] as a
timeseries.
"""
def __init__(self, path, load_in_out_streams=True):
Expand All @@ -59,10 +72,6 @@ def __init__(self, path, load_in_out_streams=True):
# metadata
self.depcode_metadata = self._collect_metadata(f, 'depcode_metadata')
self.depletion_step_metadata = self._collect_metadata(f, 'depletion_step_metadata', array=True)
#metadata = pd.DataFrame.from_records(metadata[:]).to_dict()
#for key, value in metadata.items():
# metadata[key] = value[0#]
##self.depcode_metadata = metadata

# Materials
materials = root.materials
Expand Down Expand Up @@ -171,6 +180,23 @@ def _collect_waste_streams(self, waste_stream, stream_name):

# methods to get timeseries of various values
def get_nuclide_mass(self, material, nuclide, timestep=None):
"""Get nuclide mass as a timeseries. If :attr:`timestep` is `None`,
then return the mass at all times.
Parameters
----------
material : str
Material name
nuclide : str
Nuclide string (e.g. 'U235')
timestep : idx
Timestep index
Returns
-------
nuclide_mass : numpy.ndarray
"""
nucmap = self.nuclide_idx[material]
comp = self.material_composition[material]
nuclide_mass = comp[nucmap[nuclide]]
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 @@ -35,12 +37,15 @@ def test_integration_2step_constant_ideal_removal_heavy(setup):
args,
check=True,
cwd=cwd,
stdout=sys.stdout,
stdout=subprocess.DEVNULL,
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)

#shutil.rmtree(cwd / 'saltproc_runtime')
shutil.rmtree(cwd / 'saltproc_runtime')

def read_keff(file):
db = tb.open_file(file, mode='r')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def test_integration_2step_constant_ideal_removal_heavy(setup):
args,
check=True,
cwd=cwd,
stdout=sys.stdout,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)

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.
Loading

0 comments on commit b38b2c2

Please sign in to comment.