mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
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>
49 lines
1.7 KiB
Python
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()
|