{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Multigroup Cross Section Generation Part I: Introduction\n",
    "This IPython Notebook introduces the use of the `openmc.mgxs` module to calculate multi-group cross sections for an infinite homogeneous medium. In particular, this Notebook introduces the the following features:\n",
    "\n",
    "* **General equations** for scalar-flux averaged multi-group cross sections\n",
    "* Creation of multi-group cross sections for an **infinite homogeneous medium**\n",
    "* Use of **tally arithmetic** to manipulate multi-group cross sections"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Introduction to Multi-Group Cross Sections (MGXS)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Many Monte Carlo particle transport codes, including OpenMC, use continuous-energy nuclear cross section data. However, most deterministic neutron transport codes use *multi-group cross sections* defined over discretized energy bins or *energy groups*. An example of U-235's continuous-energy fission cross section along with a 16-group cross section computed for a light water reactor spectrum is displayed below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 72752 characters]",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 1,
     "metadata": {
      "image/png": {
       "width": 350
      }
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from IPython.display import Image\n",
    "Image(filename='images/mgxs.png', width=350)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A variety of tools employing different methodologies have been developed over the years to compute multi-group cross sections for certain applications, including NJOY (LANL), MC$^2$-3 (ANL), and Serpent (VTT). The `openmc.mgxs` Python module is designed to leverage OpenMC's tally system to calculate multi-group cross sections with arbitrary energy discretizations for fine-mesh heterogeneous deterministic neutron transport applications.\n",
    "\n",
    "Before proceeding to illustrate how one may use the `openmc.mgxs` module, it is worthwhile to define the general equations used to calculate multi-group cross sections. This is only intended as a brief overview of the methodology used by `openmc.mgxs` - we refer the interested reader to the large body of literature on the subject for a more comprehensive understanding of this complex topic."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Introductory Notation\n",
    "The continuous real-valued microscopic cross section may be denoted $\\sigma_{n,x}(\\mathbf{r}, E)$ for position vector $\\mathbf{r}$, energy $E$, nuclide $n$ and interaction type $x$. Similarly, the scalar neutron flux may be denoted by $\\Phi(\\mathbf{r},E)$ for position $\\mathbf{r}$ and energy $E$. **Note**: Although nuclear cross sections are dependent on the temperature $T$ of the interacting medium, the temperature variable is neglected here for brevity."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Spatial and Energy Discretization\n",
    "The energy domain for critical systems such as thermal reactors spans more than 10 orders of magnitude of neutron energies from 10$^{-5}$ - 10$^7$ eV. The multi-group approximation discretization divides this energy range into one or more energy groups. In particular, for $G$ total groups, we denote an energy group index $g$ such that $g \\in \\{1, 2, ..., G\\}$. The energy group indices are defined such that the smaller group the higher the energy, and vice versa. The integration over neutron energies across a discrete energy group is commonly referred to as **energy condensation**.\n",
    "\n",
    "Multi-group cross sections are computed for discretized spatial zones in the geometry of interest. The spatial zones may be defined on a structured and regular fuel assembly or pin cell mesh, an arbitrary unstructured mesh or the constructive solid geometry used by OpenMC. For a geometry with $K$ distinct spatial zones, we designate each spatial zone an index $k$ such that $k \\in \\{1, 2, ..., K\\}$. The volume of each spatial zone is denoted by $V_{k}$. The integration over discrete spatial zones is commonly referred to as **spatial homogenization**."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### General Scalar-Flux Weighted MGXS\n",
    "The multi-group cross sections computed by `openmc.mgxs` are defined as a *scalar flux-weighted average* of the microscopic cross sections across each discrete energy group. This formulation is employed in order to preserve the reaction rates within each energy group and spatial zone. In particular, spatial homogenization and energy condensation are used to compute the general multi-group cross section $\\sigma_{n,x,k,g}$ as follows:\n",
    "\n",
    "$$\\sigma_{n,x,k,g} = \\frac{\\int_{E_{g}}^{E_{g-1}}\\mathrm{d}E'\\int_{\\mathbf{r} \\in V_{k}}\\mathrm{d}\\mathbf{r}\\sigma_{n,x}(\\mathbf{r},E')\\Phi(\\mathbf{r},E')}{\\int_{E_{g}}^{E_{g-1}}\\mathrm{d}E'\\int_{\\mathbf{r} \\in V_{k}}\\mathrm{d}\\mathbf{r}\\Phi(\\mathbf{r},E')}$$\n",
    "\n",
    "This scalar flux-weighted average microscopic cross section is computed by `openmc.mgxs` for most multi-group cross sections, including total, absorption, and fission reaction types. These double integrals are stochastically computed with OpenMC's tally system - in particular, [filters](../usersguide/tallies.rst#filters) on the energy range and spatial zone (material, cell or universe) define the bounds of integration for both numerator and denominator."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Multi-Group Scattering Matrices\n",
    "The general multi-group cross section $\\sigma_{n,x,k,g}$ is a vector of $G$ values for each energy group $g$. The equation presented above only discretizes the energy of the incoming neutron and neglects the outgoing energy of the neutron (if any). Hence, this formulation must be extended to account for the outgoing energy of neutrons in the discretized scattering matrix cross section used by deterministic neutron transport codes. \n",
    "\n",
    "We denote the incoming and outgoing neutron energy groups as $g$ and $g'$ for the microscopic scattering matrix cross section $\\sigma_{n,s}(\\mathbf{r},E)$. As before, spatial homogenization and energy condensation are used to find the multi-group scattering matrix cross section $\\sigma_{n,s,k,g \\to g'}$ as follows:\n",
    "\n",
    "$$\\sigma_{n,s,k,g\\rightarrow g'} = \\frac{\\int_{E_{g'}}^{E_{g'-1}}\\mathrm{d}E''\\int_{E_{g}}^{E_{g-1}}\\mathrm{d}E'\\int_{\\mathbf{r} \\in V_{k}}\\mathrm{d}\\mathbf{r}\\sigma_{n,s}(\\mathbf{r},E'\\rightarrow E'')\\Phi(\\mathbf{r},E')}{\\int_{E_{g}}^{E_{g-1}}\\mathrm{d}E'\\int_{\\mathbf{r} \\in V_{k}}\\mathrm{d}\\mathbf{r}\\Phi(\\mathbf{r},E')}$$\n",
    "\n",
    "This scalar flux-weighted multi-group microscopic scattering matrix is computed using OpenMC tallies with both energy in and energy out filters."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Multi-Group Fission Spectrum\n",
    "The energy spectrum of neutrons emitted from fission is denoted by $\\chi_{n}(\\mathbf{r},E' \\rightarrow E'')$ for incoming and outgoing energies $E'$ and $E''$, respectively. Unlike the multi-group cross sections $\\sigma_{n,x,k,g}$ considered up to this point, the fission spectrum is a probability distribution and must sum to unity. The outgoing energy is typically much less dependent on the incoming energy for fission than for scattering interactions. As a result, it is common practice to integrate over the incoming neutron energy when computing the multi-group fission spectrum. The fission spectrum may be simplified as $\\chi_{n}(\\mathbf{r},E)$ with outgoing energy $E$.\n",
    "\n",
    "Unlike the multi-group cross sections defined up to this point, the multi-group fission spectrum is weighted by the fission production rate rather than the scalar flux. This formulation is intended to preserve the total fission production rate in the multi-group deterministic calculation. In order to mathematically define the multi-group fission spectrum, we denote the microscopic fission cross section as $\\sigma_{n,f}(\\mathbf{r},E)$ and the average number of neutrons emitted from fission interactions with nuclide $n$ as $\\nu_{n}(\\mathbf{r},E)$. The multi-group fission spectrum $\\chi_{n,k,g}$ is then the probability of fission neutrons emitted into energy group $g$. \n",
    "\n",
    "Similar to before, spatial homogenization and energy condensation are used to find the multi-group fission spectrum $\\chi_{n,k,g}$ as follows:\n",
    "\n",
    "$$\\chi_{n,k,g'} = \\frac{\\int_{E_{g'}}^{E_{g'-1}}\\mathrm{d}E''\\int_{0}^{\\infty}\\mathrm{d}E'\\int_{\\mathbf{r} \\in V_{k}}\\mathrm{d}\\mathbf{r}\\chi_{n}(\\mathbf{r},E'\\rightarrow E'')\\nu_{n}(\\mathbf{r},E')\\sigma_{n,f}(\\mathbf{r},E')\\Phi(\\mathbf{r},E')}{\\int_{0}^{\\infty}\\mathrm{d}E'\\int_{\\mathbf{r} \\in V_{k}}\\mathrm{d}\\mathbf{r}\\nu_{n}(\\mathbf{r},E')\\sigma_{n,f}(\\mathbf{r},E')\\Phi(\\mathbf{r},E')}$$\n",
    "\n",
    "The fission production-weighted multi-group fission spectrum is computed using OpenMC tallies with both energy in and energy out filters.\n",
    "\n",
    "This concludes our brief overview on the methodology to compute multi-group cross sections. The following sections detail more concretely how users may employ the `openmc.mgxs` module to power simulation workflows requiring multi-group cross sections for downstream deterministic calculations."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Generate Input Files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "import openmc\n",
    "import openmc.mgxs as mgxs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# create a model object to tie geometry, materials, settings, and tallies together\n",
    "model = openmc.Model()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We being by creating a material for the homogeneous medium."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "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` object that can be exported to an actual XML file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Instantiate a Materials collection and export to XML\n",
    "model.materials = openmc.Materials([inf_medium])"
   ]
  },
  {
   "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": 6,
   "metadata": {},
   "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": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Instantiate a Cell\n",
    "cell = openmc.Cell(cell_id=1, name='cell')\n",
    "\n",
    "# Register bounding Surfaces with the Cell\n",
    "cell.region = +min_x & -max_x & +min_y & -max_y\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": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create root universe\n",
    "root_universe = openmc.Universe(name='root universe', cells=[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": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create Geometry and set root Universe\n",
    "model.geometry = openmc.Geometry(root_universe)"
   ]
  },
  {
   "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": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# OpenMC simulation parameters\n",
    "batches = 50\n",
    "inactive = 10\n",
    "particles = 2500\n",
    "\n",
    "# Instantiate a Settings object\n",
    "settings = openmc.Settings()\n",
    "settings.batches = batches\n",
    "settings.inactive = inactive\n",
    "settings.particles = particles\n",
    "settings.output = {'tallies': True}\n",
    "\n",
    "# Create an initial uniform spatial source distribution over fissionable zones\n",
    "bounds = [-0.63, -0.63, -0.63, 0.63, 0.63, 0.63]\n",
    "uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)\n",
    "settings.source = openmc.IndependentSource(space=uniform_dist)\n",
    "\n",
    "model.settings = settings"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "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": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Instantiate a 2-group EnergyGroups object\n",
    "groups = mgxs.EnergyGroups()\n",
    "groups.group_edges = np.array([0., 0.625, 20.0e6])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can now use the `EnergyGroups` object, along with our previously created materials and geometry, to instantiate some `MGXS` objects from the `openmc.mgxs` module. In particular, the following are subclasses of the generic and abstract `MGXS` class:\n",
    "\n",
    "* `TotalXS`\n",
    "* `TransportXS`\n",
    "* `AbsorptionXS`\n",
    "* `CaptureXS`\n",
    "* `FissionXS`\n",
    "* `KappaFissionXS`\n",
    "* `ScatterXS`\n",
    "* `ScatterMatrixXS`\n",
    "* `Chi`\n",
    "* `ChiPrompt`\n",
    "* `InverseVelocity`\n",
    "* `PromptNuFissionXS`\n",
    "\n",
    "Of course, we are aware that the fission cross section (`FissionXS`) can sometimes be paired with the fission neutron multiplication to become $\\nu\\sigma_f$. This can be accomodated in to the `FissionXS` class by setting the `nu` parameter to `True` as shown below.\n",
    "\n",
    "Additionally, scattering reactions (like (n,2n)) can also be defined to take in to account the neutron multiplication to become $\\nu\\sigma_s$. This can be accomodated in the the transport (`TransportXS`), scattering (`ScatterXS`), and scattering-matrix (`ScatterMatrixXS`) cross sections types by setting the `nu` parameter to `True` as shown below.\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 total, absorption and scattering cross sections with our 2-group structure."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Instantiate a few different sections\n",
    "total = mgxs.TotalXS(domain=cell, energy_groups=groups)\n",
    "absorption = mgxs.AbsorptionXS(domain=cell, energy_groups=groups)\n",
    "scattering = mgxs.ScatterXS(domain=cell, energy_groups=groups)\n",
    "\n",
    "# Note that if we wanted to incorporate neutron multiplication in the\n",
    "# scattering cross section we would write the previous line as:\n",
    "# scattering = mgxs.ScatterXS(domain=cell, energy_groups=groups, nu=True)"
   ]
  },
  {
   "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 `Absorption` object as follows. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OrderedDict([('flux',\n",
       "              Tally\n",
       "              \tID             =\t1\n",
       "              \tName           =\t\n",
       "              \tFilters        =\tCellFilter, EnergyFilter\n",
       "              \tNuclides       =\ttotal\n",
       "              \tScores         =\t['flux']\n",
       "              \tEstimator      =\ttracklength),\n",
       "             ('absorption',\n",
       "              Tally\n",
       "              \tID             =\t2\n",
       "              \tName           =\t\n",
       "              \tFilters        =\tCellFilter, EnergyFilter\n",
       "              \tNuclides       =\ttotal\n",
       "              \tScores         =\t['absorption']\n",
       "              \tEstimator      =\ttracklength)])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "absorption.tallies"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `Absorption` object includes tracklength tallies for the 'absorption' and 'flux' scores in the 2-group structure in cell 1. Now that each `MGXS` object contains the tallies that it needs, we must add these tallies to a `Tallies` object to generate the \"tallies.xml\" input file for OpenMC."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Instantiate an empty Tallies object\n",
    "tallies = openmc.Tallies()\n",
    "\n",
    "# Add total tallies to the tallies file\n",
    "tallies += total.tallies.values()\n",
    "\n",
    "# Add absorption tallies to the tallies file\n",
    "tallies += absorption.tallies.values()\n",
    "\n",
    "# Add scattering tallies to the tallies file\n",
    "tallies += scattering.tallies.values()\n",
    "\n",
    "model.tallies = tallies"
   ]
  },
  {
   "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": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/data/home/jupyter-aparler/.conda/envs/nuclear/lib/python3.11/site-packages/openmc/mixin.py:70: IDWarning: Another Filter instance already exists with id=3.\n",
      "  warn(msg, IDWarning)\n",
      "/data/home/jupyter-aparler/.conda/envs/nuclear/lib/python3.11/site-packages/openmc/mixin.py:70: IDWarning: Another Filter instance already exists with id=4.\n",
      "  warn(msg, IDWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                %%%%%%%%%%%%%%%\n",
      "                           %%%%%%%%%%%%%%%%%%%%%%%%\n",
      "                        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",
      "                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",
      "                    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",
      "                   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",
      "                                    %%%%%%%%%%%%%%%%%%%%%%%%\n",
      "                                     %%%%%%%%%%%%%%%%%%%%%%%%\n",
      "                 ###############      %%%%%%%%%%%%%%%%%%%%%%%%\n",
      "                ##################     %%%%%%%%%%%%%%%%%%%%%%%\n",
      "                ###################     %%%%%%%%%%%%%%%%%%%%%%%\n",
      "                ####################     %%%%%%%%%%%%%%%%%%%%%%\n",
      "                #####################     %%%%%%%%%%%%%%%%%%%%%\n",
      "                ######################     %%%%%%%%%%%%%%%%%%%%\n",
      "                #######################     %%%%%%%%%%%%%%%%%%\n",
      "                 #######################     %%%%%%%%%%%%%%%%%\n",
      "                 ######################     %%%%%%%%%%%%%%%%%\n",
      "                  ####################     %%%%%%%%%%%%%%%%%\n",
      "                    #################     %%%%%%%%%%%%%%%%%\n",
      "                     ###############     %%%%%%%%%%%%%%%%\n",
      "                       ############     %%%%%%%%%%%%%%%\n",
      "                          ########     %%%%%%%%%%%%%%\n",
      "                                      %%%%%%%%%%%\n",
      "\n",
      "                 | The OpenMC Monte Carlo Code\n",
      "       Copyright | 2011-2023 MIT, UChicago Argonne LLC, and contributors\n",
      "         License | https://docs.openmc.org/en/latest/license.html\n",
      "         Version | 0.13.3\n",
      "        Git SHA1 | 50e39a4e20dc9e0f3d7ccf07333f6a5e6c797c8c\n",
      "       Date/Time | 2023-11-07 11:19:46\n",
      "  OpenMP Threads | 32\n",
      "\n",
      " Reading settings XML file...\n",
      " Reading cross sections XML file...\n",
      " Reading materials XML file...\n",
      " Reading geometry XML file...\n",
      " Reading H1 from /opt/xdata/endfb-vii.1-hdf5/neutron/H1.h5\n",
      " Reading O16 from /opt/xdata/endfb-vii.1-hdf5/neutron/O16.h5\n",
      " Reading U235 from /opt/xdata/endfb-vii.1-hdf5/neutron/U235.h5\n",
      " Reading U238 from /opt/xdata/endfb-vii.1-hdf5/neutron/U238.h5\n",
      " Reading Zr90 from /opt/xdata/endfb-vii.1-hdf5/neutron/Zr90.h5\n",
      " Minimum neutron data temperature: 294 K\n",
      " Maximum neutron data temperature: 294 K\n",
      " Reading tallies XML file...\n",
      " Preparing distributed cell instances...\n",
      " Reading plot XML file...\n",
      " Writing summary.h5 file...\n",
      " Maximum neutron transport energy: 20000000 eV for H1\n",
      " Initializing source particles...\n",
      "\n",
      " ====================>     K EIGENVALUE SIMULATION     <====================\n",
      "\n",
      "  Bat./Gen.      k            Average k\n",
      "  =========   ========   ====================\n",
      "        1/1    1.17150\n",
      "        2/1    1.15245\n",
      "        3/1    1.13200\n",
      "        4/1    1.12676\n",
      "        5/1    1.18447\n",
      "        6/1    1.13531\n",
      "        7/1    1.10874\n",
      "        8/1    1.15356\n",
      "        9/1    1.15175\n",
      "       10/1    1.18493\n",
      "       11/1    1.14031\n",
      "       12/1    1.13002    1.13516 +/- 0.00514\n",
      "       13/1    1.15465    1.14166 +/- 0.00714\n",
      "       14/1    1.14178    1.14169 +/- 0.00505\n",
      "       15/1    1.17987    1.14933 +/- 0.00858\n",
      "       16/1    1.13472    1.14689 +/- 0.00742\n",
      "       17/1    1.17411    1.15078 +/- 0.00738\n",
      "       18/1    1.16947    1.15312 +/- 0.00680\n",
      "       19/1    1.15485    1.15331 +/- 0.00600\n",
      "       20/1    1.15172    1.15315 +/- 0.00537\n",
      "       21/1    1.19138    1.15663 +/- 0.00597\n",
      "       22/1    1.19872    1.16013 +/- 0.00648\n",
      "       23/1    1.19084    1.16250 +/- 0.00641\n",
      "       24/1    1.13795    1.16074 +/- 0.00619\n",
      "       25/1    1.16798    1.16122 +/- 0.00578\n",
      "       26/1    1.15718    1.16097 +/- 0.00542\n",
      "       27/1    1.16126    1.16099 +/- 0.00509\n",
      "       28/1    1.18699    1.16243 +/- 0.00501\n",
      "       29/1    1.15404    1.16199 +/- 0.00476\n",
      "       30/1    1.17851    1.16282 +/- 0.00459\n",
      "       31/1    1.14133    1.16179 +/- 0.00448\n",
      "       32/1    1.13015    1.16036 +/- 0.00451\n",
      "       33/1    1.22717    1.16326 +/- 0.00520\n",
      "       34/1    1.22948    1.16602 +/- 0.00569\n",
      "       35/1    1.17805    1.16650 +/- 0.00548\n",
      "       36/1    1.11704    1.16460 +/- 0.00560\n",
      "       37/1    1.13863    1.16364 +/- 0.00547\n",
      "       38/1    1.21268    1.16539 +/- 0.00556\n",
      "       39/1    1.15605    1.16507 +/- 0.00537\n",
      "       40/1    1.18146    1.16561 +/- 0.00522\n",
      "       41/1    1.19373    1.16652 +/- 0.00513\n",
      "       42/1    1.12231    1.16514 +/- 0.00515\n",
      "       43/1    1.17583    1.16546 +/- 0.00500\n",
      "       44/1    1.13660    1.16461 +/- 0.00493\n",
      "       45/1    1.14348    1.16401 +/- 0.00482\n",
      "       46/1    1.18429    1.16457 +/- 0.00472\n",
      "       47/1    1.13033    1.16365 +/- 0.00468\n",
      "       48/1    1.17366    1.16391 +/- 0.00457\n",
      "       49/1    1.16592    1.16396 +/- 0.00445\n",
      "       50/1    1.14117    1.16339 +/- 0.00437\n",
      " Creating state point statepoint.50.h5...\n",
      "\n",
      " =======================>     TIMING STATISTICS     <=======================\n",
      "\n",
      " Total time for initialization     = 3.4052e-01 seconds\n",
      "   Reading cross sections          = 2.8779e-01 seconds\n",
      " Total time in simulation          = 7.4353e+00 seconds\n",
      "   Time in transport only          = 2.2516e+00 seconds\n",
      "   Time in inactive batches        = 3.1451e-01 seconds\n",
      "   Time in active batches          = 7.1208e+00 seconds\n",
      "   Time synchronizing fission bank = 1.6041e-02 seconds\n",
      "     Sampling source sites         = 1.1222e-02 seconds\n",
      "     SEND/RECV source sites        = 4.7934e-03 seconds\n",
      "   Time accumulating tallies       = 5.0984e+00 seconds\n",
      "   Time writing statepoints        = 1.6719e-02 seconds\n",
      " Total time for finalization       = 1.4286e-03 seconds\n",
      " Total time elapsed                = 7.8041e+00 seconds\n",
      " Calculation Rate (inactive)       = 79489.2 particles/second\n",
      " Calculation Rate (active)         = 14043.4 particles/second\n",
      "\n",
      " ============================>     RESULTS     <============================\n",
      "\n",
      " k-effective (Collision)     = 1.16469 +/- 0.00432\n",
      " k-effective (Track-length)  = 1.16339 +/- 0.00437\n",
      " k-effective (Absorption)    = 1.16069 +/- 0.00333\n",
      " Combined k-effective        = 1.16167 +/- 0.00303\n",
      " Leakage Fraction            = 0.00000 +/- 0.00000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Run OpenMC\n",
    "statepoint_filename = model.run()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Tally Data Processing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "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": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load the last statepoint file\n",
    "sp = openmc.StatePoint(statepoint_filename)"
   ]
  },
  {
   "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. By default, a `Summary` object is automatically linked when a `StatePoint` is loaded. This is necessary for the `openmc.mgxs` module to properly process the tally data."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The statepoint is now ready to be analyzed by our multi-group cross sections. We simply have to load the tallies from the `StatePoint` into each object as follows and our `MGXS` objects will compute the cross sections for us under-the-hood."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load the tallies from the statepoint into each MGXS object\n",
    "total.load_from_statepoint(sp)\n",
    "absorption.load_from_statepoint(sp)\n",
    "scattering.load_from_statepoint(sp)\n",
    "# Close the statepoint file now that we're done getting info\n",
    "sp.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Voila! Our multi-group cross sections are now ready to rock 'n roll!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Extracting and Storing MGXS Data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's first inspect our total cross section by printing it to the screen."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Multi-Group XS\n",
      "\tReaction Type  =\ttotal\n",
      "\tDomain Type    =\tcell\n",
      "\tDomain ID      =\t1\n",
      "\tCross Sections [cm^-1]:\n",
      "            Group 1 [0.625      - 20000000.0eV]:\t6.82e-01 +/- 2.28e-01%\n",
      "            Group 2 [0.0        - 0.625     eV]:\t1.40e+00 +/- 4.97e-01%\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "total.print_xs()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Since the `openmc.mgxs` module uses [tally arithmetic](../examples/tally-arithmetic.rst) under-the-hood, the cross section is stored as a \"derived\" `Tally` object. This means that it can be queried and manipulated using all of the same methods supported for the `Tally` class in the OpenMC Python API. For example, we can construct a [Pandas](https://pandas.pydata.org/) `DataFrame` of the multi-group cross section data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\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>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>total</td>\n",
       "      <td>0.668538</td>\n",
       "      <td>0.001531</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>total</td>\n",
       "      <td>1.291603</td>\n",
       "      <td>0.006380</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   cell  group in nuclide      mean  std. dev.\n",
       "1     1         1   total  0.668538   0.001531\n",
       "0     1         2   total  1.291603   0.006380"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = scattering.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": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "absorption.export_xs_data(filename='absorption-xs', format='excel')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following code snippet shows how to export all three `MGXS` to the same HDF5 binary data store."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "total.build_hdf5_store(filename='mgxs', append=True)\n",
    "absorption.build_hdf5_store(filename='mgxs', append=True)\n",
    "scattering.build_hdf5_store(filename='mgxs', append=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Comparing MGXS with Tally Arithmetic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finally, we illustrate how one can leverage OpenMC's [tally arithmetic](../examples/tally-arithmetic.rst) data processing feature with `MGXS` objects. The `openmc.mgxs` module uses tally arithmetic to compute multi-group cross sections with automated uncertainty propagation. Each `MGXS` object includes an `xs_tally` attribute which is a \"derived\" `Tally` based on the tallies needed to compute the cross section type of interest. These derived tallies can be used in subsequent tally arithmetic operations. For example, we can use tally artithmetic to confirm that the `TotalXS` is equal to the sum of the `AbsorptionXS` and `ScatterXS` objects."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cell</th>\n",
       "      <th>energy low [eV]</th>\n",
       "      <th>energy high [eV]</th>\n",
       "      <th>nuclide</th>\n",
       "      <th>score</th>\n",
       "      <th>mean</th>\n",
       "      <th>std. dev.</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0.000</td>\n",
       "      <td>6.250000e-01</td>\n",
       "      <td>total</td>\n",
       "      <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
       "      <td>2.220446e-16</td>\n",
       "      <td>0.009455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.625</td>\n",
       "      <td>2.000000e+07</td>\n",
       "      <td>total</td>\n",
       "      <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
       "      <td>-9.992007e-16</td>\n",
       "      <td>0.002183</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   cell  energy low [eV]  energy high [eV] nuclide  \\\n",
       "0     1         0.00e+00          6.25e-01   total   \n",
       "1     1         6.25e-01          2.00e+07   total   \n",
       "\n",
       "                                               score      mean  std. dev.  \n",
       "0  (((total / flux) - (absorption / flux)) - (sca...  2.22e-16   9.45e-03  \n",
       "1  (((total / flux) - (absorption / flux)) - (sca... -9.99e-16   2.18e-03  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Use tally arithmetic to compute the difference between the total, absorption and scattering\n",
    "difference = total.xs_tally - absorption.xs_tally - scattering.xs_tally\n",
    "\n",
    "# The difference is a derived tally which can generate Pandas DataFrames for inspection\n",
    "difference.get_pandas_dataframe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Similarly, we can use tally arithmetic to compute the ratio of `AbsorptionXS` and `ScatterXS` to the `TotalXS`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cell</th>\n",
       "      <th>energy low [eV]</th>\n",
       "      <th>energy high [eV]</th>\n",
       "      <th>nuclide</th>\n",
       "      <th>score</th>\n",
       "      <th>mean</th>\n",
       "      <th>std. dev.</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0.000</td>\n",
       "      <td>6.250000e-01</td>\n",
       "      <td>total</td>\n",
       "      <td>((absorption / flux) / (total / flux))</td>\n",
       "      <td>0.076044</td>\n",
       "      <td>0.000561</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.625</td>\n",
       "      <td>2.000000e+07</td>\n",
       "      <td>total</td>\n",
       "      <td>((absorption / flux) / (total / flux))</td>\n",
       "      <td>0.019368</td>\n",
       "      <td>0.000091</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   cell  energy low [eV]  energy high [eV] nuclide  \\\n",
       "0     1         0.00e+00          6.25e-01   total   \n",
       "1     1         6.25e-01          2.00e+07   total   \n",
       "\n",
       "                                    score     mean  std. dev.  \n",
       "0  ((absorption / flux) / (total / flux)) 7.60e-02   5.61e-04  \n",
       "1  ((absorption / flux) / (total / flux)) 1.94e-02   9.11e-05  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Use tally arithmetic to compute the absorption-to-total MGXS ratio\n",
    "absorption_to_total = absorption.xs_tally / total.xs_tally\n",
    "\n",
    "# The absorption-to-total ratio is a derived tally which can generate Pandas DataFrames for inspection\n",
    "absorption_to_total.get_pandas_dataframe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cell</th>\n",
       "      <th>energy low [eV]</th>\n",
       "      <th>energy high [eV]</th>\n",
       "      <th>nuclide</th>\n",
       "      <th>score</th>\n",
       "      <th>mean</th>\n",
       "      <th>std. dev.</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0.000</td>\n",
       "      <td>6.250000e-01</td>\n",
       "      <td>total</td>\n",
       "      <td>((scatter / flux) / (total / flux))</td>\n",
       "      <td>0.923956</td>\n",
       "      <td>0.006477</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.625</td>\n",
       "      <td>2.000000e+07</td>\n",
       "      <td>total</td>\n",
       "      <td>((scatter / flux) / (total / flux))</td>\n",
       "      <td>0.980632</td>\n",
       "      <td>0.003169</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   cell  energy low [eV]  energy high [eV] nuclide  \\\n",
       "0     1         0.00e+00          6.25e-01   total   \n",
       "1     1         6.25e-01          2.00e+07   total   \n",
       "\n",
       "                                 score     mean  std. dev.  \n",
       "0  ((scatter / flux) / (total / flux)) 9.24e-01   6.48e-03  \n",
       "1  ((scatter / flux) / (total / flux)) 9.81e-01   3.17e-03  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Use tally arithmetic to compute the scattering-to-total MGXS ratio\n",
    "scattering_to_total = scattering.xs_tally / total.xs_tally\n",
    "\n",
    "# The scattering-to-total ratio is a derived tally which can generate Pandas DataFrames for inspection\n",
    "scattering_to_total.get_pandas_dataframe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lastly, we sum the derived scatter-to-total and absorption-to-total ratios to confirm that they sum to unity."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cell</th>\n",
       "      <th>energy low [eV]</th>\n",
       "      <th>energy high [eV]</th>\n",
       "      <th>nuclide</th>\n",
       "      <th>score</th>\n",
       "      <th>mean</th>\n",
       "      <th>std. dev.</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0.000</td>\n",
       "      <td>6.250000e-01</td>\n",
       "      <td>total</td>\n",
       "      <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.006501</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.625</td>\n",
       "      <td>2.000000e+07</td>\n",
       "      <td>total</td>\n",
       "      <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.003171</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   cell  energy low [eV]  energy high [eV] nuclide  \\\n",
       "0     1         0.00e+00          6.25e-01   total   \n",
       "1     1         6.25e-01          2.00e+07   total   \n",
       "\n",
       "                                               score     mean  std. dev.  \n",
       "0  (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00   6.50e-03  \n",
       "1  (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00   3.17e-03  "
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Use tally arithmetic to ensure that the absorption- and scattering-to-total MGXS ratios sum to unity\n",
    "sum_ratio = absorption_to_total + scattering_to_total\n",
    "\n",
    "# The sum ratio is a derived tally which can generate Pandas DataFrames for inspection\n",
    "sum_ratio.get_pandas_dataframe()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
