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

Revert "Think this is the correct handeling in survey." #642

Merged

Conversation

coldfix
Copy link
Collaborator

@coldfix coldfix commented Jul 3, 2018

I believe the sign change in SURVEY for SROTATION angles is inconsistent with the MAD-X manual and TWISS.

According to the manual: "A positive angle means that the new reference system is rotated clockwise about the s-axis with respect to the old system".

This means, when I specify a positive ANGLE=pi/2, followed by a SBEND with positive ANGLE (i.e. bending to the right), I expect a downward bend in global coordinates. However, SURVEY shows positive Y atfer the SBEND.

Example:

seq: sequence, l=1, refer=entry;
rot: srotation, at=0, angle=pi/2;
dip: sbend, at=0, angle=pi/2, l=1;
endsequence;

beam;
use, sequence=seq;

select, flag=twiss, column=s,x,y;
select, flag=survey, column=s,x,y,z;

survey, file="survey.tfs";
twiss, betx=1, bety=1, x=0.001, y=0.002, file="twiss.tfs";

From this, we can also see that TWISS behaves as described in the manual.

Please let me know if I did some stupid mistake.

Best, Thomas

@coveralls
Copy link

Coverage Status

Coverage remained the same at 53.803% when pulling 07f07ae on hibtc:srotation_angle_survey into ad23634 on MethodicalAcceleratorDesign:master.

@tpersson
Copy link
Contributor

tpersson commented Jul 5, 2018

I think the current implementation is correct. Remember that it is a rotation of the coordinate system which is the opposite to rotating the element also remember that we are not in the normal right handed system.

@coldfix
Copy link
Collaborator Author

coldfix commented Jul 5, 2018

Remember that it is a rotation of the coordinate system which is the opposite to rotating the element

I'm fully aware, and I assumed a confusion with precisely this fact was the reason for the inconsistency. Therefore, let's best stick to the example first.

also remember that we are not in the normal right handed system.

I did not know about that, please clarify. In which exact circumstances are we not in the right-handed coordinate system? As far as I'm aware, the documentation states and shows only right-handed coordinate systems?

Anyway, if the coordinate system is right or left handed should not matter. According to the documentation:

  • a positive ANGLE for SROTATION rolls to the right
  • a positive ANGLE for SBEND bends to the right
  • Therefore, SROTATION, ANGLE=+pi/2, followed by SBEND, ANGLE=+pi/2 is a downward bend.

This is even the exact example given in the manual in the section about SROTATION, I quote:

ROLL1: SROTATION, ANGLE= PI/2.;
ROLL2: SROTATION, ANGLE= -PI/2.;
HBEND: SBEND, L=6.0, ANGLE=0.01;
VBEND: LINE=(ROLL1,HBEND,ROLL2);

The VBEND definition above is a way to represent a bend down in the vertical plane,

However, SURVEY shows upward bend.

Twiss on the other hand correctly shows that a particle initially located on my left (positive x) is below me after the SROTATION (roll right), and one above me (positive Y) will be on my left (positive X) after I rotate -- as expected.

So I'm still convinced there is an inconsistency somewhere, either in the documentation or SURVEY/TWISS use different notions of up/down or something the like.

@tpersson
Copy link
Contributor

tpersson commented Jul 5, 2018

Thanks a lot for your comments. I already agreed to the twiss but you also convinced me for survey. I was oversimplifying and was thinking of it as just a point that got rotated where it is indeed a element being installed in the new reference system. In this case you are right the bending is downwards.

Many thanks for spotting and fixing this!

Copy link
Contributor

@tpersson tpersson left a comment

Choose a reason for hiding this comment

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

This is the correct implementation.

@tpersson tpersson merged commit 9a95c0e into MethodicalAcceleratorDesign:master Jul 5, 2018
@coldfix
Copy link
Collaborator Author

coldfix commented Jul 5, 2018

Great, thanks a lot! :)

@coldfix coldfix deleted the srotation_angle_survey branch July 5, 2018 17:10
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.

None yet

3 participants