Merge pull request #1636 from paulromano/avoid-transport-solves

Avoid transport solve for decay-only timesteps
This commit is contained in:
Andrew Johnson 2020-08-13 09:47:43 -04:00 committed by GitHub
commit 09edd01d2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 5 deletions

View file

@ -858,16 +858,29 @@ class Integrator(ABC):
return (self.operator.prev_res[-1].time[-1],
len(self.operator.prev_res) - 1)
def integrate(self):
"""Perform the entire depletion process across all steps"""
def integrate(self, final_step=True):
"""Perform the entire depletion process across all steps
Parameters
----------
final_step : bool, optional
Indicate whether or not a transport solve should be run at the end
of the last timestep.
.. versionadded:: 0.12.1
"""
with self.operator as conc:
t, self._i_res = self._get_start_data()
for i, (dt, p) in enumerate(self):
# Solve transport equation (or obtain result from restart)
if i > 0 or self.operator.prev_res is None:
conc, res = self._get_bos_data_from_operator(i, p, conc)
else:
conc, res = self._get_bos_data_from_restart(i, p, conc)
# Solve Bateman equations over time interval
proc_time, conc_list, res_list = self(conc, res.rates, dt, p, i)
# Insert BOS concentration, transport results
@ -882,8 +895,11 @@ class Integrator(ABC):
t += dt
# Final simulation
res_list = [self.operator(conc, p)]
# Final simulation -- in the case that final_step is False, a zero
# source rate is passed to the transport operator (which knows to
# just return zero reaction rates without actually doing a transport
# solve)
res_list = [self.operator(conc, p if final_step else 0.0)]
Results.save(self.operator, [conc], res_list, [t, t],
p, self._i_res + len(self), proc_time)
self.operator.write_bos_data(len(self) + self._i_res)

View file

@ -276,6 +276,16 @@ class Operator(TransportOperator):
Eigenvalue and reaction rates resulting from transport operator
"""
# Reset results in OpenMC
openmc.lib.reset()
# If the source rate is zero, return zero reaction rates without running
# a transport solve
if power == 0.0:
rates = self.reaction_rates.copy()
rates.fill(0.0)
return OperatorResult(ufloat(0.0, 0.0), rates)
# Prevent OpenMC from complaining about re-creating tallies
openmc.reset_auto_ids()
@ -290,7 +300,6 @@ class Operator(TransportOperator):
self._yield_helper.update_tally_nuclides(nuclides)
# Run OpenMC
openmc.lib.reset()
openmc.lib.run()
openmc.lib.reset_timers()