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

sign of b1 multipole in quad (sextu..) wrong? #66

Open
lnadolski opened this issue Aug 31, 2018 · 2 comments
Open

sign of b1 multipole in quad (sextu..) wrong? #66

lnadolski opened this issue Aug 31, 2018 · 2 comments

Comments

@lnadolski
Copy link
Contributor

Dear All

I am facing something strange.
I set b1 to some value in a quad (or sextupole).
The orbit generated is of opposite sign of what is expected.
In the vertical plane this is fine.

I add the testing code using ESRF lattice.

Please let me know if you confirm the bug or if I am doing something wrong.

%% ESRF Lattice
Ring=esrf;

[LinData,nu, ksi] = atlinopt(Ring,0,1:length(Ring)+1)
beta = cat(1,LinData.beta);
phase= cat(1,LinData.mu);
eta = cat(2,LinData.Dispersion)';
spos = cat(1,LinData.SPos);

Id = 6;
theta = 1e-4;
orb_ana = (sqrt(beta(Id,1)beta(:,1))/2/sin(pinu(1)).cos(abs(phase(Id,1)-phase(:,1))-pinu(1))-eta(Id,1)*eta(:,1)/mcf(Ring)/LinData(end).SPos)*theta;

Ring{Id}.PolynomB(1)=theta/Ring{Id}.Length;

cod = getcod(Ring);
cod = cod';

figure(400)
clf
subplot(2,1,1)
plot(spos, orb_ana); hold all;
plot(spos, cod(:,1),'k*');
legend('Analytical', 'AT')
ylabel('horizontal orbit')

orb_ana2 = (sqrt(beta(Id,2)beta(:,2))/2/sin(pinu(2)).cos(abs(phase(Id,2)-phase(:,2))-pinu(2))-eta(Id,3)*eta(:,3)/mcf(Ring)/LinData(end).SPos)*theta;

Ring=esrf;
Ring{Id}.PolynomA(1)=theta/Ring{Id}.Length;

cod = getcod(Ring);
cod2 = cod';

subplot(2,1,2)
plot(spos, orb_ana2); hold all;
plot(spos, cod2(:,3),'k*');
legend('Analytical', 'AT')
ylabel('vertical orbit')

@carmignani
Copy link
Member

Hello, the sign convention is different in horizontal and vertical in AT.
A positive PolynomA(1) gives a positive kick in y', a positive PolynomB(1) gives a negative kick in x'.

This is a piece of code from driftkick.c, where there is a minus sign where the horizontal kick is applied.

static void strthinkick(double* r, const double* A, const double* B, double L, int max_order)
/***************************************************************************** 
 Calculate and apply a multipole kick to a 6-dimentional
 phase space vector in a straight element (quadrupole)
 
 IMPORTANT !!!
 The reference coordinate system is straight but the field expansion may still
 contain dipole terms: PolynomA(1), PolynomB(1) - in MATLAB notation,
 A[0], B[0] - C,C++ notation
 
 ******************************************************************************/
{
   int i;
   double ReSum = B[max_order];
   double ImSum = A[max_order];
   double ReSumTemp;
   for (i=max_order-1; i>=0; i--) {
      ReSumTemp = ReSum*r[0] - ImSum*r[2] + B[i];
      ImSum = ImSum*r[0] +  ReSum*r[2] + A[i];
      ReSum = ReSumTemp;
   }
   r[1] -=  L*ReSum;
   r[3] +=  L*ImSum;
}

@lfarv
Copy link
Contributor

lfarv commented Sep 2, 2018

This is not a bug but a consequence of the field expansion in AT. You can think of a “standard” bending magnet : it bends to the right (negative angle), while if you rotate it by 90 deg. It bends to the top (positive vertical angle). So definitely, as noted by @carmignani:
Positive B1 means negative H angle
Positive A1 means positive V angle

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

No branches or pull requests

3 participants