-
Notifications
You must be signed in to change notification settings - Fork 31
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
bugfix in rotation angles and improved help of rotate_elem #713
Conversation
@oscarxblanco I did very quick check and it seems to be fine now, please let me know if this what you were expecting, thanks! |
Hi @swhite2401, In your new definition (counter-clock wise) positive pitch gives a positive vertical angle, but then, as you apply the rotation in the middle of the element you should have position components in T1 and T2 switching sign too. ring[0].T1=array([ 0. , 0. , **-0.0298004**wrongsign** , -0.20271004, 0. ,
0. ])
ring[0].T2=array([ 0. , 0. , **-0.0298004**wrongsign** , 0.20271004, 0. ,
0. ]) You could either go back to clock-wise definition and fix the bug in the angles, or, keep your new definition and fix the bug in the position components. I would suggest to fix the angle sign bug because pitch typically is defined to point downwards. Wrt to the help message
sounds misleading because the effective length could have a different meaning considering border effects and so on. I would suggest the following, or something similar
The help message still misses the information about the rotation pivot. I would suggest the following, or something similar
|
Thanks @oscarxblanco and sorry about the sign confusion... I have implemented the requested changes |
I have also fixed some unrelated PEP8 non conformity throughout the file |
Hi @swhite2401 , |
Ok , sorry I think I am going too fast on this because I am doing too many things at a time. Let me take a step back a redo the math, I will propose a consistent solution. To summarize the situation: |
So looking back at this in details and what was done in the past it seems only the sign of the yaw was inconsistent with the convention defined in the help. The terms relating to pitch and yaw in the R matrices are there just to cancel the energy dependency on the rotation angle that we would get by using T1, T2 only. Vector T:
However 2nd and 4th coordinates are, not angles but momenta. The angle is @oscarxblanco do you agree with this? Or is there something else I am missing? |
Maybe I should be documenting this in the help so that we don't have to go through it again in the future |
Hi @swhite2401, |
I don't see you suggestions you have to submit them I think |
All suggested modifications applied, thanks! |
Dear @swhite2401 , R1 =
1.0000 -0.0031 0 0 0 0
0 1.0000 0 0 0 0
0 0 1.0203 -0.0031 0 0
0 0 0 0.9801 0.1987 0
0 0 0 0 1.0000 0
0 0 **0.2027** -0.0006 0 1.0000
R2 =
1.0000 0.0031 0 0 0 0
0 1.0000 0 0 0 0
0 0 1.0203 0.0031 0 0
0 0 0 0.9801 -0.1987 0
0 0 0 0 1.0000 0
0 0 ** -0.2027** -0.0006 0 1.0000 But it is set to zero by ring[0].R1=array([[1. , 0. , 0. , 0. , 0. , 0. ],
[0. , 1. , 0. , 0. , 0. , 0. ],
[0. , 0. , 1. , 0. , 0. , 0. ],
[0. , 0. , 0. , 1. , 0.199, 0. ],
[0. , 0. , 0. , 0. , 1. , 0. ],
[0. , 0. , **0**. , 0. , 0. , 1. ]])
ring[0].R2=array([[ 1. , 0. , 0. , 0. , 0. , 0. ],
[ 0. , 1. , 0. , 0. , 0. , 0. ],
[ 0. , 0. , 1. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 1. , -0.199, 0. ],
[ 0. , 0. , 0. , 0. , 1. , 0. ],
[ 0. , 0. , **0.** , 0. , 0. , 1. ]]) It seems you are setting to zero any longitudinal effect even to first order. This could be a problem depending on the machine, but, as many elements won't change the longitudinal coordinate and the rotations It might however be a concern if rotations and harmonic cavities are combined. Hopefully the help message warning about it would be enough for the moment, ... Following
the small angles approximation the longitudinal shift of the particle
coordinates is neglected and the element length is unchanged. I will approve this merge whenever the branch is updated. |
@oscarxblanco thanks for looking through this, yes indeed longitudinal coordinate changes are ignored because they have to come together with a reduction of the element length and the insertion of drift spaces which seems rather complicated for something that would have very small impact for most usage cases. Do you request any further modifications? Your last comment seems to indicate so but I don't really get what it should be as long as we accept that the longitudinal shift is neglected, do you want me to improve the help? |
Dear @swhite2401 , I have no more requests. |
This PR answer #709 and #712. The rotate_elem function was poorly documented with wrong information and featured a mix of small angle approximation and exact calculation.
These issues are resolved in the updated function.