Skip to content

Commit

Permalink
add continue feature for depletion
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisgross1296 committed Jan 22, 2025
1 parent 560bd22 commit 1300665
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion openmc/deplete/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ def __init__(
power_density: Optional[Union[float, Sequence[float]]] = None,
source_rates: Optional[Sequence[float]] = None,
timestep_units: str = 's',
solver: str = "cram48"
solver: str = "cram48",
continue_timesteps: bool = False,
):
# Check number of stages previously used
if operator.prev_res is not None:
Expand Down Expand Up @@ -629,6 +630,27 @@ def __init__(
else:
raise ValueError(f"Invalid timestep unit '{unit}'")

# validate existing depletion steps are consistent with those passed to operator
if continue_timesteps:
completed_timesteps = operator.prev_res.get_times()
completed_source_rates = operator.prev_res.get_source_rates()
num_previous_steps_run = len(completed_timesteps)
for step in len(completed_timesteps):
if (
timesteps[step] == completed_timesteps[step]
and source_rates[step] == completed_source_rates[step]
):
continue
else:
raise ValueError(
"You are attempting to continue a run in which the previous results "
"do not have the same initial steps as those provided to the "
"Integrator. Please make sure you are using the correct timesteps,"
"powers or power densities, and previous results file."
)
seconds = seconds[num_previous_steps_run:]
source_rates = source_rates[num_previous_steps_run:]

self.timesteps = np.asarray(seconds)
self.source_rates = np.asarray(source_rates)

Expand Down

0 comments on commit 1300665

Please sign in to comment.