Skip to content

Commit

Permalink
Merge pull request #22 from jspecht3/main
Browse files Browse the repository at this point in the history
Fixes to example ipynb files I found while testing examples
  • Loading branch information
pshriwise authored May 23, 2024
2 parents 65b0133 + 73a5c97 commit ca3bd85
Show file tree
Hide file tree
Showing 24 changed files with 96 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .github/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ dependencies:
- jupyter=1.0
- nbformat
- nbconvert
- numpy=1.18
- numpy
- seaborn
- requests=2.24.0
- pytest
- vtk
- pyevtk
- xlwt
- swig
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ jobs:
with:
activate-environment: jupyter-actions
environment-file: .github/environment.yml
python-version: 3.7
python-version: 3.9

- name: Install OpenMC
shell: bash -l {0}
run: |
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
conda activate jupyter-actions
conda install -c conda-forge openmc
conda install -c conda-forge openmc==0.14.0
- name: Cache Cross Sections
id: xs-cache
Expand Down
8 changes: 6 additions & 2 deletions .test/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def process_notebook(notebook_filename, html_directory='notebook-html'):
with open(notebook_filename) as f:
nb = nbformat.read(f, as_version=4)

ep = ExecutePreprocessor(timeout=600,
ep = ExecutePreprocessor(timeout=1200,
kernel_name='python3')

try:
Expand All @@ -41,7 +41,11 @@ def find_notebooks():
.splitlines())

# Get just the notebooks from the git files
return [fn for fn in git_files if fn.endswith(".ipynb")]
notebooks = [fn for fn in git_files if fn.endswith(".ipynb")]
# remove the MGXS notebooks that use on OepnMOC for now
notebooks.remove('mgxs-part-ii.ipynb')
notebooks.remove('mgxs-part-iii.ipynb')
return notebooks


@pytest.mark.parametrize('notebook', find_notebooks())
Expand Down
8 changes: 4 additions & 4 deletions cad-based-geometry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
},
"outputs": [],
"source": [
"model.settings.source = openmc.Source(space=openmc.stats.Box([-4., -4., -4.],\n",
"model.settings.source = openmc.IndependentSource(space=openmc.stats.Box([-4., -4., -4.],\n",
" [ 4., 4., 4.]))\n",
"model.export_to_model_xml()"
]
Expand Down Expand Up @@ -610,7 +610,7 @@
"settings.run_mode = \"fixed source\"\n",
"\n",
"space = openmc.stats.Box(*geometry.bounding_box)\n",
"my_source = openmc.Source(space=space, domains=[water])\n",
"my_source = openmc.IndependentSource(space=space, domains=[water])\n",
"my_source.energy = openmc.stats.Discrete(x=[12.0,], p=[1.0,])\n",
"\n",
"settings.source = my_source"
Expand Down Expand Up @@ -1064,7 +1064,7 @@
],
"source": [
"# creates a simple isotropic neutron source in the center with 14MeV neutrons\n",
"source = openmc.Source()\n",
"source = openmc.IndependentSource()\n",
"# the distribution of radius is just a single value at the plasma major radius\n",
"radius = openmc.stats.Discrete([250.], [1])\n",
"# the distribution of source z values is just a single value\n",
Expand All @@ -1077,7 +1077,7 @@
"# sets the direction to isotropic\n",
"source.angle = openmc.stats.Isotropic()\n",
"# sets the energy distribution to a Muir distribution of D-T fusion neutrons\n",
"source.energy = openmc.stats.Muir(e0=14_000_000.0, m_rat=5.0, kt=20000.0)"
"source.energy = openmc.stats.muir(e0=14_000_000.0, m_rat=5.0, kt=20000.0)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion candu.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
"settings.particles = 1000\n",
"settings.batches = 20\n",
"settings.inactive = 10\n",
"settings.source = openmc.Source(space=openmc.stats.Point())\n",
"settings.source = openmc.IndependentSource(space=openmc.stats.Point())\n",
"settings.export_to_xml()"
]
},
Expand Down
2 changes: 1 addition & 1 deletion capi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
"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.source = openmc.source.IndependentSource(space=uniform_dist)\n",
"settings_file.export_to_xml()"
]
},
Expand Down
11 changes: 10 additions & 1 deletion chain_simple.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0"?>
<depletion_chain>
<nuclide name="Ba135" decay_modes="0" reactions="0" />
<nuclide name="Ba136" decay_modes="0" reactions="0" />
<nuclide name="Ba138" decay_modes="0" reactions="0" />
<nuclide name="I134" decay_modes="0" reactions="0" />
<nuclide name="I135" decay_modes="1" reactions="1" half_life="2.36520E+04">
<decay type="beta" target="Xe135" branching_ratio="1.0" />
<reaction type="(n,gamma)" Q="0.0" target="Xe136" /> <!-- Not precisely true, but whatever -->
Expand All @@ -8,9 +12,14 @@
<decay type=" beta" target="Cs135" branching_ratio="1.0" />
<reaction type="(n,gamma)" Q="0.0" target="Xe136" />
</nuclide>
<nuclide name="Xe134" decay_modes="0" reactions="0" />
<nuclide name="Xe136" decay_modes="0" reactions="0" />
<nuclide name="Xe137" decay_modes="0" reactions="0" />
<nuclide name="Cs135" decay_modes="0" reactions="0" />
<nuclide name="Gd157" decay_modes="0" reactions="1" >
<nuclide name="Cs136" decay_modes="0" reactions="0" />
<nuclide name="Cs138" decay_modes="0" reactions="0" />
<nuclide name="Cs138_m1" decay_modes="0" reactions="0" />
<nuclide name="Gd157" decay_modes="0" reactions="1">
<reaction type="(n,gamma)" Q="0.0" target="Nothing" />
</nuclide>
<nuclide name="Cs137" half_life="949252600.0" decay_modes="2" decay_energy="179447.6443" reactions="6">
Expand Down
6 changes: 3 additions & 3 deletions depletion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Depletion\n",
"# Pincell Depletion\n",
"This notebook is intended to introduce the reader to the depletion interface contained in OpenMC. It is recommended that you are moderately familiar with building models using the OpenMC Python API. The earlier examples are excellent starting points, as this notebook will not focus heavily on model building.\n",
"\n",
"If you have a real power reactor, the fuel composition is constantly changing as fission events produce energy, remove some fissile isotopes, and produce fission products. Other reactions, like $(n, \\alpha)$ and $(n, \\gamma)$ will alter the composition as well. Furthermore, some nuclides undergo spontaneous decay with widely ranging frequencies. Depletion is the process of modeling this behavior.\n",
Expand Down Expand Up @@ -105,8 +105,8 @@
"metadata": {},
"outputs": [],
"source": [
"bound_box = openmc.rectangular_prism(1.24, 1.24, boundary_type=\"reflective\")\n",
"root_cell = openmc.Cell(fill=pin_univ, region=bound_box)\n",
"bound_box = openmc.model.RectangularPrism(1.24, 1.24, boundary_type=\"reflective\")\n",
"root_cell = openmc.Cell(fill=pin_univ, region=-bound_box)\n",
"geometry = openmc.Geometry([root_cell])"
]
},
Expand Down
12 changes: 6 additions & 6 deletions expansion-filters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@
"source": [
"# Define surfaces used to construct regions\n",
"zmin, zmax = -10., 10.\n",
"box = openmc.model.rectangular_prism(10., 10., boundary_type='reflective')\n",
"box = openmc.model.RectangularPrism(10., 10., boundary_type='reflective')\n",
"bottom = openmc.ZPlane(z0=zmin, boundary_type='vacuum')\n",
"boron_lower = openmc.ZPlane(z0=-0.5)\n",
"boron_upper = openmc.ZPlane(z0=0.5)\n",
"top = openmc.ZPlane(z0=zmax, boundary_type='vacuum')\n",
"\n",
"# Create three cells and add them to geometry\n",
"fuel1 = openmc.Cell(fill=fuel, region=box & +bottom & -boron_lower)\n",
"absorber = openmc.Cell(fill=b4c, region=box & +boron_lower & -boron_upper)\n",
"fuel2 = openmc.Cell(fill=fuel, region=box & +boron_upper & -top)\n",
"fuel1 = openmc.Cell(fill=fuel, region=-box & +bottom & -boron_lower)\n",
"absorber = openmc.Cell(fill=b4c, region=-box & +boron_lower & -boron_upper)\n",
"fuel2 = openmc.Cell(fill=fuel, region=-box & +boron_upper & -top)\n",
"geom = openmc.Geometry([fuel1, absorber, fuel2])"
]
},
Expand All @@ -91,7 +91,7 @@
"source": [
"settings = openmc.Settings()\n",
"spatial_dist = openmc.stats.Box(*geom.bounding_box)\n",
"settings.source = openmc.Source(space=spatial_dist)\n",
"settings.source = openmc.IndependentSource(space=spatial_dist)\n",
"settings.batches = 210\n",
"settings.inactive = 10\n",
"settings.particles = 1000"
Expand Down Expand Up @@ -506,7 +506,7 @@
"source": [
"settings = openmc.Settings()\n",
"spatial_dist = openmc.stats.Box(*geom.bounding_box)\n",
"settings.source = openmc.Source(space=spatial_dist)\n",
"settings.source = openmc.IndependentSource(space=spatial_dist)\n",
"settings.batches = 100\n",
"settings.inactive = 20\n",
"settings.particles = 100000"
Expand Down
2 changes: 1 addition & 1 deletion hexagonal-lattice.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
}
],
"source": [
"main_cell.region = openmc.model.hexagonal_prism(\n",
"main_cell.region = -openmc.model.HexagonalPrism(\n",
" edge_length=4*lattice.pitch[0],\n",
" orientation='x',\n",
" boundary_type='vacuum'\n",
Expand Down
18 changes: 8 additions & 10 deletions mdgxs-part-i.ipynb

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions mdgxs-part-ii.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
"# Create an initial uniform spatial source distribution over fissionable zones\n",
"bounds = [-10.71, -10.71, -10, 10.71, 10.71, 10.]\n",
"uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)\n",
"settings.source = openmc.Source(space=uniform_dist)"
"settings.source = openmc.IndependentSource(space=uniform_dist)"
]
},
{
Expand Down Expand Up @@ -376,12 +376,10 @@
"outputs": [],
"source": [
"# Instantiate a 20-group EnergyGroups object\n",
"energy_groups = openmc.mgxs.EnergyGroups()\n",
"energy_groups.group_edges = np.logspace(-3, 7.3, 21)\n",
"energy_groups = openmc.mgxs.EnergyGroups(group_edges=np.logspace(-3, 7.3, 21))\n",
"\n",
"# Instantiate a 1-group EnergyGroups object\n",
"one_group = openmc.mgxs.EnergyGroups()\n",
"one_group.group_edges = np.array([energy_groups.group_edges[0], energy_groups.group_edges[-1]])"
"one_group = openmc.mgxs.EnergyGroups(group_edges=np.array([energy_groups.group_edges[0], energy_groups.group_edges[-1]]))"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion mg-mode-part-i.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
"# Create an initial uniform spatial source distribution over fissionable zones\n",
"bounds = [-32.13, -10.71, -1e50, 10.71, 32.13, 1e50]\n",
"uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)\n",
"settings.source = openmc.Source(space=uniform_dist)\n",
"settings.source = openmc.IndependentSource(space=uniform_dist)\n",
"\n",
"# Tell OpenMC we want to run in eigenvalue mode\n",
"settings.run_mode = 'eigenvalue'\n",
Expand Down
14 changes: 7 additions & 7 deletions mg-mode-part-ii.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
"# Create an initial uniform spatial source distribution over fissionable zones\n",
"bounds = [-10.71, -10.71, -10, 10.71, 10.71, 10.]\n",
"uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)\n",
"settings.source = openmc.Source(space=uniform_dist)\n",
"settings.source = openmc.IndependentSource(space=uniform_dist)\n",
"\n",
"model.settings = settings"
]
Expand Down Expand Up @@ -914,24 +914,24 @@
"source": [
"# First lets plot the fuel data\n",
"# We will first add the continuous-energy data\n",
"fig = openmc.plot_xs(fuel, ['total'])\n",
"fig = openmc.plot_xs(reactions={fuel: ['total']})\n",
"\n",
"# We will now add in the corresponding multi-group data and show the result\n",
"openmc.plot_xs(fuel_mg, ['total'], plot_CE=False, mg_cross_sections='mgxs.h5', axis=fig.axes[0])\n",
"openmc.plot_xs(reactions={fuel_mg: ['total']}, plot_CE=False, mg_cross_sections='mgxs.h5', axis=fig.axes[0])\n",
"fig.axes[0].legend().set_visible(False)\n",
"plt.show()\n",
"plt.close()\n",
"\n",
"# Then repeat for the zircaloy data\n",
"fig = openmc.plot_xs(zircaloy, ['total'])\n",
"openmc.plot_xs(zircaloy_mg, ['total'], plot_CE=False, mg_cross_sections='mgxs.h5', axis=fig.axes[0])\n",
"fig = openmc.plot_xs(reactions={zircaloy: ['total']})\n",
"openmc.plot_xs(reactions={zircaloy_mg: ['total']}, plot_CE=False, mg_cross_sections='mgxs.h5', axis=fig.axes[0])\n",
"fig.axes[0].legend().set_visible(False)\n",
"plt.show()\n",
"plt.close()\n",
"\n",
"# And finally repeat for the water data\n",
"fig = openmc.plot_xs(water, ['total'])\n",
"openmc.plot_xs(water_mg, ['total'], plot_CE=False, mg_cross_sections='mgxs.h5', axis=fig.axes[0])\n",
"fig = openmc.plot_xs(reactions={water: ['total']})\n",
"openmc.plot_xs(reactions={water_mg: ['total']}, plot_CE=False, mg_cross_sections='mgxs.h5', axis=fig.axes[0])\n",
"fig.axes[0].legend().set_visible(False)\n",
"plt.show()\n",
"plt.close()"
Expand Down
5 changes: 2 additions & 3 deletions mg-mode-part-iii.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@
"# Create an initial uniform spatial source distribution over fissionable zones\n",
"bounds = [pin_pitch, pin_pitch, 10, length - pin_pitch, length - pin_pitch, 10]\n",
"uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)\n",
"settings.source = openmc.Source(space=uniform_dist)\n",
"settings.source = openmc.IndependentSource(space=uniform_dist)\n",
"\n",
"model.settings = settings"
]
Expand All @@ -466,8 +466,7 @@
"outputs": [],
"source": [
"# Instantiate a 2-group EnergyGroups object\n",
"groups = openmc.mgxs.EnergyGroups()\n",
"groups.group_edges = np.array([0., 0.625, 20.0e6])"
"groups = openmc.mgxs.EnergyGroups(group_edges=np.array([0., 0.625, 20.0e6]))"
]
},
{
Expand Down
9 changes: 4 additions & 5 deletions mgxs-part-i.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit ca3bd85

Please sign in to comment.