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

Add reactivity control to coupled transport-depletion analyses #2693

Open
wants to merge 67 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
41653f0
first commit to new branch
church89 Aug 23, 2023
1d3f0ca
batchwise first commits
church89 Sep 4, 2023
f561da1
update unit test
church89 Sep 5, 2023
652df2b
add test unit
church89 Sep 5, 2023
c08b762
unit test update
church89 Sep 6, 2023
7b27002
further improvements to the module
church89 Sep 12, 2023
0910bf2
add unit and regression tests
church89 Sep 12, 2023
2cd774e
Merge pull request #10 from openmc-dev/develop
church89 Sep 12, 2023
562baad
add missing docstrings
church89 Sep 13, 2023
7643aaf
remove unused import
church89 Sep 13, 2023
1777cee
add missing returns
church89 Sep 13, 2023
6eb6651
fix typo
church89 Sep 13, 2023
42b8e3d
Merge pull request #11 from openmc-dev/develop
church89 Sep 14, 2023
2d48f17
prevent to openmc batchwise_root when to there
church89 Sep 14, 2023
d56fb98
Apply suggestions from code review
church89 Feb 5, 2024
5e2023a
address comments by @drewejohnson
church89 Feb 5, 2024
4a2788e
fix some docstrings
church89 Feb 6, 2024
3110e45
reformatted with black
church89 Feb 6, 2024
a4f1f16
refactoring of _search_for_keff method
church89 Feb 6, 2024
0c804dd
fix some spelling typos
church89 Feb 6, 2024
38ed171
first commit to new branch
church89 Aug 23, 2023
cea8801
resolve conflicts
church89 Feb 7, 2024
7138d2d
update unit test
church89 Sep 5, 2023
872fa81
add test unit
church89 Sep 5, 2023
c16bece
unit test update
church89 Sep 6, 2023
643a75f
further improvements to the module
church89 Sep 12, 2023
94abad5
add unit and regression tests
church89 Sep 12, 2023
688631c
add missing docstrings
church89 Sep 13, 2023
325969f
remove unused import
church89 Sep 13, 2023
5d6e991
add missing returns
church89 Sep 13, 2023
85a1f35
fix typo
church89 Sep 13, 2023
d69a8a8
prevent to openmc batchwise_root when to there
church89 Sep 14, 2023
13ee2e3
Apply suggestions from code review
church89 Feb 5, 2024
1731fda
address comments by @drewejohnson
church89 Feb 5, 2024
e8c36f6
fix some docstrings
church89 Feb 6, 2024
e4c0ad2
reformatted with black
church89 Feb 6, 2024
f1213a4
refactoring of _search_for_keff method
church89 Feb 6, 2024
12a988d
fix some spelling typos
church89 Feb 6, 2024
ad8c7ed
fix conflicts
church89 Feb 7, 2024
ef4fe68
missing underscore
church89 Feb 7, 2024
1aad455
add batchwise get method and update unit test
church89 Feb 12, 2024
f3dfdf8
Apply suggestions from code review
church89 Mar 14, 2024
9d6c5be
address comments by @drewejohnson
church89 Mar 14, 2024
a4b44ed
address more comments by @drewejohnson
church89 Mar 15, 2024
0a2933c
replaced batchwise nomenclature with reactivity_control one
church89 Mar 15, 2024
0ccc75a
update regression reference result files
church89 Mar 15, 2024
da184bb
few fixes
church89 Mar 18, 2024
64543ff
fix unit test failing
church89 Mar 18, 2024
9328e5b
explicit path argument in SIIntegrator step result save method, since…
church89 Mar 19, 2024
a4731ab
add reactivity control restarting condition to integrator class
church89 Mar 19, 2024
49191d4
Merge branch 'develop' into batchwise_pr
church89 Mar 20, 2024
ee13d16
remove unused index argumnet in restart method to comply with latest …
church89 Mar 20, 2024
12a1e70
make sure cell attribute vector maintain initial coordinates
church89 Mar 21, 2024
f67b231
make sure bracket type is an array and apply black code style
church89 Mar 21, 2024
06366b5
fix failing regression test
church89 Mar 21, 2024
fbf91c4
update reference result files
church89 Mar 21, 2024
21e1ac6
change warning message
church89 Mar 26, 2024
6ad6ea0
restore check conditions in adaptive search_for_keff routine
church89 Apr 8, 2024
efc1f61
made ReactivityControllers settable through the integrator
church89 Apr 16, 2024
75ca1f2
Merge pull request #31 from openmsr/reactivity_control
church89 Apr 16, 2024
d2fa7a0
extend use of paramteric geometry to lattice and not only universe
church89 May 7, 2024
7583f78
implement suggested changes to reactivity control classes
church89 Jun 5, 2024
fa13a81
update tests
church89 Jun 6, 2024
c3a6705
Merge pull request #32 from openmsr/reactivity_control_abstrac
church89 Jun 6, 2024
e7c15cf
add forgotten argument to StepResult save method
church89 Jun 6, 2024
4f988cf
Merge remote-tracking branch 'openmsr/add_path_to_step_res' into batc…
church89 Jun 6, 2024
f576e87
Merge branch 'develop' into batchwise_pr
church89 Jun 6, 2024
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
1 change: 1 addition & 0 deletions openmc/deplete/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .results import *
from .integrators import *
from .transfer_rates import *
from .reactivity_control import *
from . import abc
from . import cram
from . import helpers
74 changes: 66 additions & 8 deletions openmc/deplete/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import numpy as np
from uncertainties import ufloat

