Skip to content

Commit dbdcd9a

Browse files
committed
added option for chain object
1 parent bf271bd commit dbdcd9a

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

openmc/deplete/abc.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ class TransportOperator(ABC):
126126
127127
Parameters
128128
----------
129-
chain_file : str
130-
Path to the depletion chain XML file
129+
chain_file : str | Chain
130+
Path to the depletion chain XML file or instance of openmc.deplete.Chain.
131131
fission_q : dict, optional
132132
Dictionary of nuclides and their fission Q values [eV]. If not given,
133133
values will be pulled from the ``chain_file``.
@@ -149,7 +149,15 @@ def __init__(self, chain_file, fission_q=None, prev_results=None):
149149
self.output_dir = '.'
150150

151151
# Read depletion chain
152-
self.chain = Chain.from_xml(chain_file, fission_q)
152+
if isinstance(chain_file, Chain):
153+
self.chain = chain_file
154+
elif isinstance(chain_file, str):
155+
self.chain = Chain.from_xml(chain_file, fission_q)
156+
else:
157+
raise TypeError(
158+
f"Expected chain_file to be a string or Chain, not {type(chain_file)}"
159+
)
160+
153161
if prev_results is None:
154162
self.prev_res = None
155163
else:

openmc/deplete/openmc_operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class OpenMCOperator(TransportOperator):
3636
cross_sections : str or list of MicroXS
3737
Path to continuous energy cross section library, or list of objects
3838
containing cross sections.
39-
chain_file : str, optional
40-
Path to the depletion chain XML file. Defaults to
41-
openmc.config['chain_file'].
39+
chain_file : str | Chain
40+
Path to the depletion chain XML file or instance of openmc.deplete.Chain.
41+
Defaults to ``openmc.config['chain_file']``.
4242
prev_results : Results, optional
4343
Results from a previous depletion calculation. If this argument is
4444
specified, the depletion calculation will start from the latest state

0 commit comments

Comments
 (0)