From f85dc9dc9b52f38d151e82cd5bdcb9475a66c250 Mon Sep 17 00:00:00 2001 From: Ethan Peterson Date: Thu, 10 Mar 2022 13:35:41 -0500 Subject: [PATCH 1/2] adding helper method for EnergyFilter creation --- openmc/filter.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/openmc/filter.py b/openmc/filter.py index df06d713fe..be3d976799 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -1324,6 +1324,20 @@ class EnergyFilter(RealFilter): cv.check_greater_than('filter value', v0, 0., equality=True) cv.check_greater_than('filter value', v1, 0., equality=True) + @classmethod + def from_group_structure(cls, group_structure): + """Construct an EnergyFilter instance from a standard group structure. + + Parameters + ---------- + group_structure : str + Name of the group structure. Must be a valid key of + openmc.mgxs.GROUP_STRUCTURES dictionary. + + """ + + return cls(openmc.mgxs.GROUP_STRUCTURES[group_structure.upper()]) + class EnergyoutFilter(EnergyFilter): """Bins tally events based on outgoing particle energy. From da53fd6e6e19edd86d090559d8714d0b3227d1c6 Mon Sep 17 00:00:00 2001 From: Ethan Peterson Date: Thu, 10 Mar 2022 15:37:18 -0500 Subject: [PATCH 2/2] added unit test --- tests/unit_tests/test_filters.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unit_tests/test_filters.py b/tests/unit_tests/test_filters.py index 49526ac673..6b344b827e 100644 --- a/tests/unit_tests/test_filters.py +++ b/tests/unit_tests/test_filters.py @@ -240,3 +240,9 @@ def test_first_moment(run_in_tmpdir, box_model): assert first_score(sph_scat_tally) == scatter assert first_score(sph_flux_tally) == approx(flux) assert first_score(zernike_tally) == approx(scatter) + + +def test_energy(): + f = openmc.EnergyFilter.from_group_structure('CCFE-709') + assert f.bins.shape == (709, 2) + assert len(f.values) == 710