mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-24 12:05:32 -04:00
2381 lines
93 KiB
Text
2381 lines
93 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"This notebook demonstrates how to use the **``openmc.mgxs``** module to generate multi-group cross sections with OpenMC.\n",
|
|
"\n",
|
|
"**Note:** that this Notebook was created using [OpenMOC](https://mit-crpg.github.io/OpenMOC/) to verify the multi-group cross-sections generated by OpenMC. In order to run this Notebook, you must have [OpenMOC](https://mit-crpg.github.io/OpenMOC/) installed on your system, along with OpenCG to convert the OpenMC geometries into OpenMOC geometries."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import numpy as np\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"\n",
|
|
"import openmc\n",
|
|
"import openmc.mgxs as mgxs\n",
|
|
"\n",
|
|
"%matplotlib inline"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Infinite Homogeneous Medium"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We first construct a simple homogeneous infinite medium problem to illustrate use of the `openmc.mgxs` module to generate multi-group cross sections."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Generate Inputs"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"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",
|
|
"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 a material for the homogeneous medium."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate a Material and register the Nuclides\n",
|
|
"inf_medium = openmc.Material(name='moderator')\n",
|
|
"inf_medium.set_density('g/cc', 5.)\n",
|
|
"inf_medium.add_nuclide(h1, 0.028999667)\n",
|
|
"inf_medium.add_nuclide(o16, 0.01450188)\n",
|
|
"inf_medium.add_nuclide(u235, 0.000114142)\n",
|
|
"inf_medium.add_nuclide(u238, 0.006886019)\n",
|
|
"inf_medium.add_nuclide(zr90, 0.002116053)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"With our material, we can now create a materials file object that can be exported to an actual XML file."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate a MaterialsFile, register all Materials, and export to XML\n",
|
|
"materials_file = openmc.MaterialsFile()\n",
|
|
"materials_file.default_xs = '71c'\n",
|
|
"materials_file.add_material(inf_medium)\n",
|
|
"materials_file.export_to_xml()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Now let's move on to the geometry. This problem will be a simple square cell with reflective boundary conditions to simulate an infinite homogeneous medium. The first step is to create the outer bounding surfaces of the problem."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate boundary Planes\n",
|
|
"min_x = openmc.XPlane(boundary_type='reflective', x0=-0.63)\n",
|
|
"max_x = openmc.XPlane(boundary_type='reflective', x0=0.63)\n",
|
|
"min_y = openmc.YPlane(boundary_type='reflective', y0=-0.63)\n",
|
|
"max_y = openmc.YPlane(boundary_type='reflective', y0=0.63)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"With the surfaces defined, we can now create a cell that is defined by intersections of half-spaces created by the surfaces."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Instantiate a Cell\n",
|
|
"cell = openmc.Cell(cell_id=1, name='cell')\n",
|
|
"\n",
|
|
"# Register bounding Surfaces with the Cell\n",
|
|
"cell.add_surface(surface=min_x, halfspace=+1)\n",
|
|
"cell.add_surface(surface=max_x, halfspace=-1)\n",
|
|
"cell.add_surface(surface=min_y, halfspace=+1)\n",
|
|
"cell.add_surface(surface=max_y, halfspace=-1)\n",
|
|
"\n",
|
|
"# Fill the Cell with the Material\n",
|
|
"cell.fill = inf_medium"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"OpenMC requires that there is a \"root\" universe. Let us create a root universe and add our square cell to it."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate Universe\n",
|
|
"root_universe = openmc.Universe(universe_id=0, name='root universe')\n",
|
|
"root_universe.add_cell(cell)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We now must create a geometry that is assigned a root universe, put the geometry into a geometry file, and export it to XML."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Create Geometry and set root Universe\n",
|
|
"openmc_geometry = openmc.Geometry()\n",
|
|
"openmc_geometry.root_universe = root_universe\n",
|
|
"\n",
|
|
"# Instantiate a GeometryFile\n",
|
|
"geometry_file = openmc.GeometryFile()\n",
|
|
"geometry_file.geometry = openmc_geometry\n",
|
|
"\n",
|
|
"# Export to \"geometry.xml\"\n",
|
|
"geometry_file.export_to_xml()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Next, we must 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": 9,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# OpenMC simulation parameters\n",
|
|
"batches = 50\n",
|
|
"inactive = 10\n",
|
|
"particles = 2500\n",
|
|
"\n",
|
|
"# Instantiate a SettingsFile\n",
|
|
"settings_file = openmc.SettingsFile()\n",
|
|
"settings_file.batches = batches\n",
|
|
"settings_file.inactive = inactive\n",
|
|
"settings_file.particles = particles\n",
|
|
"settings_file.output = {'tallies': True, 'summary': True}\n",
|
|
"bounds = [-0.63, -0.63, -0.63, 0.63, 0.63, 0.63]\n",
|
|
"settings_file.set_source_space('box', bounds)\n",
|
|
"\n",
|
|
"# Export to \"settings.xml\"\n",
|
|
"settings_file.export_to_xml()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Now we are finally ready to make use of the `openmc.mgxs` module to generate multi-group cross sections! First, let's define a \"fine\" 8-group and \"coarse\" 2-group structures using the built-in `EnergyGroups` class."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate a \"fine\" 8-group EneryGroups object\n",
|
|
"fine_groups = mgxs.EnergyGroups()\n",
|
|
"fine_groups.group_edges = np.array([0., 0.058e-6, 0.14e-6, 0.28e-6,\n",
|
|
" 0.625e-6, 4.e-6, 5.53e-3, 821.e-3, 20.])\n",
|
|
"\n",
|
|
"# Instantiate a \"coarse\" 2-group EneryGroups object\n",
|
|
"coarse_groups = mgxs.EnergyGroups()\n",
|
|
"coarse_groups.group_edges = np.array([0., 0.625e-6, 20.])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We can now use the fine and coarse `EnergyGroups` objects, along with our previously created materials and geometry, to instantiate some `MultiGroupXS` objects from the `openmc.mgxs` module. In particular, the following are subclasses of generic and abstract `MultiGroupXS` class:\n",
|
|
"\n",
|
|
"* `TotalXS`\n",
|
|
"* `TransportXS`\n",
|
|
"* `AbsorptionXS`\n",
|
|
"* `CaptureXS`\n",
|
|
"* `FissionXS`\n",
|
|
"* `NuFissionXS`\n",
|
|
"* `ScatterXS`\n",
|
|
"* `NuScatterXS`\n",
|
|
"* `ScatterMatrixXS`\n",
|
|
"* `NuScatterMatrixXS`\n",
|
|
"* `Chi`\n",
|
|
"\n",
|
|
"These classes provide us with an interface to generate the tally inputs as well as perform post-processing of OpenMC's tally data to compute the respective multi-group cross sections. In this case, let's create the multi-group cross sections needed to run an OpenMOC simulation to verify the accuracy of our cross sections. In particular, we will define total, nu-fission, nu-scatter and chi cross sections for our infinite medium cell as the domain and our fine 8-group structure as our energy groups."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate cross sections needed for an OpenMOC simulation\n",
|
|
"transport = mgxs.TransportXS(domain=cell, domain_type='cell', groups=fine_groups)\n",
|
|
"nufission = mgxs.NuFissionXS(domain=cell, domain_type='cell', groups=fine_groups)\n",
|
|
"nuscatter = mgxs.NuScatterMatrixXS(domain=cell, domain_type='cell', groups=fine_groups)\n",
|
|
"chi = mgxs.Chi(domain=cell, domain_type='cell', groups=fine_groups)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Next, we must instruct our multi-group cross section objects to generate the tallies needed to calculate each of them in OpenMC. This can be done with the `MultiGroupXS.create_tallies()` routine."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instruct each multi-group cross section to generate tallies\n",
|
|
"transport.create_tallies()\n",
|
|
"nufission.create_tallies()\n",
|
|
"nuscatter.create_tallies()\n",
|
|
"chi.create_tallies()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Each multi-group cross section object stores its tallies in a Python dictionary called `tallies`. We can inspect the tallies in the dictionary for our `NuFission` object as follows. "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 13,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'flux': Tally\n",
|
|
" \tID =\t10003\n",
|
|
" \tName =\t\n",
|
|
" \tFilters =\t\n",
|
|
" \t\tcell\t[1]\n",
|
|
" \t\tenergy\t[ 0.00000000e+00 5.80000000e-08 1.40000000e-07 2.80000000e-07\n",
|
|
" 6.25000000e-07 4.00000000e-06 5.53000000e-03 8.21000000e-01\n",
|
|
" 2.00000000e+01]\n",
|
|
" \tNuclides =\ttotal \n",
|
|
" \tScores =\t['flux']\n",
|
|
" \tEstimator =\ttracklength, 'nu-fission': Tally\n",
|
|
" \tID =\t10004\n",
|
|
" \tName =\t\n",
|
|
" \tFilters =\t\n",
|
|
" \t\tcell\t[1]\n",
|
|
" \t\tenergy\t[ 0.00000000e+00 5.80000000e-08 1.40000000e-07 2.80000000e-07\n",
|
|
" 6.25000000e-07 4.00000000e-06 5.53000000e-03 8.21000000e-01\n",
|
|
" 2.00000000e+01]\n",
|
|
" \tNuclides =\ttotal \n",
|
|
" \tScores =\t['nu-fission']\n",
|
|
" \tEstimator =\ttracklength}"
|
|
]
|
|
},
|
|
"execution_count": 13,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"nufission.tallies"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"The `NuFission` object includes tracklength tallies for the 'nu-fission' and 'flux' scores in the 8-group structure in cell 1. Now that each multi-group cross section object contains the tallies that it needs, we must add these tallies to a `TalliesFile` object to generate the \"tallies.xml\" input file for OpenMC."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate an empty TalliesFile\n",
|
|
"tallies_file = openmc.TalliesFile()\n",
|
|
"\n",
|
|
"# Add transport tallies to the tallies file\n",
|
|
"for tally in transport.tallies.values():\n",
|
|
" tallies_file.add_tally(tally, merge=True)\n",
|
|
"\n",
|
|
"# Add nu-fission tallies to the tallies file\n",
|
|
"for tally in nufission.tallies.values():\n",
|
|
" tallies_file.add_tally(tally, merge=True)\n",
|
|
"\n",
|
|
"# Add nu-scatter tallies to the tallies file\n",
|
|
"for tally in nuscatter.tallies.values():\n",
|
|
" tallies_file.add_tally(tally, merge=True)\n",
|
|
"\n",
|
|
"# Add chi tallies to the tallies file \n",
|
|
"for tally in chi.tallies.values():\n",
|
|
" tallies_file.add_tally(tally, merge=True)\n",
|
|
" \n",
|
|
"# Export to \"tallies.xml\"\n",
|
|
"tallies_file.export_to_xml()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Now we a have a complete set of inputs, so we can go ahead and run our simulation."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"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-2015 Massachusetts Institute of Technology\n",
|
|
" License: http://mit-crpg.github.io/openmc/license.html\n",
|
|
" Version: 0.7.0\n",
|
|
" Git SHA1: 23535afa1c69644bb299bde18a094c3b99d53ae0\n",
|
|
" Date/Time: 2015-10-08 16:01:19\n",
|
|
" MPI Processes: 1\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: 1001.71c\n",
|
|
" Loading ACE cross section table: 8016.71c\n",
|
|
" Loading ACE cross section table: 92235.71c\n",
|
|
" Loading ACE cross section table: 92238.71c\n",
|
|
" Loading ACE cross section table: 40090.71c\n",
|
|
" Initializing source particles...\n",
|
|
"\n",
|
|
" ===========================================================================\n",
|
|
" ====================> K EIGENVALUE SIMULATION <====================\n",
|
|
" ===========================================================================\n",
|
|
"\n",
|
|
" Bat./Gen. k Average k \n",
|
|
" ========= ======== ==================== \n",
|
|
" 1/1 1.19804 \n",
|
|
" 2/1 1.12945 \n",
|
|
" 3/1 1.15573 \n",
|
|
" 4/1 1.13929 \n",
|
|
" 5/1 1.16300 \n",
|
|
" 6/1 1.22117 \n",
|
|
" 7/1 1.19012 \n",
|
|
" 8/1 1.11299 \n",
|
|
" 9/1 1.16066 \n",
|
|
" 10/1 1.12566 \n",
|
|
" 11/1 1.20854 \n",
|
|
" 12/1 1.14691 1.17773 +/- 0.03082\n",
|
|
" 13/1 1.17204 1.17583 +/- 0.01789\n",
|
|
" 14/1 1.14148 1.16724 +/- 0.01529\n",
|
|
" 15/1 1.17272 1.16834 +/- 0.01189\n",
|
|
" 16/1 1.18575 1.17124 +/- 0.01014\n",
|
|
" 17/1 1.20498 1.17606 +/- 0.00983\n",
|
|
" 18/1 1.14754 1.17249 +/- 0.00923\n",
|
|
" 19/1 1.18141 1.17348 +/- 0.00820\n",
|
|
" 20/1 1.15074 1.17121 +/- 0.00768\n",
|
|
" 21/1 1.15914 1.17011 +/- 0.00703\n",
|
|
" 22/1 1.14586 1.16809 +/- 0.00673\n",
|
|
" 23/1 1.18999 1.16978 +/- 0.00642\n",
|
|
" 24/1 1.15101 1.16844 +/- 0.00609\n",
|
|
" 25/1 1.13791 1.16640 +/- 0.00602\n",
|
|
" 26/1 1.19791 1.16837 +/- 0.00597\n",
|
|
" 27/1 1.19818 1.17012 +/- 0.00587\n",
|
|
" 28/1 1.14160 1.16854 +/- 0.00576\n",
|
|
" 29/1 1.11487 1.16571 +/- 0.00614\n",
|
|
" 30/1 1.17538 1.16620 +/- 0.00584\n",
|
|
" 31/1 1.20210 1.16791 +/- 0.00581\n",
|
|
" 32/1 1.20078 1.16940 +/- 0.00574\n",
|
|
" 33/1 1.14624 1.16839 +/- 0.00558\n",
|
|
" 34/1 1.14618 1.16747 +/- 0.00542\n",
|
|
" 35/1 1.16866 1.16752 +/- 0.00520\n",
|
|
" 36/1 1.18565 1.16821 +/- 0.00504\n",
|
|
" 37/1 1.16824 1.16821 +/- 0.00485\n",
|
|
" 38/1 1.18299 1.16874 +/- 0.00471\n",
|
|
" 39/1 1.21418 1.17031 +/- 0.00480\n",
|
|
" 40/1 1.11167 1.16835 +/- 0.00504\n",
|
|
" 41/1 1.11545 1.16665 +/- 0.00516\n",
|
|
" 42/1 1.11114 1.16491 +/- 0.00529\n",
|
|
" 43/1 1.14227 1.16423 +/- 0.00517\n",
|
|
" 44/1 1.14104 1.16355 +/- 0.00506\n",
|
|
" 45/1 1.16756 1.16366 +/- 0.00492\n",
|
|
" 46/1 1.13065 1.16274 +/- 0.00487\n",
|
|
" 47/1 1.11251 1.16139 +/- 0.00492\n",
|
|
" 48/1 1.14731 1.16101 +/- 0.00481\n",
|
|
" 49/1 1.16691 1.16117 +/- 0.00469\n",
|
|
" 50/1 1.19679 1.16206 +/- 0.00465\n",
|
|
" Creating state point statepoint.50.h5...\n",
|
|
"\n",
|
|
" ===========================================================================\n",
|
|
" ======================> SIMULATION FINISHED <======================\n",
|
|
" ===========================================================================\n",
|
|
"\n",
|
|
"\n",
|
|
" =======================> TIMING STATISTICS <=======================\n",
|
|
"\n",
|
|
" Total time for initialization = 3.9700E-01 seconds\n",
|
|
" Reading cross sections = 9.1000E-02 seconds\n",
|
|
" Total time in simulation = 1.2622E+01 seconds\n",
|
|
" Time in transport only = 1.2608E+01 seconds\n",
|
|
" Time in inactive batches = 1.8770E+00 seconds\n",
|
|
" Time in active batches = 1.0745E+01 seconds\n",
|
|
" Time synchronizing fission bank = 4.0000E-03 seconds\n",
|
|
" Sampling source sites = 3.0000E-03 seconds\n",
|
|
" SEND/RECV source sites = 0.0000E+00 seconds\n",
|
|
" Time accumulating tallies = 0.0000E+00 seconds\n",
|
|
" Total time for finalization = 3.0000E-03 seconds\n",
|
|
" Total time elapsed = 1.3030E+01 seconds\n",
|
|
" Calculation Rate (inactive) = 13319.1 neutrons/second\n",
|
|
" Calculation Rate (active) = 9306.65 neutrons/second\n",
|
|
"\n",
|
|
" ============================> RESULTS <============================\n",
|
|
"\n",
|
|
" k-effective (Collision) = 1.16131 +/- 0.00453\n",
|
|
" k-effective (Track-length) = 1.16206 +/- 0.00465\n",
|
|
" k-effective (Absorption) = 1.16096 +/- 0.00364\n",
|
|
" Combined k-effective = 1.16120 +/- 0.00325\n",
|
|
" Leakage Fraction = 0.00000 +/- 0.00000\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"0"
|
|
]
|
|
},
|
|
"execution_count": 16,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# Run OpenMC!\n",
|
|
"executor = openmc.Executor()\n",
|
|
"executor.run_simulation()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Tally Data Processing"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Our simulation ran successfully and created a statepoint file with all the tally data in it. We begin our analysis here loading the statepoint file and 'reading' the results. By default, data from the statepoint file is only read into memory when it is requested. This helps keep the memory use to a minimum even when a statepoint file may be huge."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 17,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Load the last statepoint file\n",
|
|
"sp = openmc.StatePoint('statepoint.50.h5')"
|
|
]
|
|
},
|
|
{
|
|
"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 which 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": 18,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Load the summary file and link it with the statepoint\n",
|
|
"su = openmc.Summary('summary.h5')\n",
|
|
"sp.link_with_summary(su)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"The statepoint is now ready to be analyzed by our multi-group cross sections. The first step is to load the tallies from the statepoint into each object."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 19,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Load the tallies from the statepoint into each MultiGroupXS object\n",
|
|
"transport.load_from_statepoint(sp)\n",
|
|
"nufission.load_from_statepoint(sp)\n",
|
|
"nuscatter.load_from_statepoint(sp)\n",
|
|
"chi.load_from_statepoint(sp)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"The multi-group cross section objects can now use OpenMC's [tally arithmetic](http://mit-crpg.github.io/openmc/pythonapi/examples/pandas-dataframes.html) to compute cross sections from the tally data."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 20,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/tallies.py:1486: RuntimeWarning: invalid value encountered in divide\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"transport.compute_xs()\n",
|
|
"nufission.compute_xs()\n",
|
|
"nuscatter.compute_xs()\n",
|
|
"chi.compute_xs()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Voila! Our multi-group cross sections are now ready to rock 'n roll!"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Cross Section Data Visualization"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Let's first inspect our fission production cross section by printing it to the screen."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 21,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Multi-Group XS\n",
|
|
"\tReaction Type =\tnu-fission\n",
|
|
"\tDomain Type =\tcell\n",
|
|
"\tDomain ID =\t1\n",
|
|
"\tCross Sections [cm^-1]:\n",
|
|
" Group 1 [0.821 - 20.0 MeV]:\t1.11e-02 +/- 7.69e-01%\n",
|
|
" Group 2 [0.00553 - 0.821 MeV]:\t6.59e-04 +/- 2.97e-01%\n",
|
|
" Group 3 [4e-06 - 0.00553 MeV]:\t8.95e-03 +/- 5.12e-01%\n",
|
|
" Group 4 [6.25e-07 - 4e-06 MeV]:\t1.45e-02 +/- 7.10e-01%\n",
|
|
" Group 5 [2.8e-07 - 6.25e-07 MeV]:\t4.71e-02 +/- 1.02e+00%\n",
|
|
" Group 6 [1.4e-07 - 2.8e-07 MeV]:\t7.29e-02 +/- 8.86e-01%\n",
|
|
" Group 7 [5.8e-08 - 1.4e-07 MeV]:\t1.11e-01 +/- 6.67e-01%\n",
|
|
" Group 8 [0.0 - 5.8e-08 MeV]:\t2.38e-01 +/- 7.71e-01%\n",
|
|
"\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"nufission.print_xs()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Since the `openmc.mgxs` module uses tally arithmetic under-the-hood, the cross section is stored as a \"derived\" tally. This means that it can be queried and manipulated using all of the same method supported for the `Tally` class in the OpenMC Python API. For example, we can construct a Pandas DataFrame of the multi-group cross section data."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 22,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
|
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|
" <thead>\n",
|
|
" <tr style=\"text-align: right;\">\n",
|
|
" <th></th>\n",
|
|
" <th>cell</th>\n",
|
|
" <th>group in</th>\n",
|
|
" <th>group out</th>\n",
|
|
" <th>nuclide</th>\n",
|
|
" <th>mean</th>\n",
|
|
" <th>std. dev.</th>\n",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" <tr>\n",
|
|
" <th>63</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.076970</td>\n",
|
|
" <td>0.001012</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>62</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.087876</td>\n",
|
|
" <td>0.000344</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>61</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>3</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.000418</td>\n",
|
|
" <td>0.000023</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>60</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>4</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>59</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>5</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>58</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>6</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>57</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>7</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>56</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>8</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>55</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>54</th>\n",
|
|
" <td>1</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>total</td>\n",
|
|
" <td>0.266499</td>\n",
|
|
" <td>0.001265</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"text/plain": [
|
|
" cell group in group out nuclide mean std. dev.\n",
|
|
"63 1 1 1 total 0.076970 0.001012\n",
|
|
"62 1 1 2 total 0.087876 0.000344\n",
|
|
"61 1 1 3 total 0.000418 0.000023\n",
|
|
"60 1 1 4 total 0.000000 0.000000\n",
|
|
"59 1 1 5 total 0.000000 0.000000\n",
|
|
"58 1 1 6 total 0.000000 0.000000\n",
|
|
"57 1 1 7 total 0.000000 0.000000\n",
|
|
"56 1 1 8 total 0.000000 0.000000\n",
|
|
"55 1 2 1 total 0.000000 0.000000\n",
|
|
"54 1 2 2 total 0.266499 0.001265"
|
|
]
|
|
},
|
|
"execution_count": 22,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"df = nuscatter.get_pandas_dataframe()\n",
|
|
"df.head(10)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Each multi-group cross section object can be easily exported to a variety of file formats, including CSV, Excel, and LaTeX for storage or data processing."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 23,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"transport.export_xs_data(filename='transport-xs', format='excel')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"The following code snippet shows how to export all of four cross sections to the same HDF5 binary data store."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 24,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"transport.build_hdf5_store(filename='mgxs', append=True)\n",
|
|
"nufission.build_hdf5_store(filename='mgxs', append=True)\n",
|
|
"nuscatter.build_hdf5_store(filename='mgxs', append=True)\n",
|
|
"chi.build_hdf5_store(filename='mgxs', append=True)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Verification with OpenMOC"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Of course it is always a good idea to verify that one's cross sections are accurate. We can easily do so here with the deterministic transport code OpenMOC. First, we will use OpenCG to reconstruct our OpenMC geometry from the summary file into a equivalent OpenMOC geometry."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 25,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/usr/lib/pymodules/python2.7/matplotlib/__init__.py:1173: UserWarning: This call to matplotlib.use() has no effect\n",
|
|
"because the backend has already been chosen;\n",
|
|
"matplotlib.use() must be called *before* pylab, matplotlib.pyplot,\n",
|
|
"or matplotlib.backends is imported for the first time.\n",
|
|
"\n",
|
|
" warnings.warn(_use_error_msg)\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Import OpenMOC and the OpenMOC/OpenCG compatibility module\n",
|
|
"import openmoc\n",
|
|
"from openmoc.compatible import get_openmoc_geometry\n",
|
|
"\n",
|
|
"# Create an OpenCG Geometry from the OpenMC Geometry stored in the summary\n",
|
|
"su.make_opencg_geometry()\n",
|
|
"\n",
|
|
"# Create an OpenMOC Geometry from the OpenCG Geometry\n",
|
|
"openmoc_geometry = get_openmoc_geometry(su.opencg_geometry)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Now, we can inject the multi-group cross sections into the equivalent infinite homogeneous medium OpenMOC geometry."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 26,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Get all OpenMOC cells in the gometry\n",
|
|
"openmoc_cells = openmoc_geometry.getRootUniverse().getAllCells()\n",
|
|
"\n",
|
|
"# Inject multi-group cross sections into OpenMOC Materials\n",
|
|
"for cell_id, cell in openmoc_cells.items():\n",
|
|
" \n",
|
|
" # Get a reference to the Material filling this Cell\n",
|
|
" openmoc_material = cell.getFillMaterial()\n",
|
|
" \n",
|
|
" # Set the number of energy groups for the Material\n",
|
|
" openmoc_material.setNumEnergyGroups(fine_groups.num_groups)\n",
|
|
" \n",
|
|
" # Inject NumPy arrays of cross section data into the Material\n",
|
|
" openmoc_material.setSigmaT(transport.get_xs().flatten())\n",
|
|
" openmoc_material.setNuSigmaF(nufission.get_xs().flatten())\n",
|
|
" openmoc_material.setSigmaS(nuscatter.get_xs().flatten())\n",
|
|
" openmoc_material.setChi(chi.get_xs().flatten())"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We are now ready to run OpenMOC to verify our cross-sections from OpenMC."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 27,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"[ NORMAL ] Ray tracing for track segmentation...\n",
|
|
"[ NORMAL ] Dumping tracks to file...\n",
|
|
"[ NORMAL ] Computing the eigenvalue...\n",
|
|
"[ NORMAL ] Iteration 0:\tk_eff = 0.685185\tres = 0.000E+00\n",
|
|
"[ NORMAL ] Iteration 1:\tk_eff = 0.785642\tres = 3.148E-01\n",
|
|
"[ NORMAL ] Iteration 2:\tk_eff = 0.750185\tres = 1.466E-01\n",
|
|
"[ NORMAL ] Iteration 3:\tk_eff = 0.728847\tres = 4.513E-02\n",
|
|
"[ NORMAL ] Iteration 4:\tk_eff = 0.695633\tres = 2.844E-02\n",
|
|
"[ NORMAL ] Iteration 5:\tk_eff = 0.663357\tres = 4.557E-02\n",
|
|
"[ NORMAL ] Iteration 6:\tk_eff = 0.632339\tres = 4.640E-02\n",
|
|
"[ NORMAL ] Iteration 7:\tk_eff = 0.604187\tres = 4.676E-02\n",
|
|
"[ NORMAL ] Iteration 8:\tk_eff = 0.579451\tres = 4.452E-02\n",
|
|
"[ NORMAL ] Iteration 9:\tk_eff = 0.558474\tres = 4.094E-02\n",
|
|
"[ NORMAL ] Iteration 10:\tk_eff = 0.541436\tres = 3.620E-02\n",
|
|
"[ NORMAL ] Iteration 11:\tk_eff = 0.528380\tres = 3.051E-02\n",
|
|
"[ NORMAL ] Iteration 12:\tk_eff = 0.519273\tres = 2.411E-02\n",
|
|
"[ NORMAL ] Iteration 13:\tk_eff = 0.513991\tres = 1.724E-02\n",
|
|
"[ NORMAL ] Iteration 14:\tk_eff = 0.512364\tres = 1.017E-02\n",
|
|
"[ NORMAL ] Iteration 15:\tk_eff = 0.514171\tres = 3.165E-03\n",
|
|
"[ NORMAL ] Iteration 16:\tk_eff = 0.519155\tres = 3.527E-03\n",
|
|
"[ NORMAL ] Iteration 17:\tk_eff = 0.527038\tres = 9.693E-03\n",
|
|
"[ NORMAL ] Iteration 18:\tk_eff = 0.537524\tres = 1.518E-02\n",
|
|
"[ NORMAL ] Iteration 19:\tk_eff = 0.550310\tres = 1.990E-02\n",
|
|
"[ NORMAL ] Iteration 20:\tk_eff = 0.565096\tres = 2.379E-02\n",
|
|
"[ NORMAL ] Iteration 21:\tk_eff = 0.581585\tres = 2.687E-02\n",
|
|
"[ NORMAL ] Iteration 22:\tk_eff = 0.599493\tres = 2.918E-02\n",
|
|
"[ NORMAL ] Iteration 23:\tk_eff = 0.618548\tres = 3.079E-02\n",
|
|
"[ NORMAL ] Iteration 24:\tk_eff = 0.638497\tres = 3.179E-02\n",
|
|
"[ NORMAL ] Iteration 25:\tk_eff = 0.659105\tres = 3.225E-02\n",
|
|
"[ NORMAL ] Iteration 26:\tk_eff = 0.680156\tres = 3.228E-02\n",
|
|
"[ NORMAL ] Iteration 27:\tk_eff = 0.701456\tres = 3.194E-02\n",
|
|
"[ NORMAL ] Iteration 28:\tk_eff = 0.722831\tres = 3.132E-02\n",
|
|
"[ NORMAL ] Iteration 29:\tk_eff = 0.744127\tres = 3.047E-02\n",
|
|
"[ NORMAL ] Iteration 30:\tk_eff = 0.765209\tres = 2.946E-02\n",
|
|
"[ NORMAL ] Iteration 31:\tk_eff = 0.785961\tres = 2.833E-02\n",
|
|
"[ NORMAL ] Iteration 32:\tk_eff = 0.806283\tres = 2.712E-02\n",
|
|
"[ NORMAL ] Iteration 33:\tk_eff = 0.826093\tres = 2.586E-02\n",
|
|
"[ NORMAL ] Iteration 34:\tk_eff = 0.845324\tres = 2.457E-02\n",
|
|
"[ NORMAL ] Iteration 35:\tk_eff = 0.863921\tres = 2.328E-02\n",
|
|
"[ NORMAL ] Iteration 36:\tk_eff = 0.881841\tres = 2.200E-02\n",
|
|
"[ NORMAL ] Iteration 37:\tk_eff = 0.899055\tres = 2.074E-02\n",
|
|
"[ NORMAL ] Iteration 38:\tk_eff = 0.915540\tres = 1.952E-02\n",
|
|
"[ NORMAL ] Iteration 39:\tk_eff = 0.931284\tres = 1.834E-02\n",
|
|
"[ NORMAL ] Iteration 40:\tk_eff = 0.946283\tres = 1.720E-02\n",
|
|
"[ NORMAL ] Iteration 41:\tk_eff = 0.960536\tres = 1.610E-02\n",
|
|
"[ NORMAL ] Iteration 42:\tk_eff = 0.974052\tres = 1.506E-02\n",
|
|
"[ NORMAL ] Iteration 43:\tk_eff = 0.986841\tres = 1.407E-02\n",
|
|
"[ NORMAL ] Iteration 44:\tk_eff = 0.998920\tres = 1.313E-02\n",
|
|
"[ NORMAL ] Iteration 45:\tk_eff = 1.010307\tres = 1.224E-02\n",
|
|
"[ NORMAL ] Iteration 46:\tk_eff = 1.021023\tres = 1.140E-02\n",
|
|
"[ NORMAL ] Iteration 47:\tk_eff = 1.031091\tres = 1.061E-02\n",
|
|
"[ NORMAL ] Iteration 48:\tk_eff = 1.040537\tres = 9.861E-03\n",
|
|
"[ NORMAL ] Iteration 49:\tk_eff = 1.049386\tres = 9.161E-03\n",
|
|
"[ NORMAL ] Iteration 50:\tk_eff = 1.057664\tres = 8.504E-03\n",
|
|
"[ NORMAL ] Iteration 51:\tk_eff = 1.065399\tres = 7.889E-03\n",
|
|
"[ NORMAL ] Iteration 52:\tk_eff = 1.072617\tres = 7.313E-03\n",
|
|
"[ NORMAL ] Iteration 53:\tk_eff = 1.079345\tres = 6.775E-03\n",
|
|
"[ NORMAL ] Iteration 54:\tk_eff = 1.085609\tres = 6.273E-03\n",
|
|
"[ NORMAL ] Iteration 55:\tk_eff = 1.091436\tres = 5.804E-03\n",
|
|
"[ NORMAL ] Iteration 56:\tk_eff = 1.096851\tres = 5.367E-03\n",
|
|
"[ NORMAL ] Iteration 57:\tk_eff = 1.101877\tres = 4.961E-03\n",
|
|
"[ NORMAL ] Iteration 58:\tk_eff = 1.106540\tres = 4.583E-03\n",
|
|
"[ NORMAL ] Iteration 59:\tk_eff = 1.110860\tres = 4.231E-03\n",
|
|
"[ NORMAL ] Iteration 60:\tk_eff = 1.114861\tres = 3.905E-03\n",
|
|
"[ NORMAL ] Iteration 61:\tk_eff = 1.118563\tres = 3.602E-03\n",
|
|
"[ NORMAL ] Iteration 62:\tk_eff = 1.121986\tres = 3.321E-03\n",
|
|
"[ NORMAL ] Iteration 63:\tk_eff = 1.125149\tres = 3.060E-03\n",
|
|
"[ NORMAL ] Iteration 64:\tk_eff = 1.128069\tres = 2.819E-03\n",
|
|
"[ NORMAL ] Iteration 65:\tk_eff = 1.130764\tres = 2.595E-03\n",
|
|
"[ NORMAL ] Iteration 66:\tk_eff = 1.133248\tres = 2.389E-03\n",
|
|
"[ NORMAL ] Iteration 67:\tk_eff = 1.135538\tres = 2.197E-03\n",
|
|
"[ NORMAL ] Iteration 68:\tk_eff = 1.137648\tres = 2.021E-03\n",
|
|
"[ NORMAL ] Iteration 69:\tk_eff = 1.139590\tres = 1.858E-03\n",
|
|
"[ NORMAL ] Iteration 70:\tk_eff = 1.141377\tres = 1.707E-03\n",
|
|
"[ NORMAL ] Iteration 71:\tk_eff = 1.143021\tres = 1.568E-03\n",
|
|
"[ NORMAL ] Iteration 72:\tk_eff = 1.144531\tres = 1.440E-03\n",
|
|
"[ NORMAL ] Iteration 73:\tk_eff = 1.145920\tres = 1.322E-03\n",
|
|
"[ NORMAL ] Iteration 74:\tk_eff = 1.147195\tres = 1.213E-03\n",
|
|
"[ NORMAL ] Iteration 75:\tk_eff = 1.148365\tres = 1.113E-03\n",
|
|
"[ NORMAL ] Iteration 76:\tk_eff = 1.149440\tres = 1.020E-03\n",
|
|
"[ NORMAL ] Iteration 77:\tk_eff = 1.150425\tres = 9.356E-04\n",
|
|
"[ NORMAL ] Iteration 78:\tk_eff = 1.151329\tres = 8.574E-04\n",
|
|
"[ NORMAL ] Iteration 79:\tk_eff = 1.152157\tres = 7.856E-04\n",
|
|
"[ NORMAL ] Iteration 80:\tk_eff = 1.152916\tres = 7.196E-04\n",
|
|
"[ NORMAL ] Iteration 81:\tk_eff = 1.153612\tres = 6.590E-04\n",
|
|
"[ NORMAL ] Iteration 82:\tk_eff = 1.154249\tres = 6.033E-04\n",
|
|
"[ NORMAL ] Iteration 83:\tk_eff = 1.154832\tres = 5.522E-04\n",
|
|
"[ NORMAL ] Iteration 84:\tk_eff = 1.155366\tres = 5.053E-04\n",
|
|
"[ NORMAL ] Iteration 85:\tk_eff = 1.155855\tres = 4.623E-04\n",
|
|
"[ NORMAL ] Iteration 86:\tk_eff = 1.156302\tres = 4.229E-04\n",
|
|
"[ NORMAL ] Iteration 87:\tk_eff = 1.156710\tres = 3.866E-04\n",
|
|
"[ NORMAL ] Iteration 88:\tk_eff = 1.157084\tres = 3.535E-04\n",
|
|
"[ NORMAL ] Iteration 89:\tk_eff = 1.157426\tres = 3.230E-04\n",
|
|
"[ NORMAL ] Iteration 90:\tk_eff = 1.157738\tres = 2.952E-04\n",
|
|
"[ NORMAL ] Iteration 91:\tk_eff = 1.158023\tres = 2.697E-04\n",
|
|
"[ NORMAL ] Iteration 92:\tk_eff = 1.158284\tres = 2.464E-04\n",
|
|
"[ NORMAL ] Iteration 93:\tk_eff = 1.158522\tres = 2.251E-04\n",
|
|
"[ NORMAL ] Iteration 94:\tk_eff = 1.158739\tres = 2.055E-04\n",
|
|
"[ NORMAL ] Iteration 95:\tk_eff = 1.158937\tres = 1.876E-04\n",
|
|
"[ NORMAL ] Iteration 96:\tk_eff = 1.159119\tres = 1.713E-04\n",
|
|
"[ NORMAL ] Iteration 97:\tk_eff = 1.159284\tres = 1.564E-04\n",
|
|
"[ NORMAL ] Iteration 98:\tk_eff = 1.159435\tres = 1.428E-04\n",
|
|
"[ NORMAL ] Iteration 99:\tk_eff = 1.159573\tres = 1.301E-04\n",
|
|
"[ NORMAL ] Iteration 100:\tk_eff = 1.159699\tres = 1.188E-04\n",
|
|
"[ NORMAL ] Iteration 101:\tk_eff = 1.159813\tres = 1.083E-04\n",
|
|
"[ NORMAL ] Iteration 102:\tk_eff = 1.159917\tres = 9.880E-05\n",
|
|
"[ NORMAL ] Iteration 103:\tk_eff = 1.160013\tres = 9.009E-05\n",
|
|
"[ NORMAL ] Iteration 104:\tk_eff = 1.160100\tres = 8.222E-05\n",
|
|
"[ NORMAL ] Iteration 105:\tk_eff = 1.160179\tres = 7.487E-05\n",
|
|
"[ NORMAL ] Iteration 106:\tk_eff = 1.160251\tres = 6.824E-05\n",
|
|
"[ NORMAL ] Iteration 107:\tk_eff = 1.160317\tres = 6.223E-05\n",
|
|
"[ NORMAL ] Iteration 108:\tk_eff = 1.160376\tres = 5.675E-05\n",
|
|
"[ NORMAL ] Iteration 109:\tk_eff = 1.160431\tres = 5.174E-05\n",
|
|
"[ NORMAL ] Iteration 110:\tk_eff = 1.160481\tres = 4.715E-05\n",
|
|
"[ NORMAL ] Iteration 111:\tk_eff = 1.160527\tres = 4.298E-05\n",
|
|
"[ NORMAL ] Iteration 112:\tk_eff = 1.160568\tres = 3.910E-05\n",
|
|
"[ NORMAL ] Iteration 113:\tk_eff = 1.160605\tres = 3.561E-05\n",
|
|
"[ NORMAL ] Iteration 114:\tk_eff = 1.160640\tres = 3.242E-05\n",
|
|
"[ NORMAL ] Iteration 115:\tk_eff = 1.160671\tres = 2.960E-05\n",
|
|
"[ NORMAL ] Iteration 116:\tk_eff = 1.160699\tres = 2.689E-05\n",
|
|
"[ NORMAL ] Iteration 117:\tk_eff = 1.160725\tres = 2.452E-05\n",
|
|
"[ NORMAL ] Iteration 118:\tk_eff = 1.160749\tres = 2.232E-05\n",
|
|
"[ NORMAL ] Iteration 119:\tk_eff = 1.160770\tres = 2.034E-05\n",
|
|
"[ NORMAL ] Iteration 120:\tk_eff = 1.160790\tres = 1.855E-05\n",
|
|
"[ NORMAL ] Iteration 121:\tk_eff = 1.160807\tres = 1.687E-05\n",
|
|
"[ NORMAL ] Iteration 122:\tk_eff = 1.160824\tres = 1.538E-05\n",
|
|
"[ NORMAL ] Iteration 123:\tk_eff = 1.160838\tres = 1.399E-05\n",
|
|
"[ NORMAL ] Iteration 124:\tk_eff = 1.160852\tres = 1.280E-05\n",
|
|
"[ NORMAL ] Iteration 125:\tk_eff = 1.160864\tres = 1.149E-05\n",
|
|
"[ NORMAL ] Iteration 126:\tk_eff = 1.160875\tres = 1.061E-05\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Generate tracks for OpenMOC\n",
|
|
"openmoc_geometry.initializeFlatSourceRegions()\n",
|
|
"track_generator = openmoc.TrackGenerator(openmoc_geometry, 128, 0.1)\n",
|
|
"track_generator.generateTracks()\n",
|
|
"\n",
|
|
"# Run OpenMOC\n",
|
|
"solver = openmoc.CPUSolver(track_generator)\n",
|
|
"solver.computeEigenvalue()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We report the eigenvalues computed by OpenMC and OpenMOC here together to summarize our results."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 28,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"openmc keff = 1.161200\n",
|
|
"openmoc keff = 1.160875\n",
|
|
"bias [pcm]: -32.5\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Print report of keff and bias with OpenMC\n",
|
|
"openmoc_keff = solver.getKeff()\n",
|
|
"openmc_keff = sp.k_combined[0]\n",
|
|
"bias = (openmoc_keff - openmc_keff) * 1e5\n",
|
|
"\n",
|
|
"print('openmc keff = {0:1.6f}'.format(openmc_keff))\n",
|
|
"print('openmoc keff = {0:1.6f}'.format(openmoc_keff))\n",
|
|
"print('bias [pcm]: {0:1.1f}'.format(bias))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Although there is a non-trivial bias, one can easily run the preceding code with more particle histories to show that both codes converge to the same eigenvalue with <10 pcm bias. It should be noted that this discrepancy is due to use of tracklength tallies for `NuFission`, while one must use more slowly converging analog tallies for `TransportXS`, `NuScatterMatrixXS` and `Chi` (which require an 'energyout' filter)."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Fuel Pin Cell"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"In this section we show how to compute multi-group cross sections for a fuel pin cell. In addition, we will illustrate how to use some of the more advanced features in `openmc.mgxs` such as nuclide-by-nuclide microscopic cross section tallies and downstream energy group condensation."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Generate Inputs"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"this time we separate our nuclides into three distinct materials for water, clad and fuel."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 29,
|
|
"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",
|
|
"\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 materials, we can now create a materials file object that can be exported to an actual XML file."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 30,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate a MaterialsFile, add Materials\n",
|
|
"materials_file = openmc.MaterialsFile()\n",
|
|
"materials_file.add_material(fuel)\n",
|
|
"materials_file.add_material(water)\n",
|
|
"materials_file.add_material(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. Our problem will have three regions for the fuel, the clad, and the surrounding coolant. The first step is to create the bounding surfaces -- in this case two cylinders and six reflective planes."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 31,
|
|
"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",
|
|
"# Use both reflective and vacuum boundaries to make life interesting\n",
|
|
"min_x = openmc.XPlane(x0=-0.63, boundary_type='reflective')\n",
|
|
"max_x = openmc.XPlane(x0=+0.63, boundary_type='reflective')\n",
|
|
"min_y = openmc.YPlane(y0=-0.63, boundary_type='reflective')\n",
|
|
"max_y = openmc.YPlane(y0=+0.63, boundary_type='reflective')\n",
|
|
"min_z = openmc.ZPlane(z0=-0.63, boundary_type='reflective')\n",
|
|
"max_z = openmc.ZPlane(z0=+0.63, boundary_type='reflective')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"With the surfaces defined, we can now create cells that are defined by intersections of half-spaces created by the surfaces."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 32,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Create a Universe to encapsulate a fuel pin\n",
|
|
"pin_cell_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.add_surface(fuel_outer_radius, halfspace=-1)\n",
|
|
"pin_cell_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.add_surface(fuel_outer_radius, halfspace=+1)\n",
|
|
"clad_cell.add_surface(clad_outer_radius, halfspace=-1)\n",
|
|
"pin_cell_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.add_surface(clad_outer_radius, halfspace=+1)\n",
|
|
"pin_cell_universe.add_cell(moderator_cell)"
|
|
]
|
|
},
|
|
{
|
|
"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": 33,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/universe.py:223: DeprecationWarning: Cell.add_surface(...) has been deprecated and may be removed in a future version. The region for a Cell should be defined using the region property directly.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Create root Cell\n",
|
|
"root_cell = openmc.Cell(name='root cell')\n",
|
|
"root_cell.fill = pin_cell_universe\n",
|
|
"\n",
|
|
"# Add boundary planes\n",
|
|
"root_cell.add_surface(min_x, halfspace=+1)\n",
|
|
"root_cell.add_surface(max_x, halfspace=-1)\n",
|
|
"root_cell.add_surface(min_y, halfspace=+1)\n",
|
|
"root_cell.add_surface(max_y, halfspace=-1)\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, put the geometry into a geometry file, and export it to XML."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 34,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Create Geometry and set root Universe\n",
|
|
"openmc_geometry = openmc.Geometry()\n",
|
|
"openmc_geometry.root_universe = root_universe\n",
|
|
"\n",
|
|
"# Instantiate a GeometryFile\n",
|
|
"geometry_file = openmc.GeometryFile()\n",
|
|
"geometry_file.geometry = openmc_geometry\n",
|
|
"\n",
|
|
"# Export to \"geometry.xml\"\n",
|
|
"geometry_file.export_to_xml()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We will reuse our settings from the previous simulation. Now, we let's create transport, nu-fission, nu-scatter and chi multi-group cross sections for each cell."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 35,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Extract all Cells filled by Materials\n",
|
|
"openmc_cells = openmc_geometry.get_all_material_cells()\n",
|
|
"\n",
|
|
"# Create dictionary to store multi-group cross sections for all cells\n",
|
|
"xs_library = {}\n",
|
|
"\n",
|
|
"# Instantiate 8-group cross sections for each cell\n",
|
|
"for cell in openmc_cells:\n",
|
|
" xs_library[cell.id] = {}\n",
|
|
" xs_library[cell.id]['transport'] = mgxs.TransportXS(groups=fine_groups)\n",
|
|
" xs_library[cell.id]['nu-fission'] = mgxs.NuFissionXS(groups=fine_groups)\n",
|
|
" xs_library[cell.id]['nu-scatter'] = mgxs.NuScatterMatrixXS(groups=fine_groups)\n",
|
|
" xs_library[cell.id]['chi'] = mgxs.Chi(groups=fine_groups)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"In this case, we did not give our cross sections a spatial domain in their constructors. Instead, we will loop over all cells to set each cross sections domain. In addition, we will set each cross section to tally cross sections on a per-nuclide basis through the use of the `by_nuclide` instance attribute. "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 36,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Instantiate an empty TalliesFile\n",
|
|
"tallies_file = openmc.TalliesFile()\n",
|
|
"\n",
|
|
"# Iterate over all cells and cross section types\n",
|
|
"for cell in openmc_cells:\n",
|
|
" for rxn_type in xs_library[cell.id].keys():\n",
|
|
"\n",
|
|
" # Set the cross sections domain type to the cell\n",
|
|
" xs_library[cell.id][rxn_type].domain = cell\n",
|
|
" xs_library[cell.id][rxn_type].domain_type = 'cell'\n",
|
|
" \n",
|
|
" # Tally cross sections by nuclide (e.g., micro cross sections)\n",
|
|
" xs_library[cell.id][rxn_type].by_nuclide = True\n",
|
|
" \n",
|
|
" # Create OpenMC tallies for this cross section\n",
|
|
" xs_library[cell.id][rxn_type].create_tallies()\n",
|
|
" \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",
|
|
"\n",
|
|
"# Export to \"tallies.xml\"\n",
|
|
"tallies_file.export_to_xml()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Now we a have a complete set of inputs, so we can go ahead and run our simulation."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 37,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"0"
|
|
]
|
|
},
|
|
"execution_count": 37,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# Delete old HDF5 files\n",
|
|
"!rm *.h5\n",
|
|
"\n",
|
|
"# Run OpenMC with the output throttled!\n",
|
|
"executor = openmc.Executor()\n",
|
|
"executor.run_simulation(output=False)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Tally Data Processing"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Our simulation ran successfully and created a statepoint file with all the tally data in it. As before, we begin our analysis here loading the statepoint file."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 38,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Load the last statepoint and summary files\n",
|
|
"sp = openmc.StatePoint('statepoint.50.h5')\n",
|
|
"su = openmc.Summary('summary.h5')\n",
|
|
"sp.link_with_summary(su)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"The statepoint is now ready to be analyzed by our multi-group cross sections. Next, we load the tallies from the statepoint into each object and to compute the cross sections using tally arithmetic."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 39,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Iterate over all cells and cross section types\n",
|
|
"for cell in openmc_cells:\n",
|
|
" for rxn_type in xs_library[cell.id].keys():\n",
|
|
" xs_library[cell.id][rxn_type].load_from_statepoint(sp)\n",
|
|
" xs_library[cell.id][rxn_type].compute_xs()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"That's it! Our multi-group cross sections are now ready for the big spotlight. This time we have cross sections in three distinct spatial zones - fuel, clad and moderator - on a per-nuclide basis."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Cross Section Data Visualization"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Let's first inspect one of our cross sections by printing it to the screen as a microscopic cross section in units of barns."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 40,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Multi-Group XS\n",
|
|
"\tReaction Type =\tnu-fission\n",
|
|
"\tDomain Type =\tcell\n",
|
|
"\tDomain ID =\t10000\n",
|
|
"\tNuclide =\tU-235\n",
|
|
"\tCross Sections [barns]:\n",
|
|
" Group 1 [0.821 - 20.0 MeV]:\t3.30e+00 +/- 5.91e-01%\n",
|
|
" Group 2 [0.00553 - 0.821 MeV]:\t3.97e+00 +/- 4.03e-01%\n",
|
|
" Group 3 [4e-06 - 0.00553 MeV]:\t5.48e+01 +/- 5.56e-01%\n",
|
|
" Group 4 [6.25e-07 - 4e-06 MeV]:\t8.84e+01 +/- 8.48e-01%\n",
|
|
" Group 5 [2.8e-07 - 6.25e-07 MeV]:\t2.89e+02 +/- 1.25e+00%\n",
|
|
" Group 6 [1.4e-07 - 2.8e-07 MeV]:\t4.49e+02 +/- 1.09e+00%\n",
|
|
" Group 7 [5.8e-08 - 1.4e-07 MeV]:\t6.87e+02 +/- 7.98e-01%\n",
|
|
" Group 8 [0.0 - 5.8e-08 MeV]:\t1.44e+03 +/- 5.73e-01%\n",
|
|
"\n",
|
|
"\tNuclide =\tU-238\n",
|
|
"\tCross Sections [barns]:\n",
|
|
" Group 1 [0.821 - 20.0 MeV]:\t1.06e+00 +/- 6.74e-01%\n",
|
|
" Group 2 [0.00553 - 0.821 MeV]:\t1.22e-03 +/- 8.28e-01%\n",
|
|
" Group 3 [4e-06 - 0.00553 MeV]:\t4.75e-04 +/- 7.97e+00%\n",
|
|
" Group 4 [6.25e-07 - 4e-06 MeV]:\t6.53e-06 +/- 7.56e-01%\n",
|
|
" Group 5 [2.8e-07 - 6.25e-07 MeV]:\t1.07e-05 +/- 1.22e+00%\n",
|
|
" Group 6 [1.4e-07 - 2.8e-07 MeV]:\t1.55e-05 +/- 1.09e+00%\n",
|
|
" Group 7 [5.8e-08 - 1.4e-07 MeV]:\t2.30e-05 +/- 7.97e-01%\n",
|
|
" Group 8 [0.0 - 5.8e-08 MeV]:\t4.25e-05 +/- 5.72e-01%\n",
|
|
"\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"nufission = xs_library[fuel_cell.id]['nu-fission']\n",
|
|
"nufission.print_xs(xs_type='micro', nuclides=['U-235', 'U-238'])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Our multi-group cross sections are capable of summing across all nuclides to provide us with macroscopic cross sections as well."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 41,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Multi-Group XS\n",
|
|
"\tReaction Type =\tnu-fission\n",
|
|
"\tDomain Type =\tcell\n",
|
|
"\tDomain ID =\t10000\n",
|
|
"\tCross Sections [cm^-1]:\n",
|
|
" Group 1 [0.821 - 20.0 MeV]:\t2.52e-02 +/- 6.42e-01%\n",
|
|
" Group 2 [0.00553 - 0.821 MeV]:\t1.52e-03 +/- 3.96e-01%\n",
|
|
" Group 3 [4e-06 - 0.00553 MeV]:\t2.06e-02 +/- 5.56e-01%\n",
|
|
" Group 4 [6.25e-07 - 4e-06 MeV]:\t3.32e-02 +/- 8.48e-01%\n",
|
|
" Group 5 [2.8e-07 - 6.25e-07 MeV]:\t1.09e-01 +/- 1.25e+00%\n",
|
|
" Group 6 [1.4e-07 - 2.8e-07 MeV]:\t1.69e-01 +/- 1.09e+00%\n",
|
|
" Group 7 [5.8e-08 - 1.4e-07 MeV]:\t2.58e-01 +/- 7.98e-01%\n",
|
|
" Group 8 [0.0 - 5.8e-08 MeV]:\t5.41e-01 +/- 5.73e-01%\n",
|
|
"\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"nufission = xs_library[fuel_cell.id]['nu-fission']\n",
|
|
"nufission.print_xs(xs_type='macro', nuclides='sum')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Although a printed report is nice, it is not scalable or flexible. Let's extract the cross section data for the moderator as a Pandas DataFrame."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 42,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
|
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|
" <thead>\n",
|
|
" <tr style=\"text-align: right;\">\n",
|
|
" <th></th>\n",
|
|
" <th>cell</th>\n",
|
|
" <th>group in</th>\n",
|
|
" <th>group out</th>\n",
|
|
" <th>nuclide</th>\n",
|
|
" <th>mean</th>\n",
|
|
" <th>std. dev.</th>\n",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" <tr>\n",
|
|
" <th>126</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>O-16</td>\n",
|
|
" <td>1.560098</td>\n",
|
|
" <td>0.017801</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>127</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>H-1</td>\n",
|
|
" <td>0.234877</td>\n",
|
|
" <td>0.010096</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>124</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>O-16</td>\n",
|
|
" <td>0.288236</td>\n",
|
|
" <td>0.004397</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>125</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>H-1</td>\n",
|
|
" <td>1.587815</td>\n",
|
|
" <td>0.007847</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>122</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>3</td>\n",
|
|
" <td>O-16</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>123</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>3</td>\n",
|
|
" <td>H-1</td>\n",
|
|
" <td>0.010122</td>\n",
|
|
" <td>0.000513</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>120</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>4</td>\n",
|
|
" <td>O-16</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>121</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>4</td>\n",
|
|
" <td>H-1</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>118</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>5</td>\n",
|
|
" <td>O-16</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>119</th>\n",
|
|
" <td>10002</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>5</td>\n",
|
|
" <td>H-1</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" <td>0.000000</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"text/plain": [
|
|
" cell group in group out nuclide mean std. dev.\n",
|
|
"126 10002 1 1 O-16 1.560098 0.017801\n",
|
|
"127 10002 1 1 H-1 0.234877 0.010096\n",
|
|
"124 10002 1 2 O-16 0.288236 0.004397\n",
|
|
"125 10002 1 2 H-1 1.587815 0.007847\n",
|
|
"122 10002 1 3 O-16 0.000000 0.000000\n",
|
|
"123 10002 1 3 H-1 0.010122 0.000513\n",
|
|
"120 10002 1 4 O-16 0.000000 0.000000\n",
|
|
"121 10002 1 4 H-1 0.000000 0.000000\n",
|
|
"118 10002 1 5 O-16 0.000000 0.000000\n",
|
|
"119 10002 1 5 H-1 0.000000 0.000000"
|
|
]
|
|
},
|
|
"execution_count": 42,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"nuscatter = xs_library[moderator_cell.id]['nu-scatter']\n",
|
|
"df = nuscatter.get_pandas_dataframe(xs_type='micro')\n",
|
|
"df.head(10)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We can easily use the Pandas DataFrame to extract the H-1 and O-16 scattering matrices separately."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 43,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Slice DataFrame in two for each nuclide's mean values\n",
|
|
"h1 = df[df['nuclide'] == 'H-1']['mean']\n",
|
|
"o16 = df[df['nuclide'] == 'O-16']['mean']\n",
|
|
"\n",
|
|
"# Cast DataFrames as NumPy arrays\n",
|
|
"h1 = h1.as_matrix()\n",
|
|
"o16 = o16.as_matrix()\n",
|
|
"\n",
|
|
"# Reshape arrays to 2D matrix for plotting\n",
|
|
"h1.shape = (fine_groups.num_groups, fine_groups.num_groups)\n",
|
|
"o16.shape = (fine_groups.num_groups, fine_groups.num_groups)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Matplotlib's `imshow` routine can be used to plot the matrices to illustrate their sparsity structures."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 44,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWYAAADDCAYAAACxgLv/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFxZJREFUeJzt3XmYVNWZx/FvAyIKCijGBRiaxA0VRVTcpROX4BLNzKhR\n46jEOMZldOIel9gkJsRM4q6joxFxJRHRcVc0NGpcEVAEdVzoCAooi7iAcaHmj/cUVV3Ucqrq3KrT\nze/zPPV01/bWuVXvfe+5596qAyIiIiIiIiIiIiIiIiIiIiIiIiIiNfHfwIX1bkQAHWU5JDl7Am/U\nuxEBdJTlaKMV2DvntuOAp4s8ZxvgMeAjYIXHaxwCTAeWuuc8CTSW18xVNAO35dzWAhxfZdykNGLv\n1dSc2/sAXwKzPeMcR/HPZnV3HDAD+ByYB1wH9CzxnMOBZ91zJuW5vzNwCfA+8An2GRaK2Q+4B8vz\nj11bji1nAfJoxHKnU9ZtxxF3HrRgbd425/Z73e17ecZZAXw7XLPK16n0QxKRcpdyfAmMw68Ib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R6ItWk6dupUNe89\n2JRlL2E/njWB6o5edwcWklnB2iPldWWqzW3ltYiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiHRs/w9e\ned7lsJ91IAAAAABJRU5ErkJggg==\n",
|
|
"text/plain": [
|
|
"<matplotlib.figure.Figure at 0x7f1072ec7dd0>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"# Create plot of the H-1 scattering matrix\n",
|
|
"fig = plt.subplot(121)\n",
|
|
"fig.imshow(h1, interpolation='nearest')\n",
|
|
"plt.title('H-1 Scattering Matrix')\n",
|
|
"\n",
|
|
"# Create plot of the O-16 scattering matrix\n",
|
|
"fig2 = plt.subplot(122)\n",
|
|
"fig2.imshow(o16, interpolation='nearest')\n",
|
|
"plt.title('O-16 Scattering Matrix')\n",
|
|
"\n",
|
|
"# Show the plot on screen\n",
|
|
"plt.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Next, we illustate how one can easily take multi-group cross sections and condense them down to a coarser energy group structure using. The `get_condensed_xs(...)` class method takes in as a parameter an `EnergyGroups` object with a coarse(r) group structure and returns a new multi-group cross section condensed to the coarse groups. We illustrate this process below using the 2-group structure created earlier."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 45,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Extract the 16-group transport cross section for the fuel\n",
|
|
"fine_xs = xs_library[fuel_cell.id]['transport']\n",
|
|
"\n",
|
|
"# Condense to the 2-group structure\n",
|
|
"condense_xs = fine_xs.get_condensed_xs(coarse_groups)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Group condensation is as simple as that! We now have a new coarse 2-group cross section in addition to our original 16-group cross section. Let's inspect the 2-group cross section by printing it to the screen and extracting a Pandas DataFrame as we have already learned how to do."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 46,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Multi-Group XS\n",
|
|
"\tReaction Type =\ttransport\n",
|
|
"\tDomain Type =\tcell\n",
|
|
"\tDomain ID =\t10000\n",
|
|
"\tNuclide =\tU-238\n",
|
|
"\tCross Sections [cm^-1]:\n",
|
|
" Group 1 [6.25e-07 - 20.0 MeV]:\t2.17e-01 +/- 4.04e-01%\n",
|
|
" Group 2 [0.0 - 6.25e-07 MeV]:\t2.53e-01 +/- 5.85e-01%\n",
|
|
"\n",
|
|
"\tNuclide =\tO-16\n",
|
|
"\tCross Sections [cm^-1]:\n",
|
|
" Group 1 [6.25e-07 - 20.0 MeV]:\t1.45e-01 +/- 4.10e-01%\n",
|
|
" Group 2 [0.0 - 6.25e-07 MeV]:\t1.75e-01 +/- 6.46e-01%\n",
|
|
"\n",
|
|
"\tNuclide =\tU-235\n",
|
|
"\tCross Sections [cm^-1]:\n",
|
|
" Group 1 [6.25e-07 - 20.0 MeV]:\t7.91e-03 +/- 1.22e+00%\n",
|
|
" Group 2 [0.0 - 6.25e-07 MeV]:\t1.82e-01 +/- 4.98e-01%\n",
|
|
"\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"condense_xs.print_xs()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 47,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
|
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|
" <thead>\n",
|
|
" <tr style=\"text-align: right;\">\n",
|
|
" <th></th>\n",
|
|
" <th>cell</th>\n",
|
|
" <th>group in</th>\n",
|
|
" <th>nuclide</th>\n",
|
|
" <th>mean</th>\n",
|
|
" <th>std. dev.</th>\n",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" <tr>\n",
|
|
" <th>3</th>\n",
|
|
" <td>10000</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>U-238</td>\n",
|
|
" <td>9.589323</td>\n",
|
|
" <td>0.038756</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>4</th>\n",
|
|
" <td>10000</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>O-16</td>\n",
|
|
" <td>3.159101</td>\n",
|
|
" <td>0.012939</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>5</th>\n",
|
|
" <td>10000</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>U-235</td>\n",
|
|
" <td>21.095256</td>\n",
|
|
" <td>0.257787</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>0</th>\n",
|
|
" <td>10000</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>U-238</td>\n",
|
|
" <td>11.178844</td>\n",
|
|
" <td>0.065428</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>1</th>\n",
|
|
" <td>10000</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>O-16</td>\n",
|
|
" <td>3.800027</td>\n",
|
|
" <td>0.024538</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>2</th>\n",
|
|
" <td>10000</td>\n",
|
|
" <td>2</td>\n",
|
|
" <td>U-235</td>\n",
|
|
" <td>485.513530</td>\n",
|
|
" <td>2.418761</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"text/plain": [
|
|
" cell group in nuclide mean std. dev.\n",
|
|
"3 10000 1 U-238 9.589323 0.038756\n",
|
|
"4 10000 1 O-16 3.159101 0.012939\n",
|
|
"5 10000 1 U-235 21.095256 0.257787\n",
|
|
"0 10000 2 U-238 11.178844 0.065428\n",
|
|
"1 10000 2 O-16 3.800027 0.024538\n",
|
|
"2 10000 2 U-235 485.513530 2.418761"
|
|
]
|
|
},
|
|
"execution_count": 47,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"df = condense_xs.get_pandas_dataframe(xs_type='micro')\n",
|
|
"df"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Verification with OpenMOC"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Finally, let's verify our cross sections using OpenMOC. First, we use OpenCG construct an equivalent OpenMOC geometry just as we did before."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 48,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Create an OpenCG Geometry from the OpenMC Geometry stored in the summary\n",
|
|
"su.make_opencg_geometry()\n",
|
|
"\n",
|
|
"# Create an OpenMOC Geometry from the OpenCG Geometry\n",
|
|
"openmoc_geometry = get_openmoc_geometry(su.opencg_geometry)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Likewise, we can inject the multi-group cross sections into the equivalent fuel pin cell OpenMOC geometry."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 49,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Get all OpenMOC cells in the gometry\n",
|
|
"openmoc_cells = openmoc_geometry.getRootUniverse().getAllCells()\n",
|
|
"\n",
|
|
"# Inject multi-group cross sections into OpenMOC Materials\n",
|
|
"# NOTE: This code will work for 1, 10, or 1,000s of cells\n",
|
|
"# as is the case for a complicated geometry like BEAVRS\n",
|
|
"for cell_id, cell in openmoc_cells.items():\n",
|
|
" \n",
|
|
" # Ignore the root cell\n",
|
|
" if cell.getName() == 'root cell':\n",
|
|
" continue\n",
|
|
" \n",
|
|
" # Get a reference to the Material filling this Cell\n",
|
|
" openmoc_material = cell.getFillMaterial()\n",
|
|
" \n",
|
|
" # Set the number of energy groups for the Material\n",
|
|
" openmoc_material.setNumEnergyGroups(fine_groups.num_groups)\n",
|
|
" \n",
|
|
" # Extract the appropriate cross section objects for this cell\n",
|
|
" transport = xs_library[cell_id]['transport']\n",
|
|
" nufission = xs_library[cell_id]['nu-fission']\n",
|
|
" nuscatter = xs_library[cell_id]['nu-scatter']\n",
|
|
" chi = xs_library[cell_id]['chi']\n",
|
|
" \n",
|
|
" # Inject NumPy arrays of cross section data into the Material\n",
|
|
" # NOTE: In each case we must sum across nuclides to get the\n",
|
|
" # macroscopic cross sections needed by OpenMOC\n",
|
|
" openmoc_material.setSigmaT(transport.get_xs(nuclides='sum').flatten())\n",
|
|
" openmoc_material.setNuSigmaF(nufission.get_xs(nuclides='sum').flatten())\n",
|
|
" openmoc_material.setSigmaS(nuscatter.get_xs(nuclides='sum').flatten())\n",
|
|
" openmoc_material.setChi(chi.get_xs(nuclides='sum').flatten())"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We are now ready to run OpenMOC to verify our cross-sections from OpenMC."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 50,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Throttle OpenMOC output to screen\n",
|
|
"openmoc.log.set_log_level('WARNING')\n",
|
|
"\n",
|
|
"# Generate tracks for OpenMOC\n",
|
|
"openmoc_geometry.initializeFlatSourceRegions()\n",
|
|
"track_generator = openmoc.TrackGenerator(openmoc_geometry, 128, 0.1)\n",
|
|
"track_generator.generateTracks()\n",
|
|
"\n",
|
|
"# Run OpenMOC\n",
|
|
"solver = openmoc.CPUSolver(track_generator)\n",
|
|
"solver.computeEigenvalue()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We report the eigenvalues computed by OpenMC and OpenMOC here together to summarize our results."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 51,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"openmc keff = 1.227616\n",
|
|
"openmoc keff = 1.225325\n",
|
|
"bias [pcm]: -229.1\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Print report of keff and bias with OpenMC\n",
|
|
"openmoc_keff = solver.getKeff()\n",
|
|
"openmc_keff = sp.k_combined[0]\n",
|
|
"bias = (openmoc_keff - openmc_keff) * 1e5\n",
|
|
"\n",
|
|
"print('openmc keff = {0:1.6f}'.format(openmc_keff))\n",
|
|
"print('openmoc keff = {0:1.6f}'.format(openmoc_keff))\n",
|
|
"print('bias [pcm]: {0:1.1f}'.format(bias))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"As a sanity check, let's run a simulation with the coarse 2-group cross sections to ensure that they produce a reasonable result."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 52,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n",
|
|
"/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:633: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"su.make_opencg_geometry()\n",
|
|
"openmoc_geometry = get_openmoc_geometry(su.opencg_geometry)\n",
|
|
"openmoc_cells = openmoc_geometry.getRootUniverse().getAllCells()\n",
|
|
"\n",
|
|
"# Inject multi-group cross sections into OpenMOC Materials\n",
|
|
"for cell_id, cell in openmoc_cells.items():\n",
|
|
" \n",
|
|
" # Ignore the root cell\n",
|
|
" if cell.getName() == 'root cell':\n",
|
|
" continue\n",
|
|
" \n",
|
|
" openmoc_material = cell.getFillMaterial()\n",
|
|
" openmoc_material.setNumEnergyGroups(coarse_groups.num_groups)\n",
|
|
" \n",
|
|
" # Extract the appropriate cross section objects for this cell\n",
|
|
" transport = xs_library[cell_id]['transport']\n",
|
|
" nufission = xs_library[cell_id]['nu-fission']\n",
|
|
" nuscatter = xs_library[cell_id]['nu-scatter']\n",
|
|
" chi = xs_library[cell_id]['chi']\n",
|
|
" \n",
|
|
" # Perform group condensation\n",
|
|
" transport = transport.get_condensed_xs(coarse_groups)\n",
|
|
" nufission = nufission.get_condensed_xs(coarse_groups)\n",
|
|
" nuscatter = nuscatter.get_condensed_xs(coarse_groups)\n",
|
|
" chi = chi.get_condensed_xs(coarse_groups)\n",
|
|
" \n",
|
|
" # Inject NumPy arrays of cross section data into the Material\n",
|
|
" openmoc_material.setSigmaT(transport.get_xs(nuclides='sum').flatten())\n",
|
|
" openmoc_material.setNuSigmaF(nufission.get_xs(nuclides='sum').flatten())\n",
|
|
" openmoc_material.setSigmaS(nuscatter.get_xs(nuclides='sum').flatten())\n",
|
|
" openmoc_material.setChi(chi.get_xs(nuclides='sum').flatten())"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 53,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Generate tracks for OpenMOC\n",
|
|
"openmoc_geometry.initializeFlatSourceRegions()\n",
|
|
"track_generator = openmoc.TrackGenerator(openmoc_geometry, 128, 0.1)\n",
|
|
"track_generator.generateTracks()\n",
|
|
"\n",
|
|
"# Run OpenMOC\n",
|
|
"solver = openmoc.CPUSolver(track_generator)\n",
|
|
"solver.computeEigenvalue()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 54,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"openmc keff = 1.227616\n",
|
|
"openmoc keff = 1.227096\n",
|
|
"bias [pcm]: -52.0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Print report of keff and bias with OpenMC\n",
|
|
"openmoc_keff = solver.getKeff()\n",
|
|
"openmc_keff = sp.k_combined[0]\n",
|
|
"bias = (openmoc_keff - openmc_keff) * 1e5\n",
|
|
"\n",
|
|
"print('openmc keff = {0:1.6f}'.format(openmc_keff))\n",
|
|
"print('openmoc keff = {0:1.6f}'.format(openmoc_keff))\n",
|
|
"print('bias [pcm]: {0:1.1f}'.format(bias))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"There is a non-trivial bias in both the 2-group and 8-group cases. In the case of the pin cell, one can show that these biases do not converge to <100 pcm with more particle histories. In the case of heterogeneous geometries, additional measures must be taken to address the following three sources of bias:\n",
|
|
"\n",
|
|
"* Appropriate transport-corrected cross sections\n",
|
|
"* Spatial discretization of OpenMOC's mesh\n",
|
|
"* Constant-in-angle multi-group cross sections"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 2",
|
|
"language": "python",
|
|
"name": "python2"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 2
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython2",
|
|
"version": "2.7.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0
|
|
}
|