added unit tests for the new integrators

This commit is contained in:
liangjg 2019-01-09 10:39:40 -05:00
parent 952bddb61e
commit 57ea52a46c
6 changed files with 162 additions and 10 deletions

View file

@ -86,14 +86,16 @@ def si_celi(operator, timesteps, power=None, power_density=None,
i_res = len(operator.prev_res)
# Get the concentrations and reaction rates for the first
# beginning-of-timestep (BOS)
# Compute with s (stage number) times as many neutrons for statistics
# reasons if no previous calculation results loaded
# beginning-of-timestep (BOS). Compute with m (stage number) times as
# many neutrons as later simulations for statistics reasons if no
# previous calculation results present
if operator.prev_res is None:
x = [copy.deepcopy(vec)]
operator.settings.particles *= m
if hasattr(operator, "settings"):
operator.settings.particles *= m
op_results = [operator(x[0], power[0])]
operator.settings.particles //= m
if hasattr(operator, "settings"):
operator.settings.particles //= m
else:
# Get initial concentration
x = [operator.prev_res[-1].data[0]]

View file

@ -114,14 +114,16 @@ def si_leqi(operator, timesteps, power=None, power_density=None,
i_res = len(operator.prev_res)
# Get the concentrations and reaction rates for the first
# beginning-of-timestep (BOS)
# Compute with s (stage number) times as many neutrons for statistics
# reasons if no previous calculation results loaded
# beginning-of-timestep (BOS). Compute with m (stage number) times as
# many neutrons as later simulations for statistics reasons if no
# previous calculation results present
if operator.prev_res is None:
x = [copy.deepcopy(vec)]
operator.settings.particles *= m
if hasattr(operator, "settings"):
operator.settings.particles *= m
op_results = [operator(x[0], power[0])]
operator.settings.particles //= m
if hasattr(operator, "settings"):
operator.settings.particles //= m
else:
# Get initial concentration
x = [operator.prev_res[-1].data[0]]

View file

@ -0,0 +1,37 @@
"""Regression tests for openmc.deplete.integrator.cf4 algorithm.
These tests integrate a simple test problem described in dummy_geometry.py.
"""
from pytest import approx
import openmc.deplete
from tests import dummy_operator
def test_cf4(run_in_tmpdir):
"""Integral regression test of integrator algorithm using CF4"""
op = dummy_operator.DummyOperator()
op.output_dir = "test_integrator_regression"
# Perform simulation using the cf4 algorithm
dt = [0.75, 0.75]
power = 1.0
openmc.deplete.cf4(op, dt, power, print_out=False)
# Load the files
res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5")
_, y1 = res.get_atoms("1", "1")
_, y2 = res.get_atoms("1", "2")
# Reference solution
s1 = [2.06101629, 1.37783588]
s2 = [2.57241318, 2.63731630]
assert y1[1] == approx(s1[0])
assert y2[1] == approx(s1[1])
assert y1[2] == approx(s2[0])
assert y2[2] == approx(s2[1])

View file

@ -0,0 +1,37 @@
"""Regression tests for openmc.deplete.integrator.epc_rk4 algorithm.
These tests integrate a simple test problem described in dummy_geometry.py.
"""
from pytest import approx
import openmc.deplete
from tests import dummy_operator
def test_epc_rk4(run_in_tmpdir):
"""Integral regression test of integrator algorithm using epc_rk4"""
op = dummy_operator.DummyOperator()
op.output_dir = "test_integrator_regression"
# Perform simulation using the epc_rk4 algorithm
dt = [0.75, 0.75]
power = 1.0
openmc.deplete.epc_rk4(op, dt, power, print_out=False)
# Load the files
res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5")
_, y1 = res.get_atoms("1", "1")
_, y2 = res.get_atoms("1", "2")
# Reference solution
s1 = [2.01978516, 1.42038037]
s2 = [2.05246421, 3.06177191]
assert y1[1] == approx(s1[0])
assert y2[1] == approx(s1[1])
assert y1[2] == approx(s2[0])
assert y2[2] == approx(s2[1])

View file

@ -0,0 +1,37 @@
"""Regression tests for openmc.deplete.integrator.si_celi algorithm.
These tests integrate a simple test problem described in dummy_geometry.py.
"""
from pytest import approx
import openmc.deplete
from tests import dummy_operator
def test_si_celi(run_in_tmpdir):
"""Integral regression test of integrator algorithm using si_celi"""
op = dummy_operator.DummyOperator()
op.output_dir = "test_integrator_regression"
# Perform simulation using the si_celi algorithm
dt = [0.75, 0.75]
power = 1.0
openmc.deplete.si_celi(op, dt, power, print_out=False)
# Load the files
res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5")
_, y1 = res.get_atoms("1", "1")
_, y2 = res.get_atoms("1", "2")
# Reference solution
s1 = [2.03325094, 1.16826254]
s2 = [2.69291933, 0.37907772]
assert y1[1] == approx(s1[0])
assert y2[1] == approx(s1[1])
assert y1[2] == approx(s2[0])
assert y2[2] == approx(s2[1])

View file

@ -0,0 +1,37 @@
"""Regression tests for openmc.deplete.integrator.si_leqi algorithm.
These tests integrate a simple test problem described in dummy_geometry.py.
"""
from pytest import approx
import openmc.deplete
from tests import dummy_operator
def test_si_leqi(run_in_tmpdir):
"""Integral regression test of integrator algorithm using si_leqi"""
op = dummy_operator.DummyOperator()
op.output_dir = "test_integrator_regression"
# Perform simulation using the si_leqi algorithm
dt = [0.75, 0.75]
power = 1.0
openmc.deplete.si_leqi(op, dt, power, print_out=False)
# Load the files
res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5")
_, y1 = res.get_atoms("1", "1")
_, y2 = res.get_atoms("1", "2")
# Reference solution
s1 = [2.03325094, 1.16826254]
s2 = [2.92711288, 0.53753236]
assert y1[1] == approx(s1[0])
assert y2[1] == approx(s1[1])
assert y1[2] == approx(s2[0])
assert y2[2] == approx(s2[1])