MAD-X icon indicating copy to clipboard operation
MAD-X copied to clipboard

Survey calculations with permanent misalignments show inconsistent results.

Open rdemaria opened this issue 8 months ago • 1 comments

This example shows:

mb: sbend,l=1,angle=pi/2;
mq: quadrupole,l=1,k1=0.0;

ss: sequence, l=10;
mq.1:mq, at=1,dx=0,dy=0.0,dpsi=0.0,dphi=0.3,dtheta=0.0;
mb, at=2;
mq.2:mq, at=3,dx=0.0,dy=0.0,dpsi=0.0,dphi=0.3,dtheta=0.0;
endsequence;

beam;
use,sequence=ss;
survey,file=survey.tfs,perm_align_survey=true;
name         l  angle   s        x           y       z   theta         phi psi
ss$start.ENT 0      0   0        0           0       0       0           0   0
ss$start.EXI 0      0   0        0           0       0       0           0   0
mq.1.ENT     1      0 0.5        0           0     0.5       0         0.3   0
mq.1.EXI     1      0 1.5        0     0.29552 1.45534       0         0.3   0
mb.ENT       1 1.5708 1.5        0           0     1.5       0           0   0
mb.EXI       1 1.5708 2.5 -0.63662           0 2.13662 -1.5708           0   0
mq.2.ENT     1      0 2.5 -0.63662           0 2.13662 -1.5708 1.80954e-17 0.3
mq.2.EXI     1      0 3.5 -1.63662 1.80954e-17 2.13662 -1.5708 1.80954e-17 0.3
ss$end.ENT   0      0  10 -8.13662           0 2.13662 -1.5708           0   0
ss$end.EXI   0      0  10 -8.13662           0 2.13662 -1.5708           0   0

That the first dphi correctly gives an elevation angle, while the second dphi, transform in dpsi giving a tilt!

The code in this location is:

          V_AL = V
          W_AL = W
          if(is_permalign() .ne. 0) then
            VE(1) =   node_value('dx ')
            VE(2) =   node_value('dy ')
            VE(3) =   node_value('ds ')
            V_AL = V_AL + matmul(W_AL,VE)
            dphi   = node_value('dphi ')
            dpsi   = node_value('dpsi ')
            dtheta = node_value('dtheta ')

            call sumtrx(dtheta, dphi, dpsi, we_t)
            W_AL = matmul(we_t,W_AL) ! Is this the right way?
          endif

rdemaria avatar Jun 26 '24 15:06 rdemaria