From a4ed73fc113619269c21db6ead8b5845fde1d712 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 23 Feb 2016 10:48:47 -0600 Subject: [PATCH] Update Jupyter notebooks based on Tally property changes --- .../pythonapi/examples/mgxs-part-iii.ipynb | 5 +- .../examples/pandas-dataframes.ipynb | 22 +- .../pythonapi/examples/post-processing.ipynb | 5 +- .../pythonapi/examples/tally-arithmetic.ipynb | 455 +++++++++--------- 4 files changed, 237 insertions(+), 250 deletions(-) diff --git a/docs/source/pythonapi/examples/mgxs-part-iii.ipynb b/docs/source/pythonapi/examples/mgxs-part-iii.ipynb index dcb496160..c3f19aa22 100644 --- a/docs/source/pythonapi/examples/mgxs-part-iii.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-iii.ipynb @@ -689,9 +689,8 @@ "\n", "# Instantiate the Tally\n", "tally = openmc.Tally(name='mesh tally')\n", - "tally.add_filter(mesh_filter)\n", - "tally.add_score('fission')\n", - "tally.add_score('nu-fission')\n", + "tally.filters = [mesh_filter]\n", + "tally.scores = ['fission', 'nu-fission']\n", "\n", "# Add mesh and Tally to TalliesFile\n", "tallies_file.add_mesh(mesh)\n", diff --git a/docs/source/pythonapi/examples/pandas-dataframes.ipynb b/docs/source/pythonapi/examples/pandas-dataframes.ipynb index ac5d4e410..85f64ff6f 100644 --- a/docs/source/pythonapi/examples/pandas-dataframes.ipynb +++ b/docs/source/pythonapi/examples/pandas-dataframes.ipynb @@ -453,10 +453,8 @@ "\n", "# Instantiate the Tally\n", "tally = openmc.Tally(name='mesh tally')\n", - "tally.add_filter(mesh_filter)\n", - "tally.add_filter(energy_filter)\n", - "tally.add_score('fission')\n", - "tally.add_score('nu-fission')\n", + "tally.filters = [mesh_filter, energy_filter]\n", + "tally.scores = ['fission', 'nu-fission']\n", "\n", "# Add mesh and Tally to TalliesFile\n", "tallies_file.add_mesh(mesh)\n", @@ -483,10 +481,9 @@ "\n", "# Instantiate the tally\n", "tally = openmc.Tally(name='cell tally')\n", - "tally.add_filter(cell_filter)\n", - "tally.add_score('scatter-y2')\n", - "tally.add_nuclide(u235)\n", - "tally.add_nuclide(u238)\n", + "tally.filters = [cell_filter]\n", + "tally.scores = ['scatter-y2']\n", + "tally.nuclides = [u235, u238]\n", "\n", "# Add mesh and tally to TalliesFile\n", "tallies_file.add_tally(tally)" @@ -512,14 +509,13 @@ "\n", "# Instantiate tally Trigger for kicks\n", "trigger = openmc.Trigger(trigger_type='std_dev', threshold=5e-5)\n", - "trigger.add_score('absorption')\n", + "trigger.scores = ['absorption']\n", "\n", "# Instantiate the Tally\n", "tally = openmc.Tally(name='distribcell tally')\n", - "tally.add_filter(distribcell_filter)\n", - "tally.add_score('absorption')\n", - "tally.add_score('scatter')\n", - "tally.add_trigger(trigger)\n", + "tally.filters = [distribcell_filter]\n", + "tally.scores = ['absorption', 'scatter']\n", + "tally.triggers = [trigger]\n", "\n", "# Add mesh and tally to TalliesFile\n", "tallies_file.add_tally(tally)" diff --git a/docs/source/pythonapi/examples/post-processing.ipynb b/docs/source/pythonapi/examples/post-processing.ipynb index 7fbca6864..6526f0307 100644 --- a/docs/source/pythonapi/examples/post-processing.ipynb +++ b/docs/source/pythonapi/examples/post-processing.ipynb @@ -408,9 +408,8 @@ "\n", "# Create mesh tally to score flux and fission rate\n", "tally = openmc.Tally(name='flux')\n", - "tally.add_filter(mesh_filter)\n", - "tally.add_score('flux')\n", - "tally.add_score('fission')\n", + "tally.filters = [mesh_filter]\n", + "tally.scores = ['flux', 'fission']\n", "tallies_file.add_tally(tally)" ] }, diff --git a/docs/source/pythonapi/examples/tally-arithmetic.ipynb b/docs/source/pythonapi/examples/tally-arithmetic.ipynb index 3a61b0979..d1325e487 100644 --- a/docs/source/pythonapi/examples/tally-arithmetic.ipynb +++ b/docs/source/pythonapi/examples/tally-arithmetic.ipynb @@ -418,29 +418,25 @@ "\n", "# Instantiate flux Tally in moderator and fuel\n", "tally = openmc.Tally(name='flux')\n", - "tally.add_filter(openmc.Filter(type='cell', bins=[fuel_cell.id, moderator_cell.id]))\n", - "tally.add_filter(energy_filter)\n", - "tally.add_score('flux')\n", + "tally.filters = [openmc.Filter(type='cell', bins=[fuel_cell.id, moderator_cell.id]),\n", + " energy_filter]\n", + "tally.scores = ['flux']\n", "tallies_file.add_tally(tally)\n", "\n", "# Instantiate reaction rate Tally in fuel\n", "tally = openmc.Tally(name='fuel rxn rates')\n", - "tally.add_filter(openmc.Filter(type='cell', bins=[fuel_cell.id]))\n", - "tally.add_filter(energy_filter)\n", - "tally.add_score('nu-fission')\n", - "tally.add_score('scatter')\n", - "tally.add_nuclide(u238)\n", - "tally.add_nuclide(u235)\n", + "tally.filters = [openmc.Filter(type='cell', bins=[fuel_cell.id]),\n", + " energy_filter]\n", + "tally.scores = ['nu-fission', 'scatter']\n", + "tally.nuclides = [u238, u235]\n", "tallies_file.add_tally(tally)\n", "\n", "# Instantiate reaction rate Tally in moderator\n", "tally = openmc.Tally(name='moderator rxn rates')\n", - "tally.add_filter(openmc.Filter(type='cell', bins=[moderator_cell.id]))\n", - "tally.add_filter(energy_filter)\n", - "tally.add_score('absorption')\n", - "tally.add_score('total')\n", - "tally.add_nuclide(o16)\n", - "tally.add_nuclide(h1)\n", + "tally.filters = [openmc.Filter(type='cell', bins=[moderator_cell.id])]\n", + "tally.filters.append(energy_filter)\n", + "tally.scores = ['absorption', 'total']\n", + "tally.nuclides = [o16, h1]\n", "tallies_file.add_tally(tally)" ] }, @@ -455,8 +451,8 @@ "# K-Eigenvalue (infinity) tallies\n", "fiss_rate = openmc.Tally(name='fiss. rate')\n", "abs_rate = openmc.Tally(name='abs. rate')\n", - "fiss_rate.add_score('nu-fission')\n", - "abs_rate.add_score('absorption')\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)" ] @@ -471,8 +467,8 @@ "source": [ "# Resonance Escape Probability tallies\n", "therm_abs_rate = openmc.Tally(name='therm. abs. rate')\n", - "therm_abs_rate.add_score('absorption')\n", - "therm_abs_rate.add_filter(openmc.Filter(type='energy', bins=[0., 0.625e-6]))\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)" ] }, @@ -486,9 +482,9 @@ "source": [ "# Thermal Flux Utilization tallies\n", "fuel_therm_abs_rate = openmc.Tally(name='fuel therm. abs. rate')\n", - "fuel_therm_abs_rate.add_score('absorption')\n", - "fuel_therm_abs_rate.add_filter(openmc.Filter(type='energy', bins=[0., 0.625e-6]))\n", - "fuel_therm_abs_rate.add_filter(openmc.Filter(type='cell', bins=[fuel_cell.id]))\n", + "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)" ] }, @@ -502,8 +498,8 @@ "source": [ "# Fast Fission Factor tallies\n", "therm_fiss_rate = openmc.Tally(name='therm. fiss. rate')\n", - "therm_fiss_rate.add_score('nu-fission')\n", - "therm_fiss_rate.add_filter(openmc.Filter(type='energy', bins=[0., 0.625e-6]))\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)" ] }, @@ -520,12 +516,10 @@ "\n", "# Instantiate flux Tally in moderator and fuel\n", "tally = openmc.Tally(name='need-to-slice')\n", - "tally.add_filter(openmc.Filter(type='cell', bins=[fuel_cell.id, moderator_cell.id]))\n", - "tally.add_filter(energy_filter)\n", - "tally.add_score('nu-fission')\n", - "tally.add_score('scatter')\n", - "tally.add_nuclide(h1)\n", - "tally.add_nuclide(u238)\n", + "tally.filters = [openmc.Filter(type='cell', bins=[fuel_cell.id, moderator_cell.id]),\n", + " energy_filter]\n", + "tally.scores = ['nu-fission', 'scatter']\n", + "tally.nuclides = [h1, u238]\n", "tallies_file.add_tally(tally)" ] }, @@ -533,7 +527,7 @@ "cell_type": "code", "execution_count": 22, "metadata": { - "collapsed": true + "collapsed": false }, "outputs": [], "source": [ @@ -576,9 +570,8 @@ " Copyright: 2011-2015 Massachusetts Institute of Technology\n", " License: http://mit-crpg.github.io/openmc/license.html\n", " Version: 0.7.1\n", - " Git SHA1: 34381b40a9445a727e360873aaa6ef892af1cb6a\n", - " Date/Time: 2016-02-07 16:05:17\n", - " MPI Processes: 1\n", + " Git SHA1: b9efc990c7eb58f4a41524d59ae73396c9929436\n", + " Date/Time: 2016-02-23 10:52:44\n", "\n", " ===========================================================================\n", " ========================> INITIALIZATION <=========================\n", @@ -634,20 +627,20 @@ "\n", " =======================> TIMING STATISTICS <=======================\n", "\n", - " Total time for initialization = 3.4700E-01 seconds\n", - " Reading cross sections = 9.1000E-02 seconds\n", - " Total time in simulation = 7.3920E+00 seconds\n", - " Time in transport only = 7.3820E+00 seconds\n", - " Time in inactive batches = 1.0930E+00 seconds\n", - " Time in active batches = 6.2990E+00 seconds\n", - " Time synchronizing fission bank = 2.0000E-03 seconds\n", - " Sampling source sites = 1.0000E-03 seconds\n", - " SEND/RECV source sites = 0.0000E+00 seconds\n", + " Total time for initialization = 8.4700E-01 seconds\n", + " Reading cross sections = 5.8300E-01 seconds\n", + " Total time in simulation = 1.6037E+01 seconds\n", + " Time in transport only = 1.6026E+01 seconds\n", + " Time in inactive batches = 2.3070E+00 seconds\n", + " Time in active batches = 1.3730E+01 seconds\n", + " Time synchronizing fission bank = 5.0000E-03 seconds\n", + " Sampling source sites = 4.0000E-03 seconds\n", + " SEND/RECV source sites = 1.0000E-03 seconds\n", " Time accumulating tallies = 0.0000E+00 seconds\n", - " Total time for finalization = 2.0000E-03 seconds\n", - " Total time elapsed = 7.7510E+00 seconds\n", - " Calculation Rate (inactive) = 11436.4 neutrons/second\n", - " Calculation Rate (active) = 5953.33 neutrons/second\n", + " Total time for finalization = 3.0000E-03 seconds\n", + " Total time elapsed = 1.6899E+01 seconds\n", + " Calculation Rate (inactive) = 5418.29 neutrons/second\n", + " Calculation Rate (active) = 2731.25 neutrons/second\n", "\n", " ============================> RESULTS <============================\n", "\n", @@ -759,10 +752,10 @@ " \n", " \n", " 0\n", - " total\n", - " (nu-fission / absorption)\n", - " 1.040166\n", - " 0.009069\n", + " total\n", + " (nu-fission / absorption)\n", + " 1.040166\n", + " 0.009069\n", " \n", " \n", "\n", @@ -821,12 +814,12 @@ " \n", " \n", " 0\n", - " 0\n", - " 0.000001\n", - " total\n", - " absorption\n", - " 0.694707\n", - " 0.006699\n", + " 0\n", + " 0.000001\n", + " total\n", + " absorption\n", + " 0.694707\n", + " 0.006699\n", " \n", " \n", "\n", @@ -883,12 +876,12 @@ " \n", " \n", " 0\n", - " 0\n", - " 0.000001\n", - " total\n", - " nu-fission\n", - " 1.201216\n", - " 0.012288\n", + " 0\n", + " 0.000001\n", + " total\n", + " nu-fission\n", + " 1.201216\n", + " 0.012288\n", " \n", " \n", "\n", @@ -947,13 +940,13 @@ " \n", " \n", " 0\n", - " 0\n", - " 0.000001\n", - " 10000\n", - " total\n", - " absorption\n", - " 0.74925\n", - " 0.008257\n", + " 0\n", + " 0.000001\n", + " 10000\n", + " total\n", + " absorption\n", + " 0.74925\n", + " 0.008257\n", " \n", " \n", "\n", @@ -1013,13 +1006,13 @@ " \n", " \n", " 0\n", - " 0\n", - " 0.000001\n", - " 10000\n", - " total\n", - " (nu-fission / absorption)\n", - " 1.663616\n", - " 0.018624\n", + " 0\n", + " 0.000001\n", + " 10000\n", + " total\n", + " (nu-fission / absorption)\n", + " 1.663616\n", + " 0.018624\n", " \n", " \n", "\n", @@ -1078,13 +1071,13 @@ " \n", " \n", " 0\n", - " 0\n", - " 0.000001\n", - " 10000\n", - " total\n", - " (((absorption * nu-fission) * absorption) * (n...\n", - " 1.040166\n", - " 0.021928\n", + " 0\n", + " 0.000001\n", + " 10000\n", + " total\n", + " (((absorption * nu-fission) * absorption) * (n...\n", + " 1.040166\n", + " 0.021928\n", " \n", " \n", "\n", @@ -1160,83 +1153,83 @@ " \n", " \n", " 0\n", - " 10000\n", - " 0.000000\n", - " 0.000001\n", - " (U-238 / total)\n", - " (nu-fission / flux)\n", - " 0.000001\n", - " 7.377419e-09\n", + " 10000\n", + " 0.000000\n", + " 0.000001\n", + " (U-238 / total)\n", + " (nu-fission / flux)\n", + " 0.000001\n", + " 7.377419e-09\n", " \n", " \n", " 1\n", - " 10000\n", - " 0.000000\n", - " 0.000001\n", - " (U-238 / total)\n", - " (scatter / flux)\n", - " 0.209989\n", - " 2.303838e-03\n", + " 10000\n", + " 0.000000\n", + " 0.000001\n", + " (U-238 / total)\n", + " (scatter / flux)\n", + " 0.209989\n", + " 2.303838e-03\n", " \n", " \n", " 2\n", - " 10000\n", - " 0.000000\n", - " 0.000001\n", - " (U-235 / total)\n", - " (nu-fission / flux)\n", - " 0.356420\n", - " 3.951669e-03\n", + " 10000\n", + " 0.000000\n", + " 0.000001\n", + " (U-235 / total)\n", + " (nu-fission / flux)\n", + " 0.356420\n", + " 3.951669e-03\n", " \n", " \n", " 3\n", - " 10000\n", - " 0.000000\n", - " 0.000001\n", - " (U-235 / total)\n", - " (scatter / flux)\n", - " 0.005555\n", - " 6.101004e-05\n", + " 10000\n", + " 0.000000\n", + " 0.000001\n", + " (U-235 / total)\n", + " (scatter / flux)\n", + " 0.005555\n", + " 6.101004e-05\n", " \n", " \n", " 4\n", - " 10000\n", - " 0.000001\n", - " 20.000000\n", - " (U-238 / total)\n", - " (nu-fission / flux)\n", - " 0.007155\n", - " 8.053460e-05\n", + " 10000\n", + " 0.000001\n", + " 20.000000\n", + " (U-238 / total)\n", + " (nu-fission / flux)\n", + " 0.007155\n", + " 8.053460e-05\n", " \n", " \n", " 5\n", - " 10000\n", - " 0.000001\n", - " 20.000000\n", - " (U-238 / total)\n", - " (scatter / flux)\n", - " 0.227770\n", - " 1.079289e-03\n", + " 10000\n", + " 0.000001\n", + " 20.000000\n", + " (U-238 / total)\n", + " (scatter / flux)\n", + " 0.227770\n", + " 1.079289e-03\n", " \n", " \n", " 6\n", - " 10000\n", - " 0.000001\n", - " 20.000000\n", - " (U-235 / total)\n", - " (nu-fission / flux)\n", - " 0.008067\n", - " 5.254797e-05\n", + " 10000\n", + " 0.000001\n", + " 20.000000\n", + " (U-235 / total)\n", + " (nu-fission / flux)\n", + " 0.008067\n", + " 5.254797e-05\n", " \n", " \n", " 7\n", - " 10000\n", - " 0.000001\n", - " 20.000000\n", - " (U-235 / total)\n", - " (scatter / flux)\n", - " 0.003367\n", - " 1.647058e-05\n", + " 10000\n", + " 0.000001\n", + " 20.000000\n", + " (U-235 / total)\n", + " (scatter / flux)\n", + " 0.003367\n", + " 1.647058e-05\n", " \n", " \n", "\n", @@ -1395,43 +1388,43 @@ " \n", " \n", " 0\n", - " 10000\n", - " 0.000000\n", - " 0.000001\n", - " U-238\n", - " nu-fission\n", - " 0.000002\n", - " 1.283958e-08\n", + " 10000\n", + " 0.000000\n", + " 0.000001\n", + " U-238\n", + " nu-fission\n", + " 0.000002\n", + " 1.283958e-08\n", " \n", " \n", " 1\n", - " 10000\n", - " 0.000000\n", - " 0.000001\n", - " U-235\n", - " nu-fission\n", - " 0.868553\n", - " 6.880390e-03\n", + " 10000\n", + " 0.000000\n", + " 0.000001\n", + " U-235\n", + " nu-fission\n", + " 0.868553\n", + " 6.880390e-03\n", " \n", " \n", " 2\n", - " 10000\n", - " 0.000001\n", - " 20.000000\n", - " U-238\n", - " nu-fission\n", - " 0.082149\n", - " 8.837250e-04\n", + " 10000\n", + " 0.000001\n", + " 20.000000\n", + " U-238\n", + " nu-fission\n", + " 0.082149\n", + " 8.837250e-04\n", " \n", " \n", " 3\n", - " 10000\n", - " 0.000001\n", - " 20.000000\n", - " U-235\n", - " nu-fission\n", - " 0.092618\n", - " 5.195308e-04\n", + " 10000\n", + " 0.000001\n", + " 20.000000\n", + " U-235\n", + " nu-fission\n", + " 0.092618\n", + " 5.195308e-04\n", " \n", " \n", "\n", @@ -1489,93 +1482,93 @@ " \n", " \n", " 0\n", - " 10002\n", - " 1.000000e-08\n", - " 0.000000\n", - " H-1\n", - " scatter\n", - " 4.619398\n", - " 0.040124\n", + " 10002\n", + " 1.000000e-08\n", + " 0.000000\n", + " H-1\n", + " scatter\n", + " 4.619398\n", + " 0.040124\n", " \n", " \n", " 1\n", - " 10002\n", - " 1.080060e-07\n", - " 0.000001\n", - " H-1\n", - " scatter\n", - " 2.030757\n", - " 0.011239\n", + " 10002\n", + " 1.080060e-07\n", + " 0.000001\n", + " H-1\n", + " scatter\n", + " 2.030757\n", + " 0.011239\n", " \n", " \n", " 2\n", - " 10002\n", - " 1.166529e-06\n", - " 0.000013\n", - " H-1\n", - " scatter\n", - " 1.658488\n", - " 0.009777\n", + " 10002\n", + " 1.166529e-06\n", + " 0.000013\n", + " H-1\n", + " scatter\n", + " 1.658488\n", + " 0.009777\n", " \n", " \n", " 3\n", - " 10002\n", - " 1.259921e-05\n", - " 0.000136\n", - " H-1\n", - " scatter\n", - " 1.853002\n", - " 0.007378\n", + " 10002\n", + " 1.259921e-05\n", + " 0.000136\n", + " H-1\n", + " scatter\n", + " 1.853002\n", + " 0.007378\n", " \n", " \n", " 4\n", - " 10002\n", - " 1.360790e-04\n", - " 0.001470\n", - " H-1\n", - " scatter\n", - " 2.050773\n", - " 0.012484\n", + " 10002\n", + " 1.360790e-04\n", + " 0.001470\n", + " H-1\n", + " scatter\n", + " 2.050773\n", + " 0.012484\n", " \n", " \n", " 5\n", - " 10002\n", - " 1.469734e-03\n", - " 0.015874\n", - " H-1\n", - " scatter\n", - " 2.131759\n", - " 0.007821\n", + " 10002\n", + " 1.469734e-03\n", + " 0.015874\n", + " H-1\n", + " scatter\n", + " 2.131759\n", + " 0.007821\n", " \n", " \n", " 6\n", - " 10002\n", - " 1.587401e-02\n", - " 0.171449\n", - " H-1\n", - " scatter\n", - " 2.213710\n", - " 0.015159\n", + " 10002\n", + " 1.587401e-02\n", + " 0.171449\n", + " H-1\n", + " scatter\n", + " 2.213710\n", + " 0.015159\n", " \n", " \n", " 7\n", - " 10002\n", - " 1.714488e-01\n", - " 1.851749\n", - " H-1\n", - " scatter\n", - " 2.011925\n", - " 0.009406\n", + " 10002\n", + " 1.714488e-01\n", + " 1.851749\n", + " H-1\n", + " scatter\n", + " 2.011925\n", + " 0.009406\n", " \n", " \n", " 8\n", - " 10002\n", - " 1.851749e+00\n", - " 20.000000\n", - " H-1\n", - " scatter\n", - " 0.371280\n", - " 0.003949\n", + " 10002\n", + " 1.851749e+00\n", + " 20.000000\n", + " H-1\n", + " scatter\n", + " 0.371280\n", + " 0.003949\n", " \n", " \n", "\n",