Skip to content

Extend ParticleProductionFilter to support multiple particle types#3780

Open
paulromano wants to merge 7 commits intoopenmc-dev:developfrom
paulromano:particle-prod-multiple
Open

Extend ParticleProductionFilter to support multiple particle types#3780
paulromano wants to merge 7 commits intoopenmc-dev:developfrom
paulromano:particle-prod-multiple

Conversation

@paulromano
Copy link
Contributor

Description

This PR extends ParticleProductionFilter to allow tallying production of multiple secondary particle types in a single filter, avoiding the need for multiple tallies when tracking different secondary particles. The constructor has been changed from ParticleProductionFilter(particle, bins) to ParticleProductionFilter(particles, energies=None), where particles accepts a single particle or list of particles, and energies is now optional (defaulting to None for no energy binning). The filter becomes two-dimensional with shape (n_particles, n_energy_bins) and bins are flattened as particle_index * n_energy_bins + energy_bin. Using the filter to get particle production rates looks like:

# Track photon and neutron production in 3 energy groups
production_filter = openmc.ParticleProductionFilter(
    particles=['photon', 'neutron'],
    energies=[0.0, 1e5, 1e6, 20e6]
)

tally = openmc.Tally()
tally.filters = [production_filter]
tally.scores = ['events']

One issue that needed to be fixed was that the "events" score was hard-coded to be a value of 1.0 per tally contribution regardless of filter weights. Because ParticleProductionFilter sets the filter weight to the weight of the secondary particle, that needs to be accounted for. I've updated the logic so that the unity value gets multiplied by the filter weight before accumulation.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant