mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Read chain file for deplete.Operator from OPENMC_CROSS_SECTIONS
If a chain_file is not passed when initializing an openmc.deplete.Operator object, then the chain_file will be read from the depletion_chain node from $OPENMC_CROSS_SECTIONS. A deprecation warning is raised if the environment variable OPENMC_DEPLETE_CHAIN is still set, informing the users that this information can instead be placed in their cross section file. Documentation is updated describing the logic in the chain_file search to reflect this in - TransportOperator - Operator - Chain . Closes #1239
This commit is contained in:
parent
1dd3ffbfcc
commit
cc98d13793
3 changed files with 27 additions and 7 deletions
|
|
@ -8,6 +8,8 @@ from collections import namedtuple
|
|||
import os
|
||||
from pathlib import Path
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from xml.etree import ElementTree as ET
|
||||
from warnings import warn
|
||||
|
||||
from .chain import Chain
|
||||
|
||||
|
|
@ -43,8 +45,9 @@ class TransportOperator(metaclass=ABCMeta):
|
|||
Parameters
|
||||
----------
|
||||
chain_file : str, optional
|
||||
Path to the depletion chain XML file. Defaults to the
|
||||
:envvar:`OPENMC_DEPLETE_CHAIN` environment variable if it exists.
|
||||
Path to the depletion chain XML file. Defaults to the file
|
||||
listed under ``depletion_chain`` in
|
||||
:envvar:`OPENMC_CROSS_SECTIONS` environment variable.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -62,8 +65,23 @@ class TransportOperator(metaclass=ABCMeta):
|
|||
if chain_file is None:
|
||||
chain_file = os.environ.get("OPENMC_DEPLETE_CHAIN", None)
|
||||
if chain_file is None:
|
||||
raise IOError("No chain specified, either manually or in "
|
||||
"environment variable OPENMC_DEPLETE_CHAIN.")
|
||||
xs_file = os.environ.get("OPENMC_CROSS_SECTIONS", None)
|
||||
if xs_file is None:
|
||||
raise IOError(
|
||||
"OPENMC_CROSS_SECTIONS environment variable "
|
||||
"not set.")
|
||||
root = ET.parse(xs_file).getroot()
|
||||
node = root.find("depletion_chain")
|
||||
if node is None:
|
||||
raise IOError(
|
||||
"No chain specified, either manually or "
|
||||
"under depletion_chain in environment variable "
|
||||
"OPENMC_CROSS_SECTIONS.")
|
||||
chain_file = node.get("path")
|
||||
else:
|
||||
warn("Use of OPENMC_DEPLETE_CHAIN is deprecated in favor "
|
||||
"of adding depletion_chain to OPENMC_CROSS_SECTIONS",
|
||||
DeprecationWarning)
|
||||
self.chain = Chain.from_xml(chain_file)
|
||||
|
||||
@abstractmethod
|
||||
|
|
|
|||
|
|
@ -107,7 +107,8 @@ class Chain(object):
|
|||
yield sublibrary files. The depletion chain used during a depletion
|
||||
simulation is indicated by either an argument to
|
||||
:class:`openmc.deplete.Operator` or through the
|
||||
:envvar:`OPENMC_DEPLETE_CHAIN` environment variable.
|
||||
``depletion_chain`` item in the :envvar:`OPENMC_CROSS_SECTIONS`
|
||||
environment variable.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
|
|||
|
|
@ -64,8 +64,9 @@ class Operator(TransportOperator):
|
|||
settings : openmc.Settings
|
||||
OpenMC Settings object
|
||||
chain_file : str, optional
|
||||
Path to the depletion chain XML file. Defaults to the
|
||||
:envvar:`OPENMC_DEPLETE_CHAIN` environment variable if it exists.
|
||||
Path to the depletion chain XML file. Defaults to the file
|
||||
listed under ``depletion_chain`` in
|
||||
:envvar:`OPENMC_CROSS_SECTIONS` environment variable.
|
||||
prev_results : ResultsList, optional
|
||||
Results from a previous depletion calculation. If this argument is
|
||||
specified, the depletion calculation will start from the latest state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue