Pass prev_res onto TransportOperator.__init__

Document that this attribute will either be a
ResultsList or None, both on TransportOperator and
Operator.
This commit is contained in:
Andrew Johnson 2019-08-06 17:00:41 -05:00
parent 78943d1086
commit e286940f8e
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB
2 changed files with 19 additions and 16 deletions

View file

@ -17,6 +17,7 @@ from numpy import nonzero, empty
from openmc.data import DataLibrary, JOULE_PER_EV
from openmc.checkvalue import check_type, check_greater_than
from .chain import Chain
from .results_list import ResultsList
OperatorResult = namedtuple('OperatorResult', ['k', 'rates'])
OperatorResult.__doc__ = """\
@ -61,6 +62,8 @@ class TransportOperator(ABC):
in initial condition to ensure they exist in the decay chain.
Only done for nuclides with reaction rates.
Defaults to 1.0e3.
prev_results : ResultsList, optional
Results from a previous depletion calculation.
Attributes
----------
@ -68,8 +71,12 @@ class TransportOperator(ABC):
Initial atom density [atoms/cm^3] to add for nuclides that are zero
in initial condition to ensure they exist in the decay chain.
Only done for nuclides with reaction rates.
prev_res : ResultsList or None
Results from a previous depletion calculation. ``None`` if no
results are to be used.
"""
def __init__(self, chain_file=None, fission_q=None, dilute_initial=1.0e3):
def __init__(self, chain_file=None, fission_q=None, dilute_initial=1.0e3,
prev_results=None):
self.dilute_initial = dilute_initial
self.output_dir = '.'
@ -93,6 +100,11 @@ class TransportOperator(ABC):
"of adding depletion_chain to OPENMC_CROSS_SECTIONS",
FutureWarning)
self.chain = Chain.from_xml(chain_file, fission_q)
if prev_results is None:
self.prev_res = None
else:
check_type("previous results", prev_results, ResultsList)
self.prev_results = prev_res
@property
def dilute_initial(self):
@ -122,7 +134,6 @@ class TransportOperator(ABC):
Eigenvalue and reaction rates resulting from transport operator
"""
pass
def __enter__(self):
# Save current directory and move to specific output directory
@ -157,8 +168,6 @@ class TransportOperator(ABC):
Total density for initial conditions.
"""
pass
@abstractmethod
def get_results_info(self):
"""Returns volume list, cell lists, and nuc lists.
@ -175,8 +184,6 @@ class TransportOperator(ABC):
All burnable materials in the geometry.
"""
pass
def finalize(self):
pass

View file

@ -112,28 +112,24 @@ class Operator(TransportOperator):
Initial heavy metal inventory
local_mats : list of str
All burnable material IDs being managed by a single process
prev_res : ResultsList
Results from a previous depletion calculation
prev_res : ResultsList or None
Results from a previous depletion calculation. ``None`` if no
results are to be used.
diff_burnable_mats : bool
Whether to differentiate burnable materials with multiple instances
"""
def __init__(self, geometry, settings, chain_file=None, prev_results=None,
diff_burnable_mats=False, fission_q=None,
dilute_initial=1.0e3):
super().__init__(chain_file, fission_q, dilute_initial)
super().__init__(chain_file, fission_q, dilute_initial, prev_results)
self.round_number = False
self.settings = settings
self.geometry = geometry
self.diff_burnable_mats = diff_burnable_mats
if prev_results is not None:
if self.prev_res is not None:
# Reload volumes into geometry
prev_results[-1].transfer_volumes(geometry)
# Store previous results in operator
self.prev_res = prev_results
else:
self.prev_res = None
self.prev_results[-1].transfer_volumes(geometry)
# Differentiate burnable materials with multiple instances
if self.diff_burnable_mats: