Make Materials, Plots, and Tallies list-like

This commit is contained in:
Paul Romano 2016-04-29 16:14:02 -05:00
parent ae083cf5d4
commit d9b097dbaf
31 changed files with 373 additions and 297 deletions

View file

@ -212,10 +212,9 @@
},
"outputs": [],
"source": [
"# Instantiate a Materials object, register all Materials, and export to XML\n",
"materials_file = openmc.Materials()\n",
"# Instantiate a Materials collection and export to XML\n",
"materials_file = openmc.Materials([inf_medium])\n",
"materials_file.default_xs = '71c'\n",
"materials_file.add_material(inf_medium)\n",
"materials_file.export_to_xml()"
]
},
@ -466,17 +465,14 @@
"tallies_file = openmc.Tallies()\n",
"\n",
"# Add total tallies to the tallies file\n",
"for tally in total.tallies.values():\n",
" tallies_file.add_tally(tally)\n",
"tallies_file += total.tallies.values()\n",
"\n",
"# Add absorption tallies to the tallies file\n",
"for tally in absorption.tallies.values():\n",
" tallies_file.add_tally(tally)\n",
"tallies_file += absorption.tallies.values()\n",
"\n",
"# Add scattering tallies to the tallies file\n",
"for tally in scattering.tallies.values():\n",
" tallies_file.add_tally(tally)\n",
" \n",
"tallies_file += scattering.tallies.values()\n",
"\n",
"# Export to \"tallies.xml\"\n",
"tallies_file.export_to_xml()"
]

View file

