From 1d791a16c9298a3bd97d033ceaf35f76a3aa09a8 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 17 Jul 2019 16:29:55 -0500 Subject: [PATCH] Pass iteration index to Integrator.__call__ For the higher order methods, like LEQI, a lower order method may be called for the first few steps. The LEQI method, with no restart data, will call CELI for the first iteration. To aid this, concrete Integrator classes will be passed an integer for the current iteration. Some methods, like the CECM and CELI, do not need this information. To maintain a consistent API, the iteration is an optional value to be passed to CECM.__call__, but will not be used. The default value in the call signature is ``_i=-1``, with documentation repeating that the value is not used nor needed. --- openmc/deplete/integrator/abc.py | 12 +++++++----- openmc/deplete/integrator/cecm.py | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/openmc/deplete/integrator/abc.py b/openmc/deplete/integrator/abc.py index 51877e5e6..c2324b35c 100644 --- a/openmc/deplete/integrator/abc.py +++ b/openmc/deplete/integrator/abc.py @@ -54,7 +54,7 @@ class Integrator(ABC): self.power = power @abstractmethod - def __call__(self, conc, rates, dt, power): + def __call__(self, conc, rates, dt, power, i): """Perform the integration across one time step Parameters @@ -67,6 +67,8 @@ class Integrator(ABC): Time in [s] for the entire depletion interval power : float Power of the system [W] + i : int + Current depletion step index Returns ------- @@ -111,11 +113,11 @@ class Integrator(ABC): def integrate(self): """Perform the entire depletion process across all steps""" with self.operator as conc: - t, i_start = self._get_start_data() + t, self._ires = self._get_start_data() for i, (dt, p) in enumerate(self): conc, res = self._get_bos_data(i, p, conc) - proc_time, conc_list, res_list = self(conc, res.rates, dt, p) + proc_time, conc_list, res_list = self(conc, res.rates, dt, p, i) # Insert BOS concentration, transport results conc_list.insert(0, conc) @@ -125,7 +127,7 @@ class Integrator(ABC): conc = conc_list.pop() self._save_results( - conc_list, res_list, [t, t + dt], p, i_start + i, + conc_list, res_list, [t, t + dt], p, self._ires + i, proc_time) t += dt @@ -133,7 +135,7 @@ class Integrator(ABC): # Final simulation res_list = [self.operator(conc, p)] self._save_results( - [conc], res_list, [t, t], p, i_start + len(self)) + [conc], res_list, [t, t], p, self._ires + len(self)) def _save_results(self, conc_list, results_list, time_list, power, index, proc_time=None): diff --git a/openmc/deplete/integrator/cecm.py b/openmc/deplete/integrator/cecm.py index 1bf6e5809..b9b7dedc6 100644 --- a/openmc/deplete/integrator/cecm.py +++ b/openmc/deplete/integrator/cecm.py @@ -25,7 +25,7 @@ class CECMIntegrator(Integrator): \end{aligned} """ - def __call__(self, conc, rates, dt, power): + def __call__(self, conc, rates, dt, power, _i=-1): """Integrate using CE/CM Parameters @@ -38,6 +38,8 @@ class CECMIntegrator(Integrator): Time in [s] for the entire depletion interval power : float Power of the system [W] + _i : int, optional + Current iteration count. Not used Returns -------