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

Add random selector helper class #217

Merged
merged 7 commits into from Apr 20, 2021

Conversation

sethrj
Copy link
Member

@sethrj sethrj commented Apr 16, 2021

This may be a bit over-engineered, but it abstracts the selection of a discrete PDF that's calculated on-the-fly. I'd intended to use it for the ElementSelector, Livermore, and AtomicRelaxation; but the element selector would be ugly (either re-instantiating the Selector at each sample, or requiring ugly templates to make it class data, or rephrasing it to be a function), and the Livermore/Atomic cases allow a "remainder" for the PDFs -- it's OK if they don't add up to one.

Regardless of those absences, I've implemented the selector in PhysicsStepUtils (which makes the code much cleaner) and replaced the awkward construction in the Rayleigh sampler with the simpler Selector. It is slightly less efficient (requiring one more subtraction) but I can't imagine that being a big deal.

For the purpose of testing, I wrote a SequenceEngine that allows us to use an arbitrary "random" number sequence that enables fine-grained testing of random distributions, and could also be used in our Interactor tests to make sure all of the rejection cases behave exactly as expected.

@sethrj sethrj added the core Software engineering infrastructure label Apr 16, 2021
@sethrj sethrj mentioned this pull request Apr 17, 2021
23 tasks
Copy link
Contributor

@amandalund amandalund left a comment

Choose a reason for hiding this comment

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

Nice additions, @sethrj! Looks good to me.

@sethrj sethrj merged commit e06c10f into celeritas-project:master Apr 20, 2021
@sethrj sethrj deleted the random-selector branch April 20, 2021 06:30
Comment on lines +50 to +51
v -= i;
return v;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the advantage of the code use over 'just'

   return v - i;

since 'v' does not appear to be a reference?

Copy link
Member Author

Choose a reason for hiding this comment

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

Requires defining an extra operator for the detail iterator

@sethrj sethrj added the enhancement New feature or request label Feb 18, 2023
@sethrj sethrj added physics Particles, processes, and stepping algorithms and removed core Software engineering infrastructure labels Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request physics Particles, processes, and stepping algorithms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants