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.
Data files are not included with the python package, but can be downloaded from the GitHub repository. For this tutorial, the files are placed in the directory identified with the SERPENT_TOOLS_DATA
environment variable.
In [1]:
import os
branchFile = os.path.join(
os.environ["SERPENT_TOOLS_DATA"],
"demo.coe",
)
This notebook demonstrates the capability of the serpentTools
package to read branching coefficient files. The format of these files is structured to iterate over:
The output files are described in more detail on the SERPENT Wiki
Note
Without modifying the settings, the BranchingReader
assumes that all group constant data is presented without the associated uncertainties. See below for examples on the various ways to adjust the UserSettings
In [2]:
%matplotlib inline
import serpentTools
In [3]:
r0 = serpentTools.read(branchFile)
The branches are stored in custom dictionary-like BranchContainer
objects in the branches
dictionary
In [4]:
r0.branches.keys()
Out[4]:
Here, the keys are tuples of strings indicating what perturbations/branch states were applied for each SERPENT
solution. Examining a particular case
In [5]:
b0 = r0.branches['B1000', 'FT600']
print(b0)
SERPENT
allows the user to define variables for each branch through:
var V1_name V1_value
cards. These are stored in the stateData
attribute
In [6]:
b0.stateData
Out[6]:
The keys 'DATE'
, 'TIME'
, and 'VERSION'
are included by default in the output, while the 'BOR'
and 'TFU'
have been defined for this branch.
The BranchContainer
stores group constant data in HomogUniv
objects as a dictionary.
In [7]:
for key in b0:
print(key)
The keys here are UnivTuple
instances indicating the universe ID and point in burnup schedule.
These universes can be obtained by indexing into the BranchContainer
, or by using the getUniv
method.
In [8]:
univ0 = b0['0', 1, 1, None]
univ0
Out[8]:
In [9]:
univ0.name, univ0.bu, univ0.step, univ0.day
Out[9]:
In [10]:
univ1 = b0.getUniv('0', burnup=1)
univ2 = b0.getUniv('0', index=1)
assert univ0 is univ1 is univ2
Group constant data is spread out across sub-dictionaries:
infExp
: Expected values for infinite medium group constantsinfUnc
: Relative uncertainties for infinite medium group constantsb1Exp
: Expected values for leakge-corrected group constantsb1Unc
: Relative uncertainties for leakge-corrected group constantsgc
: Group constant data that does not match the INF
nor B1
schemegcUnc
: Relative uncertainties for data in gc
For this problem, only expected values for infinite and critical spectrum (B1) group constants are returned, so only the infExp
and b1Exp
dictionaries contain data
In [11]:
univ0.infExp
Out[11]:
In [12]:
univ0.infUnc
Out[12]:
In [13]:
univ0.b1Exp
Out[13]:
In [14]:
univ0.gc
Out[14]:
In [15]:
univ0.gcUnc
Out[15]:
Group constants and their associated uncertainties can be obtained using the get
method.
In [16]:
univ0.get('infFiss')
Out[16]:
In [17]:
try:
univ0.get('infS0', uncertainty=True)
except KeyError as ke: # no uncertainties here
print(str(ke))
HomogUniv
objects are capable of plotting homogenized data using the plot
method. This method is tuned to plot group constants, such as cross sections, for a known group structure. This is reflected in the default axis scaling, but can be adjusted on a per case basis. If the group structure is not known, then the data is plotted simply against bin-index.
In [18]:
univ0.plot('infFiss')
Out[18]:
In [19]:
univ0.plot(['infFiss', 'b1Tot'], loglog=False);
The ResultsReader
example has a more thorough example of this plot
method, including formatting the line labels.
In [20]:
for names, branch in r0.iterBranches():
print(names, branch)
The SERPENT
set coefpara
card already restricts the data present in the coeffient file to user control, and the BranchingReader
includes similar control.
Below are the various settings that the BranchingReader
uses to read and process coefficient files.
In our example above, the BOR
and TFU
variables represented boron concentration and fuel temperature, and can easily be cast into numeric values using the branching.floatVariables
and branching.intVariables
settings. From the previous example, we see that the default action is to store all state data variables as strings.
In [21]:
assert isinstance(b0.stateData['BOR'], str)
As demonstrated in the Settings example, use of xs.variableExtras
xs.variableGroups
controls what data is stored on the HomogUniv
objects. By default, all variables present in the coefficient file are stored.
In [22]:
from serpentTools.settings import rc
rc['branching.floatVariables'] = ['BOR']
rc['branching.intVariables'] = ['TFU']
rc['xs.getB1XS'] = False
rc['xs.variableExtras'] = ['INF_TOT', 'INF_SCATT0']
r1 = serpentTools.read(branchFile)
In [23]:
b1 = r1.branches['B1000', 'FT600']
In [24]:
b1.stateData
Out[24]:
In [25]:
assert isinstance(b1.stateData['BOR'], float)
assert isinstance(b1.stateData['TFU'], int)
Inspecting the data stored on the homogenized universes reveals only the variables explicitly requested are present
In [26]:
univ4 = b1.getUniv('0', 0)
univ4.infExp
Out[26]:
In [27]:
univ4.b1Exp
Out[27]:
The BranchingReader
is capable of reading coefficient files created by the SERPENT
automated branching process. The data is stored according to the branch parameters, universe information, and burnup. This reader also supports user control of the processing by selecting what state parameters should be converted from strings to numeric types, and further down-selection of data.