PageRenderTime 25ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/src/utils/curlyh.m

http://slac-lucretia.googlecode.com/
MATLAB | 39 lines | 21 code | 3 blank | 15 comment | 1 complexity | 502800a28bf557555c6aeba5270a649c MD5 | raw file
Possible License(s): BSD-2-Clause
  1. function H=curlyh(b,a,n,np,l,theta,k1)
  2. % H=curlyH(b,a,n,np,l,theta,k1);
  3. %
  4. % Computes <H> for normal boundary magnets per equation (20) of
  5. % SLAC-PUB-1193, "Evaluation of Synchrotron Radiation Integrals"
  6. %
  7. % Inputs:
  8. %
  9. % b = beta at entrance of magnet [meter]
  10. % a = alpha (= -b'/2) at entrance of magnet
  11. % n = eta at entrance of magnet [meter]
  12. % np = eta-prime at entrance of magnet
  13. % l = length of magnet [meter]
  14. % theta = bend angle of magnet [radian]
  15. % k1 = quadrupole strength of magnet [1/meter^2]
  16. % (k1>0 for focusing, k1<0 for defocusing)
  17. h=theta/l;
  18. Ksq=h^2+k1;
  19. if (Ksq<0)
  20. K=sqrt(-Ksq);
  21. Kl=K*l;
  22. C=cosh(Kl);
  23. S=sinh(Kl);
  24. sgn=-1;
  25. else
  26. K=sqrt(Ksq);
  27. Kl=K*l;
  28. C=cos(Kl);
  29. S=sin(Kl);
  30. sgn=1;
  31. end
  32. g=(1+a^2)/b;
  33. H=g*n^2+2*a*n*np+b*np^2 ...
  34. +sgn*2*l*h*(-(g*n+a*np)*(Kl-S)/(K*Kl^2)+(a*n+b*np)*(1-C)/(Kl^2)) ...
  35. +(l*h)^2*(g*(3*Kl-4*S+S*C)/(2*K^2*Kl^3)-a*(1-C)^2/(K*Kl^3) ...
  36. +sgn*b*(Kl-C*S)/(2*Kl^3));