Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source rejection by domain (cell, material, universe) #2235

Merged
merged 6 commits into from
Oct 3, 2022

Conversation

paulromano
Copy link
Contributor

This PR implements the ability to specify a set of a cells, materials, or universes that are used to "filter" sampled source sites and closes #1829. The way it works is:

  1. The user specifies Source(..., domains=[...]), where domains is a list of either cells, materials, or universes that will be used for rejection.
  2. At runtime, positions will be sampled from whatever spatial distribution was specified (e.g., openmc.stats.Box), but then those points will be checked against the list of domains, if present. If a point is not within the specified list of domains, it will be rejected.

The attribute handling for the Source class follows the same design as for the VolumeCalculation class. Namely, even though the constructor specifies domains, this is turned into domain_type and domain_ids attributes. This is done so that a Source object doesn't have to be inextricably linked to actual geometry objects.

@pshriwise and I discussed other overall design alternatives for this feature. In particular, we discussed the possibility of having a much more complex system based on rejection filters, which could be generalized to other uses (for example, rejection based on the energy or angle). We ended up steering away from that idea as it seemed a bit over-engineered, and our guess was that 99% of practical use-cases would just be simple spatial rejection, which is handled by a simpler design here.

@pshriwise
Copy link
Contributor

@paulromano what would you think of having attributes for each domain type? This would allow rejection on a mixture of domain types if a user wanted to reject source sites for an entire universe and a few specific cells in another universe, for example.

@paulromano
Copy link
Contributor Author

@pshriwise I did consider that, but it didn't seem to me that it would be worth the extra complexity. The case of combining a universe and some other cells could also be represented by using only cells.

@pshriwise
Copy link
Contributor

@pshriwise I did consider that, but it didn't seem to me that it would be worth the extra complexity. The case of combining a universe and some other cells could also be represented by using only cells.

Hrmmm yeah that's a fair point -- either of the material or unvierse domain types can be represented equivalently using a set of cells. It's also consistent with how we handle volume calculations I suppose. I'm on board 😃

Co-authored-by: Jonathan Shimwell <drshimwell@gmail.com>
Co-authored-by: Jonathan Shimwell <drshimwell@gmail.com>
Copy link
Contributor

@pshriwise pshriwise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is sure to be a crowd-pleaser 🎉 I believe we've gotten requests for this feature a number of times. Some small comments from me here.

src/source.cpp Outdated Show resolved Hide resolved
src/source.cpp Outdated Show resolved Hide resolved
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
@pshriwise
Copy link
Contributor

Thank you @paulromano!

@pshriwise pshriwise merged commit 47488ec into openmc-dev:develop Oct 3, 2022
@paulromano paulromano deleted the source-rejection branch October 3, 2022 16:27
@pshriwise pshriwise mentioned this pull request Nov 6, 2023
5 tasks
@gridley gridley mentioned this pull request Mar 16, 2024
5 tasks
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.

Generic filter for rejecting sources points when sampling
3 participants