{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "s8q2_PI6vJDd",
    "outputId": "b4a99b1c-90b1-4484-bb73-ed358a0d9b2b"
   },
   "source": [
    "# A VHTR geometry \n",
    "This notebook can be used as a template for modeling VHTR reactors."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "id": "ztdDaVCavN_I"
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import openmc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "Ran-jogzvQvC",
    "outputId": "422e9494-2575-4625-c4c1-20a55a442142"
   },
   "outputs": [],
   "source": [
    "# Materials definitions\n",
    "\n",
    "fuel = openmc.Material(name='Fuel')\n",
    "fuel.add_element('U', 1.0, enrichment=4.0)\n",
    "fuel.add_nuclide('O16', 2.0)\n",
    "fuel.set_density('g/cm3', 10.41)\n",
    "\n",
    "buffer = openmc.Material(name='Buffer')\n",
    "buffer.add_element('C', 1.0)\n",
    "buffer.set_density('g/cm3', 0.95)\n",
    "buffer.add_s_alpha_beta('c_Graphite')\n",
    "\n",
    "IPyC = openmc.Material(name='Inner PyC')\n",
    "IPyC.add_element('C', 1.0)\n",
    "IPyC.set_density('g/cm3', 1.9)\n",
    "IPyC.add_s_alpha_beta('c_Graphite')\n",
    "\n",
    "SiC = openmc.Material(name = \"SiC\")\n",
    "SiC.add_element(\"Si\", 0.5)\n",
    "SiC.add_element(\"C\", 0.5)\n",
    "SiC.set_density(\"g/cm3\", 3.18)\n",
    "\n",
    "OPyC = openmc.Material(name='Outer PyC')\n",
    "OPyC.add_element('C', 1.0)\n",
    "OPyC.set_density('g/cm3', 1.9)\n",
    "OPyC.add_s_alpha_beta('c_Graphite')\n",
    "\n",
    "graphite = openmc.Material(name='Graphite')\n",
    "graphite.add_element('C', 1.0)\n",
    "graphite.set_density('g/cm3', 1.7)\n",
    "graphite.add_s_alpha_beta('c_Graphite')\n",
    "\n",
    "helium = openmc.Material(name='Helium')\n",
    "helium.add_element('He', 1.0)\n",
    "helium.set_density('g/cm3', 0.000166)\n",
    "\n",
    "b4c = openmc.Material(name='B4C Poison')\n",
    "b4c.add_element('B', 4.0, enrichment=18.7, enrichment_target='B10', enrichment_type='wo')\n",
    "b4c.add_element('C', 1.0)\n",
    "b4c.set_density('g/cm3', 1.82)\n",
    "\n",
    "# Instantiate a Materials collection and export to xml\n",
    "materials_list = [fuel, buffer, IPyC, SiC, OPyC, graphite, helium, b4c]\n",
    "materials_file = openmc.Materials(materials_list)\n",
    "materials_file.export_to_xml()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 282
    },
    "id": "OU_alkFfwVGd",
    "outputId": "7c06ff69-2077-456e-b860-9b385465151f"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f5702afba10>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 12864 characters]",
      "text/plain": [
       "<Figure size 258.065x259.74 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Geometry definitions for TRISO particles\n",
    "\n",
    "kernelsph = openmc.Sphere(r=250e-4)\n",
    "buffsph = openmc.Sphere(r=350e-4)\n",
    "IPyCsph = openmc.Sphere(r=390e-4)\n",
    "SiCsph = openmc.Sphere(r=425e-4)\n",
    "OPyCsph = openmc.Sphere(r=470e-4)\n",
    "\n",
    "layers = [kernelsph, buffsph, IPyCsph, SiCsph, OPyCsph]\n",
    "triso_mats = [fuel, buffer, IPyC, SiC, OPyC]\n",
    "triso_cells = []\n",
    "for i in range(5):\n",
    "  if (i == 0):\n",
    "    triso_cells.append(openmc.Cell(fill=triso_mats[0], region=-layers[0]))\n",
    "  else:\n",
    "    triso_cells.append(openmc.Cell(fill=triso_mats[i], region=+layers[i-1] & -layers[i]))\n",
    "\n",
    "triso_universe = openmc.Universe(cells=triso_cells)\n",
    "triso_colors = {triso_cells[0]: (199, 51, 51), triso_cells[1]: (176, 227, 74),\n",
    "                triso_cells[2]: (74, 186, 120), triso_cells[3]: (31, 74, 107),\n",
    "                triso_cells[4]: (74, 186, 120)}\n",
    "triso_universe.plot(width = (0.1, 0.1), colors = triso_colors)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "iRZUbB1uqld6",
    "outputId": "371a1ccc-3603-447a-8721-2c0090b2448c"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[Cell\n",
      "\tID             =\t1\n",
      "\tName           =\t\n",
      "\tFill           =\tMaterial 1\n",
      "\tRegion         =\t-1\n",
      "\tRotation       =\tNone\n",
      "\tTemperature    =\tNone\n",
      "\tTranslation    =\tNone\n",
      "\tVolume         =\tNone\n",
      ", Cell\n",
      "\tID             =\t2\n",
      "\tName           =\t\n",
      "\tFill           =\tMaterial 2\n",
      "\tRegion         =\t(1 -2)\n",
      "\tRotation       =\tNone\n",
      "\tTemperature    =\tNone\n",
      "\tTranslation    =\tNone\n",
      "\tVolume         =\tNone\n",
      ", Cell\n",
      "\tID             =\t3\n",
      "\tName           =\t\n",
      "\tFill           =\tMaterial 3\n",
      "\tRegion         =\t(2 -3)\n",
      "\tRotation       =\tNone\n",
      "\tTemperature    =\tNone\n",
      "\tTranslation    =\tNone\n",
      "\tVolume         =\tNone\n",
      ", Cell\n",
      "\tID             =\t4\n",
      "\tName           =\t\n",
      "\tFill           =\tMaterial 4\n",
      "\tRegion         =\t(3 -4)\n",
      "\tRotation       =\tNone\n",
      "\tTemperature    =\tNone\n",
      "\tTranslation    =\tNone\n",
      "\tVolume         =\tNone\n",
      ", Cell\n",
      "\tID             =\t5\n",
      "\tName           =\t\n",
      "\tFill           =\tMaterial 5\n",
      "\tRegion         =\t(4 -5)\n",
      "\tRotation       =\tNone\n",
      "\tTemperature    =\tNone\n",
      "\tTranslation    =\tNone\n",
      "\tVolume         =\tNone\n",
      "]\n"
     ]
    }
   ],
   "source": [
    "print(triso_cells)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "id": "9ZjOD3umK-RO"
   },
   "outputs": [],
   "source": [
    "# Generating TRISO particle lattice in cylindrical pin cell\n",
    "\n",
    "cylsurf = openmc.ZCylinder(r=0.6225)\n",
    "maxz = openmc.ZPlane(z0=1.95, boundary_type='reflective')\n",
    "minz = openmc.ZPlane(z0=-1.95, boundary_type='reflective')\n",
    "\n",
    "lattice_region = -cylsurf & -maxz & +minz\n",
    "triso_outer_radius = 465e-4\n",
    "spheres = openmc.model.pack_spheres(radius=triso_outer_radius, region=lattice_region, pf=0.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "id": "u7tWPGkaQaPP"
   },
   "outputs": [],
   "source": [
    "triso_particles = [openmc.model.TRISO(triso_outer_radius, fill=triso_universe, center=c) for c in spheres]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "OIyhbji9Rvzr",
    "outputId": "4f4e84a2-0b07-4318-c1b6-1b1f55a1a232"
   },
   "outputs": [],
   "source": [
    "vol_triso = 4/3 * 3.14 * triso_outer_radius**3 * len(triso_particles)\n",
    "actual_pf = vol_triso/(3.14 * (0.6225) ** 2 * 3.9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "id": "2Z8EXBSgR_yq"
   },
   "outputs": [],
   "source": [
    "lattice_cell = openmc.Cell(region=lattice_region)\n",
    "lower_left, upp_right = lattice_cell.region.bounding_box\n",
    "shape = (4, 4, 4)\n",
    "pitch = (upp_right - lower_left)/shape\n",
    "triso_latt = openmc.model.create_triso_lattice(triso_particles, lower_left, pitch, shape, graphite)\n",
    "lattice_cell.fill = triso_latt\n",
    "\n",
    "lattice_universe = openmc.Universe(cells=[lattice_cell])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 282
    },
    "id": "8S3JIn-x9doF",
    "outputId": "da1312f4-92c6-4100-97a2-66af845295f7"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f56f8ad9a90>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 25212 characters]",
      "text/plain": [
       "<Figure size 258.065x259.74 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "lattice_universe.plot(width=(1.4,1.4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 282
    },
    "id": "yTqFsu7U9Pmf",
    "outputId": "ebd66100-aa13-452b-912a-a1fed9e964f5"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f56f91a37d0>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 21460 characters]",
      "text/plain": [
       "<Figure size 258.065x259.74 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "lattice_universe.plot(width=(1.4,1.4), color_by='material', colors = {graphite: (20, 23, 66)})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "j3_6A6g-L_d4"
   },
   "source": [
    "**Testing Pin Cell Embedded In Graphite Block**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "id": "t80buCTqL-84"
   },
   "outputs": [],
   "source": [
    "hexaregion = openmc.model.hexagonal_prism(edge_length = 0.85, orientation = 'x', boundary_type='reflective')\n",
    "\n",
    "outer_region = hexaregion & +cylsurf & -maxz & +minz\n",
    "outer_pin_cell = openmc.Cell(fill=graphite, region = outer_region)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "id": "ho_e-y7Cgi_q"
   },
   "outputs": [],
   "source": [
    "pin_cell_universe = openmc.Universe(cells=[lattice_cell, outer_pin_cell])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 282
    },
    "id": "76wi7ezZgoHj",
    "outputId": "55590ede-ff67-4a78-96d2-87d902b2c366"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f56f81d46d0>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 21028 characters]",
      "text/plain": [
       "<Figure size 258.065x259.74 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pin_cell_universe.plot(width=(1.8, 1.8), color_by='cell', colors = {outer_pin_cell: (20, 23, 66)})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "jJasUqJAhn_e"
   },
   "source": [
    "As expected, the outside hexagonal block and the non-triso area of the pin cell are both filled with graphite:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 282
    },
    "id": "SnF1LEnihncs",
    "outputId": "f9671980-db4b-4ce0-99a4-867aa59fe5d9"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f56f716aa10>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 16072 characters]",
      "text/plain": [
       "<Figure size 258.065x259.74 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pin_cell_universe.plot(width=(1.9, 1.9), color_by='material', colors = {graphite: (20, 23, 66), fuel: (255, 219, 145)})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "Mp8W0NWEhzhZ",
    "outputId": "2204e776-fed4-4007-a05d-cba6acb11789"
   },
   "outputs": [],
   "source": [
    "geom = openmc.Geometry(pin_cell_universe)\n",
    "geom.export_to_xml()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "OKwVl93-GboP"
   },
   "source": [
    "**Creating Coolant Channels/Cells (Helium fill)**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "id": "lLnEBbE3aJqa"
   },
   "outputs": [],
   "source": [
    "small_coolant_surf = openmc.ZCylinder(r=0.6375)\n",
    "big_coolant_surf = openmc.ZCylinder(r=0.79375)\n",
    "\n",
    "small_coolant_cell = openmc.Cell(region=-small_coolant_surf & -maxz & +minz, fill=helium)\n",
    "big_coolant_cell = openmc.Cell(region=-big_coolant_surf & -maxz & +minz, fill=helium)\n",
    "\n",
    "outside_small_cell = openmc.Cell(region=+small_coolant_surf & -maxz & +minz, fill=graphite)\n",
    "outside_big_cell = openmc.Cell(region=+big_coolant_surf & -maxz & +minz, fill=graphite)\n",
    "\n",
    "small_coolant_universe = openmc.Universe(cells=[small_coolant_cell, outside_small_cell])\n",
    "big_coolant_universe = openmc.Universe(cells=[big_coolant_cell, outside_big_cell])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "2wVWLYBZAJdL"
   },
   "source": [
    "**Burnable Poison Rod Geometry**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 286
    },
    "id": "aJnsdDgr7KeF",
    "outputId": "f73b7161-dd64-49db-cd48-cde093cb4af9"
   },
   "outputs": [],
   "source": [
    "poison_surf = openmc.ZCylinder(r=0.6375)\n",
    "poison_cell = openmc.Cell(region=-poison_surf & -maxz & +minz, fill=b4c)\n",
    "outside_poison_cell = openmc.Cell(region=+poison_surf & -maxz & +minz, fill=graphite)\n",
    "\n",
    "poison_universe = openmc.Universe(cells=[poison_cell, outside_poison_cell])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "FSEppy7-wB1-"
   },
   "source": [
    "**Defining Material Outside Pin Cell For Use in Assemblies**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "id": "ijZDqnyY7Y2f"
   },
   "outputs": [],
   "source": [
    "outer_pin_region = +cylsurf & -maxz & +minz\n",
    "outer_pin_cell = openmc.Cell(fill=graphite, region=outer_pin_region)\n",
    "\n",
    "total_pin_cell_universe = openmc.Universe(cells=[lattice_cell, outer_pin_cell])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 282
    },
    "id": "s-DGB0Nf8guO",
    "outputId": "355536e5-e765-4900-9c97-e2ed00503f8f"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f56f716b7d0>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 15188 characters]",
      "text/plain": [
       "<Figure size 258.065x259.74 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "total_pin_cell_universe.plot(width=(1.9, 1.9), color_by='material', colors = {graphite: (20, 23, 66)})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "LfIatUoiIeSa"
   },
   "source": [
    "**Constructing Geometry of Hexagonal Fuel Assembly**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "id": "gxixGDvIIXnH"
   },
   "outputs": [],
   "source": [
    "outer_graphite_cell = openmc.Cell(fill=graphite)\n",
    "outer_graphite_universe = openmc.Universe(cells=[outer_graphite_cell])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "id": "0lt1V5rQJFlY"
   },
   "outputs": [],
   "source": [
    "assemblylat = openmc.HexLattice(name=\"Assembly\")\n",
    "assemblylat.outer = outer_graphite_universe\n",
    "assemblylat.pitch = (1.9,)\n",
    "assemblylat.center = (0.0, 0.0)\n",
    "assemblylat.orientation = 'x'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "id": "6NyajaT_Dhdf"
   },
   "outputs": [],
   "source": [
    "def repeat_lat_element(n, pad_left, pad_right):\n",
    "  ring = []\n",
    "  for i in range(6):\n",
    "    ring += pad_left\n",
    "    for i in range(n):\n",
    "      ring.extend([total_pin_cell_universe]*2 + [big_coolant_universe])\n",
    "    ring += pad_right\n",
    "\n",
    "  return ring"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "id": "eMfy_09gPIjE"
   },
   "outputs": [],
   "source": [
    "def build_outer_ring(n, insert_poison_rod):\n",
    "  REPEAT_SECTION = 2\n",
    "  ring = []\n",
    "\n",
    "  # burnable poison rods sides\n",
    "  poisonring = []\n",
    "  poisonring += [insert_poison_rod] + [total_pin_cell_universe] + [big_coolant_universe]\n",
    "  for i in range(REPEAT_SECTION):\n",
    "      poisonring.extend([total_pin_cell_universe]*2 + [big_coolant_universe])\n",
    "  poisonring += [total_pin_cell_universe]\n",
    "\n",
    "  # normal sides\n",
    "  base = []\n",
    "  base += [outer_graphite_universe] + [total_pin_cell_universe] + [big_coolant_universe]\n",
    "  for i in range(REPEAT_SECTION):\n",
    "      base.extend([total_pin_cell_universe]*2 + [big_coolant_universe])\n",
    "  base += [total_pin_cell_universe]\n",
    "\n",
    "  ring.extend(poisonring * n + base * (6 - n))\n",
    "\n",
    "  return ring"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "id": "vygU8F5vLG2x"
   },
   "outputs": [],
   "source": [
    "def build_all_rings(insert_poison_rod):\n",
    "  rings = []\n",
    "\n",
    "  outer_ring = build_outer_ring(2, insert_poison_rod)\n",
    "  rings.append(outer_ring)\n",
    "\n",
    "  for i in range(1, 8): # rings 1 through 7\n",
    "    ring_left = []\n",
    "    ring_right = []\n",
    "    if (i % 3 == 1):\n",
    "      ring_left = [big_coolant_universe]\n",
    "      ring_right = [total_pin_cell_universe]*2\n",
    "    elif (i % 3 == 2):\n",
    "      ring_left = [total_pin_cell_universe] + [big_coolant_universe]\n",
    "    else:\n",
    "      ring_right = [total_pin_cell_universe]\n",
    "\n",
    "    n = 0\n",
    "    if (i <= 3):\n",
    "      n = 2\n",
    "    elif (i <= 6):\n",
    "      n = 1\n",
    "    else:\n",
    "      n = 0\n",
    "\n",
    "    cur_ring = repeat_lat_element(n, ring_left, ring_right)\n",
    "    rings.append(cur_ring)\n",
    "\n",
    "  inner_ring = []\n",
    "  for i in range(6):\n",
    "    inner_ring.extend([total_pin_cell_universe] + [small_coolant_universe])\n",
    "  rings.append(inner_ring)\n",
    "  rings.append([outer_graphite_universe]*6)\n",
    "  rings.append([outer_graphite_universe])\n",
    "\n",
    "  return rings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "id": "KAqeuKY2j19E"
   },
   "outputs": [],
   "source": [
    "rings = build_all_rings(poison_universe)\n",
    "assemblylat.universes = rings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "id": "LZWflaDwla6d"
   },
   "outputs": [],
   "source": [
    "assembly_surf = openmc.model.hexagonal_prism(edge_length=21, orientation='x', boundary_type='reflective')\n",
    "assembly_cell = openmc.Cell(fill=assemblylat, region=assembly_surf & +minz & -maxz)\n",
    "assembly_universe = openmc.Universe(cells=[assembly_cell])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 282
    },
    "id": "iMr7NMMTs6kT",
    "outputId": "a1ece088-efa8-4cc1-da2a-258fbe0ac6d6"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f56f8001510>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 22288 characters]",
      "text/plain": [
       "<Figure size 258.065x259.74 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "assembly_universe.plot(width=(42, 42), color_by='material', colors={helium: (252, 0, 69), graphite: (20, 23, 66), b4c:  (1, 217, 26)})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "pIFgdKfmyY7b",
    "outputId": "b3e9bf24-0450-47ad-9430-023413ec58f6"
   },
   "outputs": [],
   "source": [
    "geom = openmc.Geometry(assembly_universe)\n",
    "geom.export_to_xml()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "id": "RUFinDv9-4AH"
   },
   "outputs": [],
   "source": [
    "# OpenMC simulation parameters\n",
    "\n",
    "batches = 100\n",
    "inactive = 10\n",
    "particles = 5000\n",
    "\n",
    "settings_file = openmc.Settings()\n",
    "settings_file.batches = batches\n",
    "settings_file.inactive = inactive\n",
    "settings_file.particles = particles\n",
    "settings_file.output = {'tallies': True}\n",
    "\n",
    "bounds = [-5, -5, -0.63, 5, 5, 0.63]\n",
    "uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)\n",
    "settings_file.source = openmc.IndependentSource(space=uniform_dist)\n",
    "\n",
    "settings_file.export_to_xml()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "name": "VHTR.ipynb",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "openmc-env",
   "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