from openmc.checkvalue import check_type, check_greater_than, PathLike
from openmc.checkvalue import check_value, check_type, check_greater_than, PathLike
from openmc.mpi import comm
from openmc import Material
from .stepresult import StepResult
Expand All @@ -29,7 +29,12 @@
from .pool import deplete
from .reaction_rates import ReactionRates
from .transfer_rates import TransferRates

from openmc import Material, Cell
from .reactivity_control import (
GeometricalCellReactivityController,
TemperatureCellReactivityController,
RefuelMaterialReactivityController
)

__all__ = [
"OperatorResult", "TransportOperator",
Expand Down Expand Up @@ -563,6 +568,9 @@ class Integrator(ABC):

transfer_rates : openmc.deplete.TransferRates
Instance of TransferRates class to perform continuous transfer during depletion
reactivity_control : openmc.deplete.ReactivityController
Instance of ReactivityController class to perform reactivity control during
transport-depletion simulation.

.. versionadded:: 0.14.0

Expand Down Expand Up @@ -653,6 +661,7 @@ def __init__(
self.source_rates = np.asarray(source_rates)

self.transfer_rates = None
self._reactivity_control = None

if isinstance(solver, str):
# Delay importing of cram module, which requires this file
Expand Down Expand Up @@ -701,6 +710,10 @@ def solver(self, func):

self._solver = func

@property
def reactivity_control(self):
return self._reactivity_control

def _timed_deplete(self, n, rates, dt, matrix_func=None):
start = time.time()
results = deplete(
Expand Down Expand Up @@ -787,6 +800,13 @@ def _get_start_data(self):
return (self.operator.prev_res[-1].time[-1],
len(self.operator.prev_res) - 1)

def _get_bos_from_reactivity_control(self, step_index, bos_conc):
"""Get BOS from reactivity control."""
x = deepcopy(bos_conc)
# Get new vector after keff criticality control
x, root = self._reactivity_control.search_for_keff(x, step_index)
return x, root

def integrate(
self,
final_step: bool = True,
Expand Down Expand Up @@ -821,10 +841,18 @@ def integrate(

# Solve transport equation (or obtain result from restart)
if i > 0 or self.operator.prev_res is None:
# Update geometry/material according to reactivity control
if self._reactivity_control is not None and source_rate != 0.0:
n, root = self._get_bos_from_reactivity_control(i, n)
else:
root = None
n, res = self._get_bos_data_from_operator(i, source_rate, n)
else:
n, res = self._get_bos_data_from_restart(source_rate, n)

if self._reactivity_control:
root = self.operator.prev_res[-1].reac_cont
else:
root = None
# Solve Bateman equations over time interval
proc_time, n_list, res_list = self(n, res.rates, dt, source_rate, i)

Expand All @@ -834,9 +862,8 @@ def integrate(

# Remove actual EOS concentration for next step
n = n_list.pop()

StepResult.save(self.operator, n_list, res_list, [t, t + dt],
source_rate, self._i_res + i, proc_time, path)
source_rate, self._i_res + i, proc_time, root, path)

t += dt

Expand All @@ -846,9 +873,13 @@ def integrate(
# solve)
if output and final_step and comm.rank == 0:
print(f"[openmc.deplete] t={t} (final operator evaluation)")
if self._reactivity_control is not None and source_rate != 0.0:
n, root = self._get_bos_from_reactivity_control(i+1, n)
else:
root = None
res_list = [self.operator(n, source_rate if final_step else 0.0)]
StepResult.save(self.operator, [n], res_list, [t, t],
source_rate, self._i_res + len(self), proc_time)
source_rate, self._i_res + len(self), proc_time, root)
self.operator.write_bos_data(len(self) + self._i_res)

self.operator.finalize()
Expand Down Expand Up @@ -887,6 +918,33 @@ def add_transfer_rate(
self.transfer_rates.set_transfer_rate(material, components, transfer_rate,
transfer_rate_units, destination_material)

def add_reactivity_control(self, obj, attr, **kwargs):
"""Add reactivity control to integrator scheme.

Parameters
----------
obj : openmc.Cell or openmc.Material object or id or str name
Cell or Materials identifier to where add reactivity control
attr : str
Attribute to specify the type of reactivity control. Accepted values
are: 'translation', 'rotation', 'temperature' for an openmc.Cell
object; 'refuel' for an openmc.Material object.
**kwargs
keyword arguments that are passed to ReactivityController.

"""
check_value('attribute', attr, ('translation', 'rotation',
'temperature', 'refuel'))
if attr in ('translation', 'rotation'):
reactivity_control = GeometricalCellReactivityController
elif attr == 'temperature':
reactivity_control = TemperatureCellReactivityController
elif attr == 'refuel':
reactivity_control = RefuelMaterialReactivityController

self._reactivity_control = reactivity_control.from_params(obj, attr,
self.operator,**kwargs)

@add_params
class SIIntegrator(Integrator):
r"""Abstract class for the Stochastic Implicit Euler integrators
Expand Down Expand Up @@ -1046,13 +1104,13 @@ def integrate(
n = n_list.pop()

StepResult.save(self.operator, n_list, res_list, [t, t + dt],
p, self._i_res + i, proc_time, path)
p, self._i_res + i, proc_time, path=path)

t += dt

# No final simulation for SIE, use last iteration results
StepResult.save(self.operator, [n], [res_list[-1]], [t, t],
p, self._i_res + len(self), proc_time, path)
p, self._i_res + len(self), proc_time, path=path)
self.operator.write_bos_data(self._i_res + len(self))

self.operator.finalize()
Expand Down
Loading