diff --git a/openmc/examples.py b/openmc/examples.py
index d48d26839..a5138377e 100644
--- a/openmc/examples.py
+++ b/openmc/examples.py
@@ -1,3 +1,5 @@
+from numbers import Integral
+
import numpy as np
import openmc
@@ -538,20 +540,20 @@ def pwr_assembly():
return model
-def slab_mg(reps=None, as_macro=True):
- """Create a one-group, 1D slab model.
+def slab_mg(num_regions=1, mat_names=None, mgxslib_name='2g.h5'):
+ """Create a 1D slab model.
Parameters
----------
- reps : list, optional
- List of angular representations. Each item corresponds to materials and
- dictates the angular representation of the multi-group cross
- sections---isotropic ('iso') or angle-dependent ('ang'), and if Legendre
- scattering or tabular scattering ('mu') is used. Thus, items can be
- 'ang', 'ang_mu', 'iso', or 'iso_mu'.
+ num_regions : int, optional
+ Number of regions in the problem, each with a unique MGXS dataset.
+ Defaults to 1.
- as_macro : bool, optional
- Whether :class:`openmc.Macroscopic` is used
+ mat_names : Iterable of str, optional
+ List of the material names to use; defaults to ['mat_1', 'mat_2',...].
+
+ mgxslib_name : str, optional
+ MGXS Library file to use; defaults to '2g.h5'.
Returns
-------
@@ -559,71 +561,82 @@ def slab_mg(reps=None, as_macro=True):
One-group, 1D slab model
"""
+
+ openmc.check_type('num_regions', num_regions, Integral)
+ openmc.check_greater_than('num_regions', num_regions, 0)
+ if mat_names is not None:
+ openmc.check_length('mat_names', mat_names, num_regions)
+ openmc.check_iterable_type('mat_names', mat_names, str)
+ else:
+ mat_names = []
+ for i in range(num_regions):
+ mat_names.append('mat_' + str(i + 1))
+
+ # # Make Materials
+ materials_file = openmc.Materials()
+ macros = []
+ mats = []
+ for i in range(len(mat_names)):
+ macros.append(openmc.Macroscopic('mat_' + str(i + 1)))
+ mats.append(openmc.Material(name=mat_names[i]))
+ mats[-1].set_density('macro', 1.0)
+ mats[-1].add_macroscopic(macros[-1])
+
+ materials_file += mats
+
+ materials_file.cross_sections = mgxslib_name
+
+ # # Make Geometry
+ rad_outer = 929.45
+ # Set a cell boundary to exist for every material above (exclude the 0)
+ rads = np.linspace(0., rad_outer, len(mats) + 1, endpoint=True)[1:]
+
+ # Instantiate Universe
+ root = openmc.Universe(universe_id=0, name='root universe')
+ cells = []
+
+ surfs = []
+ surfs.append(openmc.XPlane(x0=0., boundary_type='reflective'))
+ for r, rad in enumerate(rads):
+ if r == len(rads) - 1:
+ surfs.append(openmc.XPlane(x0=rad, boundary_type='vacuum'))
+ else:
+ surfs.append(openmc.XPlane(x0=rad))
+
+ # Instantiate Cells
+ cells = []
+ for c in range(len(surfs) - 1):
+ cells.append(openmc.Cell())
+ cells[-1].region = (+surfs[c] & -surfs[c + 1])
+ cells[-1].fill = mats[c]
+
+ # Register Cells with Universe
+ root.add_cells(cells)
+
+ # Instantiate a Geometry, register the root Universe, and export to XML
+ geometry_file = openmc.Geometry(root)
+
+ # # Make Settings
+ # Instantiate a Settings object, set all runtime parameters
+ settings_file = openmc.Settings()
+ settings_file.energy_mode = "multi-group"
+ settings_file.tabular_legendre = {'enable': False}
+ settings_file.batches = 10
+ settings_file.inactive = 5
+ settings_file.particles = 1000
+
+ # Build source distribution
+ INF = 1000.
+ bounds = [0., -INF, -INF, rads[0], INF, INF]
+ uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:])
+ settings_file.source = openmc.source.Source(space=uniform_dist)
+
+ settings_file.output = {'summary': False}
+
model = openmc.model.Model()
-
- # Define materials needed for 1D/1G slab problem
- mat_names = ['uo2', 'clad', 'lwtr']
- mgxs_reps = ['ang', 'ang_mu', 'iso', 'iso_mu']
-
- if reps is None:
- reps = mgxs_reps
-
- xs = []
- i = 0
- for mat in mat_names:
- for rep in reps:
- i += 1
- name = mat + '_' + rep
- xs.append(name)
- if as_macro:
- m = openmc.Material(name=str(i))
- m.set_density('macro', 1.)
- m.add_macroscopic(name)
- else:
- m = openmc.Material(name=str(i))
- m.set_density('atom/b-cm', 1.)
- m.add_nuclide(name, 1.0, 'ao')
- model.materials.append(m)
-
- # Define the materials file
- model.xs_data = xs
- model.materials.cross_sections = "../../1d_mgxs.h5"
-
- # Define surfaces.
- # Assembly/Problem Boundary
- left = openmc.XPlane(x0=0.0, boundary_type='reflective')
- right = openmc.XPlane(x0=10.0, boundary_type='reflective')
- bottom = openmc.YPlane(y0=0.0, boundary_type='reflective')
- top = openmc.YPlane(y0=10.0, boundary_type='reflective')
-
- # for each material add a plane
- planes = [openmc.ZPlane(z0=0.0, boundary_type='reflective')]
- dz = round(5. / float(len(model.materials)), 4)
- for i in range(len(model.materials) - 1):
- planes.append(openmc.ZPlane(z0=dz * float(i + 1)))
- planes.append(openmc.ZPlane(z0=5.0, boundary_type='reflective'))
-
- # Define cells for each material
- model.geometry.root_universe = openmc.Universe(name='root universe')
- xy = +left & -right & +bottom & -top
- for i, mat in enumerate(model.materials):
- c = openmc.Cell(fill=mat, region=xy & +planes[i] & -planes[i + 1])
- model.geometry.root_universe.add_cell(c)
-
- model.settings.batches = 10
- model.settings.inactive = 5
- model.settings.particles = 100
- model.settings.source = openmc.Source(space=openmc.stats.Box(
- [0.0, 0.0, 0.0], [10.0, 10.0, 5.]))
- model.settings.energy_mode = "multi-group"
-
- plot = openmc.Plot()
- plot.filename = 'mat'
- plot.origin = (5.0, 5.0, 2.5)
- plot.width = (2.5, 2.5)
- plot.basis = 'xz'
- plot.pixels = (3000, 3000)
- plot.color_by = 'material'
- model.plots.append(plot)
+ model.geometry = geometry_file
+ model.materials = materials_file
+ model.settings = settings_file
+ model.xs_data = macros
return model
diff --git a/tests/1d_mgxs.h5 b/tests/1d_mgxs.h5
deleted file mode 100644
index 0f747345a..000000000
Binary files a/tests/1d_mgxs.h5 and /dev/null differ
diff --git a/tests/regression_tests/mg_basic/__init__.py b/tests/regression_tests/mg_basic/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/regression_tests/mg_basic/inputs_true.dat b/tests/regression_tests/mg_basic/inputs_true.dat
deleted file mode 100644
index a0efdbde0..000000000
--- a/tests/regression_tests/mg_basic/inputs_true.dat
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ../../1d_mgxs.h5
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- eigenvalue
- 100
- 10
- 5
-
-
- 0.0 0.0 0.0 10.0 10.0 5.0
-
-
- multi-group
-
diff --git a/tests/regression_tests/mg_basic/results_true.dat b/tests/regression_tests/mg_basic/results_true.dat
deleted file mode 100644
index ddb57d00b..000000000
--- a/tests/regression_tests/mg_basic/results_true.dat
+++ /dev/null
@@ -1,2 +0,0 @@
-k-combined:
-1.073147E+00 1.602384E-02
diff --git a/tests/regression_tests/mg_basic/test.py b/tests/regression_tests/mg_basic/test.py
deleted file mode 100644
index 3c22e6040..000000000
--- a/tests/regression_tests/mg_basic/test.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from openmc.examples import slab_mg
-
-from tests.testing_harness import PyAPITestHarness
-
-
-def test_mg_basic():
- model = slab_mg()
- harness = PyAPITestHarness('statepoint.10.h5', model)
- harness.main()
diff --git a/tests/regression_tests/mg_benchmark/test.py b/tests/regression_tests/mg_benchmark/test.py
index 97cef92ad..c29c7ca1f 100644
--- a/tests/regression_tests/mg_benchmark/test.py
+++ b/tests/regression_tests/mg_benchmark/test.py
@@ -3,6 +3,7 @@ import os
import numpy as np
import openmc
+from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
@@ -73,86 +74,6 @@ def create_library():
mg_cross_sections_file.export_to_hdf5('2g.h5')
-def create_model():
- create_library()
-
- # # Make Materials
- materials_file = openmc.Materials()
-
- mat_names = ['base leg', 'base tab', 'base hist', 'base matrix', 'base ang']
- macros = []
- mats = []
- for i in range(len(mat_names)):
- macros.append(openmc.Macroscopic('mat_' + str(i + 1)))
- mats.append(openmc.Material(name=mat_names[i]))
- mats[-1].set_density('macro', 1.0)
- mats[-1].add_macroscopic(macros[-1])
-
- # Add in the microscopic data
- mats.append(openmc.Material(name='micro'))
- mats[-1].set_density("sum")
- mats[-1].add_nuclide("mat_1", 0.5)
- mats[-1].add_nuclide("mat_6", 0.5)
-
- materials_file += mats
-
- materials_file.cross_sections = '2g.h5'
-
- # # Make Geometry
- rad_outer = 929.45
- # Set a cell boundary to exist for every material above (exclude the 0)
- rads = np.linspace(0., rad_outer, len(mats) + 1, endpoint=True)[1:]
-
- # Instantiate Universe
- root = openmc.Universe(universe_id=0, name='root universe')
- cells = []
-
- surfs = []
- surfs.append(openmc.XPlane(x0=0., boundary_type='reflective'))
- for r, rad in enumerate(rads):
- if r == len(rads) - 1:
- surfs.append(openmc.XPlane(x0=rad, boundary_type='vacuum'))
- else:
- surfs.append(openmc.XPlane(x0=rad))
-
- # Instantiate Cells
- cells = []
- for c in range(len(surfs) - 1):
- cells.append(openmc.Cell())
- cells[-1].region = (+surfs[c] & -surfs[c + 1])
- cells[-1].fill = mats[c]
-
- # Register Cells with Universe
- root.add_cells(cells)
-
- # Instantiate a Geometry, register the root Universe, and export to XML
- geometry_file = openmc.Geometry(root)
-
- # # Make Settings
- # Instantiate a Settings object, set all runtime parameters
- settings_file = openmc.Settings()
- settings_file.energy_mode = "multi-group"
- settings_file.tabular_legendre = {'enable': False}
- settings_file.batches = 10
- settings_file.inactive = 5
- settings_file.particles = 1000
-
- # Build source distribution
- INF = 1000.
- bounds = [0., -INF, -INF, rads[0], INF, INF]
- uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:])
- settings_file.source = openmc.source.Source(space=uniform_dist)
-
- settings_file.output = {'summary': False}
-
- model = openmc.model.Model()
- model.geometry = geometry_file
- model.materials = materials_file
- model.settings = settings_file
-
- return model
-
-
class MGXSTestHarness(PyAPITestHarness):
def _cleanup(self):
super()._cleanup()
@@ -162,6 +83,15 @@ class MGXSTestHarness(PyAPITestHarness):
def test_mg_benchmark():
- model = create_model()
+ create_library()
+ mat_names = ['base leg', 'base tab', 'base hist', 'base matrix',
+ 'base ang', 'micro']
+ model = slab_mg(num_regions=6, mat_names=mat_names)
+ # Modify the last material to be a microscopic combination of nuclides
+ model.materials[-1] = openmc.Material(name='micro', material_id=6)
+ model.materials[-1].set_density("sum")
+ model.materials[-1].add_nuclide("mat_1", 0.5)
+ model.materials[-1].add_nuclide("mat_6", 0.5)
+
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/regression_tests/mg_benchmark_delayed/test.py b/tests/regression_tests/mg_benchmark_delayed/test.py
index 72bd34e1b..6c527bbe3 100644
--- a/tests/regression_tests/mg_benchmark_delayed/test.py
+++ b/tests/regression_tests/mg_benchmark_delayed/test.py
@@ -3,6 +3,7 @@ import os
import numpy as np
import openmc
+from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
@@ -71,7 +72,8 @@ def create_library():
mat_4 = openmc.XSdata('mat_4', groups)
mat_4.order = 1
mat_4.num_delayed_groups = 2
- mat_4.set_prompt_nu_fission(one_m_beta * np.outer(np.multiply(nu, fiss), chi))
+ mat_4.set_prompt_nu_fission(one_m_beta *
+ np.outer(np.multiply(nu, fiss), chi))
delay_nu_fiss = np.zeros((n_dg, groups.num_groups, groups.num_groups))
for dg in range(n_dg):
for g in range(groups.num_groups):
@@ -87,80 +89,6 @@ def create_library():
mg_cross_sections_file.export_to_hdf5('2g.h5')
-def create_model():
- create_library()
-
- # # Make Materials
- materials_file = openmc.Materials()
-
- mat_names = ['vec beta', 'vec no beta', 'matrix beta', 'matrix no beta']
- macros = []
- mats = []
- for i in range(len(mat_names)):
- macros.append(openmc.Macroscopic('mat_' + str(i + 1)))
- mats.append(openmc.Material(name=mat_names[i]))
- mats[-1].set_density('macro', 1.0)
- mats[-1].add_macroscopic(macros[-1])
-
- materials_file += mats
-
- materials_file.cross_sections = '2g.h5'
-
- # # Make Geometry
- rad_outer = 929.45
- # Set a cell boundary to exist for every material above (exclude the 0)
- rads = np.linspace(0., rad_outer, len(mats) + 1, endpoint=True)[1:]
-
- # Instantiate Universe
- root = openmc.Universe(universe_id=0, name='root universe')
- cells = []
-
- surfs = []
- surfs.append(openmc.XPlane(x0=0., boundary_type='reflective'))
- for r, rad in enumerate(rads):
- if r == len(rads) - 1:
- surfs.append(openmc.XPlane(x0=rad, boundary_type='vacuum'))
- else:
- surfs.append(openmc.XPlane(x0=rad))
-
- # Instantiate Cells
- cells = []
- for c in range(len(surfs) - 1):
- cells.append(openmc.Cell())
- cells[-1].region = (+surfs[c] & -surfs[c + 1])
- cells[-1].fill = mats[c]
-
- # Register Cells with Universe
- root.add_cells(cells)
-
- # Instantiate a Geometry, register the root Universe, and export to XML
- geometry_file = openmc.Geometry(root)
-
- # # Make Settings
- # Instantiate a Settings object, set all runtime parameters
- settings_file = openmc.Settings()
- settings_file.energy_mode = "multi-group"
- settings_file.tabular_legendre = {'enable': False}
- settings_file.batches = 10
- settings_file.inactive = 5
- settings_file.particles = 1000
-
- # Build source distribution
- INF = 1000.
- bounds = [0., -INF, -INF, rads[0], INF, INF]
- uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:])
- settings_file.source = openmc.source.Source(space=uniform_dist)
-
- settings_file.output = {'summary': False}
-
- model = openmc.model.Model()
- model.geometry = geometry_file
- model.materials = materials_file
- model.settings = settings_file
-
- return model
-
-
class MGXSTestHarness(PyAPITestHarness):
def _cleanup(self):
super()._cleanup()
@@ -170,6 +98,9 @@ class MGXSTestHarness(PyAPITestHarness):
def test_mg_benchmark():
- model = create_model()
+ create_library()
+ model = slab_mg(num_regions=4, mat_names=['vec beta', 'vec no beta',
+ 'matrix beta', 'matrix no beta'])
+
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/regression_tests/mg_convert/test.py b/tests/regression_tests/mg_convert/test.py
index 1ace10c80..4cc6b656a 100755
--- a/tests/regression_tests/mg_convert/test.py
+++ b/tests/regression_tests/mg_convert/test.py
@@ -17,7 +17,7 @@ def build_mgxs_library(convert):
# Instantiate the energy group data
groups = openmc.mgxs.EnergyGroups(group_edges=[1e-5, 0.625, 20.0e6])
- # Instantiate the 7-group (C5G7) cross section data
+ # Instantiate the 2-group (C5G7) cross section data
uo2_xsdata = openmc.XSdata('UO2', groups)
uo2_xsdata.order = 2
uo2_xsdata.set_total([2., 2.])
diff --git a/tests/regression_tests/mg_legendre/inputs_true.dat b/tests/regression_tests/mg_legendre/inputs_true.dat
index 754808095..ad3b434e6 100644
--- a/tests/regression_tests/mg_legendre/inputs_true.dat
+++ b/tests/regression_tests/mg_legendre/inputs_true.dat
@@ -1,44 +1,31 @@
- |
- |
- |
+ |
-
-
-
-
-
-
-
+
- ../../1d_mgxs.h5
-
+ 2g.h5
+
-
-
-
-
-
-
-
-
-
+
eigenvalue
- 100
+ 1000
10
5
- 0.0 0.0 0.0 10.0 10.0 5.0
+ 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0
+
multi-group
false
diff --git a/tests/regression_tests/mg_legendre/results_true.dat b/tests/regression_tests/mg_legendre/results_true.dat
index d0f8c319e..4a9d98237 100644
--- a/tests/regression_tests/mg_legendre/results_true.dat
+++ b/tests/regression_tests/mg_legendre/results_true.dat
@@ -1,2 +1,2 @@
k-combined:
-1.110122E+00 2.549637E-02
+9.934975E-01 2.679669E-02
diff --git a/tests/regression_tests/mg_legendre/test.py b/tests/regression_tests/mg_legendre/test.py
index 5a57f758e..b5a05c706 100644
--- a/tests/regression_tests/mg_legendre/test.py
+++ b/tests/regression_tests/mg_legendre/test.py
@@ -1,10 +1,54 @@
+import os
+
+import numpy as np
+
+import openmc
from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
+def create_library():
+ # Instantiate the energy group data and file object
+ groups = openmc.mgxs.EnergyGroups(group_edges=[0.0, 0.625, 20.0e6])
+
+ mg_cross_sections_file = openmc.MGXSLibrary(groups)
+
+ # Make the base, isotropic data
+ nu = [2.50, 2.50]
+ fiss = np.array([0.002817, 0.097])
+ capture = [0.008708, 0.02518]
+ absorption = np.add(capture, fiss)
+ scatter = np.array(
+ [[[0.31980, 0.06694], [0.004555, -0.0003972]],
+ [[0.00000, 0.00000], [0.424100, 0.05439000]]])
+ total = [0.33588, 0.54628]
+ chi = [1., 0.]
+
+ mat_1 = openmc.XSdata('mat_1', groups)
+ mat_1.order = 1
+ mat_1.set_nu_fission(np.multiply(nu, fiss))
+ mat_1.set_absorption(absorption)
+ mat_1.set_scatter_matrix(scatter)
+ mat_1.set_total(total)
+ mat_1.set_chi(chi)
+ mg_cross_sections_file.add_xsdata(mat_1)
+
+ # Write the file
+ mg_cross_sections_file.export_to_hdf5('2g.h5')
+
+
+class MGXSTestHarness(PyAPITestHarness):
+ def _cleanup(self):
+ super()._cleanup()
+ f = '2g.h5'
+ if os.path.exists(f):
+ os.remove(f)
+
+
def test_mg_legendre():
- model = slab_mg(reps=['iso'])
+ create_library()
+ model = slab_mg()
model.settings.tabular_legendre = {'enable': False}
harness = PyAPITestHarness('statepoint.10.h5', model)
diff --git a/tests/regression_tests/mg_max_order/inputs_true.dat b/tests/regression_tests/mg_max_order/inputs_true.dat
index 023d468d4..2ac83852c 100644
--- a/tests/regression_tests/mg_max_order/inputs_true.dat
+++ b/tests/regression_tests/mg_max_order/inputs_true.dat
@@ -1,44 +1,34 @@
- |
- |
- |
+ |
-
-
-
-
-
-
-
+
- ../../1d_mgxs.h5
-
+ 2g.h5
+
-
-
-
-
-
-
-
-
-
+
eigenvalue
- 100
+ 1000
10
5
- 0.0 0.0 0.0 10.0 10.0 5.0
+ 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0
+
multi-group
1
+
+ false
+
diff --git a/tests/regression_tests/mg_max_order/results_true.dat b/tests/regression_tests/mg_max_order/results_true.dat
index adfcd44a8..4a9d98237 100644
--- a/tests/regression_tests/mg_max_order/results_true.dat
+++ b/tests/regression_tests/mg_max_order/results_true.dat
@@ -1,2 +1,2 @@
k-combined:
-1.074551E+00 1.871525E-02
+9.934975E-01 2.679669E-02
diff --git a/tests/regression_tests/mg_max_order/test.py b/tests/regression_tests/mg_max_order/test.py
index 20cc4f805..97d3f57d7 100644
--- a/tests/regression_tests/mg_max_order/test.py
+++ b/tests/regression_tests/mg_max_order/test.py
@@ -1,10 +1,55 @@
+import os
+
+import numpy as np
+
+import openmc
from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
+def create_library():
+ # Instantiate the energy group data and file object
+ groups = openmc.mgxs.EnergyGroups(group_edges=[0.0, 0.625, 20.0e6])
+
+ mg_cross_sections_file = openmc.MGXSLibrary(groups)
+
+ # Make the base, isotropic data
+ nu = [2.50, 2.50]
+ fiss = np.array([0.002817, 0.097])
+ capture = [0.008708, 0.02518]
+ absorption = np.add(capture, fiss)
+ scatter = np.array(
+ [[[0.31980, 0.06694, 0.003], [0.004555, -0.0003972, 0.00002]],
+ [[0.00000, 0.00000, 0.000], [0.424100, 0.05439000, 0.0025]]])
+ total = [0.33588, 0.54628]
+ chi = [1., 0.]
+
+ mat_1 = openmc.XSdata('mat_1', groups)
+ mat_1.order = 2
+ mat_1.set_nu_fission(np.multiply(nu, fiss))
+ mat_1.set_absorption(absorption)
+ mat_1.set_scatter_matrix(scatter)
+ mat_1.set_total(total)
+ mat_1.set_chi(chi)
+ mg_cross_sections_file.add_xsdata(mat_1)
+
+ # Write the file
+ mg_cross_sections_file.export_to_hdf5('2g.h5')
+
+
+class MGXSTestHarness(PyAPITestHarness):
+ def _cleanup(self):
+ super()._cleanup()
+ f = '2g.h5'
+ if os.path.exists(f):
+ os.remove(f)
+
+
def test_mg_max_order():
- model = slab_mg(reps=['iso'])
+ create_library()
+ model = slab_mg()
model.settings.max_order = 1
+
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/regression_tests/mg_nuclide/__init__.py b/tests/regression_tests/mg_nuclide/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/regression_tests/mg_nuclide/inputs_true.dat b/tests/regression_tests/mg_nuclide/inputs_true.dat
deleted file mode 100644
index e11b9e3f0..000000000
--- a/tests/regression_tests/mg_nuclide/inputs_true.dat
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ../../1d_mgxs.h5
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- eigenvalue
- 100
- 10
- 5
-
-
- 0.0 0.0 0.0 10.0 10.0 5.0
-
-
- multi-group
-
diff --git a/tests/regression_tests/mg_nuclide/results_true.dat b/tests/regression_tests/mg_nuclide/results_true.dat
deleted file mode 100644
index ddb57d00b..000000000
--- a/tests/regression_tests/mg_nuclide/results_true.dat
+++ /dev/null
@@ -1,2 +0,0 @@
-k-combined:
-1.073147E+00 1.602384E-02
diff --git a/tests/regression_tests/mg_nuclide/test.py b/tests/regression_tests/mg_nuclide/test.py
deleted file mode 100644
index 44206ef28..000000000
--- a/tests/regression_tests/mg_nuclide/test.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from openmc.examples import slab_mg
-
-from tests.testing_harness import PyAPITestHarness
-
-
-def test_mg_nuclide():
- model = slab_mg(as_macro=False)
- harness = PyAPITestHarness('statepoint.10.h5', model)
- harness.main()
diff --git a/tests/regression_tests/mg_survival_biasing/inputs_true.dat b/tests/regression_tests/mg_survival_biasing/inputs_true.dat
index 4bc79d48e..5ece3ce9f 100644
--- a/tests/regression_tests/mg_survival_biasing/inputs_true.dat
+++ b/tests/regression_tests/mg_survival_biasing/inputs_true.dat
@@ -1,98 +1,34 @@
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
+ |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
- ../../1d_mgxs.h5
-
+ 2g.h5
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
eigenvalue
- 100
+ 1000
10
5
- 0.0 0.0 0.0 10.0 10.0 5.0
+ 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0
+
multi-group
true
+
+ false
+
diff --git a/tests/regression_tests/mg_survival_biasing/results_true.dat b/tests/regression_tests/mg_survival_biasing/results_true.dat
index b20d63288..ebe98679f 100644
--- a/tests/regression_tests/mg_survival_biasing/results_true.dat
+++ b/tests/regression_tests/mg_survival_biasing/results_true.dat
@@ -1,2 +1,2 @@
k-combined:
-1.080832E+00 1.336780E-02
+9.979905E-01 6.207495E-03
diff --git a/tests/regression_tests/mg_survival_biasing/test.py b/tests/regression_tests/mg_survival_biasing/test.py
index 3c6c77a37..5d75611a9 100644
--- a/tests/regression_tests/mg_survival_biasing/test.py
+++ b/tests/regression_tests/mg_survival_biasing/test.py
@@ -1,10 +1,55 @@
+import os
+
+import numpy as np
+
+import openmc
from openmc.examples import slab_mg
from tests.testing_harness import PyAPITestHarness
+def create_library():
+ # Instantiate the energy group data and file object
+ groups = openmc.mgxs.EnergyGroups(group_edges=[0.0, 0.625, 20.0e6])
+
+ mg_cross_sections_file = openmc.MGXSLibrary(groups)
+
+ # Make the base, isotropic data
+ nu = [2.50, 2.50]
+ fiss = np.array([0.002817, 0.097])
+ capture = [0.008708, 0.02518]
+ absorption = np.add(capture, fiss)
+ scatter = np.array(
+ [[[0.31980, 0.06694], [0.004555, -0.0003972]],
+ [[0.00000, 0.00000], [0.424100, 0.05439000]]])
+ total = [0.33588, 0.54628]
+ chi = [1., 0.]
+
+ mat_1 = openmc.XSdata('mat_1', groups)
+ mat_1.order = 1
+ mat_1.set_nu_fission(np.multiply(nu, fiss))
+ mat_1.set_absorption(absorption)
+ mat_1.set_scatter_matrix(scatter)
+ mat_1.set_total(total)
+ mat_1.set_chi(chi)
+ mg_cross_sections_file.add_xsdata(mat_1)
+
+ # Write the file
+ mg_cross_sections_file.export_to_hdf5('2g.h5')
+
+
+class MGXSTestHarness(PyAPITestHarness):
+ def _cleanup(self):
+ super()._cleanup()
+ f = '2g.h5'
+ if os.path.exists(f):
+ os.remove(f)
+
+
def test_mg_survival_biasing():
+ create_library()
model = slab_mg()
model.settings.survival_biasing = True
+
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/regression_tests/mg_tallies/inputs_true.dat b/tests/regression_tests/mg_tallies/inputs_true.dat
index 7b5067014..a9b821c56 100644
--- a/tests/regression_tests/mg_tallies/inputs_true.dat
+++ b/tests/regression_tests/mg_tallies/inputs_true.dat
@@ -1,112 +1,48 @@
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
+ |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
- ../../1d_mgxs.h5
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ 2g.h5
+
+
+
eigenvalue
- 100
+ 1000
10
5
- 0.0 0.0 0.0 10.0 10.0 5.0
+ 0.0 -1000.0 -1000.0 929.45 1000.0 1000.0
+
multi-group
+
+ false
+
- 1 1 10
+ 10 1 1
0.0 0.0 0.0
- 10 10 5
+ 929.45 1000 1000
1
- 1 2 3 4 5 6 7 8 9 10 11 12
+ 1
0.0 20000000.0
@@ -115,10 +51,10 @@
0.0 20000000.0
- 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0
+ 0.0 0.625 20000000.0
- 1e-05 0.0635 10.0 100.0 1000.0 500000.0 1000000.0 20000000.0
+ 0.0 0.625 20000000.0
5
@@ -170,60 +106,60 @@
5
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
total absorption fission nu-fission
analog
5
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
total absorption fission nu-fission
tracklength
6 1
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
total absorption fission nu-fission scatter nu-scatter
analog
6 1
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
total absorption fission nu-fission
collision
6 1
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
total absorption fission nu-fission
tracklength
6 1 2
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
scatter nu-scatter nu-fission
6 3
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
total absorption fission nu-fission scatter nu-scatter
analog
6 3
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
total absorption fission nu-fission
collision
6 3
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
total absorption fission nu-fission
tracklength
6 3 4
- uo2_ang uo2_ang_mu uo2_iso uo2_iso_mu clad_ang clad_ang_mu clad_iso clad_iso_mu lwtr_ang lwtr_ang_mu lwtr_iso lwtr_iso_mu
+ mat_1
scatter nu-scatter nu-fission
diff --git a/tests/regression_tests/mg_tallies/results_true.dat b/tests/regression_tests/mg_tallies/results_true.dat
index 87470bdf4..78a5883fe 100644
--- a/tests/regression_tests/mg_tallies/results_true.dat
+++ b/tests/regression_tests/mg_tallies/results_true.dat
@@ -1 +1 @@
-9183f8b191f2e62334f992acd865d29e3f4e3f871a6df498e280fc4e2d91f2d2d20c732fbd75fa88e2e8c576f86e744f7655af6bb9da66e9b28b1009c8742899
\ No newline at end of file
+41ea1f6b17c58a8141921af2f1d044eda93f3a9bca9463ee023af2e9865da613ace90fc8a25b42edde128ed827182ea9df0fe09d9b7887282d0ec092692cf717
\ No newline at end of file
diff --git a/tests/regression_tests/mg_tallies/test.py b/tests/regression_tests/mg_tallies/test.py
index 8952cc4ad..26d53c230 100644
--- a/tests/regression_tests/mg_tallies/test.py
+++ b/tests/regression_tests/mg_tallies/test.py
@@ -1,23 +1,66 @@
+import os
+
+import numpy as np
+
import openmc
from openmc.examples import slab_mg
from tests.testing_harness import HashedPyAPITestHarness
+def create_library():
+ # Instantiate the energy group data and file object
+ groups = openmc.mgxs.EnergyGroups(group_edges=[0.0, 0.625, 20.0e6])
+
+ mg_cross_sections_file = openmc.MGXSLibrary(groups)
+
+ # Make the base, isotropic data
+ nu = [2.50, 2.50]
+ fiss = np.array([0.002817, 0.097])
+ capture = [0.008708, 0.02518]
+ absorption = np.add(capture, fiss)
+ scatter = np.array(
+ [[[0.31980, 0.06694], [0.004555, -0.0003972]],
+ [[0.00000, 0.00000], [0.424100, 0.05439000]]])
+ total = [0.33588, 0.54628]
+ chi = [1., 0.]
+
+ mat_1 = openmc.XSdata('mat_1', groups)
+ mat_1.order = 1
+ mat_1.set_nu_fission(np.multiply(nu, fiss))
+ mat_1.set_absorption(absorption)
+ mat_1.set_scatter_matrix(scatter)
+ mat_1.set_total(total)
+ mat_1.set_chi(chi)
+ mg_cross_sections_file.add_xsdata(mat_1)
+
+ # Write the file
+ mg_cross_sections_file.export_to_hdf5('2g.h5')
+
+
+class MGXSTestHarness(HashedPyAPITestHarness):
+ def _cleanup(self):
+ super()._cleanup()
+ f = '2g.h5'
+ if os.path.exists(f):
+ os.remove(f)
+
+
def test_mg_tallies():
- model = slab_mg(as_macro=False)
+ create_library()
+ model = slab_mg()
# Instantiate a tally mesh
mesh = openmc.Mesh(mesh_id=1)
mesh.type = 'regular'
- mesh.dimension = [1, 1, 10]
+ mesh.dimension = [10, 1, 1]
mesh.lower_left = [0.0, 0.0, 0.0]
- mesh.upper_right = [10, 10, 5]
+ mesh.upper_right = [929.45, 1000, 1000]
# Instantiate some tally filters
energy_filter = openmc.EnergyFilter([0.0, 20.0e6])
energyout_filter = openmc.EnergyoutFilter([0.0, 20.0e6])
- energies = [1e-5, 0.0635, 10.0, 1.0e2, 1.0e3, 0.5e6, 1.0e6, 20.0e6]
+ energies = [0.0, 0.625, 20.0e6]
matching_energy_filter = openmc.EnergyFilter(energies)
matching_eout_filter = openmc.EnergyoutFilter(energies)
mesh_filter = openmc.MeshFilter(mesh)