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
depFile = os.path.join(
os.environ["SERPENT_TOOLS_DATA"],
"demo_dep.m",
)
This notebook demonstrates the capabilities of the serpentTools
in regards to reading depleted material files. SERPENT [1] produces a burned material file, containing the evolution of material properties through burnup for all burned materials present in the problem.
The DepletionReader
is capable of reading this file, and storing the data inside DepletedMaterial
objects.
Each such object has methods and attributes that should ease analysis.
In [2]:
%matplotlib inline
import serpentTools
from serpentTools.settings import rc
In [3]:
dep = serpentTools.read(depFile)
The materials read in from the file are stored in the materials
dictionary, where the keys represent the name of specific materials, and the corresponding values are the depleted material.
In [4]:
dep.materials
Out[4]:
Metadata, such as the isotopic vector and depletion schedule are also present on the reader as attributes.
In [4]:
print(str(dep.names))
In [5]:
dep.burnup
Out[5]:
In [6]:
dep.days
Out[6]:
In [7]:
print(str(dep.zais))
In [8]:
fuel = dep.materials['fuel0']
print(fuel.burnup)
assert fuel.days is dep.days
Materials can also be obtained by indexing directly into the reader like a dictionary
In [9]:
assert dep["fuel0"] is dep.materials["fuel0"] is dep.get("fuel0")
All of the variables present in the depletion file for this material are present, stored in the data
dictionary. These are also stored as attributes on the reader
In [10]:
fuel.data.keys()
Out[10]:
In [11]:
print(fuel.adens)
assert fuel.adens is fuel.data['adens']
Similar to the original file, the rows of the matrix correspond to positions in the isotopic vector, and the columns correspond to positions in burnup/day vectors.
In [12]:
print(fuel.mdens.shape) # rows, columns
print(fuel.burnup.shape)
print(len(fuel.names))
At the heart of the DepletedMaterial
object is the getValues
method. This method acts as an slicing mechanism that returns data for a select number of isotopes at select points in time. getValues
requires two arguments for the units of time requested, e.g. days
or burnup
, and the name of the data requested. This second value must be a key in the data
dictionary.
Specific days or values of burnup can be passed with the timePoints
keyword. This will instruct the slicing tool to retrieve data that corresponds to values of days
or burnup
in the timePoints
list. By default the method returns data for every time point on the material unless timePoints
is given. Similarly, one can pass a string or list of strings as the names
or zai
argument and obtain data for those specific isotopes. Data for every isotope is given if names
and zai
are not given.
In [13]:
dayPoints = [0, 5, 10, 30]
iso = ['Xe135', 'Sm149']
zai = [541350, 621490]
isoVals = fuel.getValues('days', 'a', dayPoints, iso)
print(isoVals)
zaiVals = fuel.getValues('days', 'a', dayPoints, zai=zai)
assert not (zaiVals - isoVals).any()
The DepletedMaterial
uses this slicing for the built in plot
routine. plot
takes the same slicing arguments as getValues
, and includes some optional formatting arguments.
By default, the plot method will plot data for all isotopes present, leading to very busy plots. The plots can be cleaned up by passing isotope names or ZZAAAI
identifiers to the names
or zai
arguments, respectively.
In [14]:
fuel.plot('burnup', 'ingTox', names='Xe135');
In [15]:
fuel.plot('burnup', 'mdens', zai=[541350, 531350]);
This type of plotting can also be applied to the DepletedMaterial
level, with similar options for formatting and retrieving data. The materials to be plotted can be filtered using the materials
argument. The labelFmt
argument can be used to apply a consistent label to each unique plot. This argument supports brace-delimited formatting, and will automatically replace strings like {mat}
with the name of the material. The table below contains the special strings and their replacements
String | Replacement |
---|---|
{mat} |
Name of the material |
{iso} |
Name of the isotope, e.g. 'U235' |
{zai} |
ZZAAAI of the isotope, e.g. 922350 |
In [16]:
dep.plot('burnup', 'adens', names=iso,
materials=['fuel0', 'total'],
labelFmt="{mat}: {iso} // {zai}", loglog=True);
depletion.materialVariables
- Control what data is stored for each materialdepletion.materials
- Control what materials are storeddepletion.metadataKeys
- Control what non-material data is storeddepletion.processTotal
- If True
, store the block contain data for all depleted materialsBelow is an example of configuring a DepletionReader
that only stores the burnup days, and atomic density for all materials that begin with bglass
followed by at least one integer.
In [17]:
rc['depletion.processTotal'] = False
rc['depletion.metadataKeys'] = ['BU']
rc['depletion.materialVariables'] = ['ADENS']
rc['depletion.materials'] = [r'bglass\d+']
bgReader= serpentTools.read(depFile)
In [18]:
bgReader.materials.keys()
Out[18]:
In [19]:
bglass = bgReader.materials['bglass0']
bglass.data.keys()
Out[19]:
pandas.DataFrame
If you have the pandas
python package installed, you can use the DepletedMaterial.toDataFrame
method to export depletion data to a tabular layout. The method will retrieve data for all isotopes unless names
or zai
are given. For compactness, only a few isotopes will be demonstrated here.
In [22]:
fuel.toDataFrame("adens", names=["U235", "Pu239", "Xe135"]).head()
Out[22]:
Arguments can be used to control the time values in the index and column structure
In [21]:
fuel.toDataFrame("adens", time="burnup", zai=[922350, 541350]).head()
Out[21]:
The DepletionReader
is capable of reading and storing all the data from the SERPENT burned materials file. Upon reading, the reader creates custom DepletedMaterial
objects that are responsible for storing and retrieving the data. These objects also have a handy plot
method for quick analysis. Use of the rc
settings control object allows increased control over the data selected from the output file.