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

Fix CMFD to work with scipy 1.13 #2936

Merged
merged 1 commit into from
Apr 4, 2024
Merged
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
14 changes: 9 additions & 5 deletions openmc/cmfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,14 +982,16 @@ def _initialize_linsolver(self):
temp_data = np.ones(len(loss_row))
temp_loss = sparse.csr_matrix((temp_data, (loss_row, loss_col)),
shape=(n, n))
temp_loss.sort_indices()

# Pass coremap as 1-d array of 32-bit integers
coremap = np.swapaxes(self._coremap, 0, 2).flatten().astype(np.int32)

args = temp_loss.indptr, len(temp_loss.indptr), \
temp_loss.indices, len(temp_loss.indices), n, \
return openmc.lib._dll.openmc_initialize_linsolver(
temp_loss.indptr.astype(np.int32), len(temp_loss.indptr),
temp_loss.indices.astype(np.int32), len(temp_loss.indices), n,
self._spectral, coremap, self._use_all_threads
return openmc.lib._dll.openmc_initialize_linsolver(*args)
)

def _write_cmfd_output(self):
"""Write CMFD output to buffer at the end of each batch"""
Expand Down Expand Up @@ -1585,6 +1587,7 @@ def _build_loss_matrix(self, adjoint):
loss_row = self._loss_row
loss_col = self._loss_col
loss = sparse.csr_matrix((data, (loss_row, loss_col)), shape=(n, n))
loss.sort_indices()
return loss

def _build_prod_matrix(self, adjoint):
Expand All @@ -1611,6 +1614,7 @@ def _build_prod_matrix(self, adjoint):
prod_row = self._prod_row
prod_col = self._prod_col
prod = sparse.csr_matrix((data, (prod_row, prod_col)), shape=(n, n))
prod.sort_indices()
return prod

def _execute_power_iter(self, loss, prod):
Expand Down Expand Up @@ -2307,8 +2311,8 @@ def _precompute_matrix_indices(self):
constant_values=_CMFD_NOACCEL)[:,:,1:]

# Create empty row and column vectors to store for loss matrix
row = np.array([])
col = np.array([])
row = np.array([], dtype=int)
col = np.array([], dtype=int)

# Store all indices used to populate production and loss matrix
is_accel = self._coremap != _CMFD_NOACCEL
Expand Down