Skip to content

Commit

Permalink
Added parametric search example problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Dec 21, 2023
1 parent 59fc7ae commit b771d01
Showing 1 changed file with 74 additions and 88 deletions.
162 changes: 74 additions & 88 deletions demo/Pin_cell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,18 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "828d41f1-76d8-4dd0-ae22-3b5b7952726d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'0.2.3dev2'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import montepy\n",
"montepy.__version__"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "c5d3aa79-57bf-4036-b40f-69c2f5d80dd4",
"metadata": {},
"outputs": [],
Expand All @@ -34,75 +23,20 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "9432edc7-1f64-4bd3-9697-84165325ed30",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MCNP problem for: pin_cell.imcnp\n",
"TITLE: Made up PWR pin Cell Problem\n",
"CELL: 1, mat: 1, DENS: 10.0 g/cm3\n",
"CELL: 2, mat: 0, DENS: None\n",
"CELL: 3, mat: 10, DENS: 5.0 g/cm3\n",
"CELL: 5, mat: 2, DENS: 1.0 g/cm3\n",
"Mode: {<Particle.NEUTRON: 'N'>}\n",
"DATA INPUT: nps "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"problem"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "086f6d12-8052-4b30-b39e-cc4caa6555a8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Numbered_object_collection: obj_class: <class 'montepy.data_inputs.material.Material'>, problem: MCNP problem for: pin_cell.imcnp, TITLE: Made up PWR pin Cell Problem\n",
"Objects: [MATERIAL: 1 fractions: atom\n",
" U-235 (80c) 0.04\n",
" U-238 (80c) 0.96\n",
", MATERIAL: 2 fractions: atom\n",
" H-1 (80c) 0.66\n",
" O-16 (80c) 0.33\n",
", MATERIAL: 10 fractions: atom\n",
"Zr-90 (80c) 0.515\n",
"Zr-91 (80c) 0.112\n",
"Zr-92 (80c) 0.171\n",
"Zr-94 (80c) 0.174\n",
"Zr-96 (80c) 0.028\n",
"]\n",
"Number cache: {1: MATERIAL: 1 fractions: atom\n",
" U-235 (80c) 0.04\n",
" U-238 (80c) 0.96\n",
", 2: MATERIAL: 2 fractions: atom\n",
" H-1 (80c) 0.66\n",
" O-16 (80c) 0.33\n",
", 10: MATERIAL: 10 fractions: atom\n",
"Zr-90 (80c) 0.515\n",
"Zr-91 (80c) 0.112\n",
"Zr-92 (80c) 0.171\n",
"Zr-94 (80c) 0.174\n",
"Zr-96 (80c) 0.028\n",
"}"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"problem.materials"
]
Expand All @@ -112,7 +46,7 @@
"id": "aa6cff1e-fe5e-4401-836a-455db3aa49eb",
"metadata": {},
"source": [
"Theres some issues\n",
"There's some issues\n",
"==================\n",
"\n",
"* Density was defined wrong\n",
Expand All @@ -121,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "fe75b6c4-5e75-4255-8d5f-bc300342d2c1",
"metadata": {},
"outputs": [],
Expand All @@ -133,25 +67,77 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "192b3eca-4178-471a-af14-64d7e5734c60",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CELL: 1, mat: 1, DENS: 10.0 g/cm3\n",
"CELL: 2, mat: 0, DENS: None\n",
"CELL: 3, mat: 10, DENS: 5.0 g/cm3\n",
"CELL: 5, mat: 2, DENS: 1.0 g/cm3\n"
]
}
],
"outputs": [],
"source": [
"for cell in problem.cells:\n",
" print(cell)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6b2ba1cc-65be-43ad-8999-5bc3f5b04968",
"metadata": {},
"outputs": [],
"source": [
"material = problem.materials[1]\n",
"for material in problem.materials:\n",
" for componenet in material.material_components:\n",
" componenet.library = \"00c\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f1c794a6-3926-4bbb-b82d-a2dab8d8f741",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"problem.materials"
]
},
{
"cell_type": "markdown",
"id": "54111f69-8bcc-4c6b-9c34-81e4d615240e",
"metadata": {},
"source": [
"Parametric Sweep\n",
"================\n",
"\n",
"* We will sweep the fuel radius from 0.35 in to 0.5 in\n",
"* We will also sweep the fuel pitch from 1 in to 1.5 in"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4cb4dfed-2fbd-4653-ad97-160ffc649af3",
"metadata": {},
"outputs": [],
"source": [
"fuel_wall = problem.surfaces[1]\n",
"gap_wall = problem.surfaces[2]\n",
"clad_wall = problem.surfaces[3]\n",
"\n",
"GAP_OFFSET = gap_wall.radius - fuel_wall.radius\n",
"CLAD_OFFSET = clad_wall.radius - fuel_wall.radius\n",
"\n",
"box_walls = problem.surfaces[101:107]\n",
"\n",
"for pin_radius in [0.35, 0.375, 0.4, 0.425, 0.45, 0.475, 0.5]:\n",
" for pitch in [1.0, 1.1, 1.2, 1.3, 1.4, 1.5]:\n",
" fuel_wall.radius = pin_radius\n",
" gap_wall.radius = pin_radius + GAP_OFFSET\n",
" clad_wall.radius = pin_radius + CLAD_OFFSET\n",
" for plane in box_walls:\n",
" plane.location = (pitch / 2) * (-1 if plane.location < 0 else 1)\n",
" problem.write_to_file(f\"parametric/pin_cell_{pin_radius}r_{pitch}p.imcnp\")"
]
}
],
"metadata": {
Expand Down

0 comments on commit b771d01

Please sign in to comment.