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

Makes the direction of the Y-rotation the same as the geometrical definition #993

Merged
merged 8 commits into from Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile_test
Expand Up @@ -77,7 +77,7 @@ test-ptc-twiss-1 test-ptc-twiss-2 test-ptc-twiss-3 test-ptc-twiss-4 \
test-ptc-twiss-old1 test-ptc-twiss-old2 test-ptc-twiss-old3 test-ptc-twiss-old4 test-ptc-twiss-old5 test-ptc-twiss-old6 test-ptc-twiss-old7 \
test-ptc-twiss-5D test-ptc-twiss-5Dt test-ptc-twiss-56D test-ptc-twiss-56Dt test-ptc-twiss-56Dl test-ptc-twiss-56Dtl test-ptc-twiss-6D test-ptc-twiss-6D-ALS \
test-ptc-twiss-accel-56D test-ptc-twiss-56Dt-ini_map_man test-ptc-twiss-56Dt-ini_mtx_man test-ptc-twiss-56Dt-ini_mtx_tbl test-ptc-twiss-tilt \
test-ptc-normal test-ptc-normal-5D-beambeam \
test-ptc-normal test-ptc-normal-5D-beambeam test-ptc-twiss-rotations \
test-ptc-twiss-normal-genfu test-ptc-twiss-normal-5D test-ptc-twiss-normal-6D test-ptc-twiss-maptable \
test-ptc-track test-ptc-track-2 test-ptc-track-3 test-ptc-track-4 test-ptc-track-5 \
test-ptc-track-acd test-ptc-track-acd-2 test-ptc-track-6Dtl-acd \
Expand Down
2 changes: 1 addition & 1 deletion doc/latexuguide/makethin.tex
Expand Up @@ -10,7 +10,7 @@ \chapter{Slicing a sequence into thin lenses}
thin (zero length) element slices or simplified thick slices as required
by \madx tracking or conversion to \texttt{SIXTRACK} input format.

DISCLAIMER: Several \madx commands such as {\texttt{ELIGN}}, {\texttt{EFCOMP}} won't directly work on sequences produced by {\texttt{MAKETHIN}}. In order to use such commands on a thin sequence, it is advisable to save the sequence on a file, and then re-load it.
DISCLAIMER: Several \madx commands such as {\texttt{ELIGN}}, {\texttt{EFCOMP}} won't directly work on sequences produced by {\texttt{MAKETHIN}}. In order to use such commands on a thin sequence, it is advisable to save the sequence on a file, and then re-load it. Also note that after \texttt{MAKETHIN} you will have to do a \texttt{USE} command.

\section{MAKETHIN}
\label{sec:makethin}
Expand Down
3 changes: 2 additions & 1 deletion src/madx_ptc_module.f90
Expand Up @@ -1306,7 +1306,7 @@ subroutine ptc_input()
key%magnet="CHANGEREF"
PATCH_ANG = zero
PATCH_TRANS = zero
patch_ang(2)=node_value('angle ')
patch_ang(2)=-node_value('angle ')
key%list%patchg=2
do i=1,3
key%list%ang(i)=patch_ang(i)
Expand Down Expand Up @@ -1435,6 +1435,7 @@ subroutine ptc_input()
key%list%ang(i)=patch_ang(i)
key%list%t(i)=patch_trans(i)
enddo
key%list%ang(2)=-patch_ang(2) ! Change the sign of the y-rotation to be the geometrical angle.
case(36) ! TRANSLATION
key%magnet="CHANGEREF"
PATCH_ANG = zero
Expand Down
2 changes: 1 addition & 1 deletion src/trrun.f90
Expand Up @@ -1378,7 +1378,7 @@ subroutine ttyrot(track,ktrack)
double precision :: x, px, y, py, t, pt, pz, ptt
double precision :: node_value

angle = node_value('angle ')
angle = -node_value('angle ') !Sign to be consistent with a geometrical rotation
if (angle .eq. 0) return

angle = angle * node_value('other_bv ')
Expand Down
2 changes: 1 addition & 1 deletion src/twiss.f90
Expand Up @@ -6839,7 +6839,7 @@ SUBROUTINE tmyrot(ftrk,orbit,fmap,ek,re,te)
double precision :: al_errors(align_max)

!---- Initialize.
angle = node_value('angle ')
angle = -node_value('angle ') !Note that we should have the negative angle here
if (angle .eq. 0) return
!al_errors = 0d0
angle = angle * node_value('other_bv ')
Expand Down
2 changes: 2 additions & 0 deletions tests/test-ptc-twiss-rotations/test-ptc-twiss-rotations.cfg
@@ -0,0 +1,2 @@
1-8 * skip # head
* * any abs=1e-12 rel=2e-10
147 changes: 147 additions & 0 deletions tests/test-ptc-twiss-rotations/test-ptc-twiss-rotations.madx
@@ -0,0 +1,147 @@
circum=3;
beam;
trans: translation, dx=0.1, dy=0.2;

