Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid division by 0 if source rate at last time step before restart w… #22

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions openmc/deplete/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ def _get_bos_data_from_restart(self, step_index, source_rate, bos_conc):
k = ufloat(res.k[0, 0], res.k[0, 1])

# Scale reaction rates by ratio of source rates
rates *= source_rate / res.source_rate
if res.source_rate != 0.0:
rates *= source_rate / res.source_rate
return bos_conc, OperatorResult(k, rates)

def _get_start_data(self):
Expand Down Expand Up @@ -808,16 +809,28 @@ def integrate(self, final_step=True, output=True):
# Solve transport equation (or obtain result from restart)
if i > 0 or self.operator.prev_res is None:
# Update geometry/material according to batchwise definition
if self.batchwise and source_rate != 0.0:
n, root = self._get_bos_from_batchwise(i, n)
if self.batchwise:
if source_rate != 0.0:
n, root = self._get_bos_from_batchwise(i, n)
else:
# Store root at previous timestep
root = self.batchwise._get_cell_attrib()
else:
root = None
n, res = self._get_bos_data_from_operator(i, source_rate, n)
else:
n, res = self._get_bos_data_from_restart(i, source_rate, n)
if self.batchwise:
root = self.operator.prev_res[-1].batchwise
self.batchwise.update_from_restart(n, root)
#TODO: this is just temporary (import math)
import math
if math.isnan(root):
prev_res_ts = -2
while (math.isnan(root)):
root = self.operator.prev_res[prev_res_ts].batchwise
prev_res_ts -= 1

self.batchwise.update_from_restart(i, n, root)
else:
root = None

Expand Down
18 changes: 9 additions & 9 deletions openmc/deplete/batchwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _model_builder(self, param):
"""

@abstractmethod
def update_from_restart(self, x, root):
def update_from_restart(self, step_index, x, root):
"""
"""

Expand Down Expand Up @@ -812,9 +812,9 @@ def search_for_keff(self, x, step_index):

return x, root

def update_from_restart(self, x, root):
def update_from_restart(self, step_index, x, root):
self._set_cell_attrib(root)
super()._update_materials(x)
super()._update_materials(x, step_index)

class BatchwiseCellGeometrical(BatchwiseCell):
"""
Expand Down Expand Up @@ -1222,8 +1222,8 @@ def _calculate_volumes(self, res):
volumes[mat_id] = number_i.get_mat_volume(mat_id)
return volumes

def update_from_restart(self, x, root):
super()._update_materials(x)
def update_from_restart(self, step_index, x, root):
super()._update_materials(x, step_index)

class BatchwiseMaterialRefuel(BatchwiseMaterial):
"""
Expand Down Expand Up @@ -1938,15 +1938,15 @@ def set_density_function(self, mats, density_func, oxidation_states):
def add_material(self, mat, value, mat_vector, timestep, units):
self.bw_geom.add_material(mat, value, mat_vector, timestep, units)

def update_from_restart(self, x, root):
def update_from_restart(self, step_index, x, root):
"""
This is for a restart. TODO update abc class
Parameters
----------
x : list of numpy.ndarray
Total atom concentrations
"""
self.bw_geom.update_from_restart(x, root)
self.bw_geom.update_from_restart(step_index, x, root)

def search_for_keff(self, x, step_index):
"""
Expand Down Expand Up @@ -2046,15 +2046,15 @@ def set_density_function(self, mats, density_func, oxidation_states):
def add_material(self, mat, value, mat_vector, timestep, units):
self.bw_geom.add_material(mat, value, mat_vector, timestep, units)

def update_from_restart(self, x, root):
def update_from_restart(self, step_index, x, root):
"""
This is for a restart. TODO update abc class
Parameters
----------
x : list of numpy.ndarray
Total atom concentrations
"""
self.bw_geom.update_from_restart(x, root)
self.bw_geom.update_from_restart(step_index, x, root)

def search_for_keff(self, x, step_index):
"""
Expand Down