Skip to content

Commit

Permalink
integrate adaptive with mpi
Browse files Browse the repository at this point in the history
  • Loading branch information
church89 committed Dec 21, 2023
1 parent 2e9b7b4 commit fa5f8f2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions openmc/deplete/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ def integrate(self, final_step=True, output=True):

self.operator.finalize()

def integrate_adaptive(self, material_name, nuclides, final_step=True,
def integrate_adaptive(self, material_id, nuclides, final_step=True,
output=True, tol=2e-7, err=2e-4, rho1=0.5, rho2=5, f=0.8):
"""Perform the entire depletion process across all steps
Expand All @@ -884,9 +884,7 @@ def integrate_adaptive(self, material_name, nuclides, final_step=True,
with change_directory(self.operator.output_dir):
n = self.operator.initial_condition()
t, self._i_res = self._get_start_data()
mat_id = [mat.id for mat in self.operator.materials \
if mat.name == material_name][0]
mat_idx = self.operator._mat_index_map[str(mat_id)]

nuc_ids = [id for nuc,id in self.chain.nuclide_dict.items() if nuc in nuclides]

dt = self.timesteps[0]
Expand Down Expand Up @@ -937,9 +935,19 @@ def integrate_adaptive(self, material_name, nuclides, final_step=True,
n = n_list.pop()
StepResult.save(self.operator, n_list, res_list, [t, t + dt],
source_rate, self._i_res + i, proc_time, root)

dt *= self._adapt_timestep(n_list[1:][0], n, mat_idx, nuc_ids,

for rank in range(comm.size):
number_i = comm.bcast(self.operator.number, root=rank)
if material_id in number_i.materials:
rank_mat = rank

if material_id in self.operator.local_mats:
mat_idx = self.operator.local_mats.index(material_id)
dt *= self._adapt_timestep(n_list[1:][0], n, mat_idx, nuc_ids,
tol, err, rho1, rho2, f)
comm.barrier()
dt = comm.bcast(dt, root=rank_mat)

t += dt
i += 1
# Final simulation -- in the case that final_step is False, a zero
Expand All @@ -961,6 +969,7 @@ def integrate_adaptive(self, material_name, nuclides, final_step=True,

def _adapt_timestep(self, n_pred, n_corr, mat_idx, nuc_ids, tol, err, rho1,
rho2, f ):

filt_pred = take(n_pred[mat_idx], nuc_ids)
filt_corr = take(n_corr[mat_idx], nuc_ids)

Expand Down

0 comments on commit fa5f8f2

Please sign in to comment.