Extend ParticleProductionFilter to support multiple particle types#3780
Extend ParticleProductionFilter to support multiple particle types#3780paulromano wants to merge 14 commits intoopenmc-dev:developfrom
Conversation
pshriwise
left a comment
There was a problem hiding this comment.
Nice!! New valuable capability fits pretty cleanly into the tally system.
A few minor inline comments from me and one larger thought:
On the C++ side the ParticleProductionFilter inherits from EnergyFilter, but we re-implement almost every method of the parent class. From what I can see, what is reused from the EnergyFilter class is the bins_ vector and use of the set_bins method, which sets the matches_transport_groups attribute that isn't used in the new class. In contrast to the EnergyOutFilter that re-implements only a couple of methods of the EnergyFilter, this inheritance feels more awkward and like it might warrant it's own set of source files. Not a deal breaker for me on merging this, just sharing observations and something to consider.
|
@pshriwise Your comments have been addressed. Let me know if you have any further requests! |
Description
This PR extends
ParticleProductionFilterto 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 fromParticleProductionFilter(particle, bins)toParticleProductionFilter(particles, energies=None), whereparticlesaccepts a single particle or list of particles, andenergiesis now optional (defaulting toNonefor no energy binning). The filter becomes two-dimensional with shape(n_particles, n_energy_bins)and bins are flattened asparticle_index * n_energy_bins + energy_bin. Using the filter to get particle production rates looks like: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
ParticleProductionFiltersets 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