-
Notifications
You must be signed in to change notification settings - Fork 35
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 helper functions for sampling/calculating direction in interactors #1301
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Amanda! It's definitely an improvement to unify these implementations (though there might be a couple in the neutron physics too, and eventually optical as well, so perhaps we should move the helper utils to phys
?)
inline CELER_FUNCTION Real3 calc_exiting_direction(real_type inc_momentum, | ||
real_type out_momentum, | ||
Real3 const& inc_dir, | ||
Real3 const& out_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about a little detail helper:
struct Momentum {
real_type magnitude;
Real3 const& direction;
};
so the components are more strongly associated:
result.direction = calc_exiting_direction(
{inc_momentum_.value(), inc_direction_},
{gamma_energy_.value(), secondary_->direction});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that.
* Sample azimuthal angle, calculate Cartesian vector, and rotate direction. | ||
*/ | ||
struct CartesianTransformSampler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like ...
* Sample azimuthal angle, calculate Cartesian vector, and rotate direction. | |
*/ | |
struct CartesianTransformSampler | |
* Sample an exiting direction from a polar cosine and incident direction. | |
* | |
* Combine an already-sampled change in polar cosine (dot product of incident | |
* and exiting) with a sampled uniform azimuthal direction, and apply that | |
* rotation to the original track's incident direction. | |
*/ | |
struct ExitingDirectionSampler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, thanks!
src/celeritas/phys/PhysicsUtils.hh
Outdated
@@ -3,54 +3,62 @@ | |||
// See the top-level COPYRIGHT file for details. | |||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | |||
//---------------------------------------------------------------------------// | |||
//! \file celeritas/em/interactor/detail/Utils.hh | |||
//! \file celeritas/phys/PhysicsUtils.hh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about InteractionUtils? 😅 or is that the final "bring me a rock" that will break the camel's back...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did ask for it... sounds good!
src/celeritas/phys/PhysicsUtils.hh
Outdated
*/ | ||
inline CELER_FUNCTION Real3 calc_exiting_direction(Momentum inc_momentum, | ||
Momentum out_momentum) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we take the opportunity to add assertions on magnitude > 0
? (Or >= 0?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! That's an itch that I've wanted to scratch since we finished the initial round of EM physics.
As discussed in #1291, this adds a couple helper functions for the physics interactors. Any suggestions for better names would be welcome.