m1: MARKER;
m2: MARKER;
m3: MARKER;

xin = 0.01;
yin = 0;
xpin =0;
ypin = 0;

!Defines the sequence where rotation is done outside the element.
seq: sequence, refer=center, l=3;
m1, at = 1;
trans, at=1.000;
m2, at = 1;
m3, at = 2;
endsequence;


use, sequence=seq;
select, flag = twiss, clear;
select, flag=twiss, column=name, s, x,px, y, py, pt, t;
select, flag=twiss, column=name, s, betx, bety, mux, muy, r11, r12, r21, r22, alfx, alfy;



!!!######### Translation here ##########
twiss, BETX=1, BETY=1, file="translation.twiss", table=madx_table;
SURVEY, SEQUENCE=seq, FILE= survey_translation.out;
ptc_create_universe;
ptc_create_layout, model=2, method=2, exact=true, closed_layout=false;
ptc_setswitch, debuglevel=0, nocavity=true, fringe=true, exact_mis=true, time=true, totalpath=false;
PTC_TWISS, table=ptc_table, icase=56, no=1, betx=1, bety=1, betz=1;
write, table=ptc_table, file="twiss.ptc.translation.tfs";
!ptc_printframes, file="survey.ptc.translation.tfs", format=text;
ptc_end;

i = 0;
while(i < 9) {
i = i + 1;
SETVARS, TABLE=ptc_table, ROW=i;
ptc_x = x;
ptc_y = y;
ptc_t = t;
SETVARS, TABLE=survey, ROW=i;
survey_x = x;
survey_y = y;
survey_z = z;

tot_x = ptc_x + survey_x;
tot_y = ptc_y + survey_y;
!tot_z = ptc_t + survey_z;

print,text="Translation";
show, tot_x;
show, tot_y;

}

!!!######### X-rotation here ##########
xrot: xrotation, angle=0.002;
SEQEDIT, SEQUENCE=seq;
REPLACE, ELEMENT=trans, BY=xrot;
ENDEDIT;

use, sequence=seq;
twiss, BETX=1, BETY=1, file="xrotation.twiss", table=madx_table;
SURVEY, SEQUENCE=seq, FILE= survey_xrotation.out;
ptc_create_universe;
ptc_create_layout, model=2, method=2, exact=true, closed_layout=false;
ptc_setswitch, debuglevel=0, nocavity=true, fringe=true, exact_mis=true, time=true, totalpath=false;
PTC_TWISS, table=ptc_table, icase=56, no=1, betx=1, bety=1, betz=1;
write, table=ptc_table, file="twiss.ptc.xrotation.tfs";
!ptc_printframes, file="survey.ptc.xrotation.tfs", format=text;
ptc_end;
i = 0;
while(i < 9) {
i = i + 1;
SETVARS, TABLE=ptc_table, ROW=i;
ptc_x = x;
ptc_y = y;
ptc_t = t;
SETVARS, TABLE=survey, ROW=i;
survey_x = x;
survey_y = y;
survey_z = z;

tot_x = ptc_x + survey_x;
tot_y = ptc_y + survey_y;
!tot_z = ptc_t + survey_z;

print,text="X-rotation";
show, tot_x;
show, tot_y;

}

!!!######### Y-rotation here ##########
yrot: yrotation, angle=0.002;
SEQEDIT, SEQUENCE=seq;
REPLACE, ELEMENT=xrot, BY=yrot;
ENDEDIT;

use, sequence=seq;
twiss, BETX=1, BETY=1, file="yrotation.twiss", table=madx_table;
SURVEY, SEQUENCE=seq, FILE= survey_yrotation.out;
ptc_create_universe;
ptc_create_layout, model=2, method=2, exact=true, closed_layout=false;
ptc_setswitch, debuglevel=0, nocavity=true, fringe=true, exact_mis=true, time=true, totalpath=false;
PTC_TWISS, table=ptc_table, icase=56, no=1, betx=1, bety=1, betz=1;
write, table=ptc_table, file="twiss.ptc.yrotation.tfs";
!ptc_printframes, file="survey.ptc.yrotation.tfs", format=text;
ptc_end;
i = 0;
while(i < 9) {
i = i + 1;
SETVARS, TABLE=ptc_table, ROW=i;
ptc_x = x;
ptc_y = y;
ptc_t = t;
SETVARS, TABLE=madx_table, ROW=i;
madx_x = x;
madx_y = y;
SETVARS, TABLE=survey, ROW=i;
survey_x = x;
survey_y = y;
survey_z = z;

tot_x = ptc_x + survey_x;
tot_y = ptc_y + survey_y;
tot_z = ptc_t + survey_z;

print,text="Y-rotation PTC";
show, tot_x;
show, tot_y;

tot_x = madx_x + survey_x;
tot_y = madx_y + survey_y;

print,text="Y-rotation MAD-X";
show, tot_x;
show, tot_y;

}