Skip to content

Commit

Permalink
Change matrix format to CSC in depletion (#2764)
Browse files Browse the repository at this point in the history
  • Loading branch information
eepeterson committed Nov 28, 2023
1 parent b66c6d4 commit 8b2698f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
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

0 comments on commit 8b2698f

Please sign in to comment.