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

Single crystal PG powder fix #1521

Merged
merged 4 commits into from
Nov 21, 2023
Merged

Single crystal PG powder fix #1521

merged 4 commits into from
Nov 21, 2023

Conversation

mads-bertelsen
Copy link
Contributor

The PG and powder mode for the Single_crystal component rotates the neutron velocities randomly to simulate the random orientation of crystallites. This change of coordinate system was not reverted when propagating the neutron to the scattering position inside of the crystal, and it could thus happen the ray was moved outside of the crystal.

The code was fixed by storing and using the velocity in the component frame and using that just for the propagation when one of the two modes are used.

The Single_crystal_process in Union was checked for the same problem, it was not relevant in that implementation, but other updates the powder system was moved to the Union equivalent, as it now rotates around three directions instead of just two, which is necessary to make a completely random crystal orientation in the powder.

Mads Bertelsen added 2 commits November 20, 2023 15:32
…stal.

The reason was that the crystal was propagated to its scattering position within the crystal using the crystalite frame instead of the component
frame, which thus can result in a position outside the crystal. The fix is simply to save the velocity in the component frame and reuse that for
the PROP_DT call.
…ns for the powder mode instead of just one.
@willend
Copy link
Contributor

willend commented Nov 21, 2023

I ran a few tests with Test_Monochromators and Test_SX and all looks good.
Did a reset of some whitespace to original structure.

Copy link
Contributor

@willend willend left a comment

Choose a reason for hiding this comment

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

I believe the changes are OK, but have pushed a few reverts of modified whitespace. (This in my point of view always clutters what the meaning/implication of the "actual" fix is. :-) )

@willend willend merged commit 239b2a2 into main Nov 21, 2023
@willend willend deleted the Single_crystal_PG_powder_fix branch October 7, 2024 11:15
@farhi
Copy link
Contributor

farhi commented Oct 11, 2024

This issue fix has created bug #1732
So the fix is not relevant, and it is probably better to keep some escaping neutrons, rather than having no powder mode.

farhi added a commit to farhi/McCode that referenced this pull request Oct 11, 2024
willend added a commit that referenced this pull request Oct 11, 2024
McStas: Fix #1732: Single_crystal powder mode was broken by #1521
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.

3 participants