-
Notifications
You must be signed in to change notification settings - Fork 596
[Point Detector] Add distribution get_pdf functionality #3550
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
base: develop
Are you sure you want to change the base?
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.
Nice work @itay-space!
My review focus more on the code structure side of things.
I did not check the maths.
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
|
@GuySten , Thanks for the suggestion! These classes already rely on two independent 1D distributions (polar and azimuthal), and the evaluate methods are implemented at that level. The sphere distributions just combine those underlying 1D PDFs, so the functionality is already covered. |
|
@itay-space, the conversion is not trivial because of the reference direction, so I think that adding this functionality is worth while. |
|
@GuySten I’m not sure why this would be different from the other cases (I can’t see it right now), but sure, go ahead and add the functionality. I have no objections. Thanks! |
|
I am waiting for #3582 to be merged to add the functionality I talked about. |
|
@paulromano, I am reminding you to look at this PR when you have some time. |
Thanks for breaking out this small PR and great to see it is now merged |
|
I've added the functionality I wanted. @paulromano, could you take some time to review this PR? You asked to review this RP before we are merging it, and I want to merge this PR and continue to the next parts of the point detector work. |
|
@GuySten Yes, I will try to get to it this week |
paulromano
left a comment
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.
@itay-space @GuySten Just wanted to let you know I am starting to go through this PR. It's not as simple as I was hoping as there is quite a bit of effectively duplicated code in the AngleEnergy classes. I'll see what I can do with it but let me know if either of you have ideas.
|
I simplified this PR significantly. |
|
@paulromano, could you take some time to look at this PR? |
|
Thanks for the ping @GuySten. I'm working through PR reviews this week and will try to get to this one. |
src/secondary_thermal.cpp
Outdated
| vector<double> energies_cut(energies.begin(), energies.begin() + i + 1); | ||
| vector<double> factors_cut(factors.begin(), factors.begin() + i + 1); | ||
|
|
||
| vector<double> mu_vector_rev; | ||
| std::transform(energies_cut.begin(), energies_cut.end(), | ||
| std::back_inserter(mu_vector_rev), | ||
| [E_in](double Ei) { return 1 - 2 * Ei / E_in; }); | ||
| vector<double> mu_vector(mu_vector_rev.rbegin(), mu_vector_rev.rend()); | ||
|
|
||
| auto f = xt::adapt(factors_cut, { | ||
| factors_cut.size(), | ||
| }); | ||
| auto weights = xt::diff(f); | ||
| weights /= xt::sum(weights); | ||
| vector<double> w(weights.begin(), weights.end()); |
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.
The use of std::vector here results in dynamic memory allocation, which is undesirable within any code that appears within the transport loop since it is threaded. @itay-space @GuySten can you guys see if you can restructure this to avoid the use of new vector objects?
|
@paulromano, I've managed to reduce the number of vector allocations to 2. |
|
@paulromano, I have some ideas of how to reduce the memory allocations further Are you okay with merging it as is and open an issue to improve memory allocations in the future? |
Description
This PR is the first step in breaking down the point detector tally project into smaller, reviewable pieces, following the large PR #3109
and the paper Development and benchmarking of a point detector in OpenMC.
As suggested during the earlier discussion (thanks @GuySten, @gridley, @shimwell !), the natural starting point is to add the ability to correctly calculate PDFs on the C++ side.
Accordingly, this PR introduces the get_pdf implementations for the distribution classes. This is essentially a clean cut from the original large PR, with the goal of keeping the scope focused and review manageable.
We plan to follow up with tests and additional pieces of the point detector work in subsequent PRs.
Checklist