\(\(\( (*\ 
      Updated\ in\ July' 06\ by\ Elena\ Benedetto\  -> \ 
        New\ quadrupoles\ and\ powering\ scheme\ in\ order\ to\ make\ a\ low\ beta\ insertion\ and\ accomodate\ a\ Ion\ stripper\ foil\ \((\(\(->\)\(\ \)\(M . Martini\)\), \ 
              see\ his\ presentation\ \(20/10\)/
                  05)\) . \ 
Quadrupoles\ QDE210\ and\ QF0215\ disconnected\ from\ the\ strings\ and\ powered\ separately . \ 
            Now\ the\ defocusing\ string\ start\ with\ QDE240\ and\ the\ focusing\ with\ QFO225 . \ 
            The\ magnet\ QF0215\ \((was\ 0.8  
              m\ long)\)\ has\ been\ replaced\ by\ a\ "long"\ one \((1.2  
                m)\) . \ \ \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \ Additional\ quadrupoles\ have\ been\ \(installed : \ 
                                        QDE163\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\), \ QDE207, \ QDE213, \ 
      QDE217 \((\(->\)\(old\ QFO215\))\)\ but\ are\ NOT\ YET\ IN\ THE\ NOTEBOOK\ beacuse\ they\ are\ not\ used\ for\ the\ proton\ at\ 26 
         GeV . \ \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! \(! ! \)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)\)*) \)\(
\)\(\ \)\)\)

Off[General::spell]; Off[General::spell1];

<< Statistics`DescriptiveStatistics`

momentum = 26.0

Bρ = 3.3356 momentum

Input values (either currents or strength)

Input strengths

k1QFO105 = 0.20394437;
k1QDE120 =  -0.08760635913;
k1QFO135 = 0.07869850886;
k1QDE150 =  -0.06954970925;
k1QFO165 = 0.07263829231;
k1QDE180 = -0.07244909;
k1QFO205 =    0.06097295;

    
k1QDE210 = 0.1042264261;      
k1QDE240S = 
        0.1044314276/1.001966885636;
 (* k1QDE220S = 
          k1QDE240S*1.001966885636; *) 



k1QFO215 = 
      0.07121418128;     
k1QFO225S = 
      0.1068212719;



\(\(k1QFO375 = \ 
        0.1321434752;\)\ \ 


 (*\ \(! additional\ quadrupoles\ QDE163\), \ QDE207, \ QDE213, \ 
      QDE217 \((\(->\)\(old\ QFO215\))\)\  : \ 
        have\ all\ zero\ strenght\ for\ the\ proton\ at\ 26  
          GeV\ 
NOT\ YET\ IN\ THE\ \(\(NOTEBOOK!!\)!!\)\ *) 
\)

Input currents

IQFO105 = 531.6;
IQDE120 =  175.40;
IQFO135 = 156.03;
IQDE150 = 142.52;
IQFO165 = 144.81;
IQDE180 = 146.57;
IQFO205 = 123.75;

    
IQDE210 = 207.70;   
IQDE240S = 207.50;   (* 
      start of the defocusing string *)                       
 (* 
      IQDE220s =  
        IQDE240*1.001966885636  !! !  
            ele - Nov' 06 *) 

\(IQFO215 = 144.05;  (*\ 
      disconnected\ from\ the\ defocusing\ string\ and\ \(changed : \ 
            since\ now\ is\ 1.2  m\ long\  - it\ was\ 0.8  m - \ 
              to\ get\ the\ same\ field\ the\ current\ should\ be\ 0.8/
                  1.2\) = \ \(2/3\ the\ previous\ value ... \) 
          apart\ from\ small\ differences\ in\ the\ calibration\ curve\ *) 

IQFO225S = 215.56; \ \  (*\ 
      start\ of\ the\ defocusing\ string\ *) 


    IQFO375 = 324.55;\)

Type QF101 (QFO105)

QF101: MAD modelling

QFO105,    K1= +.0097608*IQFO105/MOMENTUM

LQF101 = 0.645;
gLQFO105 = k1QFO105 LQF101 Bρ;
IQFO105MAD = ((k1QFO105 momentum)/0.0097608);

QF101: The two 2nd order polynomials p1QF101 and p2QF101

p1QF101[i_] = -0.004 + 0.021749 i - 
          0.000000506 (i^2);   
p2QF101[i_] = 
        0.006 + 0.021506 i - 0.000000141 (i^2);   
i  /.  
      Part[Part[NSolve[p1QF101[i] == gLQFO105, i], 1], 1]

IQFO105a = %

i  /.  
      Part[Part[NSolve[p2QF101[i] == gLQFO105, i], 1], 1]

IQFO105b = %

IQFO105k = Mean[{IQFO105a, IQFO105b}]

Type QFL (QDE120, QFO135, QDE150, QFO165, QDE180, QFO205,QFO215)

QFL: MAD modelling

LQFL = 1.2;
gLQDE120 = k1QDE120 LQFL Bρ;
gLQFO135 = k1QFO135 LQFL Bρ;
gLQDE150 = k1QDE150 LQFL Bρ;
gLQFO165 = k1QFO165 LQFL Bρ;
gLQDE180 = k1QDE180 LQFL Bρ;
gLQFO205 = k1QFO205 LQFL Bρ;
gLQFO215 = 
        k1QFO215 LQFL Bρ;


IQDE120MAD = ((k1QDE120 momentum)/0.0128163);
IQFO135MAD = ((k1QFO135 momentum)/0.0128163);
IQDE150MAD = ((k1QDE150 momentum)/0.0128163);
IQFO165MAD = ((k1QFO165 momentum)/0.0128163);
IQDE180MAD = ((k1QDE180 momentum)/0.0128163);
IQFO205MAD = ((k1QFO205 momentum)/0.0128163);
IQFO215MAD = ((k1QFO215 momentum)/0.0128163);

QFL (Q120B):  7th order polynomials p1QFL

p1QFL[i_] = 
        0.5123159 (10^(-1)) i + 0.132954 (10^(-7)) (i^3) - 
          0.1635244 (10^(-12)) (i^5) + 
          0.1443575 (10^(-18)) (i^7); 
res = 
        NSolve[p1QFL[i] == gLQDE120, i];
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];

