Copyright (c) 2017-2020 Serpent-Tools developer team, GTRC
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The serpentTools
package is designed to, without intervention, be able to store all the data contained in each of the various output files. However, the serpentTools.settings
module grants great flexibility to the user over what data is obtained through the rc
class. This notebook will provide as an intro into using this class.
All the settings are given in Default Settings, showing their default values and possible options.
In [1]:
import serpentTools
from serpentTools.settings import rc
The rc
object can be used like a dictionary, polling all possible settings with the keys
method.
In [13]:
rc.keys()
Out[13]:
Settings such as depletion.materialVariables
are specific for the DepletionReader
, while settings that are led with xs
are sent to the ResultsReader
and BranchingReader
, as well as their specific settings. The rc
class acts as a dictionary, and updating a value is as simple as
In [3]:
rc['verbosity'] = 'debug'
The rc
object automatically checks to make sure the value is of the correct type, and is an allowable option, if given.
In [4]:
try:
rc['depletion.metadataKeys'] = False
except TypeError as te:
print(te)
In [5]:
try:
rc['serpentVersion'] = '1.2.3'
except KeyError as ke:
print(ke)
The rc
module can also be used inside a context manager to revert changes.
In [6]:
with rc:
rc['depletion.metadataKeys'] = ['ZAI', 'BU']
rc['depletion.metadataKeys']
rc['verbosity'] = 'info'
Two settings control what group constant data and what variables are extracted from the results and coefficient files.
xs.variableExtras
: Full SERPENT_STYLE
variable names, i.e. INF_TOT
, FISSION_PRODUCT_DECAY_HEAT
xs.variableGroups
: Select keywords that represent blocks of common variablesThese variable groups are described in Variable Groups and rely upon the SERPENT
version to properly expand the groups.
In [7]:
rc['serpentVersion']
Out[7]:
In [8]:
rc['xs.variableGroups'] = ['kinetics', 'xs', 'diffusion']
rc['xs.variableExtras'] = ['XS_DATA_FILE_PATH']
varSet = rc.expandVariables()
print(sorted(varSet))
However, one might see that the full group constant cross sections are not present in this set
In [9]:
assert 'INF_SCATT3' not in varSet
This is because two additional settings instruct the BranchingReader
and ResultsReader
to obtain infinite medium and leakage-corrected cross sections: xs.getInfXS
and xs.getB1XS
, respectively. By default, xs.getInfXS
and xs.getB1XS
default to True. This, in conjunction with leaving the xs.variableGroups
and xs.variableExtras
settings to empty lists, instructs these readers to obtain all the data present in their respective files.
See the BrancingReader
or ResultsReader
examples for more information on using these settings to control scraped data.
The rc
object allows for settings to be updated from a yaml configuration file using the loadYaml
method. The file contains setting names as keys with the desired variables as values, as
verbosity: warning
xs.getInfXS: False
However, the loader can also expand a nested dictionary structure, as
branching:
floatVariables: [Fhi, Blo]
depletion:
materials: [fuel*]
materialVariables:
[ADENS, MDENS, VOLUME]
In [12]:
%cat myConfig.yaml
In [10]:
myConf = 'myConfig.yaml'
rc.loadYaml(myConf)
rc['xs.getInfXS']
Out[10]: