Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions openmc/deplete/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import lxml.etree as ET

from openmc.checkvalue import check_type, check_greater_than, PathLike
from openmc.checkvalue import check_type, check_length, check_greater_than, PathLike
from openmc.data import gnds_name, zam
from openmc.exceptions import DataError
from .nuclide import FissionYieldDistribution, Nuclide
Expand Down Expand Up @@ -807,37 +807,29 @@ def form_rr_term(self, tr_rates, current_timestep, mats):
# Use DOK as intermediate representation
n = len(self)
matrix = dok_array((n, n))

check_type("mats", mats, (tuple, str))
if not isinstance(mats, str):
check_type("mats", mats, tuple, str)
check_length("mats", mats, 2, 2)

# Build transfer terms (nuclide transfer only)
if isinstance(mats, str):
mat = mats
dest_mat = None
components = tr_rates.get_components(mat, current_timestep)
# Build transfer terms (transfer from one material into another)
elif isinstance(mats, tuple):
dest_mat, mat = mats
components = tr_rates.get_components(mat, current_timestep, dest_mat)

for i, nuc in enumerate(self.nuclides):
elm = re.split(r'\d+', nuc.name)[0]
# Build transfer terms (nuclide transfer only)
if isinstance(mats, str):
mat = mats
components = tr_rates.get_components(mat, current_timestep)
if not components:
break
if elm in components:
matrix[i, i] = sum(
tr_rates.get_external_rate(mat, elm, current_timestep))
elif nuc.name in components:
matrix[i, i] = sum(
tr_rates.get_external_rate(mat, nuc.name, current_timestep))
else:
matrix[i, i] = 0.0

# Build transfer terms (transfer from one material into another)
elif isinstance(mats, tuple):
dest_mat, mat = mats
components = tr_rates.get_components(mat, current_timestep, dest_mat)
if elm in components:
matrix[i, i] = tr_rates.get_external_rate(
mat, elm, current_timestep, dest_mat)[0]
elif nuc.name in components:
matrix[i, i] = tr_rates.get_external_rate(
mat, nuc.name, current_timestep, dest_mat)[0]
else:
matrix[i, i] = 0.0

if elm in components:
matrix[i, i] = sum(tr_rates.get_external_rate(mat, elm, current_timestep, dest_mat))
elif nuc.name in components:
matrix[i, i] = sum(tr_rates.get_external_rate(mat, nuc.name, current_timestep, dest_mat))

# Return CSC instead of DOK
return matrix.tocsc()

Expand Down
Loading