mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
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.
This commit is contained in:
parent
f0bb600271
commit
1d791a16c9
2 changed files with 10 additions and 6 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
-------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue