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

@ -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)"
]
},
{