Material Library¶
Download the full notebook
.
Material Library¶
PyNE comes with a pre-built library of materials Most of this data comes from a materials compendium by PNNL, which is gives canonical values for normal materials. This notebook demonstrates how to load and use this data via the MaterialLibrary
class. First the imports!
In [1]:
# the path to the nuc_data.h5 database
from pyne import nuc_data
# the material library class itself
from pyne.material_library import MaterialLibrary
The MaterialLibrary
class is a dict-like class which maps string names to Material
objects. We can instantiate this class directly from the database as follows.
In [2]:
mats = MaterialLibrary(nuc_data, datapath='/material_library/materials')
We can also take a gander at the keys in this dictionary.
In [3]:
# employing a decode from byte literals to unicode str values
# otherwise just use: list(mats.keys())[:10]
[mat.decode('utf-8') for mat in list(mats.keys())[:10]]
Out[3]:
And the values too!
In [4]:
mats['Steel, Stainless 440']
Out[4]:
You can do everything you normaly would with these materials, like print them out in MCNP form!
In [5]:
print(mats['Steel, Stainless 440'].mcnp())