Repository navigation
Enable specifying reference direction for azimuthal angle in PolarAzimuthal distribution - #3582
Merged
Merged
Conversation
GuySten
marked this pull request as ready for review
September 25, 2025 11:09
4 of 5 tasks
Member
|
I noticed the point detector work would benefit from this PR and wondered if it is worth putting in a couple of tests. I can PR to your branch if that helps def test_reference_vwu_projection():
"""When a non-orthogonal vector is provided, the setter should project out
any component along reference_uvw so the stored vector is orthogonal.
"""
pa = stats.PolarAzimuthal() # default reference_uvw == (0, 0, 1)
# Provide a vector that is not orthogonal to (0,0,1)
pa.reference_vwu = (2.0, 0.5, 0.3)
reference_v = np.asarray(pa.reference_vwu)
reference_u = np.asarray(pa.reference_uvw)
# reference_v should be orthogonal to reference_u
assert abs(np.dot(reference_v, reference_u)) < 1e-6
def test_reference_vwu_normalization():
"""When a non-normalized vector is provided, the setter should normalize
the projected vector to unit length.
"""
pa = stats.PolarAzimuthal() # default reference_uvw == (0, 0, 1)
# Provide a vector that is neither orthogonal to (0,0,1) nor unit-length
pa.reference_vwu = (2.0, 0.5, 0.3)
reference_v = np.asarray(pa.reference_vwu)
# reference_v should be unit length
assert np.isclose(np.linalg.norm(reference_v), 1.0, atol=1e-12) |
Contributor
Author
|
Thanks @shimwell. I invite you to push the tests to my PR. |
Member
PR made GuySten#33 |
added ref vwu tests
Contributor
Author
|
@shimwell, are you interested in reviewing this PR as well? |
Member
|
Yes sorry I did take a look at everything and those tests (thanks for fixing) were the only thing I thought it was missing. So this looks good to me. LGTM |
shimwell
approved these changes
Nov 3, 2025
paulromano
reviewed
Nov 3, 2025
paulromano
left a comment
Contributor
There was a problem hiding this comment.
Sorry to chime in too late here -- the name reference_vwu doesn't really make sense to me. I'll submit a follow-on PR to suggest a new name.
apingegno
pushed a commit
to apingegno/openmc
that referenced
this pull request
May 7, 2026
…muthal distribution (openmc-dev#3582) Co-authored-by: shimwell <mail@jshimwell.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently the reference direction for the azimutal angle in PolarAzimuthal distribution is not clear.
This PR enable specifying the direction in the python API so it is clear what is going on and what is the direction that corresponds to a specific phi
Checklist