Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change matrix format to CSC in depletion #2764

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions openmc/deplete/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ class Integrator(ABC):
User-supplied functions are expected to have the following signature:
``solver(A, n0, t) -> n1`` where

* ``A`` is a :class:`scipy.sparse.csr_matrix` making up the
* ``A`` is a :class:`scipy.sparse.csc_matrix` making up the
depletion matrix
* ``n0`` is a 1-D :class:`numpy.ndarray` of initial compositions
for a given material in atoms/cm3
Expand Down Expand Up @@ -921,7 +921,7 @@ class SIIntegrator(Integrator):
User-supplied functions are expected to have the following signature:
``solver(A, n0, t) -> n1`` where

* ``A`` is a :class:`scipy.sparse.csr_matrix` making up the
* ``A`` is a :class:`scipy.sparse.csc_matrix` making up the
depletion matrix
* ``n0`` is a 1-D :class:`numpy.ndarray` of initial compositions
for a given material in atoms/cm3
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def __call__(self, A, n0, dt):

Parameters
----------
A : scipy.sparse.csr_matrix
A : scipy.sparse.csc_matrix
Sparse transmutation matrix ``A[j, i]`` describing rates at
which isotope ``i`` transmutes to isotope ``j``
n0 : numpy.ndarray
Expand Down
10 changes: 5 additions & 5 deletions openmc/deplete/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def form_matrix(self, rates, fission_yields=None):

Returns
-------
scipy.sparse.csr_matrix
scipy.sparse.csc_matrix
Sparse matrix representing depletion.

See Also
Expand Down Expand Up @@ -680,11 +680,11 @@ def form_matrix(self, rates, fission_yields=None):
# Clear set of reactions
reactions.clear()

# Use DOK matrix as intermediate representation, then convert to CSR and return
# Use DOK matrix as intermediate representation, then convert to CSC and return
n = len(self)
matrix_dok = sp.dok_matrix((n, n))
dict.update(matrix_dok, matrix)
return matrix_dok.tocsr()
return matrix_dok.tocsc()

def form_rr_term(self, tr_rates, mats):
"""Function to form the transfer rate term matrices.
Expand Down Expand Up @@ -713,7 +713,7 @@ def form_rr_term(self, tr_rates, mats):

Returns
-------
scipy.sparse.csr_matrix
scipy.sparse.csc_matrix
Sparse matrix representing transfer term.

"""
Expand Down Expand Up @@ -746,7 +746,7 @@ def form_rr_term(self, tr_rates, mats):
n = len(self)
matrix_dok = sp.dok_matrix((n, n))
dict.update(matrix_dok, matrix)
return matrix_dok.tocsr()
return matrix_dok.tocsc()

def get_branch_ratios(self, reaction="(n,gamma)"):
"""Return a dictionary with reaction branching ratios
Expand Down
4 changes: 2 additions & 2 deletions openmc/deplete/cram.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def __call__(self, A, n0, dt):
Final compositions after ``dt``

"""
A = sp.csr_matrix(A * dt, dtype=np.float64)
A = dt * sp.csc_matrix(A, dtype=np.float64)
y = n0.copy()
ident = sp.eye(A.shape[0], format='csr')
ident = sp.eye(A.shape[0], format='csc')
for alpha, theta in zip(self.alpha, self.theta):
y += 2*np.real(alpha*sla.spsolve(A - theta*ident, y))
return y * self.alpha0
Expand Down