mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Provide Integrator get bos data from openmc|restart methods
All of the integrators pull the previous concentration and operator results from a restart file in the same way, but vary in how subsequent steps are handled. The predictor saves data here, while the SIE-based methods scale and reset the particles used. To this end, the _get_bos_data function has been broken into two methods: one for calling the operator and one for pulling from a restart file.
This commit is contained in:
parent
d3a7e73320
commit
a2545d7d7b
2 changed files with 31 additions and 39 deletions
|
|
@ -88,23 +88,21 @@ class Integrator(ABC):
|
|||
def __len__(self):
|
||||
return len(self.timesteps)
|
||||
|
||||
def _get_bos_data(self, step_index, step_power, prev_conc):
|
||||
if step_index > 0 or self.operator.prev_res is None:
|
||||
x = deepcopy(prev_conc)
|
||||
res = self.operator(x, step_power)
|
||||
else:
|
||||
# Get previous concentration
|
||||
x = self.operator.prev_res[-1].data[0]
|
||||
|
||||
# Get reaction rates and keff
|
||||
res = self.operator.prev_res[-1]
|
||||
res.rates = res.rates[0]
|
||||
res.k = res.k[0]
|
||||
|
||||
# Scale rates by ratio of powers
|
||||
res.rates *= step_power / res.power[0]
|
||||
def _get_bos_data_from_openmc(self, step_index, step_power, bos_conc):
|
||||
x = deepcopy(bos_conc)
|
||||
res = self.operator(x, step_power)
|
||||
return x, res
|
||||
|
||||
def _get_bos_data_from_restart(self, step_index, step_power, bos_conc):
|
||||
res = self.operator.prev_res[-1]
|
||||
bos_conc = res.data[0]
|
||||
res.rates = res.rates[0]
|
||||
res.k = res.k[0]
|
||||
|
||||
# Scale rates by ratio of powers
|
||||
res.rates *= step_power / res.power[0]
|
||||
return bos_conc, res
|
||||
|
||||
def _get_start_data(self):
|
||||
if self.operator.prev_res is None:
|
||||
return 0.0, 0
|
||||
|
|
@ -116,7 +114,10 @@ class Integrator(ABC):
|
|||
t, self._ires = self._get_start_data()
|
||||
|
||||
for i, (dt, p) in enumerate(self):
|
||||
conc, res = self._get_bos_data(i, p, conc)
|
||||
if i > 0 or self.operator.prev_res is None:
|
||||
conc, res = self._get_bos_data_from_openmc(i, p, conc)
|
||||
else:
|
||||
conc, res = self._get_bos_data_from_restart(i, p, conc)
|
||||
proc_time, conc_list, res_list = self(conc, res.rates, dt, p, i)
|
||||
|
||||
# Insert BOS concentration, transport results
|
||||
|
|
|
|||
|
|
@ -100,30 +100,17 @@ class PredictorIntegrator(Integrator):
|
|||
self.operator.prev_res[-1].time[-1],
|
||||
len(self.operator.prev_res) - 1)
|
||||
|
||||
def _get_bos_data(self, step_index, step_power, prev_conc):
|
||||
if step_index > 0 or self.operator.prev_res is None:
|
||||
conc = deepcopy(prev_conc)
|
||||
res = self.operator(conc, step_power)
|
||||
if step_index == len(self) - 1:
|
||||
tvec = [self.timesteps[step_index]] * 2
|
||||
else:
|
||||
tvec = self.timesteps[step_index:step_index + 2]
|
||||
|
||||
self._save_results(
|
||||
[conc], [res], tvec, step_power,
|
||||
self._istart + step_index, self._dep_proc_time)
|
||||
def _get_bos_data_from_openmc(self, step_index, step_power, prev_conc):
|
||||
conc = deepcopy(prev_conc)
|
||||
res = self.operator(conc, step_power)
|
||||
if step_index == len(self) - 1:
|
||||
tvec = [self.timesteps[step_index]] * 2
|
||||
else:
|
||||
# Get previous concentration
|
||||
conc = self.operator.prev_res[-1].data[0]
|
||||
|
||||
# Get reaction rates and keff
|
||||
res = self.operator.prev_res[-1]
|
||||
res.rates = res.rates[0]
|
||||
res.k = res.k[0]
|
||||
|
||||
# Scale rates by ratio of powers
|
||||
res.rates *= step_power / res.power[0]
|
||||
tvec = self.timesteps[step_index:step_index + 2]
|
||||
|
||||
self._save_results(
|
||||
[conc], [res], tvec, step_power,
|
||||
self._istart + step_index, self._dep_proc_time)
|
||||
return conc, res
|
||||
|
||||
def integrate(self):
|
||||
|
|
@ -133,7 +120,11 @@ class PredictorIntegrator(Integrator):
|
|||
t, self._istart = self._get_start_data()
|
||||
|
||||
for i, (dt, p) in enumerate(self):
|
||||
conc, res = self._get_bos_data(i, p, conc)
|
||||
if i > 0 or self.operator.prev_res is None:
|
||||
conc, res = self._get_bos_data_from_openmc(i, p, conc)
|
||||
else:
|
||||
conc, res = self._get_bos_data_from_restart(i, p, conc)
|
||||
|
||||
# __call__ returns empty list since there aren't
|
||||
# intermediate transport solutions
|
||||
self._dep_proc_time, conc, _res_list = self(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue