From 7a671655865aefa8b99847cf843dc9b5fbd70514 Mon Sep 17 00:00:00 2001 From: Adam Nelson Date: Sat, 7 May 2016 14:36:32 -0400 Subject: [PATCH] Finished generating ipython notebook and incorporating in to docs --- .../pythonapi/examples/mgxs-part-iv.ipynb | 1871 +++++++++++++++++ .../pythonapi/examples/mgxs-part-iv.rst | 13 + docs/source/pythonapi/index.rst | 1 + openmc/summary.py | 1 + 4 files changed, 1886 insertions(+) create mode 100644 docs/source/pythonapi/examples/mgxs-part-iv.ipynb create mode 100644 docs/source/pythonapi/examples/mgxs-part-iv.rst diff --git a/docs/source/pythonapi/examples/mgxs-part-iv.ipynb b/docs/source/pythonapi/examples/mgxs-part-iv.ipynb new file mode 100644 index 000000000..bc85af5c2 --- /dev/null +++ b/docs/source/pythonapi/examples/mgxs-part-iv.ipynb @@ -0,0 +1,1871 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This Notebook illustrates the use of the openmc.mgxs.Library class specifically for application in OpenMC's multi-group mode. This example notebook follows the same process as was done in MGXS Part III, but instead uses OpenMC as the multi-group solver. This Notebook illustrates the following features:\n", + "\n", + " Calculation of multi-group cross sections for a fuel assembly\n", + " Automated creation, manipulation and storage of MGXS with openmc.mgxs.Library\n", + " Validation of multi-group cross sections with OpenMC\n", + " Steady-state pin-by-pin fission rates comparison between Continuous-Energy mode and Multi-Group OpenMC.\n", + "\n", + "Note: This Notebook illustrates the use of Pandas DataFrames to containerize multi-group cross section data. We recommend using Pandas >v0.15.0 or later since OpenMC's Python API leverages the multi-indexing feature included in the most recent releases of Pandas.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Generate Input Files" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import math\n", + "import pickle\n", + "\n", + "from IPython.display import Image\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "import os\n", + "\n", + "import openmc\n", + "import openmc.mgxs\n", + "\n", + "%matplotlib inline" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "First we need to define materials that will be used in the problem. Before defining a material, we must create nuclides that are used in the material." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Instantiate some Nuclides\n", + "h1 = openmc.Nuclide('H-1')\n", + "b10 = openmc.Nuclide('B-10')\n", + "o16 = openmc.Nuclide('O-16')\n", + "u235 = openmc.Nuclide('U-235')\n", + "u238 = openmc.Nuclide('U-238')\n", + "zr90 = openmc.Nuclide('Zr-90')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With the nuclides we defined, we will now create three materials for the fuel, water, and cladding of the fuel pins." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# 1.6 enriched fuel\n", + "fuel = openmc.Material(name='1.6% Fuel')\n", + "fuel.set_density('g/cm3', 10.31341)\n", + "fuel.add_nuclide(u235, 3.7503e-4)\n", + "fuel.add_nuclide(u238, 2.2625e-2)\n", + "fuel.add_nuclide(o16, 4.6007e-2)\n", + "\n", + "# borated water\n", + "water = openmc.Material(name='Borated Water')\n", + "water.set_density('g/cm3', 0.740582)\n", + "water.add_nuclide(h1, 4.9457e-2)\n", + "water.add_nuclide(o16, 2.4732e-2)\n", + "water.add_nuclide(b10, 8.0042e-6)\n", + "\n", + "# zircaloy\n", + "zircaloy = openmc.Material(name='Zircaloy')\n", + "zircaloy.set_density('g/cm3', 6.55)\n", + "zircaloy.add_nuclide(zr90, 7.2758e-3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With our three materials, we can now create a Materials object that can be exported to an actual XML file." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# 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", + "materials_file.export_to_xml()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now let's move on to the geometry. This problem will be a square array of fuel pins and control rod guide tubes for which we can use OpenMC's lattice/universe feature. The basic universe will have three regions for the fuel, the clad, and the surrounding coolant. The first step is to create the bounding surfaces for fuel and clad, as well as the outer bounding surfaces of the problem." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Create cylinders for the fuel and clad\n", + "fuel_outer_radius = openmc.ZCylinder(x0=0.0, y0=0.0, R=0.39218)\n", + "clad_outer_radius = openmc.ZCylinder(x0=0.0, y0=0.0, R=0.45720)\n", + "\n", + "# Create boundary planes to surround the geometry\n", + "min_x = openmc.XPlane(x0=-10.71, boundary_type='reflective')\n", + "max_x = openmc.XPlane(x0=+10.71, boundary_type='reflective')\n", + "min_y = openmc.YPlane(y0=-10.71, boundary_type='reflective')\n", + "max_y = openmc.YPlane(y0=+10.71, boundary_type='reflective')\n", + "min_z = openmc.ZPlane(z0=-10., boundary_type='reflective')\n", + "max_z = openmc.ZPlane(z0=+10., boundary_type='reflective')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With the surfaces defined, we can now construct a fuel pin cell from cells that are defined by intersections of half-spaces created by the surfaces." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Create a Universe to encapsulate a fuel pin\n", + "fuel_pin_universe = openmc.Universe(name='1.6% Fuel Pin')\n", + "\n", + "# Create fuel Cell\n", + "fuel_cell = openmc.Cell(name='1.6% Fuel')\n", + "fuel_cell.fill = fuel\n", + "fuel_cell.region = -fuel_outer_radius\n", + "fuel_pin_universe.add_cell(fuel_cell)\n", + "\n", + "# Create a clad Cell\n", + "clad_cell = openmc.Cell(name='1.6% Clad')\n", + "clad_cell.fill = zircaloy\n", + "clad_cell.region = +fuel_outer_radius & -clad_outer_radius\n", + "fuel_pin_universe.add_cell(clad_cell)\n", + "\n", + "# Create a moderator Cell\n", + "moderator_cell = openmc.Cell(name='1.6% Moderator')\n", + "moderator_cell.fill = water\n", + "moderator_cell.region = +clad_outer_radius\n", + "fuel_pin_universe.add_cell(moderator_cell)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Likewise, we can construct a control rod guide tube with the same surfaces." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Create a Universe to encapsulate a control rod guide tube\n", + "guide_tube_universe = openmc.Universe(name='Guide Tube')\n", + "\n", + "# Create guide tube Cell\n", + "guide_tube_cell = openmc.Cell(name='Guide Tube Water')\n", + "guide_tube_cell.fill = water\n", + "guide_tube_cell.region = -fuel_outer_radius\n", + "guide_tube_universe.add_cell(guide_tube_cell)\n", + "\n", + "# Create a clad Cell\n", + "clad_cell = openmc.Cell(name='Guide Clad')\n", + "clad_cell.fill = zircaloy\n", + "clad_cell.region = +fuel_outer_radius & -clad_outer_radius\n", + "guide_tube_universe.add_cell(clad_cell)\n", + "\n", + "# Create a moderator Cell\n", + "moderator_cell = openmc.Cell(name='Guide Tube Moderator')\n", + "moderator_cell.fill = water\n", + "moderator_cell.region = +clad_outer_radius\n", + "guide_tube_universe.add_cell(moderator_cell)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Using the pin cell universe, we can construct a 17x17 rectangular lattice with a 1.26 cm pitch." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Create fuel assembly Lattice\n", + "assembly = openmc.RectLattice(name='1.6% Fuel Assembly')\n", + "assembly.dimension = (17, 17)\n", + "assembly.pitch = (1.26, 1.26)\n", + "assembly.lower_left = [-1.26 * 17. / 2.0] * 2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, we create a NumPy array of fuel pin and guide tube universes for the lattice." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Create array indices for guide tube locations in lattice\n", + "template_x = np.array([5, 8, 11, 3, 13, 2, 5, 8, 11, 14, 2, 5, 8,\n", + " 11, 14, 2, 5, 8, 11, 14, 3, 13, 5, 8, 11])\n", + "template_y = np.array([2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 8, 8, 8, 8,\n", + " 8, 11, 11, 11, 11, 11, 13, 13, 14, 14, 14])\n", + "\n", + "# Initialize an empty 17x17 array of the lattice universes\n", + "universes = np.empty((17, 17), dtype=openmc.Universe)\n", + "\n", + "# Fill the array with the fuel pin and guide tube universes\n", + "universes[:,:] = fuel_pin_universe\n", + "universes[template_x, template_y] = guide_tube_universe\n", + "\n", + "# Store the array of universes in the lattice\n", + "assembly.universes = universes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "OpenMC requires that there is a \"root\" universe. Let us create a root cell that is filled by the pin cell universe and then assign it to the root universe." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Create root Cell\n", + "root_cell = openmc.Cell(name='root cell')\n", + "root_cell.fill = assembly\n", + "\n", + "# Add boundary planes\n", + "root_cell.region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z\n", + "\n", + "# Create root Universe\n", + "root_universe = openmc.Universe(universe_id=0, name='root universe')\n", + "root_universe.add_cell(root_cell)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We now must create a geometry that is assigned a root universe and export it to XML." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Create Geometry and set root Universe\n", + "geometry = openmc.Geometry()\n", + "geometry.root_universe = root_universe\n", + "# Export to \"geometry.xml\"\n", + "geometry.export_to_xml()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With the geometry and materials finished, we now just need to define simulation parameters. In this case, we will use 10 inactive batches and 40 active batches each with 2500 particles." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# OpenMC simulation parameters\n", + "batches = 200\n", + "inactive = 10\n", + "particles = 5000\n", + "\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", + "settings_file.batches = batches\n", + "settings_file.inactive = inactive\n", + "settings_file.particles = particles\n", + "settings_file.output = {'tallies': False}\n", + "\n", + "# Create an initial uniform spatial source distribution over fissionable zones\n", + "bounds = [-10.71, -10.71, -10, 10.71, 10.71, 10.]\n", + "uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)\n", + "settings_file.source = openmc.source.Source(space=uniform_dist)\n", + "\n", + "# Export to \"settings.xml\"\n", + "settings_file.export_to_xml()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let us also create a Plots file that we can use to verify that our fuel assembly geometry was created successfully." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Instantiate a Plot\n", + "plot = openmc.Plot(plot_id=1)\n", + "plot.filename = 'materials-xy'\n", + "plot.origin = [0, 0, 0]\n", + "plot.pixels = [250, 250]\n", + "plot.width = [-10.71*2, -10.71*2]\n", + "plot.color = 'mat'\n", + "\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots([plot])\n", + "plot_file.export_to_xml()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With the plots.xml file, we can now generate and view the plot. OpenMC outputs plots in .ppm format, which can be converted into a compressed format like .png with the convert utility." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Run openmc in plotting mode\n", + "openmc.plot_geometry(output=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6AgMAAAD1grKuAAAABGdBTUEAALGPC/xhBQAAACBjSFJN\nAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX///9yEhLpgJFNv8Tq\nQYT7AAAAAWJLR0QAiAUdSAAAAAd0SU1FB+AFBw4WAwCoz4wAAAWFSURBVGje7Zs7cttADIZ9CSvX\ncrP0iCxUqbBc8Ag6xR6BhV2EvYvwFD4CCx1ABT1jMdgndpegRQnOrCbjpPlGESISC4A/gd27e8H5\n83CX3b4+iKJrRHkS4vkghMPBonRYWGwtfgD2YN+dRDUOoh6lACw0Noi9w2fESuEoAR/uVuMolX03\n9oXGT7F3eFL2iEfhUX1f4cPdL/ishs+68ai+udE4xPhexbjX2FfjGNoPj/DPNX4Tsd+EODr8FvsV\ndf1Hd9P2VvCi4+s/aXvrf+upAD+1/9GV1mkOH5X9vV6THtfvACslcaUCbESL61drBPtdI8SrFMWr\nELsXCkuFDYW75gbiP7d9Cf7bAYI/aCwUShrBvh30+lWQkzVgZ/HD4OixNCgcQpJ3BxU/Ln91elKo\nM5VEE38QtJ+Yv6cQ9xjKNYayyl8TypP8DfJnQ2H/b/N3ye9P83cT33SQv/sQh9gV7zZ/0dNj5HQa\nC5vVzv9+/WFN2w8KVaZ2BwL1+pv4g0x1QRfjq0dB4Q3kT277oP6VNL6gKxNU9a8zK+WLbi/Wwpdi\nhbboKqyxFOulHMj6v4W/AXbmUeAxrv9J/CqEBXaRKsXaodD4nsYvkT/G6H1D4SR/iPy1Roj9JsQ5\ne18/7EUHv1+Fvx/Xj5V9Ugb5K8TW4TZEEdcvoz/up0VTe9qsVIppKVX6a7D6y9ZvwEKjrtQxPtv6\nfXII9vCxKOGaIeAIfEF8IvAG8ie3vRK9rRQl+PPpSctbhfpTUC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HE78XnT/4H/cs5f8Q9/8Q9f8U+/5U7f3Lb\nc88fdrzzjyvm+cuf/Uu887/c88fs88954/8vO4SjPC+2QRIAAAAldEVYdGRhdGU6Y3JlYXRlADIw\nMTYtMDUtMDdUMTQ6MjI6MDMtMDQ6MDCiB/xLAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE2LTA1LTA3\nVDE0OjIyOjAzLTA0OjAw01pE9wAAAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Convert OpenMC's funky ppm to png\n", + "!convert materials-xy.ppm materials-xy.png\n", + "\n", + "# Display the materials plot inline\n", + "Image(filename='materials-xy.png')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As we can see from the plot, we have a nice array of fuel and guide tube pin cells with fuel, cladding, and water!\n", + "\n", + "# Create an MGXS Library\n", + "\n", + "Now we are ready to generate multi-group cross sections! First, let's define a 2-group structure using the built-in EnergyGroups class." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Instantiate a 2-group EnergyGroups object\n", + "groups = openmc.mgxs.EnergyGroups()\n", + "groups.group_edges = np.array([0., 0.625e-6, 20.])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, we will instantiate an openmc.mgxs.Library for the energy groups with our the fuel assembly geometry." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Initialize an 2-group MGXS Library for OpenMOC\n", + "mgxs_lib = openmc.mgxs.Library(geometry)\n", + "mgxs_lib.energy_groups = groups" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now, we must specify to the Library which types of cross sections to compute. OpenMC's multi-group mode can accept isotropic flux-weighted cross sections or angle-dependent cross sections, as well as supporting anisotropic scattering represented by either Legendre polynomials, histogram, or tabular angular distributions. At this time the MGXS Library class only supports the generation of isotropic flux-weighted cross sections and P0 scattering, so that is what will be used for this example. Therefore, we will create the following multi-group cross sections needed to run an OpenMC simulation to verify the accuracy of our cross sections: \"transport\", \"absorption\", \"nu-fission\", '\"fission\", \"nu-scatter matrix\", \"scatter matrix\", and \"chi\".\n", + "\"scatter matrix\" is needed in addition to \"nu-scatter matrix\" because OpenMC's multi-group mode can treat scattering multiplication (i.e., (n,xn) reactions)) explicitly instead of adjusting the absorption cross section to maintain neutron balance, and using this explicit treatment would require tallying of both types of scattering matrices." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Specify multi-group cross section types to compute\n", + "mgxs_lib.mgxs_types = ['transport', 'absorption', 'nu-fission', 'fission',\n", + " 'nu-scatter matrix', 'scatter matrix', 'chi']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we must specify the type of domain over which we would like the `Library` to compute multi-group cross sections. The domain type corresponds to the type of tally filter to be used in the tallies created to compute multi-group cross sections. At the present time, the `Library` supports \"material,\" \"cell,\" and \"universe\" domain types. We will use a \"cell\" domain type here to compute cross sections in each of the cells in the fuel assembly geometry.\n", + "\n", + "**Note:** By default, the `Library` class will instantiate `MGXS` objects for each and every domain (material, cell or universe) in the geometry of interest. However, one may specify a subset of these domains to the `Library.domains` property. In our case, we wish to compute multi-group cross sections in each and every cell since they will be needed in our downstream multi-group OpenMC calculation on the identical combinatorial geometry mesh." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Specify a \"cell\" domain type for the cross section tally filters\n", + "mgxs_lib.domain_type = \"cell\"\n", + "\n", + "# Specify the cell domains over which to compute multi-group cross sections\n", + "mgxs_lib.domains = geometry.get_all_material_cells()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We will instruct the library to not compute cross sections on a nuclide-by-nuclide basis, and instead to focus on generating material-specific macroscopic cross sections.\n", + "\n", + "**NOTE:** The default value of the `by_nuclide` parameter is `False`, so the following step is not necessary but is included for illustrative purposes." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Do not compute cross sections on a nuclide-by-nuclide basis\n", + "mgxs_lib.by_nuclide = False" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Lastly, we use the `Library` to construct the tallies needed to compute all of the requested multi-group cross sections in each domain and nuclide." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Construct all tallies needed for the multi-group cross section library\n", + "mgxs_lib.build_library()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The tallies can now be export to a \"tallies.xml\" input file for OpenMC.\n", + "\n", + "**NOTE:** At this point the `Library` has constructed nearly 100 distinct Tally objects. The overhead to tally in OpenMC scales as O(N) for N tallies, which can become a bottleneck for large tally datasets. To compensate for this, the Python API's `Tally`, `Filter` and `Tallies` classes allow for the smart merging of tallies when possible. The `Library` class supports this runtime optimization with the use of the optional `merge` parameter (`False` by default) for the `Library.add_to_tallies_file(...)` method, as shown below." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Create a \"tallies.xml\" file for the MGXS Library\n", + "tallies_file = openmc.Tallies()\n", + "mgxs_lib.add_to_tallies_file(tallies_file, merge=True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In addition, we instantiate a fission rate mesh tally to compare with the multi-group result." + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Instantiate a tally Mesh\n", + "mesh = openmc.Mesh(mesh_id=1)\n", + "mesh.type = 'regular'\n", + "mesh.dimension = [17, 17]\n", + "mesh.lower_left = [-10.71, -10.71]\n", + "mesh.upper_right = [+10.71, +10.71]\n", + "\n", + "# Instantiate tally Filter\n", + "mesh_filter = openmc.Filter()\n", + "mesh_filter.mesh = mesh\n", + "\n", + "# Instantiate the Tally\n", + "tally = openmc.Tally(name='mesh tally')\n", + "tally.filters = [mesh_filter]\n", + "tally.scores = ['fission']\n", + "\n", + "# Add tally to collection\n", + "tallies_file.append(tally)" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Export all tallies to a \"tallies.xml\" file\n", + "tallies_file.export_to_xml()" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " .d88888b. 888b d888 .d8888b.\n", + " d88P\" \"Y88b 8888b d8888 d88P Y88b\n", + " 888 888 88888b.d88888 888 888\n", + " 888 888 88888b. .d88b. 88888b. 888Y88888P888 888 \n", + " 888 888 888 \"88b d8P Y8b 888 \"88b 888 Y888P 888 888 \n", + " 888 888 888 888 88888888 888 888 888 Y8P 888 888 888\n", + " Y88b. .d88P 888 d88P Y8b. 888 888 888 \" 888 Y88b d88P\n", + " \"Y88888P\" 88888P\" \"Y8888 888 888 888 888 \"Y8888P\"\n", + "__________________888______________________________________________________\n", + " 888\n", + " 888\n", + "\n", + " Copyright: 2011-2016 Massachusetts Institute of Technology\n", + " License: http://openmc.readthedocs.org/en/latest/license.html\n", + " Version: 0.7.1\n", + " Git SHA1: 179e9ab147e505563d118ed58096b3d225160ffa\n", + " Date/Time: 2016-05-07 14:22:04\n", + " OpenMP Threads: 4\n", + "\n", + " ===========================================================================\n", + " ========================> INITIALIZATION <=========================\n", + " ===========================================================================\n", + "\n", + " Reading settings XML file...\n", + " Reading cross sections XML file...\n", + " Reading geometry XML file...\n", + " Reading materials XML file...\n", + " Reading tallies XML file...\n", + " Building neighboring cells lists for each surface...\n", + " Loading ACE cross section table: 92235.71c\n", + " Loading ACE cross section table: 92238.71c\n", + " Loading ACE cross section table: 8016.71c\n", + " Loading ACE cross section table: 1001.71c\n", + " Loading ACE cross section table: 5010.71c\n", + " Loading ACE cross section table: 40090.71c\n", + " Maximum neutron transport energy: 20.0000 MeV for 92235.71c\n", + " Initializing source particles...\n", + "\n", + " ===========================================================================\n", + " ====================> K EIGENVALUE SIMULATION <====================\n", + " ===========================================================================\n", + "\n", + " Bat./Gen. k Average k \n", + " ========= ======== ==================== \n", + " 1/1 1.05162 \n", + " 2/1 1.05369 \n", + " 3/1 1.02989 \n", + " 4/1 1.00126 \n", + " 5/1 1.03151 \n", + " 6/1 1.00183 \n", + " 7/1 0.99379 \n", + " 8/1 1.04193 \n", + " 9/1 1.01578 \n", + " 10/1 1.03349 \n", + " 11/1 1.03354 \n", + " 12/1 1.03646 1.03500 +/- 0.00146\n", + " 13/1 1.00873 1.02624 +/- 0.00880\n", + " 14/1 1.04263 1.03034 +/- 0.00745\n", + " 15/1 1.01556 1.02738 +/- 0.00648\n", + " 16/1 1.04897 1.03098 +/- 0.00640\n", + " 17/1 1.01796 1.02912 +/- 0.00572\n", + " 18/1 1.02276 1.02833 +/- 0.00502\n", + " 19/1 1.04003 1.02963 +/- 0.00461\n", + " 20/1 1.00695 1.02736 +/- 0.00471\n", + " 21/1 1.00012 1.02488 +/- 0.00493\n", + " 22/1 1.03580 1.02579 +/- 0.00459\n", + " 23/1 1.03427 1.02644 +/- 0.00427\n", + " 24/1 1.06024 1.02886 +/- 0.00463\n", + " 25/1 1.00742 1.02743 +/- 0.00454\n", + " 26/1 1.02556 1.02731 +/- 0.00425\n", + " 27/1 1.02207 1.02700 +/- 0.00401\n", + " 28/1 1.05847 1.02875 +/- 0.00416\n", + " 29/1 1.01125 1.02783 +/- 0.00404\n", + " 30/1 1.03213 1.02804 +/- 0.00384\n", + " 31/1 1.02241 1.02778 +/- 0.00366\n", + " 32/1 1.02675 1.02773 +/- 0.00349\n", + " 33/1 1.05484 1.02891 +/- 0.00354\n", + " 34/1 1.01893 1.02849 +/- 0.00341\n", + " 35/1 0.99044 1.02697 +/- 0.00361\n", + " 36/1 1.02602 1.02693 +/- 0.00347\n", + " 37/1 1.04107 1.02746 +/- 0.00338\n", + " 38/1 1.03237 1.02763 +/- 0.00326\n", + " 39/1 1.01489 1.02719 +/- 0.00318\n", + " 40/1 1.01065 1.02664 +/- 0.00312\n", + " 41/1 1.03722 1.02698 +/- 0.00304\n", + " 42/1 1.04339 1.02750 +/- 0.00298\n", + " 43/1 1.00921 1.02694 +/- 0.00294\n", + " 44/1 1.04576 1.02750 +/- 0.00291\n", + " 45/1 1.02580 1.02745 +/- 0.00283\n", + " 46/1 1.03464 1.02765 +/- 0.00275\n", + " 47/1 1.01552 1.02732 +/- 0.00270\n", + " 48/1 1.03357 1.02748 +/- 0.00263\n", + " 49/1 1.03439 1.02766 +/- 0.00257\n", + " 50/1 1.04281 1.02804 +/- 0.00253\n", + " 51/1 1.02902 1.02806 +/- 0.00247\n", + " 52/1 1.02245 1.02793 +/- 0.00241\n", + " 53/1 1.05271 1.02851 +/- 0.00243\n", + " 54/1 0.98630 1.02755 +/- 0.00256\n", + " 55/1 1.02690 1.02753 +/- 0.00250\n", + " 56/1 1.04107 1.02783 +/- 0.00246\n", + " 57/1 1.03029 1.02788 +/- 0.00241\n", + " 58/1 1.01874 1.02769 +/- 0.00237\n", + " 59/1 1.04211 1.02798 +/- 0.00234\n", + " 60/1 0.99584 1.02734 +/- 0.00238\n", + " 61/1 1.05166 1.02782 +/- 0.00238\n", + " 62/1 1.05572 1.02835 +/- 0.00239\n", + " 63/1 1.02694 1.02833 +/- 0.00235\n", + " 64/1 1.03314 1.02842 +/- 0.00231\n", + " 65/1 1.05850 1.02896 +/- 0.00233\n", + " 66/1 1.01100 1.02864 +/- 0.00231\n", + " 67/1 1.03784 1.02880 +/- 0.00227\n", + " 68/1 1.04084 1.02901 +/- 0.00224\n", + " 69/1 1.03932 1.02919 +/- 0.00221\n", + " 70/1 1.02564 1.02913 +/- 0.00218\n", + " 71/1 1.00027 1.02865 +/- 0.00219\n", + " 72/1 1.02385 1.02858 +/- 0.00216\n", + " 73/1 1.04885 1.02890 +/- 0.00215\n", + " 74/1 1.00298 1.02849 +/- 0.00215\n", + " 75/1 1.02009 1.02836 +/- 0.00212\n", + " 76/1 1.04505 1.02862 +/- 0.00211\n", + " 77/1 1.02889 1.02862 +/- 0.00207\n", + " 78/1 1.01306 1.02839 +/- 0.00206\n", + " 79/1 1.01817 1.02824 +/- 0.00203\n", + " 80/1 1.00533 1.02792 +/- 0.00203\n", + " 81/1 1.04439 1.02815 +/- 0.00201\n", + " 82/1 1.02212 1.02806 +/- 0.00199\n", + " 83/1 0.99419 1.02760 +/- 0.00201\n", + " 84/1 1.07132 1.02819 +/- 0.00207\n", + " 85/1 1.02710 1.02818 +/- 0.00204\n", + " 86/1 1.01702 1.02803 +/- 0.00202\n", + " 87/1 1.02134 1.02794 +/- 0.00200\n", + " 88/1 1.05231 1.02826 +/- 0.00200\n", + " 89/1 1.05290 1.02857 +/- 0.00200\n", + " 90/1 1.05751 1.02893 +/- 0.00200\n", + " 91/1 1.03970 1.02906 +/- 0.00198\n", + " 92/1 0.99678 1.02867 +/- 0.00200\n", + " 93/1 1.04471 1.02886 +/- 0.00198\n", + " 94/1 1.00820 1.02862 +/- 0.00198\n", + " 95/1 1.05823 1.02896 +/- 0.00198\n", + " 96/1 1.05118 1.02922 +/- 0.00198\n", + " 97/1 1.03617 1.02930 +/- 0.00196\n", + " 98/1 1.00585 1.02904 +/- 0.00195\n", + " 99/1 1.06663 1.02946 +/- 0.00198\n", + " 100/1 1.01802 1.02933 +/- 0.00196\n", + " 101/1 1.02695 1.02931 +/- 0.00194\n", + " 102/1 1.01642 1.02917 +/- 0.00192\n", + " 103/1 1.02567 1.02913 +/- 0.00190\n", + " 104/1 1.03519 1.02919 +/- 0.00188\n", + " 105/1 1.02439 1.02914 +/- 0.00186\n", + " 106/1 1.03779 1.02923 +/- 0.00184\n", + " 107/1 1.01304 1.02906 +/- 0.00183\n", + " 108/1 1.02541 1.02903 +/- 0.00181\n", + " 109/1 1.04297 1.02917 +/- 0.00180\n", + " 110/1 1.00442 1.02892 +/- 0.00180\n", + " 111/1 1.03102 1.02894 +/- 0.00178\n", + " 112/1 1.00380 1.02870 +/- 0.00178\n", + " 113/1 1.04010 1.02881 +/- 0.00177\n", + " 114/1 1.01297 1.02865 +/- 0.00176\n", + " 115/1 1.00130 1.02839 +/- 0.00176\n", + " 116/1 1.02001 1.02831 +/- 0.00174\n", + " 117/1 1.03847 1.02841 +/- 0.00173\n", + " 118/1 1.00371 1.02818 +/- 0.00173\n", + " 119/1 1.02650 1.02817 +/- 0.00171\n", + " 120/1 1.00767 1.02798 +/- 0.00171\n", + " 121/1 1.00408 1.02776 +/- 0.00171\n", + " 122/1 1.00235 1.02754 +/- 0.00171\n", + " 123/1 1.01212 1.02740 +/- 0.00170\n", + " 124/1 1.03278 1.02745 +/- 0.00168\n", + " 125/1 1.00818 1.02728 +/- 0.00168\n", + " 126/1 1.02132 1.02723 +/- 0.00166\n", + " 127/1 1.03677 1.02731 +/- 0.00165\n", + " 128/1 1.04148 1.02743 +/- 0.00164\n", + " 129/1 1.01245 1.02730 +/- 0.00163\n", + " 130/1 1.04172 1.02742 +/- 0.00162\n", + " 131/1 1.04519 1.02757 +/- 0.00162\n", + " 132/1 1.02495 1.02755 +/- 0.00160\n", + " 133/1 0.99747 1.02731 +/- 0.00161\n", + " 134/1 1.02411 1.02728 +/- 0.00160\n", + " 135/1 1.05750 1.02752 +/- 0.00160\n", + " 136/1 1.02341 1.02749 +/- 0.00159\n", + " 137/1 1.02212 1.02745 +/- 0.00158\n", + " 138/1 1.03464 1.02750 +/- 0.00157\n", + " 139/1 1.05920 1.02775 +/- 0.00157\n", + " 140/1 1.01911 1.02768 +/- 0.00156\n", + " 141/1 1.03076 1.02771 +/- 0.00155\n", + " 142/1 1.03648 1.02777 +/- 0.00154\n", + " 143/1 1.00382 1.02759 +/- 0.00154\n", + " 144/1 1.00366 1.02741 +/- 0.00154\n", + " 145/1 1.01638 1.02733 +/- 0.00153\n", + " 146/1 1.02418 1.02731 +/- 0.00152\n", + " 147/1 0.99267 1.02706 +/- 0.00153\n", + " 148/1 1.02575 1.02705 +/- 0.00152\n", + " 149/1 0.98560 1.02675 +/- 0.00153\n", + " 150/1 1.02725 1.02675 +/- 0.00152\n", + " 151/1 1.03723 1.02683 +/- 0.00151\n", + " 152/1 1.00857 1.02670 +/- 0.00151\n", + " 153/1 1.00642 1.02656 +/- 0.00151\n", + " 154/1 1.03461 1.02661 +/- 0.00150\n", + " 155/1 1.00088 1.02643 +/- 0.00150\n", + " 156/1 1.02589 1.02643 +/- 0.00149\n", + " 157/1 1.02494 1.02642 +/- 0.00148\n", + " 158/1 1.03303 1.02646 +/- 0.00147\n", + " 159/1 1.02276 1.02644 +/- 0.00146\n", + " 160/1 1.03293 1.02648 +/- 0.00145\n", + " 161/1 1.04758 1.02662 +/- 0.00144\n", + " 162/1 1.01033 1.02652 +/- 0.00144\n", + " 163/1 1.03883 1.02660 +/- 0.00143\n", + " 164/1 1.00519 1.02646 +/- 0.00143\n", + " 165/1 1.05958 1.02667 +/- 0.00144\n", + " 166/1 1.03849 1.02675 +/- 0.00143\n", + " 167/1 1.02306 1.02672 +/- 0.00142\n", + " 168/1 1.02693 1.02672 +/- 0.00141\n", + " 169/1 1.02584 1.02672 +/- 0.00140\n", + " 170/1 0.99388 1.02651 +/- 0.00141\n", + " 171/1 0.99376 1.02631 +/- 0.00141\n", + " 172/1 1.00453 1.02618 +/- 0.00141\n", + " 173/1 1.04516 1.02629 +/- 0.00141\n", + " 174/1 1.02402 1.02628 +/- 0.00140\n", + " 175/1 0.99012 1.02606 +/- 0.00141\n", + " 176/1 1.02084 1.02603 +/- 0.00140\n", + " 177/1 1.03959 1.02611 +/- 0.00139\n", + " 178/1 1.01719 1.02606 +/- 0.00139\n", + " 179/1 1.01671 1.02600 +/- 0.00138\n", + " 180/1 1.03691 1.02606 +/- 0.00137\n", + " 181/1 1.04276 1.02616 +/- 0.00137\n", + " 182/1 1.02002 1.02613 +/- 0.00136\n", + " 183/1 1.03081 1.02615 +/- 0.00135\n", + " 184/1 1.02432 1.02614 +/- 0.00135\n", + " 185/1 1.02225 1.02612 +/- 0.00134\n", + " 186/1 1.04722 1.02624 +/- 0.00134\n", + " 187/1 0.98045 1.02598 +/- 0.00135\n", + " 188/1 1.02555 1.02598 +/- 0.00135\n", + " 189/1 1.03645 1.02604 +/- 0.00134\n", + " 190/1 1.00407 1.02592 +/- 0.00134\n", + " 191/1 1.03033 1.02594 +/- 0.00133\n", + " 192/1 1.04175 1.02603 +/- 0.00133\n", + " 193/1 1.00555 1.02592 +/- 0.00132\n", + " 194/1 1.00183 1.02578 +/- 0.00132\n", + " 195/1 1.04328 1.02588 +/- 0.00132\n", + " 196/1 1.03041 1.02590 +/- 0.00131\n", + " 197/1 1.04791 1.02602 +/- 0.00131\n", + " 198/1 1.01366 1.02596 +/- 0.00130\n", + " 199/1 1.04471 1.02605 +/- 0.00130\n", + " 200/1 1.02416 1.02604 +/- 0.00129\n", + " Creating state point statepoint.200.h5...\n", + "\n", + " ===========================================================================\n", + " ======================> SIMULATION FINISHED <======================\n", + " ===========================================================================\n", + "\n", + "\n", + " =======================> TIMING STATISTICS <=======================\n", + "\n", + " Total time for initialization = 1.4810E+00 seconds\n", + " Reading cross sections = 1.1600E+00 seconds\n", + " Total time in simulation = 9.8823E+01 seconds\n", + " Time in transport only = 9.8622E+01 seconds\n", + " Time in inactive batches = 2.1290E+00 seconds\n", + " Time in active batches = 9.6694E+01 seconds\n", + " Time synchronizing fission bank = 1.4000E-02 seconds\n", + " Sampling source sites = 1.1000E-02 seconds\n", + " SEND/RECV source sites = 3.0000E-03 seconds\n", + " Time accumulating tallies = 2.0000E-03 seconds\n", + " Total time for finalization = 0.0000E+00 seconds\n", + " Total time elapsed = 1.0031E+02 seconds\n", + " Calculation Rate (inactive) = 23485.2 neutrons/second\n", + " Calculation Rate (active) = 9824.81 neutrons/second\n", + "\n", + " ============================> RESULTS <============================\n", + "\n", + " k-effective (Collision) = 1.02505 +/- 0.00122\n", + " k-effective (Track-length) = 1.02604 +/- 0.00129\n", + " k-effective (Absorption) = 1.02501 +/- 0.00111\n", + " Combined k-effective = 1.02544 +/- 0.00091\n", + " Leakage Fraction = 0.00000 +/- 0.00000\n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Run OpenMC\n", + "openmc.run()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To make the files available and not be over-written when running the multi-group calculation, we will now rename the statepoint and summary files." + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Move the StatePoint File\n", + "ce_spfile = './ce.h5'\n", + "os.rename('statepoint.' + str(batches) + '.h5', ce_spfile)\n", + "# Move the Summary file\n", + "ce_sumfile = './ce_summary.h5'\n", + "os.rename('summary.h5', ce_sumfile)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tally Data Processing\n", + "\n", + "Our simulation ran successfully and created statepoint and summary output files. We begin our analysis by instantiating a `StatePoint` object." + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Load the statepoint file\n", + "sp = openmc.StatePoint(ce_spfile)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next we will save the value of keff from the continuous-energy calculation for later comparison" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ce_keff = sp.k_combined" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In addition to the statepoint file, our simulation also created a summary file which encapsulates information about the materials and geometry. This is necessary for the `openmc.mgxs` module to properly process the tally data. We first create a `Summary` object and link it with the statepoint." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "su = openmc.Summary(ce_sumfile)\n", + "sp.link_with_summary(su)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next we will extract our fission distribution results from the statepoint for later comparison." + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Get the OpenMC fission rate mesh tally data\n", + "mesh_tally = sp.get_tally(name='mesh tally')\n", + "openmc_fission_rates = mesh_tally.get_values(scores=['fission'])\n", + "\n", + "# Reshape array to 2D for plotting\n", + "openmc_fission_rates.shape = (17,17)\n", + "\n", + "# Normalize to the average pin power\n", + "openmc_fission_rates /= np.mean(openmc_fission_rates)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The statepoint is now ready to be analyzed by the `Library`. We simply have to load the tallies from the statepoint into the `Library` and our `MGXS` objects will compute the cross sections for us under-the-hood." + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Initialize MGXS Library with OpenMC statepoint data\n", + "mgxs_lib.load_from_statepoint(sp)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The next step will be to prepare the input for OpenMC to use our newly created multi-group data." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Multi-Group OpenMC Calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We will now use the `Library` to produce a multi-group cross section data set for use by the OpenMC multi-group solver. " + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/nelsonag/git/openmc/openmc/tallies.py:1996: RuntimeWarning: invalid value encountered in true_divide\n", + " self_rel_err = data['self']['std. dev.'] / data['self']['mean']\n", + "/home/nelsonag/git/openmc/openmc/tallies.py:1997: RuntimeWarning: invalid value encountered in true_divide\n", + " other_rel_err = data['other']['std. dev.'] / data['other']['mean']\n", + "/home/nelsonag/git/openmc/openmc/tallies.py:1998: RuntimeWarning: invalid value encountered in true_divide\n", + " new_tally._mean = data['self']['mean'] / data['other']['mean']\n" + ] + }, + { + "data": { + "text/plain": [ + "{10000: 'fuel.2g',\n", + " 10001: 'fuel_clad.2g',\n", + " 10002: 'fuel_mod.2g',\n", + " 10003: 'gt_inmod.2g',\n", + " 10004: 'gt_clad.2g',\n", + " 10005: 'gt_outmod.2g'}" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mgxs_lib.write_mg_library(filename='mgxs', xs_type='macro',\n", + " domain_names=['fuel', 'fuel_clad', 'fuel_mod',\n", + " 'gt_inmod', 'gt_clad', 'gt_outmod'],\n", + " xs_ids='2g')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we will need to recreate similar xml files from above, beginning with materials.xml" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Instantiate our Macroscopic Data\n", + "fuel_macro = openmc.Macroscopic('fuel')\n", + "fuel_clad_macro = openmc.Macroscopic('fuel_clad')\n", + "fuel_mod_macro = openmc.Macroscopic('fuel_mod')\n", + "gt_inmod_macro = openmc.Macroscopic('gt_inmod')\n", + "gt_clad_macro = openmc.Macroscopic('gt_clad')\n", + "gt_outmod_macro = openmc.Macroscopic('gt_outmod')\n", + "\n", + "# Now define the materials\n", + "\n", + "# 1.6 enriched fuel UO2\n", + "fuel = openmc.Material(name='1.6% Fuel UO2')\n", + "fuel.set_density('macro', 1.0)\n", + "fuel.add_macroscopic(fuel_macro)\n", + "\n", + "# 1.6 enriched fuel cladding\n", + "fuel_clad = openmc.Material(name='1.6% Fuel Clad')\n", + "fuel_clad.set_density('macro', 1.0)\n", + "fuel_clad.add_macroscopic(fuel_clad_macro)\n", + "\n", + "# 1.6 enriched fuel moderator\n", + "fuel_mod = openmc.Material(name='1.6% Fuel Water')\n", + "fuel_mod.set_density('macro', 1.0)\n", + "fuel_mod.add_macroscopic(fuel_mod_macro)\n", + "\n", + "# Guide Tube Inner Moderator\n", + "gt_inmod = openmc.Material(name='GT Inner Water')\n", + "gt_inmod.set_density('macro', 1.0)\n", + "gt_inmod.add_macroscopic(gt_inmod_macro)\n", + "\n", + "# Guide Tube Cladding\n", + "gt_clad = openmc.Material(name='GT Clad')\n", + "gt_clad.set_density('macro', 1.0)\n", + "gt_clad.add_macroscopic(gt_clad_macro)\n", + "\n", + "# Guide Tube Outer Moderator\n", + "gt_outmod = openmc.Material(name='GT Outer Water')\n", + "gt_outmod.set_density('macro', 1.0)\n", + "gt_outmod.add_macroscopic(gt_outmod_macro)\n", + "\n", + "# Finally, instantiate our Materials object\n", + "materials_file = openmc.Materials((fuel, fuel_clad, fuel_mod,\n", + " gt_inmod, gt_clad, gt_outmod))\n", + "materials_file.default_xs = '2g'\n", + "\n", + "# Export to \"materials.xml\"\n", + "materials_file.export_to_xml()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For our geometry files we will simply repeat what as done for continuous-energy mode, except change the cell fill (i.e., the material) to use our newly defined materials." + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Create a Universe to encapsulate a fuel pin\n", + "fuel_pin_universe = openmc.Universe(name='1.6% Fuel Pin')\n", + "\n", + "# Create fuel Cell\n", + "fuel_cell = openmc.Cell(name='1.6% Fuel')\n", + "fuel_cell.fill = fuel\n", + "fuel_cell.region = -fuel_outer_radius\n", + "fuel_pin_universe.add_cell(fuel_cell)\n", + "\n", + "# Create a clad Cell\n", + "clad_cell = openmc.Cell(name='1.6% Clad')\n", + "clad_cell.fill = fuel_clad\n", + "clad_cell.region = +fuel_outer_radius & -clad_outer_radius\n", + "fuel_pin_universe.add_cell(clad_cell)\n", + "\n", + "# Create a moderator Cell\n", + "moderator_cell = openmc.Cell(name='1.6% Moderator')\n", + "moderator_cell.fill = fuel_mod\n", + "moderator_cell.region = +clad_outer_radius\n", + "fuel_pin_universe.add_cell(moderator_cell)\n", + "\n", + "# Create a Universe to encapsulate a control rod guide tube\n", + "guide_tube_universe = openmc.Universe(name='Guide Tube')\n", + "\n", + "# Create guide tube Cell\n", + "guide_tube_cell = openmc.Cell(name='Guide Tube Water')\n", + "guide_tube_cell.fill = gt_inmod\n", + "guide_tube_cell.region = -fuel_outer_radius\n", + "guide_tube_universe.add_cell(guide_tube_cell)\n", + "\n", + "# Create a clad Cell\n", + "clad_cell = openmc.Cell(name='Guide Clad')\n", + "clad_cell.fill = gt_clad\n", + "clad_cell.region = +fuel_outer_radius & -clad_outer_radius\n", + "guide_tube_universe.add_cell(clad_cell)\n", + "\n", + "# Create a moderator Cell\n", + "moderator_cell = openmc.Cell(name='Guide Tube Moderator')\n", + "moderator_cell.fill = gt_outmod\n", + "moderator_cell.region = +clad_outer_radius\n", + "guide_tube_universe.add_cell(moderator_cell)\n", + "\n", + "# Create fuel assembly Lattice\n", + "assembly = openmc.RectLattice(name='1.6% Fuel Assembly')\n", + "assembly.dimension = (17, 17)\n", + "assembly.pitch = (1.26, 1.26)\n", + "assembly.lower_left = [-1.26 * 17. / 2.0] * 2\n", + "\n", + "# Create array indices for guide tube locations in lattice\n", + "template_x = np.array([5, 8, 11, 3, 13, 2, 5, 8, 11, 14, 2, 5, 8,\n", + " 11, 14, 2, 5, 8, 11, 14, 3, 13, 5, 8, 11])\n", + "template_y = np.array([2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 8, 8, 8, 8,\n", + " 8, 11, 11, 11, 11, 11, 13, 13, 14, 14, 14])\n", + "\n", + "# Initialize an empty 17x17 array of the lattice universes\n", + "universes = np.empty((17, 17), dtype=openmc.Universe)\n", + "\n", + "# Fill the array with the fuel pin and guide tube universes\n", + "universes[:,:] = fuel_pin_universe\n", + "universes[template_x, template_y] = guide_tube_universe\n", + "\n", + "# Store the array of universes in the lattice\n", + "assembly.universes = universes\n", + "\n", + "# Create root Cell\n", + "root_cell = openmc.Cell(name='root cell')\n", + "root_cell.fill = assembly\n", + "\n", + "# Add boundary planes\n", + "root_cell.region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z\n", + "\n", + "# Create root Universe\n", + "root_universe = openmc.Universe(universe_id=0, name='root universe')\n", + "root_universe.add_cell(root_cell)\n", + "\n", + "# Create Geometry and set root Universe\n", + "geometry = openmc.Geometry()\n", + "geometry.root_universe = root_universe\n", + "# Export to \"geometry.xml\"\n", + "geometry.export_to_xml()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, we can make the changes we need to the settings file.\n", + "These changes are limited to telling OpenMC we will be running a multi-group calculation and pointing to the location of our multi-group cross section file." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Set the location of the cross sections file\n", + "settings_file.cross_sections = './mgxs.xml'\n", + "settings_file.energy_mode = 'multi-group'\n", + "\n", + "# Export to \"settings.xml\"\n", + "settings_file.export_to_xml()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, lets tell OpenMC we want to tally fissions over a mesh for comparison. " + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Instantiate a tally Mesh\n", + "mesh = openmc.Mesh(mesh_id=1)\n", + "mesh.type = 'regular'\n", + "mesh.dimension = [17, 17]\n", + "mesh.lower_left = [-10.71, -10.71]\n", + "mesh.upper_right = [+10.71, +10.71]\n", + "\n", + "# Instantiate tally Filter\n", + "mesh_filter = openmc.Filter()\n", + "mesh_filter.mesh = mesh\n", + "\n", + "# Instantiate the Tally\n", + "tally = openmc.Tally(name='mesh tally')\n", + "tally.filters = [mesh_filter]\n", + "tally.scores = ['fission']\n", + "\n", + "# Add tally to collection\n", + "tallies_file.append(tally)\n", + "\n", + "# Export all tallies to a \"tallies.xml\" file\n", + "tallies_file.export_to_xml()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Before we run the calculation we will close the StatePoint file (as we are about to over-write it), and then we can run the multi-group calculation." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " .d88888b. 888b d888 .d8888b.\n", + " d88P\" \"Y88b 8888b d8888 d88P Y88b\n", + " 888 888 88888b.d88888 888 888\n", + " 888 888 88888b. .d88b. 88888b. 888Y88888P888 888 \n", + " 888 888 888 \"88b d8P Y8b 888 \"88b 888 Y888P 888 888 \n", + " 888 888 888 888 88888888 888 888 888 Y8P 888 888 888\n", + " Y88b. .d88P 888 d88P Y8b. 888 888 888 \" 888 Y88b d88P\n", + " \"Y88888P\" 88888P\" \"Y8888 888 888 888 888 \"Y8888P\"\n", + "__________________888______________________________________________________\n", + " 888\n", + " 888\n", + "\n", + " Copyright: 2011-2016 Massachusetts Institute of Technology\n", + " License: http://openmc.readthedocs.org/en/latest/license.html\n", + " Version: 0.7.1\n", + " Git SHA1: 179e9ab147e505563d118ed58096b3d225160ffa\n", + " Date/Time: 2016-05-07 14:23:45\n", + " OpenMP Threads: 4\n", + "\n", + " ===========================================================================\n", + " ========================> INITIALIZATION <=========================\n", + " ===========================================================================\n", + "\n", + " Reading settings XML file...\n", + " Reading cross sections XML file...\n", + " Reading geometry XML file...\n", + " Reading materials XML file...\n", + " Reading tallies XML file...\n", + " Building neighboring cells lists for each surface...\n", + " Loading Cross Section Data...\n", + " Loading fuel.2g Data...\n", + " Loading fuel_clad.2g Data...\n", + " Loading fuel_mod.2g Data...\n", + " Loading gt_inmod.2g Data...\n", + " Loading gt_clad.2g Data...\n", + " Loading gt_outmod.2g Data...\n", + " Initializing source particles...\n", + "\n", + " ===========================================================================\n", + " ====================> K EIGENVALUE SIMULATION <====================\n", + " ===========================================================================\n", + "\n", + " Bat./Gen. k Average k \n", + " ========= ======== ==================== \n", + " 1/1 1.01863 \n", + " 2/1 1.02630 \n", + " 3/1 1.03077 \n", + " 4/1 0.99715 \n", + " 5/1 1.02328 \n", + " 6/1 1.02283 \n", + " 7/1 1.00540 \n", + " 8/1 1.02232 \n", + " 9/1 0.99782 \n", + " 10/1 1.00838 \n", + " 11/1 1.01803 \n", + " 12/1 1.02530 1.02167 +/- 0.00363\n", + " 13/1 1.00514 1.01616 +/- 0.00589\n", + " 14/1 0.98994 1.00960 +/- 0.00777\n", + " 15/1 1.01028 1.00974 +/- 0.00602\n", + " 16/1 1.04607 1.01580 +/- 0.00780\n", + " 17/1 1.03300 1.01825 +/- 0.00703\n", + " 18/1 1.03149 1.01991 +/- 0.00631\n", + " 19/1 0.98692 1.01624 +/- 0.00667\n", + " 20/1 1.05205 1.01982 +/- 0.00695\n", + " 21/1 1.01572 1.01945 +/- 0.00630\n", + " 22/1 1.02517 1.01993 +/- 0.00577\n", + " 23/1 1.00274 1.01861 +/- 0.00547\n", + " 24/1 1.04739 1.02066 +/- 0.00547\n", + " 25/1 1.01883 1.02054 +/- 0.00509\n", + " 26/1 1.02021 1.02052 +/- 0.00476\n", + " 27/1 1.04696 1.02207 +/- 0.00474\n", + " 28/1 1.02751 1.02238 +/- 0.00448\n", + " 29/1 1.09537 1.02622 +/- 0.00572\n", + " 30/1 1.03685 1.02675 +/- 0.00545\n", + " 31/1 0.99812 1.02539 +/- 0.00536\n", + " 32/1 1.02526 1.02538 +/- 0.00511\n", + " 33/1 1.05466 1.02665 +/- 0.00505\n", + " 34/1 1.04816 1.02755 +/- 0.00491\n", + " 35/1 1.00148 1.02651 +/- 0.00483\n", + " 36/1 1.02315 1.02638 +/- 0.00464\n", + " 37/1 1.05771 1.02754 +/- 0.00461\n", + " 38/1 1.01675 1.02715 +/- 0.00446\n", + " 39/1 1.03707 1.02749 +/- 0.00432\n", + " 40/1 1.01903 1.02721 +/- 0.00418\n", + " 41/1 1.00332 1.02644 +/- 0.00412\n", + " 42/1 1.02533 1.02641 +/- 0.00399\n", + " 43/1 0.98531 1.02516 +/- 0.00406\n", + " 44/1 1.00406 1.02454 +/- 0.00399\n", + " 45/1 1.01057 1.02414 +/- 0.00389\n", + " 46/1 1.02755 1.02424 +/- 0.00378\n", + " 47/1 1.02783 1.02433 +/- 0.00368\n", + " 48/1 1.00003 1.02369 +/- 0.00364\n", + " 49/1 1.00442 1.02320 +/- 0.00358\n", + " 50/1 1.03215 1.02342 +/- 0.00350\n", + " 51/1 1.01672 1.02326 +/- 0.00341\n", + " 52/1 1.03702 1.02359 +/- 0.00335\n", + " 53/1 1.02063 1.02352 +/- 0.00327\n", + " 54/1 1.04596 1.02403 +/- 0.00323\n", + " 55/1 1.01926 1.02392 +/- 0.00316\n", + " 56/1 1.03058 1.02407 +/- 0.00310\n", + " 57/1 1.06126 1.02486 +/- 0.00313\n", + " 58/1 1.06411 1.02568 +/- 0.00317\n", + " 59/1 1.03278 1.02582 +/- 0.00311\n", + " 60/1 1.04472 1.02620 +/- 0.00307\n", + " 61/1 1.00186 1.02572 +/- 0.00305\n", + " 62/1 1.01133 1.02545 +/- 0.00300\n", + " 63/1 1.03713 1.02567 +/- 0.00295\n", + " 64/1 1.01363 1.02544 +/- 0.00291\n", + " 65/1 0.98126 1.02464 +/- 0.00296\n", + " 66/1 1.01500 1.02447 +/- 0.00292\n", + " 67/1 1.02437 1.02447 +/- 0.00286\n", + " 68/1 1.05057 1.02492 +/- 0.00285\n", + " 69/1 1.04903 1.02533 +/- 0.00283\n", + " 70/1 1.02199 1.02527 +/- 0.00278\n", + " 71/1 1.00536 1.02494 +/- 0.00276\n", + " 72/1 1.01658 1.02481 +/- 0.00272\n", + " 73/1 1.00866 1.02455 +/- 0.00268\n", + " 74/1 1.01800 1.02445 +/- 0.00264\n", + " 75/1 0.99176 1.02395 +/- 0.00265\n", + " 76/1 1.03336 1.02409 +/- 0.00262\n", + " 77/1 1.02699 1.02413 +/- 0.00258\n", + " 78/1 1.01596 1.02401 +/- 0.00254\n", + " 79/1 1.02292 1.02400 +/- 0.00250\n", + " 80/1 1.04804 1.02434 +/- 0.00249\n", + " 81/1 0.99494 1.02393 +/- 0.00249\n", + " 82/1 1.02646 1.02396 +/- 0.00246\n", + " 83/1 1.01223 1.02380 +/- 0.00243\n", + " 84/1 1.02572 1.02383 +/- 0.00239\n", + " 85/1 1.02709 1.02387 +/- 0.00236\n", + " 86/1 1.00315 1.02360 +/- 0.00235\n", + " 87/1 1.01809 1.02353 +/- 0.00232\n", + " 88/1 1.01566 1.02342 +/- 0.00229\n", + " 89/1 1.01093 1.02327 +/- 0.00227\n", + " 90/1 1.02812 1.02333 +/- 0.00224\n", + " 91/1 1.02288 1.02332 +/- 0.00221\n", + " 92/1 1.04070 1.02353 +/- 0.00219\n", + " 93/1 1.03697 1.02370 +/- 0.00217\n", + " 94/1 1.03486 1.02383 +/- 0.00215\n", + " 95/1 1.06359 1.02430 +/- 0.00218\n", + " 96/1 1.04811 1.02457 +/- 0.00217\n", + " 97/1 1.01303 1.02444 +/- 0.00215\n", + " 98/1 1.01243 1.02430 +/- 0.00213\n", + " 99/1 1.03238 1.02439 +/- 0.00211\n", + " 100/1 1.02054 1.02435 +/- 0.00208\n", + " 101/1 1.00402 1.02413 +/- 0.00207\n", + " 102/1 1.03800 1.02428 +/- 0.00206\n", + " 103/1 1.02541 1.02429 +/- 0.00203\n", + " 104/1 1.06867 1.02476 +/- 0.00207\n", + " 105/1 1.03192 1.02484 +/- 0.00205\n", + " 106/1 1.00100 1.02459 +/- 0.00204\n", + " 107/1 1.01098 1.02445 +/- 0.00202\n", + " 108/1 1.02930 1.02450 +/- 0.00200\n", + " 109/1 1.02173 1.02447 +/- 0.00198\n", + " 110/1 1.01411 1.02437 +/- 0.00197\n", + " 111/1 1.03920 1.02452 +/- 0.00195\n", + " 112/1 1.01984 1.02447 +/- 0.00193\n", + " 113/1 1.03912 1.02461 +/- 0.00192\n", + " 114/1 1.04124 1.02477 +/- 0.00191\n", + " 115/1 1.04802 1.02499 +/- 0.00190\n", + " 116/1 1.04129 1.02515 +/- 0.00189\n", + " 117/1 1.03072 1.02520 +/- 0.00187\n", + " 118/1 1.05167 1.02544 +/- 0.00187\n", + " 119/1 0.99954 1.02521 +/- 0.00187\n", + " 120/1 1.00093 1.02499 +/- 0.00187\n", + " 121/1 1.04929 1.02520 +/- 0.00186\n", + " 122/1 1.04556 1.02539 +/- 0.00185\n", + " 123/1 1.03298 1.02545 +/- 0.00184\n", + " 124/1 1.01603 1.02537 +/- 0.00182\n", + " 125/1 1.03522 1.02546 +/- 0.00181\n", + " 126/1 1.05644 1.02572 +/- 0.00181\n", + " 127/1 1.03754 1.02582 +/- 0.00180\n", + " 128/1 1.01524 1.02573 +/- 0.00179\n", + " 129/1 1.01263 1.02562 +/- 0.00178\n", + " 130/1 0.99835 1.02540 +/- 0.00178\n", + " 131/1 1.01268 1.02529 +/- 0.00177\n", + " 132/1 1.03975 1.02541 +/- 0.00175\n", + " 133/1 1.00702 1.02526 +/- 0.00175\n", + " 134/1 1.02335 1.02525 +/- 0.00173\n", + " 135/1 1.04378 1.02539 +/- 0.00173\n", + " 136/1 1.04610 1.02556 +/- 0.00172\n", + " 137/1 1.02284 1.02554 +/- 0.00171\n", + " 138/1 1.05720 1.02578 +/- 0.00171\n", + " 139/1 1.00965 1.02566 +/- 0.00170\n", + " 140/1 1.03719 1.02575 +/- 0.00169\n", + " 141/1 1.02413 1.02574 +/- 0.00168\n", + " 142/1 1.03125 1.02578 +/- 0.00167\n", + " 143/1 1.03641 1.02586 +/- 0.00166\n", + " 144/1 1.02137 1.02582 +/- 0.00164\n", + " 145/1 1.01522 1.02575 +/- 0.00163\n", + " 146/1 1.05163 1.02594 +/- 0.00163\n", + " 147/1 1.03612 1.02601 +/- 0.00162\n", + " 148/1 1.03346 1.02606 +/- 0.00161\n", + " 149/1 1.02306 1.02604 +/- 0.00160\n", + " 150/1 1.01764 1.02598 +/- 0.00159\n", + " 151/1 1.01787 1.02592 +/- 0.00158\n", + " 152/1 1.03263 1.02597 +/- 0.00157\n", + " 153/1 1.01877 1.02592 +/- 0.00156\n", + " 154/1 1.02870 1.02594 +/- 0.00155\n", + " 155/1 1.03071 1.02597 +/- 0.00154\n", + " 156/1 1.04229 1.02609 +/- 0.00153\n", + " 157/1 1.03973 1.02618 +/- 0.00152\n", + " 158/1 1.02180 1.02615 +/- 0.00151\n", + " 159/1 1.01067 1.02604 +/- 0.00151\n", + " 160/1 1.02888 1.02606 +/- 0.00150\n", + " 161/1 1.01711 1.02600 +/- 0.00149\n", + " 162/1 1.01087 1.02590 +/- 0.00148\n", + " 163/1 1.01886 1.02586 +/- 0.00147\n", + " 164/1 1.02210 1.02583 +/- 0.00146\n", + " 165/1 1.04020 1.02593 +/- 0.00146\n", + " 166/1 1.03658 1.02600 +/- 0.00145\n", + " 167/1 1.03222 1.02603 +/- 0.00144\n", + " 168/1 1.03247 1.02608 +/- 0.00143\n", + " 169/1 0.99739 1.02590 +/- 0.00143\n", + " 170/1 1.02464 1.02589 +/- 0.00142\n", + " 171/1 1.04623 1.02601 +/- 0.00142\n", + " 172/1 1.04328 1.02612 +/- 0.00142\n", + " 173/1 1.00812 1.02601 +/- 0.00141\n", + " 174/1 1.01224 1.02593 +/- 0.00141\n", + " 175/1 1.00882 1.02582 +/- 0.00140\n", + " 176/1 1.01286 1.02574 +/- 0.00140\n", + " 177/1 1.02048 1.02571 +/- 0.00139\n", + " 178/1 1.04269 1.02581 +/- 0.00138\n", + " 179/1 1.05862 1.02601 +/- 0.00139\n", + " 180/1 1.02924 1.02603 +/- 0.00138\n", + " 181/1 1.01491 1.02596 +/- 0.00137\n", + " 182/1 1.04255 1.02606 +/- 0.00137\n", + " 183/1 0.99191 1.02586 +/- 0.00137\n", + " 184/1 1.00392 1.02573 +/- 0.00137\n", + " 185/1 1.02982 1.02576 +/- 0.00137\n", + " 186/1 1.02682 1.02576 +/- 0.00136\n", + " 187/1 1.01484 1.02570 +/- 0.00135\n", + " 188/1 1.02825 1.02572 +/- 0.00134\n", + " 189/1 0.98954 1.02551 +/- 0.00135\n", + " 190/1 1.00522 1.02540 +/- 0.00135\n", + " 191/1 1.03762 1.02547 +/- 0.00134\n", + " 192/1 1.02091 1.02544 +/- 0.00134\n", + " 193/1 1.04549 1.02555 +/- 0.00133\n", + " 194/1 1.05531 1.02572 +/- 0.00134\n", + " 195/1 1.01479 1.02566 +/- 0.00133\n", + " 196/1 1.01337 1.02559 +/- 0.00132\n", + " 197/1 0.99187 1.02541 +/- 0.00133\n", + " 198/1 1.01280 1.02534 +/- 0.00132\n", + " 199/1 1.00049 1.02521 +/- 0.00132\n", + " 200/1 1.01879 1.02518 +/- 0.00132\n", + " Creating state point statepoint.200.h5...\n", + "\n", + " ===========================================================================\n", + " ======================> SIMULATION FINISHED <======================\n", + " ===========================================================================\n", + "\n", + "\n", + " =======================> TIMING STATISTICS <=======================\n", + "\n", + " Total time for initialization = 6.3000E-02 seconds\n", + " Reading cross sections = 5.0000E-03 seconds\n", + " Total time in simulation = 7.3280E+01 seconds\n", + " Time in transport only = 7.3104E+01 seconds\n", + " Time in inactive batches = 1.1200E+00 seconds\n", + " Time in active batches = 7.2160E+01 seconds\n", + " Time synchronizing fission bank = 2.5000E-02 seconds\n", + " Sampling source sites = 1.8000E-02 seconds\n", + " SEND/RECV source sites = 7.0000E-03 seconds\n", + " Time accumulating tallies = 0.0000E+00 seconds\n", + " Total time for finalization = 0.0000E+00 seconds\n", + " Total time elapsed = 7.3353E+01 seconds\n", + " Calculation Rate (inactive) = 44642.9 neutrons/second\n", + " Calculation Rate (active) = 13165.2 neutrons/second\n", + "\n", + " ============================> RESULTS <============================\n", + "\n", + " k-effective (Collision) = 1.02597 +/- 0.00117\n", + " k-effective (Track-length) = 1.02518 +/- 0.00132\n", + " k-effective (Absorption) = 1.02581 +/- 0.00070\n", + " Combined k-effective = 1.02562 +/- 0.00068\n", + " Leakage Fraction = 0.00000 +/- 0.00000\n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Close the StatePoint File\n", + "sp._f.close()\n", + "\n", + "# Run the Multi-Group OpenMC Simulation\n", + "openmc.run()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Results Comparison\n", + "Now we can compare the multi-group and continuous-energy results.\n", + "\n", + "We will begin by loading the multi-group statepoint file we just finished writing and extracting the calculated keff." + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Load the last statepoint file and keff value\n", + "mgsp = openmc.StatePoint('statepoint.' + str(batches) + '.h5')\n", + "mgsu = openmc.Summary('summary.h5')\n", + "mgsp.link_with_summary(mgsu)\n", + "mg_keff = mgsp.k_combined" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Lets compare the two eigenvalues, including their bias" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Continuous-Energy keff = 1.025440\n", + "Multi-Group keff = 1.025621\n", + "bias [pcm]: -18.1\n" + ] + } + ], + "source": [ + "bias = 1.0E5 * (ce_keff[0] - mg_keff[0])\n", + "\n", + "print('Continuous-Energy keff = {0:1.6f}'.format(ce_keff[0]))\n", + "print('Multi-Group keff = {0:1.6f}'.format(mg_keff[0]))\n", + "print('bias [pcm]: {0:1.1f}'.format(bias))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We see quite good agreement with only an 18pcm difference between the two." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Flux and Pin Power Visualizations" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next we will visualize the mesh tally results obtained from both the Continuous-Energy and Multi-Group OpenMC calculations.\n", + "\n", + "First, we extract volume-integrated fission rates from the Multi-Group calculation's mesh fission rate tally for each pin cell in the fuel assembly." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we can do the same for the Multi-Group results." + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Get the OpenMC fission rate mesh tally data\n", + "mg_mesh_tally = mgsp.get_tally(name='mesh tally')\n", + "mgopenmc_fission_rates = mg_mesh_tally.get_values(scores=['fission'])\n", + "\n", + "# Reshape array to 2D for plotting\n", + "mgopenmc_fission_rates.shape = (17,17)\n", + "\n", + "# Normalize to the average pin power\n", + "mgopenmc_fission_rates /= np.mean(mgopenmc_fission_rates)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we can easily use Matplotlib to visualize the two fission rates side-by-side." + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAADDCAYAAACS2+oqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHExJREFUeJzt3Xu8HGV9x/HP75B7SCBcEkwiQUwFaosQAbGixdvxUimX\nokKqoqGIr0KttaKiFBAvQKUYK6H1JUhBuaitEbxUoiIKRQUFvLRcDUmIxxwgCUm4BpJf/3hmzWSz\nu/Pbs7tndyff9+u1r7Nn59l5np35zW9nZ+aZx9wdERHpfwPdboCIiLSHErqISEkooYuIlIQSuohI\nSSihi4iUhBK6iEhJ9FxCN7PfmNkrut2O7ZmZfcfM3t7C+//NzD7azjZtj8xss5nt3WB6abcVxeAI\nuXvhA5gP3AZsAH4HfBt4WeS9BfO9DDin1fl085F9hqeB9dljA3BHt9sVaPdZwMZcm9cDH+h2u5po\n8xrgZuDQJt7/Q2DBKLRzGfAUsEvV63cCm4E9g/PZBOydi7OmthVgLHAmcHe2jh/Mtt3Xdntd1lif\nisE2PAr30M3s/cCFwCeA6cCewMXAXxa9dztyvrtPzR5T3P3AdldgZju0e57ANbk2T3X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kvM7B4zu76XhlKr\n096zzGylmd2ePV7fzTY2q99iW3HdGaMV211P6GY2AFxEGmX9hcDxZrZvd1sVshk43N0PdPdeHT2v\n1uj1Hwa+7+77ADcAp496q+qr1V6AC919Xvb47mg3aqT6NLYV150xKrHd9YROGkr0Pndf7u7PANcA\nR3a5TRFGbyy/uuqMXn8kcHn2/HLgqFFtVAN12guxO6H2on6MbcV1B4xWbPfCipsFPJj7f2X2Wq9z\n4Hozu83MTup2Y5ow3d2HAdx9FVBwV/qecIqZ3Wlml/TaT+kC/RjbiuvR1dbY7oWEXusbqh+upfwz\ndz8IeCNppRzW7QaV1MXA8939AGAVcGGX29OMfoxtxfXoaXts90JCXwnsmft/NjDUpbaEZXsBldHg\nF5N+XveDYTObAX8Y+PihLrenIXd/2Ld0lvgCcHA329OkvottxfXo6URs90JCvw2Ya2ZzzGwccBxw\nXZfb1JCZTTKzHbPnk4FBencU+K1Gryct23dmz08Arh3tBhXYqr3ZxllxDL27nGvpq9hWXHdcx2O7\nu/dyAdx9k5mdCiwhfcFc6u53dblZRWYAi7Mu3mOAK929/g0WuqTO6PXnAV8zswXACuDN3Wvh1uq0\n95VmdgDp6otlwMlda2CT+jC2FdcdMlqxra7/IiIl0QuHXEREpA2U0EVESkIJXUSkJJTQRURKQgld\nRKQklNBFREpCCV1EpCSU0EVESuL/ASY96jLsHTMbAAAAAElFTkSuQmCC\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Plot the CE fission rates in the left subplot\n", + "fig = plt.subplot(121)\n", + "plt.imshow(openmc_fission_rates, interpolation='none', cmap='jet')\n", + "plt.title('Continuous-Energy Fission Rates')\n", + "\n", + "# Plot the MG fission rates in the right subplot\n", + "fig2 = plt.subplot(122)\n", + "plt.imshow(mgopenmc_fission_rates, interpolation='none', cmap='jet')\n", + "plt.title('Multi-Group Fission Rates')\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "We also see very good agreement between the fission rate distributions." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/docs/source/pythonapi/examples/mgxs-part-iv.rst b/docs/source/pythonapi/examples/mgxs-part-iv.rst new file mode 100644 index 000000000..e24325521 --- /dev/null +++ b/docs/source/pythonapi/examples/mgxs-part-iv.rst @@ -0,0 +1,13 @@ +.. _notebook_mgxs_part_iv: + +==================================================== +MGXS Part IV: Multi-Group Mode Cross-Section Library +==================================================== + +.. only:: html + + .. notebook:: mgxs-part-iv.ipynb + +.. only:: latex + + IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/pythonapi/index.rst b/docs/source/pythonapi/index.rst index 1631976e6..3c4899cd2 100644 --- a/docs/source/pythonapi/index.rst +++ b/docs/source/pythonapi/index.rst @@ -26,6 +26,7 @@ Example Jupyter Notebooks examples/mgxs-part-i examples/mgxs-part-ii examples/mgxs-part-iii + examples/mgxs-part-iv ------------------------------------ :mod:`openmc` -- Basic Functionality diff --git a/openmc/summary.py b/openmc/summary.py index f33397d72..af164a12c 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -41,6 +41,7 @@ class Summary(object): self._read_nuclides() self._read_geometry() self._read_tallies() + self._f.close() @property def openmc_geometry(self):