OpenMC/tests/regression_tests/particle_production_fission/test.py
John Tramm 0169fd9226
Shared Secondary Particle Bank (#3863)
Co-authored-by: John Tramm <jtramm@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
Co-authored-by: Copilot <copilot@github.com>
2026-05-19 23:23:10 -05:00

49 lines
1.7 KiB
Python

import openmc
import pytest
from openmc.utility_funcs import change_directory
from tests.testing_harness import PyAPITestHarness
@pytest.mark.parametrize("shared_secondary,subdir", [
(False, "local"),
(True, "shared"),
])
def test_particle_production_fission(shared_secondary, subdir):
"""Fixed-source model with fissionable material to test that
ParticleProductionFilter correctly counts fission-born neutrons,
with both local and shared secondary bank modes."""
with change_directory(subdir):
openmc.reset_auto_ids()
model = openmc.Model()
mat = openmc.Material()
mat.set_density('g/cm3', 18.0)
mat.add_nuclide('U235', 1.0)
model.materials.append(mat)
sph = openmc.Sphere(r=5.0, boundary_type='vacuum')
cell = openmc.Cell(fill=mat, region=-sph)
model.geometry = openmc.Geometry([cell])
source = openmc.IndependentSource()
source.energy = openmc.stats.delta_function(1.0e6)
model.settings.particles = 100
model.settings.run_mode = 'fixed source'
model.settings.batches = 2
model.settings.source = source
model.settings.create_fission_neutrons = True
model.settings.shared_secondary_bank = shared_secondary
# ParticleProductionFilter tracking fission neutron production
ppf = openmc.ParticleProductionFilter(['neutron'])
neutron_filter = openmc.ParticleFilter(['neutron'])
tally = openmc.Tally()
tally.filters = [neutron_filter, ppf]
tally.scores = ['events']
tally.estimator = 'analog'
model.tallies = [tally]
harness = PyAPITestHarness('statepoint.2.h5', model)
harness.main()