Remove Jupyter notebooks from documentation
|
|
@ -1,475 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Using the C/C++ API\n",
|
||||
"This notebook shows how to use the OpenMC C/C++ API through the openmc.lib module. This module is particularly useful for multiphysics coupling because it allows you to update the density of materials and the temperatures of cells in memory, without stopping the simulation.\n",
|
||||
"\n",
|
||||
"Warning: these bindings are still somewhat experimental and may be subject to change in future versions of OpenMC."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%matplotlib inline\n",
|
||||
"import openmc\n",
|
||||
"import openmc.lib"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<b>Generate Input Files</b>\n",
|
||||
"\n",
|
||||
"Let's start by creating a fuel rod geometry. We will make 10 zones in the z-direction which will allow us to make changes to each zone. Changes in temperature have to be made on the cell, so will make 10 cells in the axial direction. Changes in density have to be made on the material, so we will make 10 water materials. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Materials: we will make a fuel, helium, zircaloy, and 10 water materials. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"material_list = []"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"uo2 = openmc.Material(material_id=1, name='UO2 fuel at 2.4% wt enrichment')\n",
|
||||
"uo2.set_density('g/cm3', 10.29769)\n",
|
||||
"uo2.add_element('U', 1., enrichment=2.4)\n",
|
||||
"uo2.add_element('O', 2.)\n",
|
||||
"material_list.append(uo2)\n",
|
||||
"\n",
|
||||
"helium = openmc.Material(material_id=2, name='Helium for gap')\n",
|
||||
"helium.set_density('g/cm3', 0.001598)\n",
|
||||
"helium.add_element('He', 2.4044e-4)\n",
|
||||
"material_list.append(helium)\n",
|
||||
"\n",
|
||||
"zircaloy = openmc.Material(material_id=3, name='Zircaloy 4')\n",
|
||||
"zircaloy.set_density('g/cm3', 6.55)\n",
|
||||
"zircaloy.add_element('Sn', 0.014, 'wo')\n",
|
||||
"zircaloy.add_element('Fe', 0.00165, 'wo')\n",
|
||||
"zircaloy.add_element('Cr', 0.001, 'wo')\n",
|
||||
"zircaloy.add_element('Zr', 0.98335, 'wo')\n",
|
||||
"material_list.append(zircaloy)\n",
|
||||
"\n",
|
||||
"for i in range(4, 14):\n",
|
||||
" water = openmc.Material(material_id=i)\n",
|
||||
" water.set_density('g/cm3', 0.7)\n",
|
||||
" water.add_element('H', 2.0)\n",
|
||||
" water.add_element('O', 1.0)\n",
|
||||
" water.add_s_alpha_beta('c_H_in_H2O')\n",
|
||||
" material_list.append(water)\n",
|
||||
" \n",
|
||||
"materials_file = openmc.Materials(material_list)\n",
|
||||
"materials_file.export_to_xml()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Cells: we will make a fuel cylinder, a gap cylinder, a cladding cylinder, and a water exterior. Each one will be broken into 10 cells which are the 10 axial zones. The z_list is the list of axial positions that delimit those 10 zones. To keep track of all the cells, we will create lists: fuel_list, gap_list, clad_list, and water_list. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pitch = 1.25984\n",
|
||||
"fuel_or = openmc.ZCylinder(r=0.39218)\n",
|
||||
"clad_ir = openmc.ZCylinder(r=0.40005)\n",
|
||||
"clad_or = openmc.ZCylinder(r=0.4572)\n",
|
||||
"left = openmc.XPlane(x0=-pitch/2)\n",
|
||||
"right = openmc.XPlane(x0=pitch/2)\n",
|
||||
"back = openmc.YPlane(y0=-pitch/2)\n",
|
||||
"front = openmc.YPlane(y0=pitch/2)\n",
|
||||
"z = [0., 30., 60., 90., 120., 150., 180., 210., 240., 270., 300.]\n",
|
||||
"z_list = [openmc.ZPlane(z0=z_i) for z_i in z]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"left.boundary_type = 'reflective'\n",
|
||||
"right.boundary_type = 'reflective'\n",
|
||||
"front.boundary_type = 'reflective'\n",
|
||||
"back.boundary_type = 'reflective'\n",
|
||||
"z_list[0].boundary_type = 'vacuum'\n",
|
||||
"z_list[-1].boundary_type = 'vacuum'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fuel_list = []\n",
|
||||
"gap_list = []\n",
|
||||
"clad_list = []\n",
|
||||
"water_list = []\n",
|
||||
"for i in range(1, 11):\n",
|
||||
" fuel_list.append(openmc.Cell(cell_id=i))\n",
|
||||
" gap_list.append(openmc.Cell(cell_id=i+10))\n",
|
||||
" clad_list.append(openmc.Cell(cell_id=i+20))\n",
|
||||
" water_list.append(openmc.Cell(cell_id=i+30))\n",
|
||||
" \n",
|
||||
"for j, fuels in enumerate(fuel_list):\n",
|
||||
" fuels.region = -fuel_or & +z_list[j] & -z_list[j+1]\n",
|
||||
" fuels.fill = uo2\n",
|
||||
" fuels.temperature = 800.\n",
|
||||
"\n",
|
||||
"for j, gaps in enumerate(gap_list):\n",
|
||||
" gaps.region = +fuel_or & -clad_ir & +z_list[j] & -z_list[j+1]\n",
|
||||
" gaps.fill = helium\n",
|
||||
" gaps.temperature = 700.\n",
|
||||
"\n",
|
||||
"for j, clads in enumerate(clad_list):\n",
|
||||
" clads.region = +clad_ir & -clad_or & +z_list[j] & -z_list[j+1]\n",
|
||||
" clads.fill = zircaloy\n",
|
||||
" clads.temperature = 600.\n",
|
||||
"\n",
|
||||
"for j, waters in enumerate(water_list):\n",
|
||||
" waters.region = +clad_or & +left & -right & +back & -front & +z_list[j] & -z_list[j+1]\n",
|
||||
" waters.fill = material_list[j+3]\n",
|
||||
" waters.temperature = 500."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"root = openmc.Universe(name='root universe')\n",
|
||||
"root.add_cells(fuel_list)\n",
|
||||
"root.add_cells(gap_list)\n",
|
||||
"root.add_cells(clad_list)\n",
|
||||
"root.add_cells(water_list)\n",
|
||||
"geometry_file = openmc.Geometry(root)\n",
|
||||
"geometry_file.export_to_xml()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"If you are coupling this externally to a heat transfer solver, you will want to know the heat deposited by each fuel cell. So let's create a cell filter for the recoverable fission heat. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"cell_filter = openmc.CellFilter(fuel_list)\n",
|
||||
"t = openmc.Tally(tally_id=1)\n",
|
||||
"t.filters.append(cell_filter)\n",
|
||||
"t.scores = ['fission-q-recoverable']\n",
|
||||
"tallies = openmc.Tallies([t])\n",
|
||||
"tallies.export_to_xml()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Let's plot our geometry to make sure it looks like we expect. Since we made new water materials in each axial cell, and we have centered the plot at 150, we should see one color for the water material in the bottom half and a different color for the water material in the top half. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<matplotlib.image.AxesImage at 0x126d642e0>"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAFcAAAD4CAYAAACZgnpXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAIMElEQVR4nO3df6jddR3H8ecrh2K41JhL04071CxHueqiEAXSDzWhppU0CwwR1h8O+sNKK1iL9I8U8x8zmBVCxMQ/KsvKoKAWodSdqXOOxXQ2N3/MZURKaXPv/jhf19nd/XE85/u63nPu6wGX7fv9nvO9H54cvjuHe9/7qqoIjze83gsYZYlrlLhGiWuUuEaLXu8FACxZsqTGxsamPf78gV2HbR+7859sP/noVr73O555mX+fcfxh+968aMWMz9myZcv+qjpptnPPi7hjY2NMTExMe3zTvs8etv2uS+7l3V9a1sr3vuumJ3n4pxcdtu/ypT+a8TmS/tbLuXNZMEpco8Q1SlyjxDVKXKPENUpco8Q1SlyjxDVKXKPENUpco8Q1SlyjxDWaNa6kH0jaJ+mRrn0bJO2V9GDzdfGk5yyX9IKkLzoWPSx6eeXeAVw0xf5bqmpV8/XLSce+Dfxq0MUNu1l/hlZVmyWN9XpCSZcAu4AX+1/WaBjkmrtO0sPNZeNEAEnHAdcC35jtyZLWSpqQNPHcc88NsIz5q9+43wVOB1YBTwM3N/s30LlcvDDbCapqY1WNV9X4SSfN+lPqodTXj9ar6tlX/y7pduCeZvM84FOSbgROAA5K+k9V3TroQodRX3ElnVJVTzeblwKPAFTVB7oeswF4YaGGhR7iStoEnA8skbQH+DpwvqRVQAFPAJ/3LXF49fJu4fIpdn+/h+dt6GdBoySf0I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"metadata": {
|
||||
"needs_background": "light"
|
||||
},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"root.plot(basis='yz', width=[2, 10], color_by='material', origin=[0., 0., 150.], pixels=[400, 400])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Settings: everything will be standard except for the temperature settings. Since we will be working with specified temperatures, you will need temperature dependent data. I typically use the endf data found here: https://openmc.org/official-data-libraries/\n",
|
||||
"Make sure your cross sections environment variable is pointing to temperature-dependent data before using the following settings."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"lower_left = [-0.62992, -pitch/2, 0]\n",
|
||||
"upper_right = [+0.62992, +pitch/2, +300]\n",
|
||||
"uniform_dist = openmc.stats.Box(lower_left, upper_right, only_fissionable=True)\n",
|
||||
"\n",
|
||||
"settings_file = openmc.Settings()\n",
|
||||
"settings_file.batches = 100\n",
|
||||
"settings_file.inactive = 10\n",
|
||||
"settings_file.particles = 10000\n",
|
||||
"settings_file.temperature = {'multipole': True, 'method': 'interpolation', 'range': [290, 2500]}\n",
|
||||
"settings_file.source = openmc.source.Source(space=uniform_dist)\n",
|
||||
"settings_file.export_to_xml()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"To run a regular simulation, just use openmc.run(). \n",
|
||||
"However, we want to run a simulation that we can stop in the middle and update the material and cell properties. So we will use openmc.lib."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"openmc.lib.init()\n",
|
||||
"openmc.lib.simulation_init()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"There are 10 inactive batches, so we need to run next_batch() at least 10 times before the tally is activated. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for _ in range(14):\n",
|
||||
" openmc.lib.next_batch()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Let's take a look at the tally. There are 10 entries, one for each cell in the fuel."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[ 4178272.4202991 ]\n",
|
||||
" [ 9595363.82759911]\n",
|
||||
" [12307462.30060902]\n",
|
||||
" [11772927.66594472]\n",
|
||||
" [11892601.29001472]\n",
|
||||
" [12203397.88895767]\n",
|
||||
" [12851791.20965905]\n",
|
||||
" [11760027.45873386]\n",
|
||||
" [ 9293110.94735569]\n",
|
||||
" [ 4511597.61592287]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"t = openmc.lib.tallies[1]\n",
|
||||
"print(t.mean)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Now, let's make some changes to the temperatures. For this, we need to identify each cell by its id. We can use get_temperature() to compare the temperatures of the cells before and after the change. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"fuel temperature is: \n",
|
||||
"800.0\n",
|
||||
"gap temperature is: \n",
|
||||
"700.0\n",
|
||||
"clad temperature is: \n",
|
||||
"600.0\n",
|
||||
"water temperature is: \n",
|
||||
"500.00000000000006\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(\"fuel temperature is: \")\n",
|
||||
"print(openmc.lib.cells[5].get_temperature())\n",
|
||||
"print(\"gap temperature is: \")\n",
|
||||
"print(openmc.lib.cells[15].get_temperature())\n",
|
||||
"print(\"clad temperature is: \")\n",
|
||||
"print(openmc.lib.cells[25].get_temperature())\n",
|
||||
"print(\"water temperature is: \")\n",
|
||||
"print(openmc.lib.cells[35].get_temperature())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for i in range(1, 11):\n",
|
||||
" temp = 900.0\n",
|
||||
" openmc.lib.cells[i].set_temperature(temp)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"fuel temperature is: \n",
|
||||
"899.9999999999999\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(\"fuel temperature is: \")\n",
|
||||
"print(openmc.lib.cells[5].get_temperature())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Let's make a similar change for the water density. Again, we need to identify each material by its id."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for i in range(4, 14):\n",
|
||||
" density = 0.65\n",
|
||||
" openmc.lib.materials[i].set_density(density, units='g/cm3')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The new batches we run will use the new material and cell properties."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for _ in range(14):\n",
|
||||
" openmc.lib.next_batch()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"When you're ready to end the simulation, use the following:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"openmc.lib.simulation_finalize()\n",
|
||||
"openmc.lib.finalize()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../tests/chain_simple.xml
|
||||
|
|
@ -1,411 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Modeling Hexagonal Lattices\n",
|
||||
"In this example, we will create a hexagonal lattice and show how the orientation can be changed via the cell rotation property. Let's first just set up some materials and universes that we will use to fill the lattice."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%matplotlib inline\n",
|
||||
"import openmc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fuel = openmc.Material(name='fuel')\n",
|
||||
"fuel.add_nuclide('U235', 1.0)\n",
|
||||
"fuel.set_density('g/cm3', 10.0)\n",
|
||||
"\n",
|
||||
"fuel2 = openmc.Material(name='fuel2')\n",
|
||||
"fuel2.add_nuclide('U238', 1.0)\n",
|
||||
"fuel2.set_density('g/cm3', 10.0)\n",
|
||||
"\n",
|
||||
"water = openmc.Material(name='water')\n",
|
||||
"water.add_nuclide('H1', 2.0)\n",
|
||||
"water.add_nuclide('O16', 1.0)\n",
|
||||
"water.set_density('g/cm3', 1.0)\n",
|
||||
"\n",
|
||||
"materials = openmc.Materials((fuel, fuel2, water))\n",
|
||||
"materials.export_to_xml()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"With our three materials, we will set up two universes that represent pin-cells: one with a small pin and one with a big pin. Since we will be using these universes in a lattice, it's always a good idea to have an \"outer\" universe as well that is applied outside the defined lattice."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"r_pin = openmc.ZCylinder(r=0.25)\n",
|
||||
"fuel_cell = openmc.Cell(fill=fuel, region=-r_pin)\n",
|
||||
"water_cell = openmc.Cell(fill=water, region=+r_pin)\n",
|
||||
"pin_universe = openmc.Universe(cells=(fuel_cell, water_cell))\n",
|
||||
"\n",
|
||||
"r_big_pin = openmc.ZCylinder(r=0.5)\n",
|
||||
"fuel2_cell = openmc.Cell(fill=fuel2, region=-r_big_pin)\n",
|
||||
"water2_cell = openmc.Cell(fill=water, region=+r_big_pin)\n",
|
||||
"big_pin_universe = openmc.Universe(cells=(fuel2_cell, water2_cell))\n",
|
||||
"\n",
|
||||
"all_water_cell = openmc.Cell(fill=water)\n",
|
||||
"outer_universe = openmc.Universe(cells=(all_water_cell,))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Now let's create a hexagonal lattice using the `HexLattice` class:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"lattice = openmc.HexLattice()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We need to set the `center` of the lattice, the `pitch`, an `outer` universe (which is applied to all lattice elements outside of those that are defined), and a list of `universes`. Let's start with the easy ones first. Note that for a 2D lattice, we only need to specify a single number for the pitch."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"lattice.center = (0., 0.)\n",
|
||||
"lattice.pitch = (1.25,)\n",
|
||||
"lattice.outer = outer_universe"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Now we need to set the `universes` property on our lattice. It needs to be set to a list of lists of Universes, where each list of Universes corresponds to a ring of the lattice. The rings are ordered from outermost to innermost, and within each ring the indexing starts at the \"top\". To help visualize the proper indices, we can use the `show_indices()` helper method."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" (0, 0)\n",
|
||||
" (0,17) (0, 1)\n",
|
||||
" (0,16) (1, 0) (0, 2)\n",
|
||||
"(0,15) (1,11) (1, 1) (0, 3)\n",
|
||||
" (1,10) (2, 0) (1, 2)\n",
|
||||
"(0,14) (2, 5) (2, 1) (0, 4)\n",
|
||||
" (1, 9) (3, 0) (1, 3)\n",
|
||||
"(0,13) (2, 4) (2, 2) (0, 5)\n",
|
||||
" (1, 8) (2, 3) (1, 4)\n",
|
||||
"(0,12) (1, 7) (1, 5) (0, 6)\n",
|
||||
" (0,11) (1, 6) (0, 7)\n",
|
||||
" (0,10) (0, 8)\n",
|
||||
" (0, 9)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(lattice.show_indices(num_rings=4))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Let's set up a lattice where the first element in each ring is the big pin universe and all other elements are regular pin universes. \n",
|
||||
"\n",
|
||||
"From the diagram above, we see that the outer ring has 18 elements, the first ring has 12, and the second ring has 6 elements. The innermost ring of any hexagonal lattice will have only a single element. \n",
|
||||
"\n",
|
||||
"We build these rings through 'list concatenation' as follows: "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"outer_ring = [big_pin_universe] + [pin_universe]*17 # Adds up to 18\n",
|
||||
"\n",
|
||||
"ring_1 = [big_pin_universe] + [pin_universe]*11 # Adds up to 12\n",
|
||||
"\n",
|
||||
"ring_2 = [big_pin_universe] + [pin_universe]*5 # Adds up to 6\n",
|
||||
"\n",
|
||||
"inner_ring = [big_pin_universe]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We can now assign the rings (and the universes they contain) to our lattice. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"HexLattice\n",
|
||||
"\tID =\t4\n",
|
||||
"\tName =\t\n",
|
||||
"\tOrientation =\ty\n",
|
||||
"\t# Rings =\t4\n",
|
||||
"\t# Axial =\tNone\n",
|
||||
"\tCenter =\t(0.0, 0.0)\n",
|
||||
"\tPitch =\t(1.25,)\n",
|
||||
"\tOuter =\t3\n",
|
||||
"\tUniverses \n",
|
||||
" 2\n",
|
||||
" 1 1\n",
|
||||
" 1 2 1\n",
|
||||
"1 1 1 1\n",
|
||||
" 1 2 1\n",
|
||||
"1 1 1 1\n",
|
||||
" 1 2 1\n",
|
||||
"1 1 1 1\n",
|
||||
" 1 1 1\n",
|
||||
"1 1 1 1\n",
|
||||
" 1 1 1\n",
|
||||
" 1 1\n",
|
||||
" 1\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"lattice.universes = [outer_ring, \n",
|
||||
" ring_1, \n",
|
||||
" ring_2,\n",
|
||||
" inner_ring]\n",
|
||||
"print(lattice)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Now let's put our lattice inside a circular cell that will serve as the top-level cell for our geometry."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"outer_surface = openmc.ZCylinder(r=5.0, boundary_type='vacuum')\n",
|
||||
"main_cell = openmc.Cell(fill=lattice, region=-outer_surface)\n",
|
||||
"geometry = openmc.Geometry([main_cell])\n",
|
||||
"geometry.export_to_xml()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Now let's create a plot to see what our geometry looks like."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQAgMAAAD90d5fAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX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DIwLTA4LTI4VDA4OjQxOjQ2KzAxOjAwiXFbNwAAAABJRU5ErkJggg==\n",
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Image object>"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"plot = openmc.Plot.from_geometry(geometry)\n",
|
||||
"plot.color_by = 'material'\n",
|
||||
"plot.colors = colors = {\n",
|
||||
" water: 'blue',\n",
|
||||
" fuel: 'olive',\n",
|
||||
" fuel2: 'yellow'\n",
|
||||
"}\n",
|
||||
"plot.to_ipython_image()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"At this point, if we wanted to simulate the model, we would need to create an instance of `openmc.Settings`, export it to XML, and run."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Lattice orientation\n",
|
||||
"\n",
|
||||
"Now let's say we want our hexagonal lattice orientated such that two sides of the lattice are parallel to the x-axis. This can be achieved by two means: either we can rotate the cell that contains the lattice, or we can can change the `HexLattice.orientation` attribute. By default, the `orientation` is set to \"y\", indicating that two sides of the lattice are parallel to the y-axis, but we can also change it to \"x\" to make them parallel to the x-axis."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQAgMAAAD90d5fAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX///8AAP+AgAD//wDoUCWoAAAAAWJLR0QAiAUdSAAAAAd0SU1FB+QIHAkpLvz/+XkAAAakSURBVHja7Z1NlqM6DIUrAy/B+2EJDHD6nEwyft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QTXg3F6LbJgtQyM9301pCxYtVgYwSQYpRbWiUDWbellGKsUMcaK+SKmFyiijIxiglpdI9HGOmnGR/x7UUAsMUqIKRzLjN8fzmrGmhTuGQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMC0wOC0yOFQwODo0MTo0NiswMTowMPgs44sAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjAtMDgtMjhUMDg6NDE6NDYrMDE6MDCJcVs3AAAAAElFTkSuQmCC\n",
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Image object>"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Change the orientation of the lattice and re-export the geometry\n",
|
||||
"lattice.orientation = 'x'\n",
|
||||
"geometry.export_to_xml()\n",
|
||||
"\n",
|
||||
"# Run OpenMC in plotting mode\n",
|
||||
"plot.to_ipython_image()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"When we change the orientation to 'x', you can see that the first universe in each ring starts to the right along the x-axis. As before, the universes are defined in a clockwise fashion around each ring. To see the proper indices for a hexagonal lattice in this orientation, we can again call `show_indices` but pass an extra orientation argument:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" (0,12) (0,13) (0,14) (0,15)\n",
|
||||
"\n",
|
||||
" (0,11) (1, 8) (1, 9) (1,10) (0,16)\n",
|
||||
"\n",
|
||||
" (0,10) (1, 7) (2, 4) (2, 5) (1,11) (0,17)\n",
|
||||
"\n",
|
||||
"(0, 9) (1, 6) (2, 3) (3, 0) (2, 0) (1, 0) (0, 0)\n",
|
||||
"\n",
|
||||
" (0, 8) (1, 5) (2, 2) (2, 1) (1, 1) (0, 1)\n",
|
||||
"\n",
|
||||
" (0, 7) (1, 4) (1, 3) (1, 2) (0, 2)\n",
|
||||
"\n",
|
||||
" (0, 6) (0, 5) (0, 4) (0, 3)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(lattice.show_indices(4, orientation='x'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Hexagonal prisms\n",
|
||||
"\n",
|
||||
"OpenMC also contains a convenience function that can create a hexagonal prism representing the interior region of six surfaces defining a hexagon. This can be useful as a bounding surface of a hexagonal lattice. For example, if we wanted the outer boundary of our geometry to be hexagonal, we could change the `region` of the main cell:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQBAMAAABykSv/AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAElBMVEX///+TUVD//wCAgAA4vPIAAP/pte6jAAAAAWJLR0QAiAUdSAAAAAd0SU1FB+QIHAkpLvz/+XkAAAiBSURBVHja7Z3rddw6DISNDkR3ICkVrCpwjtNB3H8rNznxPkQBu3xgCAqX83fOMfkJszJFUtTb29DQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQULlCA7XgoBYgk5OCNCmJFxBqAzINkFS14WiQLS8g1ApkclIQeEm8gFA7kGmApKgdBzhbXkAoaut9mflOaBhTu4K8LwvfLx2jGcjfxtl+KRk4jihZyz8du6VkTI1AlkXol5aBA+Ebj/ulZzQpyLIIzSsaqJI8grzvWp8hBgxE5HhoXtHAZUvmuDWvaOBA6AnHd/OKBjBbd5CFk7IBBHnO8bd5RQOYLXrBoSpkSdyAvEoWBASRLS8gZAOiny0WZNs2viO1BhAkMCDbJvS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ExOGcEkiyLc0ZAIGQLopYsg+M5MAVxBEKWIIrJ8gPS/HgOULIcgdARpIvDNqpK0hhEl4MDWaM4LIoGDoSsQJST1fqcERwIezyH0CvVByttDn5ddIM/6qoXpPECLxCk7fEcuGQ5AiELEECy/IC8zJaqgUvWy/uWsoEryItzRmZlAwjydGPKrG7AksXuMT80rmjgQEgkmSEGKllPtnOADBQIO70VN65poDikjSkhBIgBK4iwvhCC0K9aAwfCbkyZj91SMnAc3HYOpldaBhCEDs2zvdIxJiDIW2goJIcfEGrHMQ2QJLUDwXL4AaFWHBMYpFlJ0Bx+QKgNxzRAktUGBM/hB4RacEwNQJqUpAXH0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0JBb/Qdzkh5bG3T0BgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMC0wOC0yOFQwODo0MTo0NiswMTowMPgs44sAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjAtMDgtMjhUMDg6NDE6NDYrMDE6MDCJcVs3AAAAAElFTkSuQmCC\n",
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Image object>"
|
||||
]
|
||||
},
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"main_cell.region = openmc.model.hexagonal_prism(\n",
|
||||
" edge_length=4*lattice.pitch[0],\n",
|
||||
" orientation='x',\n",
|
||||
" boundary_type='vacuum'\n",
|
||||
")\n",
|
||||
"geometry.export_to_xml()\n",
|
||||
"\n",
|
||||
"# Run OpenMC in plotting mode\n",
|
||||
"plot.color_by = 'cell'\n",
|
||||
"plot.to_ipython_image()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"anaconda-cloud": {},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
Before Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 97 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 101 KiB |
|
Before Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 110 KiB |