Skip to content

Commit

Permalink
Merge pull request #350 from scopatz/matlib
Browse files Browse the repository at this point in the history
Added material library example.
  • Loading branch information
Elliott Biondo authored and Elliott Biondo committed Mar 4, 2014
2 parents 32c9fd7 + 7d0ea3c commit 53ea798
Showing 1 changed file with 175 additions and 0 deletions.
175 changes: 175 additions & 0 deletions examples/material_library.ipynb
@@ -0,0 +1,175 @@
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Material Library\n",
"================\n",
"\n",
"PyNE comes with a pre-built library of materials Most of this data comes from [a materials compendium by PNNL](http://www.pnnl.gov/main/publications/external/technical_reports/PNNL-15870Rev1.pdf), 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!"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# the path to the nuc_data.h5 database\n",
"from pyne import nuc_data\n",
"\n",
"# the material library class itself\n",
"from pyne.material import MaterialLibrary"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"mats = MaterialLibrary(nuc_data, datapath='/material_library/materials', nucpath='/material_library/nucid')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also take a gander at the keys in this dictionary."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"mats.keys()[:10]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 3,
"text": [
"['Mercury',\n",
" 'Oil, Crude (Heavy, Qayarah, Iraq)',\n",
" 'Sm',\n",
" 'Lead',\n",
" 'Concrete, M-1',\n",
" 'Sc',\n",
" 'Iron, Armco Ingot',\n",
" 'Freon-13',\n",
" 'Concrete, Luminite-colemanite-baryte',\n",
" 'Air (dry, near sea level)']"
]
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And the values too!"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"mats['Steel, Stainless 440']"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"text": [
"pyne.material.Material({60120000: 0.12366250000000002, 60130000: 0.0013375000000000004, 140280000: 0.11527875000000001, 140290000: 0.00585625, 140300000: 0.003865000000000001, 150310000: 0.12500000000000003, 160320000: 0.11873750000000001, 160330000: 0.0009375000000000001, 160340000: 0.005312500000000001, 160360000: 1.2500000000000002e-05, 240500000: 0.00543125, 240520000: 0.10473625000000002, 240530000: 0.011876250000000001, 240540000: 0.002956250000000001, 250550000: 0.12500000000000003, 260540000: 0.007306250000000001, 260560000: 0.11469250000000002, 260570000: 0.002648750000000001, 260580000: 0.0003525, 420920000: 0.0181625, 420940000: 0.011437500000000003, 420950000: 0.019800000000000005, 420960000: 0.020837500000000005, 420970000: 0.012000000000000002, 420980000: 0.030487500000000004, 421000000: 0.012275000000000003}, 1.0, 7.8, -1.0, {\"name\":\"Steel, Stainless 440\"})"
]
}
],
"prompt_number": 4
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can do everything you normaly would with these materials, like print them out in MCNP form!"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print mats['Steel, Stainless 440'].mcnp()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"C name: Steel, Stainless 440\n",
"C density = 7.8\n",
"m?\n",
" 6012 -1.2366E-01\n",
" 6013 -1.3375E-03\n",
" 14028 -1.1528E-01\n",
" 14029 -5.8563E-03\n",
" 14030 -3.8650E-03\n",
" 15031 -1.2500E-01\n",
" 16032 -1.1874E-01\n",
" 16033 -9.3750E-04\n",
" 16034 -5.3125E-03\n",
" 16036 -1.2500E-05\n",
" 24050 -5.4313E-03\n",
" 24052 -1.0474E-01\n",
" 24053 -1.1876E-02\n",
" 24054 -2.9563E-03\n",
" 25055 -1.2500E-01\n",
" 26054 -7.3063E-03\n",
" 26056 -1.1469E-01\n",
" 26057 -2.6488E-03\n",
" 26058 -3.5250E-04\n",
" 42092 -1.8163E-02\n",
" 42094 -1.1438E-02\n",
" 42095 -1.9800E-02\n",
" 42096 -2.0838E-02\n",
" 42097 -1.2000E-02\n",
" 42098 -3.0488E-02\n",
" 42100 -1.2275E-02\n",
"\n"
]
}
],
"prompt_number": 5
}
],
"metadata": {}
}
]
}

0 comments on commit 53ea798

Please sign in to comment.