@ -133,11 +133,8 @@
},
"outputs": [],
"source": [
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
"# Instantiate a Materials collection\n",
"materials_file = openmc.Materials((fuel, water, zircaloy))\n",
"materials_file.default_xs = '71c'\n",
"\n",
"# Export to \"materials.xml\"\n",
@ -408,7 +405,7 @@
" \n",
" # Add OpenMC tallies to the tallies file for XML generation\n",
" for tally in xs_library[cell.id][rxn_type].tallies.values():\n",
" tallies_file.add_tally(tally, merge=True)\n",
" tallies_file.append(tally, merge=True)\n",
"\n",
"# Export to \"tallies.xml\"\n",
"tallies_file.export_to_xml()"

View file

@ -133,11 +133,8 @@
},
"outputs": [],
"source": [
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
"# Instantiate a Materials object\n",
"materials_file = openmc.Materials((fuel, water, zircaloy))\n",
"materials_file.default_xs = '71c'\n",
"\n",
"# Export to \"materials.xml\"\n",
@ -419,8 +416,7 @@
"plot.color = 'mat'\n",
"\n",
"# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.Plots()\n",
"plot_file.add_plot(plot)\n",
"plot_file = openmc.Plots([plot])\n",
"plot_file.export_to_xml()"
]
},
@ -685,9 +681,8 @@
"tally.filters = [mesh_filter]\n",
"tally.scores = ['fission', 'nu-fission']\n",
"\n",
"# Add mesh and tally to Tallies\n",
"tallies_file.add_mesh(mesh)\n",
"tallies_file.add_tally(tally)"
"# Add tally to collection\n",
"tallies_file.append(tally)"
]
},
{

View file

@ -108,11 +108,8 @@
},
"outputs": [],
"source": [
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
"# Instantiate a Materials collection\n",
"materials_file = openmc.Materials((fuel, water, zircaloy))\n",
"materials_file.default_xs = '71c'\n",
"\n",
"# Export to \"materials.xml\"\n",
@ -329,9 +326,8 @@
"plot.pixels = [250, 250]\n",
"plot.color = 'mat'\n",
"\n",
"# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.Plots()\n",
"plot_file.add_plot(plot)\n",
"# Instantiate a Plots collection and export to \"plots.xml\"\n",
"plot_file = openmc.Plots([plot])\n",
"plot_file.export_to_xml()"
]
},
@ -449,8 +445,7 @@
"tally.scores = ['fission', 'nu-fission']\n",
"\n",
"# Add mesh and Tally to Tallies\n",
"tallies_file.add_mesh(mesh)\n",
"tallies_file.add_tally(tally)"
"tallies_file.append(tally)"
]
},
{
@ -478,7 +473,7 @@
"tally.nuclides = [u235, u238]\n",
"\n",
"# Add mesh and tally to Tallies\n",
"tallies_file.add_tally(tally)"
"tallies_file.append(tally)"
]
},
{
@ -510,7 +505,7 @@
"tally.triggers = [trigger]\n",
"\n",
"# Add mesh and tally to Tallies\n",
"tallies_file.add_tally(tally)"
"tallies_file.append(tally)"
]
},
{

View file

@ -104,11 +104,8 @@
},
"outputs": [],
"source": [
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
"# Instantiate a Materials collection\n",
"materials_file = openmc.Materials((fuel, water, zircaloy))\n",
"materials_file.default_xs = '71c'\n",
"\n",
"# Export to \"materials.xml\"\n",
@ -298,9 +295,8 @@
"plot.pixels = [250, 250]\n",
"plot.color = 'mat'\n",
"\n",
"# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.Plots()\n",
"plot_file.add_plot(plot)\n",
"# Instantiate a Plots collection and export to \"plots.xml\"\n",
"plot_file = openmc.Plots([plot])\n",
"plot_file.export_to_xml()"
]
},
@ -393,17 +389,16 @@
"mesh.dimension = [100, 100]\n",
"mesh.lower_left = [-0.63, -0.63]\n",
"mesh.upper_right = [0.63, 0.63]\n",
"tallies_file.add_mesh(mesh)\n",
"\n",
"# Create mesh filter for tally\n",
"mesh_filter = openmc.Filter(type='mesh', bins=[1])\n",
"mesh_filter = openmc.Filter(type='mesh')\n",
"mesh_filter.mesh = mesh\n",
"\n",
"# Create mesh tally to score flux and fission rate\n",
"tally = openmc.Tally(name='flux')\n",
"tally.filters = [mesh_filter]\n",
"tally.scores = ['flux', 'fission']\n",
"tallies_file.add_tally(tally)"
"tallies_file.append(tally)"
]
},
{

View file

@ -126,11 +126,8 @@
},
"outputs": [],
"source": [
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
"# Instantiate a Materials collection\n",
"materials_file = openmc.Materials((fuel, water, zircaloy))\n",
"materials_file.default_xs = '71c'\n",
"\n",
"# Export to \"materials.xml\"\n",
@ -321,9 +318,8 @@
"plot.pixels = [250, 250]\n",
"plot.color = 'mat'\n",
"\n",
"# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.Plots()\n",
"plot_file.add_plot(plot)\n",
"# Instantiate a Plots collection and export to \"plots.xml\"\n",
"plot_file = openmc.Plots([plot])\n",
"plot_file.export_to_xml()"
]
},
@ -421,7 +417,7 @@
"tally.filters = [openmc.Filter(type='cell', bins=[fuel_cell.id, moderator_cell.id])]\n",
"tally.filters.append(energy_filter)\n",
"tally.scores = ['flux']\n",
"tallies_file.add_tally(tally)\n",
"tallies_file.append(tally)\n",
"\n",
"# Instantiate reaction rate Tally in fuel\n",
"tally = openmc.Tally(name='fuel rxn rates')\n",
@ -429,7 +425,7 @@
"tally.filters.append(energy_filter)\n",
"tally.scores = ['nu-fission', 'scatter']\n",
"tally.nuclides = [u238, u235]\n",
"tallies_file.add_tally(tally)\n",
"tallies_file.append(tally)\n",
"\n",
"# Instantiate reaction rate Tally in moderator\n",
"tally = openmc.Tally(name='moderator rxn rates')\n",
@ -437,7 +433,7 @@
"tally.filters.append(energy_filter)\n",
"tally.scores = ['absorption', 'total']\n",
"tally.nuclides = [o16, h1]\n",
"tallies_file.add_tally(tally)"
"tallies_file.append(tally)"
]
},
{
@ -453,8 +449,7 @@
"abs_rate = openmc.Tally(name='abs. rate')\n",
"fiss_rate.scores = ['nu-fission']\n",
"abs_rate.scores = ['absorption']\n",
"tallies_file.add_tally(fiss_rate)\n",
"tallies_file.add_tally(abs_rate)"
"tallies_file += (fiss_rate, abs_rate)",
]
},
{
@ -469,7 +464,7 @@
"therm_abs_rate = openmc.Tally(name='therm. abs. rate')\n",
"therm_abs_rate.scores = ['absorption']\n",
"therm_abs_rate.filters = [openmc.Filter(type='energy', bins=[0., 0.625e-6])]\n",
"tallies_file.add_tally(therm_abs_rate)"
"tallies_file.append(therm_abs_rate)"
]
},
{
@ -485,7 +480,7 @@
"fuel_therm_abs_rate.scores = ['absorption']\n",
"fuel_therm_abs_rate.filters = [openmc.Filter(type='energy', bins=[0., 0.625e-6]),\n",
" openmc.Filter(type='cell', bins=[fuel_cell.id])]\n",
"tallies_file.add_tally(fuel_therm_abs_rate)"
"tallies_file.append(fuel_therm_abs_rate)"
]
},
{
@ -500,7 +495,7 @@
"therm_fiss_rate = openmc.Tally(name='therm. fiss. rate')\n",
"therm_fiss_rate.scores = ['nu-fission']\n",
"therm_fiss_rate.filters = [openmc.Filter(type='energy', bins=[0., 0.625e-6])]\n",
"tallies_file.add_tally(therm_fiss_rate)"
"tallies_file.append(therm_fiss_rate)"
]
},
{
@ -520,7 +515,7 @@
"tally.filters.append(energy_filter)\n",
"tally.scores = ['nu-fission', 'scatter']\n",
"tally.nuclides = [h1, u238]\n",
"tallies_file.add_tally(tally)"
"tallies_file.append(tally)"
]
},
{