mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 05:05:30 -04:00
added unit tests for CE/LI and LE/QI
This commit is contained in:
parent
cbbac7df8d
commit
0f639937b7
4 changed files with 154 additions and 1 deletions
|
|
@ -110,6 +110,8 @@ def leqi(operator, timesteps, power=None, power_density=None, print_out=True):
|
|||
t = operator.prev_res[-1].time[-1]
|
||||
i_res = len(operator.prev_res)
|
||||
|
||||
chain = operator.chain
|
||||
|
||||
for i, (dt, p) in enumerate(zip(timesteps, power)):
|
||||
# Perform SI-CE/LI CFQ4 for the first step
|
||||
if i == 0:
|
||||
|
|
@ -149,7 +151,7 @@ def leqi(operator, timesteps, power=None, power_density=None, print_out=True):
|
|||
dt_l = dt
|
||||
|
||||
# Perform one last simulation
|
||||
x = [copy.deepcopy(vec)]
|
||||
x = [copy.deepcopy(x_new)]
|
||||
op_results = [operator(x[0], power[-1])]
|
||||
|
||||
# Create results, write to disk
|
||||
|
|
|
|||
37
tests/unit_tests/test_deplete_celi.py
Normal file
37
tests/unit_tests/test_deplete_celi.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"""Regression tests for openmc.deplete.integrator.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_celi(run_in_tmpdir):
|
||||
"""Integral regression test of integrator algorithm using celi"""
|
||||
|
||||
op = dummy_operator.DummyOperator()
|
||||
op.output_dir = "test_integrator_regression"
|
||||
|
||||
# Perform simulation using the celi algorithm
|
||||
dt = [0.75, 0.75]
|
||||
power = 1.0
|
||||
openmc.deplete.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 = [1.82078767, 0.97122898]
|
||||
s2 = [2.68441779, 0.05125966]
|
||||
|
||||
assert y1[1] == approx(s1[0])
|
||||
assert y2[1] == approx(s1[1])
|
||||
|
||||
assert y1[2] == approx(s2[0])
|
||||
assert y2[2] == approx(s2[1])
|
||||
37
tests/unit_tests/test_deplete_leqi.py
Normal file
37
tests/unit_tests/test_deplete_leqi.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"""Regression tests for openmc.deplete.integrator.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_leqi(run_in_tmpdir):
|
||||
"""Integral regression test of integrator algorithm using leqi"""
|
||||
|
||||
op = dummy_operator.DummyOperator()
|
||||
op.output_dir = "test_integrator_regression"
|
||||
|
||||
# Perform simulation using the leqi algorithm
|
||||
dt = [0.75, 0.75]
|
||||
power = 1.0
|
||||
openmc.deplete.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 = [1.82078767, 0.97122898]
|
||||
s2 = [2.74526197, 0.23339915]
|
||||
|
||||
assert y1[1] == approx(s1[0])
|
||||
assert y2[1] == approx(s1[1])
|
||||
|
||||
assert y1[2] == approx(s2[0])
|
||||
assert y2[2] == approx(s2[1])
|
||||
|
|
@ -246,6 +246,83 @@ def test_restart_epc_rk4(run_in_tmpdir):
|
|||
assert y2[3] == approx(s2[1])
|
||||
|
||||
|
||||
def test_restart_celi(run_in_tmpdir):
|
||||
"""Integral regression test of integrator algorithm using CELI."""
|
||||
|
||||
op = dummy_operator.DummyOperator()
|
||||
output_dir = "test_restart_celi"
|
||||
op.output_dir = output_dir
|
||||
|
||||
# Perform simulation
|
||||
dt = [0.75]
|
||||
power = 1.0
|
||||
openmc.deplete.celi(op, dt, power, print_out=False)
|
||||
|
||||
# Load the files
|
||||
prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5")
|
||||
|
||||
# Re-create depletion operator and load previous results
|
||||
op = dummy_operator.DummyOperator(prev_res)
|
||||
op.output_dir = output_dir
|
||||
|
||||
# Perform restarts simulation
|
||||
openmc.deplete.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 = [1.82078767, 0.97122898]
|
||||
s2 = [2.68441779, 0.05125966]
|
||||
|
||||
assert y1[1] == approx(s1[0])
|
||||
assert y2[1] == approx(s1[1])
|
||||
|
||||
assert y1[3] == approx(s2[0])
|
||||
assert y2[3] == approx(s2[1])
|
||||
|
||||
|
||||
def test_restart_leqi(run_in_tmpdir):
|
||||
"""Integral regression test of integrator algorithm using LEQI."""
|
||||
|
||||
op = dummy_operator.DummyOperator()
|
||||
output_dir = "test_restart_leqi"
|
||||
op.output_dir = output_dir
|
||||
|
||||
# Perform simulation
|
||||
dt = [0.75]
|
||||
power = 1.0
|
||||
openmc.deplete.leqi(op, dt, power, print_out=False)
|
||||
|
||||
# Load the files
|
||||
prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5")
|
||||
|
||||
# Re-create depletion operator and load previous results
|
||||
op = dummy_operator.DummyOperator(prev_res)
|
||||
op.output_dir = output_dir
|
||||
|
||||
# Perform restarts simulation
|
||||
openmc.deplete.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 = [1.82078767, 0.97122898]
|
||||
s2 = [2.74526197, 0.23339915]
|
||||
|
||||
assert y1[1] == approx(s1[0])
|
||||
assert y2[1] == approx(s1[1])
|
||||
|
||||
assert y1[3] == approx(s2[0])
|
||||
assert y2[3] == approx(s2[1])
|
||||
|
||||
def test_restart_si_celi(run_in_tmpdir):
|
||||
"""Integral regression test of integrator algorithm using SI-CELI."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue