Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to example ipynb files I found while testing examples #22

Merged
merged 42 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8b9346c
Update hexagonal-lattice.ipynb
jspecht3 May 17, 2024
f2bb47e
Update candu.ipynb
jspecht3 May 17, 2024
d804f0b
Update cad-based-geometry.ipynb
jspecht3 May 17, 2024
e223512
Update pincell.ipynb
jspecht3 May 17, 2024
fc5b511
Update post-processing.ipynb
jspecht3 May 17, 2024
6ffc202
Update pandas-dataframes.ipynb
jspecht3 May 17, 2024
cc893ca
Update tally-arithmetic.ipynb
jspecht3 May 17, 2024
6e44d3a
Update capi.ipynb
jspecht3 May 17, 2024
1037b1f
Update expansion-filters.ipynb
jspecht3 May 17, 2024
6801a4b
Update search.ipynb
jspecht3 May 17, 2024
c5e153b
Update depletion.ipynb
jspecht3 May 18, 2024
cb8770c
Update mgxs-part-i.ipynb
jspecht3 May 18, 2024
cd60322
Update mgxs-part-i.ipynb
jspecht3 May 18, 2024
40d0f58
Update mgxs-part-ii.ipynb
jspecht3 May 18, 2024
df1767d
Update mgxs-part-iii.ipynb
jspecht3 May 18, 2024
7b89127
Update mdgxs-part-i.ipynb
jspecht3 May 18, 2024
08f7a9c
Update mdgxs-part-ii.ipynb
jspecht3 May 18, 2024
0dbe311
Update mg-mode-part-i.ipynb
jspecht3 May 18, 2024
0ee3a81
Update mg-mode-part-ii.ipynb
jspecht3 May 18, 2024
d770d74
Update mg-mode-part-iii.ipynb
jspecht3 May 18, 2024
d9e3f44
Update unstructured-mesh-part-ii.ipynb
jspecht3 May 18, 2024
b322fdc
Update mdgxs-part-ii.ipynb
jspecht3 May 20, 2024
36e4c5b
Update pincell.ipynb
jspecht3 May 20, 2024
8a0581d
Update mdgxs-part-ii.ipynb
jspecht3 May 20, 2024
a7d9afd
Update mdgxs-part-i.ipynb
jspecht3 May 20, 2024
df6d9d0
Update mdgxs-part-i.ipynb
jspecht3 May 20, 2024
979d188
Update mgxs-part-i.ipynb
jspecht3 May 20, 2024
512c041
Update mg-mode-part-iii.ipynb
jspecht3 May 20, 2024
631e0ce
Updating openmc version in CI
pshriwise May 21, 2024
c02ba81
Update Python version in CI
pshriwise May 21, 2024
d1cb2e6
Removing numpy requirement
pshriwise May 21, 2024
a10bb75
Adding a couple of packages used in mgxs notebooks
pshriwise May 21, 2024
72367f0
Adding time for notebook execution
pshriwise May 21, 2024
cf77043
Updating simplified chain s.t. it's valid for depletion
pshriwise May 21, 2024
6201368
Updates to mgxs modules
pshriwise May 21, 2024
116c2fe
Change mgxs export to CSV for now
pshriwise May 23, 2024
3fcb062
More CI package updates
pshriwise May 23, 2024
ebe702d
Trying numpy 1.19
pshriwise May 23, 2024
26eb1f8
Try python 3.9
pshriwise May 23, 2024
21c756a
Back to standard numpy
pshriwise May 23, 2024
62ad71f
Don't test notebooks using openmoc for now
pshriwise May 23, 2024
73a5c97
Tired. Forgot return
pshriwise May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading