diff --git a/openmc/deplete/chain.py b/openmc/deplete/chain.py index 60716895548..e15b127d08a 100644 --- a/openmc/deplete/chain.py +++ b/openmc/deplete/chain.py @@ -597,9 +597,12 @@ def form_matrix(self, rates, fission_yields=None): -------- :meth:`get_default_fission_yields` """ - matrix = defaultdict(float) reactions = set() + # Use DOK matrix as intermediate representation for matrix + n = len(self) + matrix = sp.dok_matrix((n, n)) + if fission_yields is None: fission_yields = self.get_default_fission_yields() @@ -674,11 +677,8 @@ def form_matrix(self, rates, fission_yields=None): # Clear set of reactions reactions.clear() - # 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.tocsc() + # Return CSC representation instead of DOK + return matrix.tocsc() def form_rr_term(self, tr_rates, mats): """Function to form the transfer rate term matrices. @@ -711,7 +711,9 @@ def form_rr_term(self, tr_rates, mats): Sparse matrix representing transfer term. """ - matrix = defaultdict(float) + # Use DOK as intermediate representation + n = len(self) + matrix = sp.dok_matrix((n, n)) for i, nuc in enumerate(self.nuclides): elm = re.split(r'\d+', nuc.name)[0] @@ -737,10 +739,9 @@ def form_rr_term(self, tr_rates, mats): else: matrix[i, i] = 0.0 #Nothing else is allowed - n = len(self) - matrix_dok = sp.dok_matrix((n, n)) - dict.update(matrix_dok, matrix) - return matrix_dok.tocsc() + + # Return CSC instead of DOK + return matrix.tocsc() def get_branch_ratios(self, reaction="(n,gamma)"): """Return a dictionary with reaction branching ratios diff --git a/setup.py b/setup.py index 84a2ad367ee..eeb0b3f293c 100755 --- a/setup.py +++ b/setup.py @@ -64,7 +64,7 @@ # Dependencies 'python_requires': '>=3.7', 'install_requires': [ - 'numpy>=1.9', 'h5py', 'scipy<1.12', 'ipython', 'matplotlib', + 'numpy>=1.9', 'h5py', 'scipy', 'ipython', 'matplotlib', 'pandas', 'lxml', 'uncertainties' ], 'extras_require': {