openmc icon indicating copy to clipboard operation
openmc copied to clipboard

Generic filter for rejecting sources points when sampling

Open shimwell opened this issue 4 years ago • 7 comments
trafficstars

As originally discussed on Discourse https://openmc.discourse.group/t/source-uniform-sampling-in-cell-of-given-material/1062

It would be great to add generic filter to allow the rejection of source points when being sampled during the creation of particles.

Source sampling should allow for rejection of the proposed sampled coordinates if the coordinates are not in a user specified material or not in a user specified cell.

While the generic source sampling filter would be separate to the distributions themselves it could be passed to the distributions and the distributions should make use of the filter to ascertain if the sampling point results in a neutron or not.

Perhaps the best distribution to demonstrate this on is the openmc.stats.Box distribution as it already has a similar feature.

This will allow us to make interesting shaped sources like the example picture below which shows source sampling randomly across a openmc.stats.Box rejecting sample points that don't appear within a certain material / cell

Screenshot from 2021-04-27 20-16-20

There are some related lines in OpenMC relating to a similar feature that allows sampling points to be rejected if they are not within a fissionable material with the only_fissionable keyword that might be useful for anyone considering this feature.

https://github.com/openmc-dev/openmc/blob/efcc0c158edcc3e389eb20a5c5ffc4e0a65ef554/src/distribution_spatial.cpp#L187-L204

https://github.com/openmc-dev/openmc/blob/efcc0c158edcc3e389eb20a5c5ffc4e0a65ef554/src/source.cpp#L171-L173

https://github.com/openmc-dev/openmc/blob/efcc0c158edcc3e389eb20a5c5ffc4e0a65ef554/openmc/stats/multivariate.py#L617-L716

shimwell avatar Apr 28 '21 18:04 shimwell

I've issued a bounty reward for this issue https://www.bountysource.com/issues/98138076-generic-filter-for-rejecting-sources-points-when-sampling

shimwell avatar Apr 28 '21 19:04 shimwell

Could the spawn probability be inhomogeneous and a function of x, y, z?

RemDelaporteMathurin avatar Jun 29 '22 14:06 RemDelaporteMathurin

I have a branch with this implemented -- just need to clean it up, make it a little more generic, and open a pull request. I should have it out there in the next few weeks.

paulromano avatar Aug 31 '22 16:08 paulromano

@paulromano in some applications, the probability of birth is not homogeneous (see this example). Do you think this feature would allow users to specify a probability distribution or strengths distributions?

RemDelaporteMathurin avatar Sep 01 '22 07:09 RemDelaporteMathurin

Yes that would also work, the feature provides a cell used to exclude birth locations outside of the volume. You can throw any distribution of points and it will cut out the ones that are not within the cell.

shimwell avatar Sep 01 '22 08:09 shimwell

Oh so the usage would "just" be 1) give a bunch of sources 2) it exclude the sources outside of this cell

I thought the usage would be 1) give a cell 2) openmc samples sources in random locations within that cell

RemDelaporteMathurin avatar Sep 01 '22 08:09 RemDelaporteMathurin

:+1: user provides openmc.Source or list of openmc.Source as normal, openmc samples particle birth coordinates then birth coordinates outside of cell/material are excluded. So not quite excluding entire openmc.Sources but particles of sources which is slightly different

Oh so the usage would "just" be 1) give a bunch of sources 2) it exclude the sources outside of this cell

This approach is handy as it works for complex cell shapes. This issue also requests exclusion by material as well which will be handy for DAGMC use case where we don't always know the cell ID

shimwell avatar Sep 01 '22 08:09 shimwell