Copyright (c) 2017-2020 Serpent-Tools developers 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
mdxFile = os.path.join(
os.environ["SERPENT_TOOLS_DATA"],
"ref_mdx0.m",
)
This notebook demonstrates the capabilities of the serpentTools
in regards to reading group micro cross-section files. SERPENT [1] produces a micro depletion file, containing independent and cumulative fission yields as well as group cross-sections for the isotopes and reactions defined by the user.
The MicroXSReader
is capable of reading this file, and storing the data directly on the reader. The reader has two methods to retrieve the data and ease the analysis. Note: in order to obtain the micro depletion files, the user must set the mdep
card in the input file.
In [2]:
import serpentTools
In [3]:
mdx = serpentTools.read(mdxFile)
The fission yields read in from the file are stored in the nfy
dictionary, where the keys represent a specific (parent, energy) pair and the corresponding values is a dictionary with fission products ids and corresponding fission yield values.
In [4]:
# All the (parent, energy) pairs can be obtained by using '.keys()'
pairs = mdx.nfy.keys()
list(pairs)[0:5] # list only the first five pairs
Out[4]:
Each pair represents the isotope undergoing fission and the impending neutron energy in MeV.
In [5]:
pair = list(pairs)[0] # obtain the first (isotope, energy) pair
print('Isotope= {: 1.0f}'.format(pair[0]))
print('Energy= {} MeV'.format(pair[1]))
The results for each pair are dictionaries that contain three fields:
fissProd
list of fission products ids
indYield
corresponding list of independent fission yields
cumYield
corresponding list of cumulative fission yields
In [6]:
# Obtain the keys in the nfy dictionary
mdx.nfy[pair].keys()
Out[6]:
In [7]:
# Print only the five first fission products
print(mdx.nfy[pair]['fissProd'][0:5])
In [8]:
# Print only the five first fission independent yields
print(mdx.nfy[pair]['indYield'][0:5])
In [9]:
# Print only the five first fission cumulative yields
print(mdx.nfy[pair]['cumYield'][0:5])
Fluxes ratios and uncertainties are stored in the fluxRatio
and fluxUnc
dictionaries, where the keys represent a specific universe and the corresponding values are group fluxes values.
In [10]:
# obtain the universes
print(mdx.fluxRatio.keys())
Cross sections and their uncertainties are stored in the xsVal
and xsUnc
dictionaries, where the keys represent a specific universe and the corresponding values are dictionaries.
In [11]:
# The keys within the nested dictionary describe the isotope, reaction and special flag
print(mdx.xsVal['0'].keys())
Each key has three entries (isotope, reaction, flag)
isotope
ID of the isotope (ZZAAA0/1), int or float
reaction
MT reaction, e.g., 102 (n,gamma)
flag
special flag to describe isomeric state or fission yield distribution number
For each such key (isotope, reaction, flag) the xsVal
and xsVal
store the group-wise flux values and uncertainties respectively.
In [12]:
val = mdx.xsVal['0']
unc = mdx.xsUnc['0']
In [13]:
# Print flux values
print(val[(10010, 102, 0)])
In [14]:
# Print flux uncertainties
print(unc[(10010, 102, 0)])
The MicroXSReader
object has two get
methods.
getFY
method obtains the independent and cumulative fission yields for a specific parent (ZZAAA0/1), daughter (ZZAAA0/1), neutron energy (MeV). If no parent or daaughter is found, the method raises an exception. The method also has a special flag that indicates whether the user wants to obtain the value corresponding to the nearest energy.
getXS
method to obtain the group-wise cross-sections for a specific universe, isotope and reaction.
In [15]:
indYield, cumYield = mdx.getFY(parent=922350, energy=2.53e-08, daughter=541350 )
print('Independent yield = {}'.format(indYield))
print('Cumulative yield = {}'.format(cumYield))
By default, the method includes a flag that allows to obtain the values for the closest energy defined by the user.
In [16]:
indYield, cumYield = mdx.getFY(parent=922350, energy=1e-06, daughter=541350 )
print('Independent yield = {}'.format(indYield))
print('Cumulative yield = {}'.format(cumYield))
The user can set this boolean flag to False if only the values at existing energies are of interest.
In [17]:
indYield, cumYield = mdx.getFY(parent=922350, energy=2.53e-08, daughter=541350, flagEnergy=False )
getXS
method is used to obtain the group cross-sections for a specific universe, isotope and reaction. The method returns the values and uncertainties.
In [18]:
# Obtain the group cross-sections
vals, unc = mdx.getXS(universe='0', isotope=10010, reaction=102)
In [19]:
# Print group flux values
print(vals)
In [20]:
# Print group flux uncertainties values
print(unc)
The method includes a special flag isomeric
, which is set to zero by default.
The special flag either describes the isomeric state or fission yield distribution number.
In [21]:
# Example of how to use the isomeric flag
vals, unc = mdx.getXS(universe='0', isotope=10010, reaction=102, isomeric=0)
If the universe exist, but the isotope or reaction do not exist, the method raises an error.
In [22]:
from serpentTools.settings import rc
In [23]:
rc['microxs.getFY'] = False # True/False only
rc['microxs.getXS'] = True # True/False only
rc['microxs.getFlx'] = True # True/False only
microxs.getFY
: True or False, store fission yields
microxs.getXS
: True or False, store group cross-sections and uncertainties
microxs.getFlx
: True or False, store flux ratios and uncertainties
In [24]:
mdx = serpentTools.read(mdxFile)
In [25]:
# fission yields are not stored on the reader
mdx.nfy.keys()
Out[25]:
The MicroXSReader
is capable of reading and storing all the data from the SERPENT micro depletion file. Fission yields, cross-sections and flux ratios are stored on the reader. The reader also includes two methods getFY
and getXS
to retrieve the data. Use of the rc
settings control object allows increased control over the data selected from the output file.