Skip to content

Commit 3bdbf5e

Browse files
committed
Add two unit tests for decay_matrix
1 parent 51ebac3 commit 3bdbf5e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/unit_tests/test_deplete_chain.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,29 @@ def test_form_matrix(simple_chain):
246246
assert new_mat[r, c] == mat[r, c]
247247

248248

249+
def test_decay_matrix(simple_chain):
250+
"""Test that decay_matrix contains only radioactive decay terms."""
251+
# Nuclide order: H1(0), A(1), B(2), C(3)
252+
decay_A = log(2) / 2.36520E+04
253+
decay_B = log(2) / 3.29040E+04
254+
255+
expected = np.zeros((4, 4))
256+
expected[1, 1] = -decay_A # Loss: A decays
257+
expected[2, 1] = decay_A * 0.6 # A -> B (branching ratio 0.6)
258+
expected[3, 1] = decay_A * 0.4 # A -> C (branching ratio 0.4)
259+
expected[1, 2] = decay_B # B -> A (branching ratio 1.0)
260+
expected[2, 2] = -decay_B # Loss: B decays
261+
262+
assert np.allclose(expected, simple_chain.decay_matrix.toarray())
263+
264+
265+
def test_decay_matrix_cached(simple_chain):
266+
"""Test that decay_matrix is lazily computed and returns the same object."""
267+
m1 = simple_chain.decay_matrix
268+
m2 = simple_chain.decay_matrix
269+
assert m1 is m2
270+
271+
249272
def test_getitem():
250273
"""Test nuc_by_ind converter function."""
251274
chain = Chain()

0 commit comments

Comments
 (0)