IQDE120k = %

res = 
        NSolve[p1QFL[i] == gLQFO135, i];
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];
IQFO135k = %

res = 
        NSolve[p1QFL[i] == gLQDE150, i];
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];
IQDE150k = %

res = 
        NSolve[p1QFL[i] == gLQFO165, i];
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];
IQFO165k = %

res = 
        NSolve[p1QFL[i] == gLQDE180, i];
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];
IQDE180k = %

res = 
        NSolve[p1QFL[i] == gLQFO205, i];
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];
IQFO205k = %

res = 
        NSolve[p1QFL[i] == gLQFO215, i];
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];
IQFO215k = %

Type QFS (String QFO225.F)

QFS: MAD modelling

LQFS = 0.8;
gLQFO225S = k1QFO225S LQFS Bρ;
gLQFO375 = k1QFO375 LQFS Bρ;
IQFO225SMAD = ((k1QFO225S momentum)/0.0130411);
IQFO375MAD = ((k1QFO375 momentum)/0.0130411);

QFS (Q80):  7th order polynomials p1QFS

p1QFS[i_] = 
        0.3481475 (10^(-1)) i + 0.9651494 (10^(-8)) (i^3) - 
          0.1239243 (10^(-12)) (i^5) + 
          0.1239355 (10^(-18)) (i^7); 
res = NSolve[p1QFS[i] == gLQFO225S, i]
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];

IQFO225Sk = %

res = 
        NSolve[p1QFS[i] == gLQFO375, i];
(i /. 
            res)[[Position[Im[#] & /@ (i /. res), 0][[1, 
              1]]]];

IQFO375k = %

Type QD (String QDE240.F)

QD: MAD modelling

LQD = 0.82;
gLQDE210 = k1QDE210 LQD Bρ;
IQDE210MAD = ((k1QDE210 momentum)/0.0130155);

LQD = 0.82;
gLQDE240S = k1QDE240S LQD Bρ;
IQDE240SMAD = ((k1QDE240S momentum)/0.0130155);

QD (Q82):  5th order polynomials p1QD

p1QD[i_] = 
        0.3555191 (10^(-1)) i + 0.6142503 (10^(-8)) (i^3) - 
          0.6931895 (10^(-13)) (i^5);

res = NSolve[p1QD[i] == gLQDE210, i];
i  /.  res[[4]];
IQDE210k = %

res = NSolve[p1QD[i] == gLQDE240S, i];
i  /.  res[[4]];
IQDE240Sk = %

Line fittings for p1QD

xpoints = {50, 100, 150, 200, 250, 300, 350, 
          400};
points = 
        Transpose[{xpoints, p1QD[xpoints]}];
p1aQD[x_] = Fit[points, {1, x}, x]
p1bQD[x_] = Fit[points, {x}, x]
NSolve[p1aQD[i] == gL, i]
NSolve[p1bQD[i] == gL, i]

All quads strengths from current

k1QFO105I = 
        Mean[{p1QF101[IQFO105], p2QF101[IQFO105]}]/(Bρ LQF101);
k1QDE120I = 
        p1QFL[IQDE120]/(Bρ LQFL);
k1QDE120I = 
        p1QFL[IQDE120]/(Bρ LQFL);
k1QFO135I = 
        p1QFL[IQFO135]/(Bρ LQFL);
k1QDE150I = 
        p1QFL[IQDE150]/(Bρ LQFL);
k1QFO165I = 
        p1QFL[IQFO165]/(Bρ LQFL);
k1QDE180I = 
        p1QFL[IQDE180]/(Bρ LQFL);
k1QFO205I = 
        p1QFL[IQFO205]/(Bρ LQFL);
k1QDE210I = 
        p1QD[IQDE210]/(Bρ LQD);
k1QDE240SI = 
        p1QD[IQDE240S]/(Bρ LQD);
k1QFO215I = p1QFL[IQFO215]/(Bρ LQFL);     
k1QFO225SI = 
      p1QFS[IQFO225S]/(Bρ LQFS);
k1QFO375I = 
        p1QFS[IQFO375]/(Bρ LQFS);

k1QFO105IMAD = ((0.0097608*IQFO105)/momentum);
k1QDE120IMAD = ((0.0128163*IQDE120)/momentum);
k1QFO135IMAD = ((0.0128163*IQFO135)/momentum);
k1QDE150IMAD = ((0.0128163*IQDE150)/momentum);
k1QFO165IMAD = ((0.0128163*IQFO165)/momentum);
k1QDE180IMAD = ((0.0128163*IQDE180)/momentum);
k1QFO205IMAD = ((0.0128163*IQFO205)/momentum);
k1QDE210IMAD = ((0.0130155*IQDE210)/momentum);
k1QDE240SIMAD = ((0.0130155*IQDE240S)/momentum);
k1QFO215IMAD = ((0.0128163*IQFO215)/momentum)
k1QFO225SIMAD = ((0.0130411*IQFO225S)/momentum);
k1QFO375IMAD = ((0.0130411*IQFO375)/momentum);

strengthMAD = {k1QFO105IMAD, k1QDE120IMAD, k1QFO135IMAD, k1QDE150IMAD, 
        k1QFO165IMAD, k1QDE180IMAD, k1QFO205IMAD, k1QDE210IMAD, k1QFO215IMAD, 
        k1QDE240SIMAD*1.001966885636, k1QFO225SIMAD, k1QDE240SIMAD, 
        k1QFO375IMAD}

strengthnew = {k1QFO105I, k1QDE120I, k1QFO135I, k1QDE150I, k1QFO165I, 
          k1QDE180I, k1QFO205I, k1QDE210I, k1QFO215I, 
          k1QDE240SI*1.001966885636, k1QFO225SI, k1QDE240SI, 
          k1QFO375I};

Inputcurrent = {IQFO105, IQDE120, IQFO135, IQDE150, IQFO165, IQDE180, 
        IQFO205, IQDE210, IQFO215, IQDE220S, IQFO225S, IQDE240S, 
        IQFO375}

\(Namequad = {"QFO105", "QDE120", "QFO135", "IQDE150", "IQFO165", "IQDE180", "IQFO205", "IQDE210", "IQFO215", "IQDE220S", "IQFO225S", "IQDE240S", "IQFO375"}\)

MatrixForm[{Namequad, Inputcurrent, strengthMAD, 
        strengthnew}]

All quads currents from strengths

Inputstrength = {k1QFO105, k1QDE120, k1QFO135, k1QDE150, k1QFO165, 
          k1QDE180, k1QFO205, k1QDE210, k1QFO215, k1QDE220S, k1QFO225S, 
          k1QDE240S, k1QFO375};

CurrentMAD = {IQFO105MAD, IQDE120MAD, IQFO135MAD, IQDE150MAD, 
          IQFO165MAD, IQDE180MAD, IQFO205MAD, IQDE210MAD,  IQFO215MAD, 
          IQDE240SMAD*1.001966885636, IQFO225SMAD, IQDE240SMAD, 
          IQFO375MAD};

Currentnew = {IQFO105k, IQDE120k, IQFO135k, IQDE150k, IQFO165k, 
        IQDE180k, IQFO205k, IQDE210k, IQFO215k, IQDE240Sk*1.001966885636, 
        IQFO225Sk, IQDE240Sk, IQFO375k}

\(Namequad = {"QFO105", "QDE120", "QFO135", "IQDE150", "IQFO165", "IQDE180", "IQFO205", "IQDE210", "IQFO215", "IQDE220S", "IQFO225S", "IQDE240S", "IQFO375"}\)

MatrixForm[{Namequad, Inputstrength, CurrentMAD, 
        Currentnew}]