Skip to content

Commit

Permalink
added path arg to integrator.integrate (#2784)
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell authored Dec 12, 2023
1 parent a833c17 commit 124e62f
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions openmc/deplete/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from numpy import nonzero, empty, asarray
from uncertainties import ufloat

from openmc.checkvalue import check_type, check_greater_than
from openmc.checkvalue import check_type, check_greater_than, PathLike
from openmc.mpi import comm
from .stepresult import StepResult
from .chain import Chain
Expand Down Expand Up @@ -762,7 +762,12 @@ def _get_start_data(self):
return (self.operator.prev_res[-1].time[-1],
len(self.operator.prev_res) - 1)

def integrate(self, final_step=True, output=True):
def integrate(
self,
final_step: bool = True,
output: bool = True,
path: PathLike = 'depletion_results.h5'
):
"""Perform the entire depletion process across all steps
Parameters
Expand All @@ -776,6 +781,10 @@ def integrate(self, final_step=True, output=True):
Indicate whether to display information about progress
.. versionadded:: 0.13.1
path : PathLike
Path to file to write. Defaults to 'depletion_results.h5'.
.. versionadded:: 0.14.1
"""
with change_directory(self.operator.output_dir):
n = self.operator.initial_condition()
Expand All @@ -802,7 +811,7 @@ def integrate(self, final_step=True, output=True):
n = n_list.pop()

StepResult.save(self.operator, n_list, res_list, [t, t + dt],
source_rate, self._i_res + i, proc_time)
source_rate, self._i_res + i, proc_time, path)

t += dt

Expand Down Expand Up @@ -954,15 +963,21 @@ def _get_bos_data_from_operator(self, step_index, step_power, n_bos):
self.operator.settings.particles //= self.n_steps
return inherited

def integrate(self, output=True):
def integrate(
self,
output: bool = True,
path: PathLike = "depletion_results.h5"
):
"""Perform the entire depletion process across all steps
Parameters
----------
output : bool, optional
Indicate whether to display information about progress
path : PathLike
Path to file to write. Defaults to 'depletion_results.h5'.
.. versionadded:: 0.13.1
.. versionadded:: 0.14.1
"""
with change_directory(self.operator.output_dir):
n = self.operator.initial_condition()
Expand Down Expand Up @@ -992,13 +1007,13 @@ def integrate(self, output=True):
n = n_list.pop()

StepResult.save(self.operator, n_list, res_list, [t, t + dt],
p, self._i_res + i, proc_time)
p, self._i_res + i, proc_time, path)

t += dt

# No final simulation for SIE, use last iteration results
StepResult.save(self.operator, [n], [res_list[-1]], [t, t],
p, self._i_res + len(self), proc_time)
p, self._i_res + len(self), proc_time, path)
self.operator.write_bos_data(self._i_res + len(self))

self.operator.finalize()
Expand Down

0 comments on commit 124e62f

Please sign in to comment.