mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Much of the previous API is intact, with the major change being CRAM functions are imported from openmc.deplete.cram in the test_deplete_cram. The integrator abstract classes are placed in openmc/deplete/abc.py with all concrete classes going in to openmc/deplete/integrators.py Documentation updated accordingly
37 lines
795 B
Python
37 lines
795 B
Python
""" Tests for cram.py
|
|
|
|
Compares a few Mathematica matrix exponentials to CRAM16/CRAM48.
|
|
"""
|
|
|
|
from pytest import approx
|
|
import numpy as np
|
|
import scipy.sparse as sp
|
|
from openmc.deplete.cram import CRAM16, CRAM48
|
|
|
|
|
|
def test_CRAM16():
|
|
"""Test 16-term CRAM."""
|
|
x = np.array([1.0, 1.0])
|
|
mat = sp.csr_matrix([[-1.0, 0.0], [-2.0, -3.0]])
|
|
dt = 0.1
|
|
|
|
z = CRAM16(mat, x, dt)
|
|
|
|
# Solution from mathematica
|
|
z0 = np.array((0.904837418035960, 0.576799023327476))
|
|
|
|
assert z == approx(z0)
|
|
|
|
|
|
def test_CRAM48():
|
|
"""Test 48-term CRAM."""
|
|
x = np.array([1.0, 1.0])
|
|
mat = sp.csr_matrix([[-1.0, 0.0], [-2.0, -3.0]])
|
|
dt = 0.1
|
|
|
|
z = CRAM48(mat, x, dt)
|
|
|
|
# Solution from mathematica
|
|
z0 = np.array((0.904837418035960, 0.576799023327476))
|
|
|
|
assert z == approx(z0)
|