Change matrix format to CSC in depletion (#2764)

This commit is contained in:
Ethan Peterson 2023-11-28 08:34:02 -05:00 committed by GitHub
parent b66c6d47f2
commit 8b2698f5c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View file

@ -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
@ -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
@ -1023,7 +1023,7 @@ class DepSystemSolver(ABC):
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

View file

@ -596,7 +596,7 @@ class Chain:
Returns
-------
scipy.sparse.csr_matrix
scipy.sparse.csc_matrix
Sparse matrix representing depletion.
See Also
@ -680,11 +680,11 @@ class Chain:
# 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.
@ -713,7 +713,7 @@ class Chain:
Returns
-------
scipy.sparse.csr_matrix
scipy.sparse.csc_matrix
Sparse matrix representing transfer term.
"""
@ -746,7 +746,7 @@ class Chain:
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

View file

@ -75,9 +75,9 @@ class IPFCramSolver(DepSystemSolver):
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