source: MML/trunk/machine/SOLEIL/StorageRing/Lattices/lowalpha_AMOR/magnetcoefficients_new_calib_new_mod_low_alpha_AMOR_oct10.m @ 17

Last change on this file since 17 was 17, checked in by zhangj, 10 years ago

To have a stable version on the server.

  • Property svn:executable set to *
File size: 37.6 KB
Line 
1function [C, Leff, MagnetType, A] = magnetcoefficients(MagnetCoreType, Amps, InputType)
2%MAGNETCOEFFICIENTS - Retrieves coefficient for conversion between Physics and Hardware units
3%[C, Leff, MagnetType, A] = magnetcoefficients(MagnetCoreType)
4%
5% INPUTS
6% 1. MagnetCoreType - Family name or type of magnet
7%
8% OUTPUTS
9% 1. C vector coefficients for the polynomial expansion of the magnet field
10%    based on magnet measurements
11% 2. Leff - Effective length ie, which is used in AT
12% 3. MagnetType
13% 4. A - vector coefficients for the polynomial expansion of the curviline
14%        integral of the magnet field based on magnet measurements
15%
16% C and A are vector coefficients for the polynomial expansion of the magnet field
17% based on magnet measurements.
18%
19% The amp2k and k2amp functions convert between the two types of units.
20%   amp2k returns BLeff, B'Leff, or B"Leff scaled by Brho if A-coefficients are used.
21%   amp2k returns B    , B'    , or B"     scaled by Brho if C-coefficients are used.
22%
23% The A coefficients are direct from magnet measurements with a DC term:
24%   a8*I^8+a7*I^7+a6*I^6+a5*I^5+a4*I^4+a3*I^3+a2*I^2+a1*I+a0 = B*Leff or B'*Leff or B"*Leff
25%   A = [a8 a7 a6 a5 a4 a3 a2 a1 a0]
26%
27% C coefficients have been scaled to field (AT units, except correctors) and includes a DC term:
28%   c8 * I^8+ c7 * I^7+ c6 * I^6 + c5 * I^5 + c4 * I^4 + c3 * I^3 + c2 * I^2 + c1*I + c0 = B or B' or B"
29%   C = A/Leff
30%
31% For dipole:      k = B / Brho      (for AT: KickAngle = BLeff / Brho)
32% For quadrupole:  k = B'/ Brho
33% For sextupole:   k = B"/ Brho / 2  (to be compatible with AT)
34%                  (all coefficients all divided by 2 for sextupoles)
35%
36% MagnetCoreType is the magnet measurements name for the magnet core (string, string matrix, or cell)
37%   For SOLEIL:   BEND
38%                 Q1 - Q10 S1 - S10,
39%                 QT, HCOR, VCOR, FHCOR, FVCOR
40%
41% Leff is the effective length of the magnet
42%
43% See Also amp2k, k2amp
44
45%
46% Written by M. Yoon 4/8/03
47% Adapted By Laurent S. Nadolski354.09672
48%
49% Partie Anneau modifiï¿œe par P. Brunelle et A. Nadji le 31/03/06
50%
51% Add a switch on accelerator
52
53% NOTE: Make sure the sign on the 'C' coefficients is reversed where positive current generates negative K-values
54% Or use Tango K value set to -1
55
56% 21 octobre 2008 - P. Brunelle - Qpoles anneau - introduction des coefficents déduits de
57% l'étalonnage en courant utilisant les vraies valeurs des courants. Les anciens
58% coefficients sont commentés.
59
60% 7 mai 2009 - P. Brunelle - Spoles anneau - introduction des coefficents déduits de
61% l'étalonnage en courant utilisant les vraies valeurs des courants + répartition par intervalle de courant.
62
63% 12 juin 2009 - P. Brunelle - Qpoles anneau - répartition par intervalle de courant.
64
65if nargin < 1
66    error('MagnetCoreType input required');
67end
68
69if nargin < 2
70    Amps = 230;  % not sure!!!
71end
72
73if nargin < 3
74    InputType = 'Amps';
75end
76
77
78
79% For a string matrix
80if iscell(MagnetCoreType)
81    for i = 1:size(MagnetCoreType,1)
82        for j = 1:size(MagnetCoreType,2)
83            [C{i,j}, Leff{i,j}, MagnetType{i,j}, A{i,j}] = magnetcoefficients(MagnetCoreType{i});
84        end
85    end
86    return
87end
88
89% For a string matrix
90if size(MagnetCoreType,1) > 1
91    C=[]; Leff=[]; MagnetType=[]; A=[];
92    for i = 1:size(MagnetCoreType,1)
93        [C1, Leff1, MagnetType1, A1] = magnetcoefficients(MagnetCoreType(i,:));
94        C(i,:) = C1;
95        Leff(i,:) = Leff1;
96        MagnetType = strvcat(MagnetType, MagnetType1);
97        A(i,:) = A1;
98    end
99    return
100end
101
102%% get accelerator name
103AcceleratorName = getfamilydata('SubMachine');
104
105switch AcceleratorName
106    case 'LT1'
107        %%%%
108        switch upper(deblank(MagnetCoreType))
109
110            case 'BEND'   
111                Leff = 0.30; % 300 mm
112                % B = 1e-4 * (0.0004 Iï¿œ + 16.334 I + 1.7202)
113                a8 =  0.0;
114                a7 =  0.0;
115                a6 =  0.0;
116                a5 =  0.0;
117                a4 =  0.0;
118                a3 =  0.0;
119                a2 =  0.0;
120                a1 =  4.8861e-4;
121                a0 =  1.19e-4;
122
123                A = [a8 a7 a6 a5 a4 a3 a2 a1 a0];
124                MagnetType = 'BEND';
125
126            case {'QP'}   % 150 mm quadrupole
127                % Find the current from the given polynomial for B'Leff
128                Leff=0.150; % 162 mm;
129                a8 =  0.0;
130                a7 =  0.0;
131                a6 =  0.0;
132                a5 =  0.0;
133%                 a4 =  1.49e-6;
134%                 a3 =  2.59e-5;
135%                 a2 =  1.93e-4;
136%                 a1 =  4.98e-2;
137%                 a0 =  0.0;
138                a4 =  -1.49e-6;
139                a3 =  2.59e-5;
140                a2 =  -1.93e-4;
141                a1 =  4.98e-2;
142                a0 =  8.13e-4;             
143               
144                A = [a7 a6 a5 a4 a3 a2 a1 a0];
145                MagnetType = 'QUAD';
146
147            case {'CH','CV'}    % 16 cm horizontal corrector
148                % Magnet Spec: Theta = 0.8e-3 radians @ 2.75 GeV and 10 amps
149                % Theta = BLeff / Brho    [radians]
150                % Therefore,
151                %       Theta = ((BLeff/Amp)/ Brho) * I
152                %       BLeff/Amp = 0.8e-3 * getbrho(2.75) / 10
153                %       B*Leff = a0 * I   => a0 = 0.8e-3 * getbrho(2.75) / 10
154                %
155                % The C coefficients are w.r.t B
156                %       B = c0 + c1*I = (0 + a0*I)/Leff
157                % However, AT uses Theta in radians so the A coefficients
158                % must be used for correctors with the middle layer with
159                % the addition of the DC term
160
161                % Find the current from the given polynomial for BLeff and B
162                % NOTE: AT used BLeff (A) for correctors
163                MagnetType = 'COR';
164               
165                Leff = 1e-6; % 0.1577 m
166                a8 =  0.0;
167                a7 =  0.0;
168                a6 =  0.0;
169                a5 =  0.0;
170                a4 =  0.0;
171                a3 =  0.0;
172                a2 =  0.0;
173                a1 =  4.49e-4;
174                a0 =  0;
175                A = [a7 a6 a5 a4 a3 a2 a1 a0];
176               
177            otherwise
178                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
179                %k = 0;
180                %MagnetType = '';
181                %return
182        end
183
184        % compute B-field = int(Bdl)/Leff
185        C = A/ Leff;
186
187        MagnetType = upper(MagnetType);
188   
189    case 'StorageRing'
190        % longueur des quadrupoles ajustee a Lintermediaire ente Lmag et Lcalc
191        coeffQ =    0e-3   ;  %0e-3  ;  %  0e-3     %  0e-3 ;   %  0e-3      ;  %  8e-3  ;   % appliqué sur le premier faisceau
192        LtotQC =  0.3602 ; % 0.3602 ; %0.3539 ;%  0.3696   % 0.3539;   %  0.3695814 ;  % 0.320 ;   % longueur effective Qpole court
193        LtotQL = 0.4962  ; % 0.4962 ; %0.4917 ; %  0.5028   % 0.4917;   %  0.5027758 ;  %  0.460 ;   % longueur effective Qpole long
194        %correction offset capteur BMS -2.310-3 (P. Brunelle 30/05/06)
195        bob=0.9977*(1-coeffQ);
196        % longueur des sextupoles
197        LtotSX = 1E-08;
198       
199        switch upper(deblank(MagnetCoreType))
200                     
201            case 'BEND'   
202                % Moyenne des longueurs magnetiques mesurees = 1055.548mm
203                % Decalage en champ entre le dipole de reference et les
204                % dipoles de l'Anneau = DB/B= +1.8e-03.
205                % On part de l'etalonnage B(I) effectue sur le dipole de
206                % reference dans la zone de courant 516 - 558 A
207                % les coefficients du fit doivent etre affectes du facteur
208                % (1-1.8e-3) pour passer du dipole de reference a l'Anneau
209                % et du facteur Leff pour passer a l'integrale de champ.
210                               
211                % B=1.7063474 T correspond a 2.75 GeV
212                % longueur magnetique du modele : Leff = 1.052433;             
213                Leff=1.052433;
214                a7= 0.0;
215                a6=-0.0;
216                a5= 0.0;
217                a4=-0.0;
218                a3= 0.0;
219                a2=-9.7816E-6*(1-1.8e-3)*Leff*(1.055548/1.052433);
220                a1= 1.26066E-02*(1-1.8E-3)*Leff*(1.055548/1.052433);
221                a0= -2.24944*(1-1.8E-3)*Leff*(1.055548/1.052433);
222                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
223                MagnetType = 'BEND';
224
225  % QUADRUPOLES COURTS
226  % Correction des coefficients des QC de + 3 10-3 (manque de longueur du capteur BMS)
227               
228                case {'Q8'} 
229%                 % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 0 et 50A
230%                 % POLARITE - pour le courant et pour le gradient
231                Leff=LtotQC;
232                a7=  0.0;
233                a6=  0.0;
234                a5=  0.0;
235                a4=  0.0;
236                a3=  0.0;
237                a2=  1.19203E-6*(-1)*(1.003)*bob;
238                a1=  2.74719E-2*(1.003)*bob;
239                a0=  2.04817E-2*(-1)*(1.003)*bob;       
240                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
241                MagnetType = 'quad';
242
243                case {'Q3'}
244                % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 50 et 100A
245                % POLARITE -
246                Leff=LtotQC;
247                a7=  0.0;
248                a6=  0.0;
249                a5=  0.0;
250                a4=  0.0;
251                a3=  0.0;
252                a2=  -1.78428E-7*(-1)*(1.003)*bob;
253                a1=  2.75663E-2*(1.003)*bob;
254                a0=  1.90367E-2*(-1)*(1.003)*bob;       
255                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
256                MagnetType = 'quad'; 
257               
258                case {'Q1','Q4','Q9'}
259                % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
260                % POLARITE -
261                Leff=LtotQC;
262                a7=  0.0;
263                a6=  0.0;
264                a5=  0.0;
265                a4=  0.0;
266                a3=  0.0;
267                a2=  -1.72242E-6*(-1)*(1.003)*bob;
268                a1=  2.78608E-2*(1.003)*bob;
269                a0=  4.86245E-3*(-1)*(1.003)*bob;       
270                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
271                MagnetType = 'quad';
272               
273                % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
274                % POLARITE - pour le courant MAIS POLARITE + pour le gradient
275%                 Leff=LtotQC;
276%                 a7=  0.0;
277%                 a6=  0.0;
278%                 a5=  0.0;
279%                 a4=  0.0;
280%                 a3=  0.0;
281%                 a2=  -1.72242E-6*(1.003)*bob;
282%                 a1=  2.78608E-2*(-1)*(1.003)*bob;
283%                 a0=  4.86245E-3*(1.003)*bob;       
284%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
285%                 MagnetType = 'quad';
286               
287                case {'Q6'}
288                % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 150 et 200A
289                % POLARITE -
290                Leff=LtotQC;
291                a7=  0.0;
292                a6=  0.0;
293                a5=  0.0;
294                a4=  0.0;
295                a3=  0.0;
296                a2=  -9.77342E-6*(-1)*(1.003)*bob;
297                a1=  3.03524E-2*(1.003)*bob;
298                a0=  -1.88248E-1*(-1)*(1.003)*bob;       
299                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
300                MagnetType = 'quad';
301               
302%                 case {}
303%                 % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 150 et 200A
304%                 % POLARITE +
305%                 Leff=LtotQC;
306%                 a7=  0.0;
307%                 a6=  0.0;
308%                 a5=  0.0;
309%                 a4=  0.0;
310%                 a3=  0.0;
311%                 a2=  -9.77342E-6*(1.003)*bob;
312%                 a1=  3.03524E-2*(1.003)*bob;
313%                 a0=  -1.88248E-1*(1.003)*bob;       
314%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
315%                 MagnetType = 'quad';
316               
317                case {'Q5','Q10'}
318                % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 200 et 230A
319                % POLARITE +
320                Leff=LtotQC;
321                a7=  0.0;
322                a6=  0.0;
323                a5=  0.0;
324                a4=  0.0;
325                a3=  0.0;
326                a2=  -5.40235E-5*(1.003)*bob;
327                a1=  4.82385E-2*(1.003)*bob;
328                a0=  -1.99661*(1.003)*bob;       
329                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
330                MagnetType = 'quad';
331               
332%                 % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 230 et 250A
333%                 % POLARITE +
334%                 Leff=LtotQC;
335%                 a7=  0.0;
336%                 a6=  0.0;
337%                 a5=  0.0;
338%                 a4=  0.0;
339%                 a3=  0.0;
340%                 a2=  -1.51646E-4*(1.003)*bob;
341%                 a1=  9.16800E-2*(1.003)*bob;
342%                 a0=  -6.82533*(1.003)*bob;       
343%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
344%                 MagnetType = 'quad';
345               
346   
347% QUADRUPOLES LONGS
348%Correction des coefficients des QL de + 1.55 10-2 (manque de longueur du capteur BMS)
349           
350%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 0 et 50A
351%                 % POLARITE +
352%                 Leff=LtotQL;
353%                 a7=  0.0;
354%                 a6=  0.0;
355%                 a5=  0.0;
356%                 a4=  0.0;
357%                 a3=  0.0;
358%                 a2=  2.08013E-6*(1.0155)*bob;
359%                 a1=  4.44797E-2*(1.0155)*bob;
360%                 a0=  2.79903E-2*(1.0155)*bob;       
361%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
362%                 MagnetType = 'quad';
363%                 
364%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 50 et 100A
365%                 % POLARITE +
366%                 Leff=LtotQL;
367%                 a7=  0.0;
368%                 a6=  0.0;
369%                 a5=  0.0;
370%                 a4=  0.0;
371%                 a3=  0.0;
372%                 a2=  -3.60748E-7*(1.0155)*bob;
373%                 a1=  4.46626E-2*(1.0155)*bob;
374%                 a0=  2.47397E-2*(1.0155)*bob;       
375%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
376%                 MagnetType = 'quad';
377%                 
378%               case {''}
379%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
380%                 % POLARITE +
381%                 Leff=LtotQL;
382%                 a7=  0.0;
383%                 a6=  0.0;
384%                 a5=  0.0;
385%                 a4=  0.0;
386%                 a3=  0.0;
387%                 a2=  -4.70168E-6*(1.0155)*bob;
388%                 a1=  4.55728E-2*(1.0155)*bob;
389%                 a0=  -2.30870E-2*(1.0155)*bob;       
390%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
391%                 MagnetType = 'quad';
392               
393%                 case {''}
394%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 80 et 135A
395%                 % POLARITE +
396%                 Leff=LtotQL;
397%                 a7=  0.0;
398%                 a6=  0.0;
399%                 a5=  0.0;
400%                 a4=  0.0;
401%                 a3=  0.0;
402%                 a2=  -2.55217E-6*(1.0155)*bob;
403%                 a1=  4.50695E-2*(1.0155)*bob;
404%                 a0=  6.10246E-3*(1.0155)*bob;       
405%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
406%                 MagnetType = 'quad';
407               
408                case {'Q2'}
409%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 150 et 180A
410%                 % POLARITE +
411                Leff=LtotQL;
412                a7=  0.0;
413                a6=  0.0;
414                a5=  0.0;
415                a4=  0.0;
416                a3=  0.0;
417                a2=  -1.92014E-5*(1.0155)*bob;
418                a1=  4.99176E-2*(1.0155)*bob;
419                a0=  -3.48990E-1*(1.0155)*bob;       
420                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
421                MagnetType = 'quad';
422             
423                case {'Q7'}
424%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 180 et 220A
425%                 % POLARITE +
426                Leff=LtotQL;
427                a7=  0.0;
428                a6=  0.0;
429                a5=  0.0;
430                a4=  -2.41754E-8*(1.0155)*bob;
431                a3=  1.69646E-5*(1.0155)*bob;
432                a2=  -4.49256E-3*(1.0155)*bob;
433                a1=  5.75113E-1*(1.0155)*bob;
434                a0=  -2.35068E+1*(1.0155)*bob;       
435                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
436                MagnetType = 'quad';
437               
438%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 220 et 250A
439%                 % POLARITE +
440%                 Leff=LtotQL;
441%                 a7=  0.0;
442%                 a6=  0.0;
443%                 a5=  0.0;
444%                 a4=  0.0;
445%                 a3=  1.34349E-6*(1.0155)*bob;
446%                 a2=  -1.13030E-3*(1.0155)*bob;
447%                 a1=  3.35009E-1*(1.0155)*bob;
448%                 a0=  -2.37155E+1*(1.0155)*bob;       
449%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
450%                 MagnetType = 'quad';
451
452 % SEXTUPOLES : on multiplie les coefficients par 2 car ils sont exprimes en B"L et non B"L/2
453                % REPARTITION par intervalle de courant.
454                % les intervalles de courant non utilises sont commentes.
455
456%           case{''}
457                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 0 et 60A
458                % POLARITE (courant) + mais H - car alimentation sextupole "retournée"
459%                 Leff=LtotSX;
460%                 a7=  0.0;
461%                 a6=  0.0;
462%                 a5=  0.0;
463%                 a4=  0.0;
464%                 a3=  0.0;
465%                 a2=  (-1)*-5.7905804E-6;
466%                 a1=  (-1)* 1.5465642E-1;
467%                 a0=  (-1)*2.4064497E-1;
468%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
469%                 MagnetType = 'SEXT';
470
471          case{'S1'}
472                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 0 et 60A
473                % POLARITE +
474                Leff=LtotSX;
475                a7=  0.0;
476                a6=  0.0;
477                a5=  0.0;
478                a4=  0.0;
479                a3=  0.0;
480                a2=  -5.7905804E-6;
481                a1=  1.5465642E-1;
482                a0=  2.4064497E-1;
483                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
484                MagnetType = 'SEXT';
485
486%             case{''}
487%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 60 et 100A
488%                 % POLARITE -
489%                 Leff=LtotSX;
490%                 a7=  0.0;
491%                 a6=  0.0;
492%                 a5=  0.0;
493%                 a4=  0.0;
494%                 a3=  0.0;
495%                 a2=  (-1)*-2.8698688E-6;
496%                 a1=   1.5442027E-1;
497%                 a0=  (-1)*2.4480159E-1;
498%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
499%                 MagnetType = 'SEXT';
500
501            case{'S7'}
502                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
503                % POLARITE -
504                Leff=LtotSX;
505                a7=  0.0;
506                a6=  0.0;
507                a5=  0.0;
508                a4=  0.0;
509                a3=  0.0;
510                a2=  -4.8549355E-6*(-1);
511                a1=   1.5483805E-1;
512                a0=   2.2290378E-1*(-1);
513                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
514                MagnetType = 'SEXT';
515
516%             case{}
517%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
518%                 % POLARITE +
519%                 Leff=LtotSX;
520%                 a7=  0.0;
521%                 a6=  0.0;
522%                 a5=  0.0;
523%                 a4=  0.0;
524%                 a3=  0.0;
525%                 a2=  -4.8549355E-6;
526%                 a1=   1.5483805E-1;
527%                 a0=   2.2290378E-1;
528%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
529%                 MagnetType = 'SEXT';
530
531            case{'S6','S10','S11'}
532                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 150 et 200A
533                % POLARITE +
534                Leff=LtotSX;
535                a7=  0.0;
536                a6=  0.0;
537                a5=  0.0;
538                a4=  0.0;
539                a3=  0.0;
540                a2=  -6.1567262E-6;
541                a1=   1.5520734E-1;
542                a0=   1.9694261E-1;
543                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
544                MagnetType = 'SEXT';
545
546            case{'S5','S8','S9'}
547                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 150 et 200A
548                % POLARITE -
549                Leff=LtotSX;
550                a7=  0.0;
551                a6=  0.0;
552                a5=  0.0;
553                a4=  0.0;
554                a3=  0.0;
555                a2=  -6.1567262E-6*(-1);
556                a1=   1.5520734E-1;
557                a0=   1.9694261E-1*(-1);
558                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
559                MagnetType = 'SEXT';
560
561            case{'S2'}
562                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 200 et 250A
563                % POLARITE -
564                Leff=LtotSX;
565                a7=  0.0;
566                a6=  0.0;
567                a5=  0.0;
568                a4=  0.0;
569                a3=  0.0;
570                a2=  -1.3881816E-5*(-1);
571                a1=   1.5827135E-1;
572                a0=  -1.0713717E-1*(-1);
573                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
574                MagnetType = 'SEXT';
575
576
577%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 200 et 250A
578%                 % POLARITE +
579%                 Leff=LtotSX;
580%                 a7=  0.0;
581%                 a6=  0.0;
582%                 a5=  0.0;
583%                 a4=  0.0;
584%                 a3=  0.0;
585%                 a2=  -1.3881816E-5;
586%                 a1=   1.5827135E-1;
587%                 a0=  -1.0713717E-1;
588%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
589%                 MagnetType = 'SEXT';
590
591
592%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 250 et 300A
593%                 % POLARITE -
594%                 Leff=LtotSX;
595%                 a7=  0.0;
596%                 a6=  0.0;
597%                 a5=  0.0;
598%                 a4=  0.0;
599%                 a3=  0.0;
600%                 a2=  -4.0540578E-5*(-1);
601%                 a1=   1.7188604E-1;
602%                 a0=  -1.8459591E+0*(-1);
603%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
604%                 MagnetType = 'SEXT';
605
606%             case {}
607%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 250 et 300A
608%                 % POLARITE +
609%                 Leff=LtotSX;
610%                 a7=  0.0;
611%                 a6=  0.0;
612%                 a5=  0.0;
613%                 a4=  0.0;
614%                 a3=  0.0;
615%                 a2=  -4.0540578E-5;
616%                 a1=   1.7188604E-1;
617%                 a0=  -1.8459591E+0;
618%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
619%                 MagnetType = 'SEXT';
620               
621            case {'S4'}
622                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 310 et 330A
623                % POLARITE +
624                Leff=LtotSX;
625                a7=  0.0;
626                a6=  0.0;
627                a5=  0.0;
628                a4=  0.0;
629                a3=  0.0;
630                a2=  0.0;
631                a1=  1.422341E-01;
632                a0=  3.4460054E+00;
633                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
634                MagnetType = 'SEXT';   
635
636            case {'S3'}
637                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 310 et 330A
638                % POLARITE -
639                Leff=LtotSX;
640                a7=  0.0;
641                a6=  0.0;
642                a5=  0.0;
643                a4=  0.0;
644                a3=  0.0;
645                a2=  0.0;
646                a1=  1.422341E-01;
647                a0=  3.4460054E+00*(-1);
648                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
649                 MagnetType = 'SEXT';       
650
651%%               
652               
653            case 'QT'    % 160 mm dans sextupole
654                % Etalonnage: moyenne sur les 32 sextupï¿œles incluant un QT.
655                % Efficacite = 3 G.m/A @ R=32mm; soit 93.83 G/A
656                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
657                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
658                Leff = 1e-8;
659                a7= 0.0;
660                a6= 0.0;
661                a5= 0.0;
662                a4= 0.0;
663                a3= 0.0;
664                a2= 0.0;
665                a1= 93.83E-4;
666                a0= 0.0;
667                A = [a7 a6 a5 a4 a3 a2 a1 a0];
668
669                MagnetType = 'QT';
670
671             case 'SQ'   % 160 mm dans sextupole
672                % Etalonnage: moyenne sur les 32 sextupï¿œles incluant un QT.
673                % Efficacitee = 3 G.m/A @ R=32mm; soit 93.83 G/A
674                % Le signe du courant est donnee par le DeviceServer (Tango)
675                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
676                Leff = 1e-8;
677                a7= 0.0;
678                a6= 0.0;
679                a5= 0.0;
680                a4= 0.0;
681                a3= 0.0;
682                a2= 0.0;
683                a1= 93.83E-4;
684                a0= 0.0;
685                A = [a7 a6 a5 a4 a3 a2 a1 a0];
686
687                MagnetType = 'QT';               
688               
689            case {'HCOR'}    % 16 cm horizontal corrector
690                % Etalonnage: moyenne sur les 56 sextupï¿œles incluant un CORH.
691                % Efficacitï¿œ = 8.143 G.m/A
692                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
693                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
694                Leff = 0.16;
695                a7= 0.0;
696                a6= 0.0;
697                a5= 0.0;
698                a4= 0.0;
699                a3= 0.0;
700                a2= 0.0;
701                a1= 8.143E-4;
702                a0= 0.0;
703                A = [a7 a6 a5 a4 a3 a2 a1 a0];
704
705                MagnetType = 'COR';
706               
707
708            case {'FHCOR'}    % 10 cm horizontal corrector
709                % Magnet Spec: Theta = 280e-6 radians @ 2.75 GeV and 10 amps
710                % Theta = BLeff / Brho    [radians]
711                % Therefore,
712                %       Theta = ((BLeff/Amp)/ Brho) * I
713                %       BLeff/Amp = 280e-6 * getbrho(2.75) / 10
714                %       B*Leff = a0 * I   => a0 = 0.8e-3 * getbrho(2.75) / 10
715                %
716                % The C coefficients are w.r.t B
717                %       B = c0 + c1*I = (0 + a0*I)/Leff
718                % However, AT uses Theta in radians so the A coefficients
719                % must be used for correctors with the middle layer with
720                % the addition of the DC term
721
722                % Find the current from the given polynomial for BLeff and B
723                % NOTE: AT used BLeff (A) for correctors
724                Leff = .10;
725                imax = 10;
726                cormax = 28e-6 ; % 28 urad for imax = 10 A
727                MagnetType = 'COR';
728                A = [0 cormax*getbrho(2.75)/imax 0];
729
730            case {'VCOR'}    % 16 cm vertical corrector
731                % Etalonnage: moyenne sur les 56 sextupï¿œles incluant un CORV.
732                % Efficacitï¿œ = 4.642 G.m/A
733                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
734                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
735                Leff = 0.16;
736                a7= 0.0;
737                a6= 0.0;
738                a5= 0.0;
739                a4= 0.0;
740                a3= 0.0;
741                a2= 0.0;
742                a1= 4.642E-4;
743                a0= 0.0;
744                A = [a7 a6 a5 a4 a3 a2 a1 a0];
745
746                MagnetType = 'COR';
747
748            case {'FVCOR'}    % 10 cm vertical corrector
749                % Find the current from the given polynomial for BLeff and B
750                Leff = .10;
751                imax = 10;
752                cormax = 23e-6 ; % 23 urad for imax = 10 A
753                MagnetType = 'COR';
754                A = [0 cormax*getbrho(2.75)/imax 0];
755
756            case {'K_INJ'}
757                % Kicker d'injection
758                % étalonnage provisoire
759                % attention l'element n'etant pas dans le modele,definition
760                % de A ambigue
761                Leff = .6;
762                vmax = 8000;
763                alphamax = 8e-3 ; % 8 mrad pour 8000 V
764                MagnetType = 'K_INJ';
765                A = [0 alphamax*getbrho(2.75)/vmax 0]*Leff;
766               
767             case {'K_INJ1'}
768                % Kickers d'injection 1 et 4
769                Leff = .6;
770                vmax = 7500; % tension de mesure
771                SBDL = 75.230e-3 ; % somme de Bdl mesurée
772                MagnetType = 'K_INJ1';
773                A = [0 -SBDL/vmax 0]*Leff;
774               
775             case {'K_INJ2'}
776                % Kickers d'injection 2 et 3
777                Leff = .6;
778                vmax = 7500;% tension de mesure
779                SBDL = 74.800e-3 ; % somme de Bdl mesurée
780                MagnetType = 'K_INJ2'; 
781                A = [0 SBDL/vmax 0]*Leff;
782               
783            case {'SEP_P'}
784                % Septum passif d'injection
785                Leff = .6;
786                vmax = 547; % tension de mesure V
787                SBDL = 263e-3; % somme de Bdl mesurée
788                MagnetType = 'SEP_P';
789                A = [0 SBDL/vmax 0]*Leff;
790               
791             case {'SEP_A'}
792                % Septum actif d'injection
793                Leff = 1.;
794                vmax = 111;
795                MagnetType = 'SEP_A';
796                SBDL = 1147.8e-3 ; % Somme de Bdl mesurée à 111 V
797                A = [0 SBDL/vmax 0]*Leff;
798
799            otherwise
800                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
801                k = 0;
802                MagnetType = '';
803                return
804        end
805
806        % compute B-field = int(Bdl)/Leff
807        C = A / Leff;
808
809        MagnetType = upper(MagnetType);
810
811
812        % Power Series Denominator (Factoral) be AT compatible
813        if strcmpi(MagnetType,'SEXT')
814            C = C / 2;
815        end
816        if strcmpi(MagnetType,'OCTO')
817            C = C / 6;
818        end
819        return;
820       
821    case 'Booster'
822        %%%%
823        switch upper(deblank(MagnetCoreType))
824
825            case 'BEND'   
826                % B[T] = 0.00020 + 0.0013516 I[A]
827                % B[T] = 0.00020 + (0.0013051 + 0.00005/540 I) I[A] Alex
828                Leff = 2.160; % 2160 mm               
829                a8 =  0.0;
830                a7 =  0.0;
831                a6 =  0.0;
832                a5 =  0.0;
833                a4 =  0.0;
834                a3 =  0.0;
835                a2 =  9.2e-8*Leff;
836                a1 =  0.0013051*Leff;
837                a0 =  2.0e-3*Leff;
838
839                A = [a8 a7 a6 a5 a4 a3 a2 a1 a0];
840                MagnetType = 'BEND';
841
842            case {'QF'}   % 400 mm quadrupole
843                % Find the current from the given polynomial for B'Leff
844                % G[T/m] = 0.0465 + 0.0516 I[A] Alex
845                Leff=0.400;
846                a8 =  0.0;
847                a7 =  0.0;
848                a6 =  0.0;
849                a5 =  0.0;
850                a4 =  0.0;
851                a3 =  0.0;
852                a2 =  0.0;
853                a1 =  0.0516*Leff;
854                a0 =  0.0465*Leff;
855               
856                A = [a7 a6 a5 a4 a3 a2 a1 a0]; %*getbrho(0.1);
857                MagnetType = 'QUAD';
858
859            case {'QD'}   % 400 mm quadrupole
860                % Find the current from the given polynomial for B'Leff
861                % G[T/m] = 0.0485 + 0.0518 I[A] Alex
862                Leff=0.400;
863                a8 =  0.0;
864                a7 =  0.0;
865                a6 =  0.0;
866                a5 =  0.0;
867                a4 =  0.0;
868                a3 =  0.0;
869                a2 =  0.0;
870                a1 =  -0.0518*Leff;
871                a0 =  -0.0485*Leff;
872               
873                A = [a7 a6 a5 a4 a3 a2 a1 a0]; %*getbrho(0.1);
874                MagnetType = 'QUAD';
875
876            case {'SF', 'SD'}   % 150 mm sextupole
877                % Find the current from the given polynomial for B'Leff
878                % HL [T/m] = 0.2 I [A] (deja intï¿œgrï¿œ)
879                Leff=1.e-8; % thin lens;
880                a8 =  0.0;
881                a7 =  0.0;
882                a6 =  0.0;
883                a5 =  0.0;
884                a4 =  0.0;
885                a3 =  0.0;
886                a2 =  0.0;
887                a1 =  0.2*2;
888                a0 =  0.0;
889               
890                A = [a7 a6 a5 a4 a3 a2 a1 a0];
891                MagnetType = 'SEXT';
892               
893            case {'HCOR','VCOR'}    % ?? cm horizontal corrector
894                % Magnet Spec: Theta = 0.8e-3 radians @ 2.75 GeV and 10 amps
895                % Theta = BLeff / Brho    [radians]
896                % Therefore,
897                %       Theta = ((BLeff/Amp)/ Brho) * I
898                %       BLeff/Amp = 0.8e-3 * getbrho(2.75) / 10
899                %       B*Leff = a0 * I   => a0 = 0.8e-3 * getbrho(2.75) / 10
900                %
901                % The C coefficients are w.r.t B
902                %       B = c0 + c1*I = (0 + a0*I)/Leff
903                % However, AT uses Theta in radians so the A coefficients
904                % must be used for correctors with the middle layer with
905                % the addition of the DC term
906
907                % Find the current from the given polynomial for BLeff and B
908                % NOTE: AT used BLeff (A) for correctors
909                MagnetType = 'COR';
910                % theta [mrad] = 1.34 I[A] @ 0.1 GeV
911                Leff = 1e-6;
912                a8 =  0.0;
913                a7 =  0.0;
914                a6 =  0.0;
915                a5 =  0.0;
916                a4 =  0.0;
917                a3 =  0.0;
918                a2 =  0.0;
919                a1 =  1.34e-3*getbrho(0.1);
920                a0 =  0;
921                A = [a7 a6 a5 a4 a3 a2 a1 a0];
922               
923            otherwise
924                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
925                %k = 0;
926                %MagnetType = '';
927                %return
928        end
929
930        % compute B-field = int(Bdl)/Leff
931        C = A/ Leff;
932 
933        % Power Series Denominator (Factoral) be AT compatible
934        if strcmpi(MagnetType,'SEXT')
935            C = C / 2;
936        end
937 
938        MagnetType = upper(MagnetType);
939
940    case 'LT2'
941        %%%%
942        switch upper(deblank(MagnetCoreType))
943
944            case 'BEND'   
945                % les coefficients et longueur magnétique sont recopiés de l'anneau
946                Leff=1.052433;
947                a7= 0.0;
948                a6=-0.0;
949                a5= 0.0;
950                a4=-0.0;
951                a3= 0.0;
952                a2=-9.7816E-6*(1-1.8e-3)*Leff*(1.055548/1.052433);
953                a1= 1.26066E-02*(1-1.8E-3)*Leff*(1.055548/1.052433);
954                a0= -2.24944*(1-1.8E-3)*Leff*(1.055548/1.052433);
955                A = [a7 a6 a5 a4 a3 a2 a1 a0];
956               
957
958                MagnetType = 'BEND';
959
960            case {'QP'}   % 400 mm quadrupole
961                % Find the current from the given polynomial for B'Leff
962               
963                % G[T/m] = 0.1175 + 0.0517 I[A]
964                % le rémanent est + fort que pour les quad Booster car les
965                % courants max sont + eleves
966                Leff=0.400;
967%                 a8 =  0.0;
968%                 a7 =  0.0;
969%                 a6 =  0.0;
970%                 a5 =  0.0;
971%                 a4 =  0.0;
972%                 a3 =  0.0;
973%                 a2 =  0.0;
974%                 a1 =  0.0517*Leff;
975%                 a0 =  0.1175*Leff;
976               
977                a8 =  0.0;
978                a7 =  0.0;
979                a6 =  0.0;
980                a5 =  0.0;
981                a4 =  -1.3345e-10;
982                a3 =  8.1746e-8;
983                a2 =  -1.6548e-5;
984                a1 =  2.197e-2;
985                a0 =  2.73e-2;
986                A = [a7 a6 a5 a4 a3 a2 a1 a0];
987                MagnetType = 'QUAD';
988
989            case {'CH','CV'}    % 16 cm horizontal corrector
990               
991
992               
993                % Magnet Spec: Theta = environ 1 mradians @ 2.75 GeV and 10 amps
994                % Theta = BLeff / Brho    [radians]
995                % Therefore,
996                %       Theta = ((BLeff/Amp)/ Brho) * I
997                %       BLeff/Amp = 1.e-3 * getbrho(2.75) / 10
998                %       B*Leff = a1 * I   => a1 = 1.e-3 * getbrho(2.75) / 10
999                %
1000                % The C coefficients are w.r.t B
1001                %       B = c0 + c1*I = (0 + a0*I)/Leff
1002                % However, AT uses Theta in radians so the A coefficients
1003                % must be used for correctors with the middle layer with
1004                % the addition of the DC term
1005
1006                % Find the current from the given polynomial for BLeff and B
1007                % NOTE: AT used BLeff (A) for correctors
1008               
1009                % environ 32 cm  corrector
1010                % Efficacitï¿œ = 11.06 G.m/A
1011                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
1012                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) =
1013                % magnetcoefficien
1014               
1015                MagnetType = 'COR';
1016               
1017                Leff = 1e-6; % 0.1577 m
1018                a8 =  0.0;
1019                a7 =  0.0;
1020                a6 =  0.0;
1021                a5 =  0.0;
1022                a4 =  0.0;
1023                a3 =  0.0;
1024                a2 =  0.0;
1025                a1 =  110.6e-4/10;
1026                a0 =  0;
1027                A = [a7 a6 a5 a4 a3 a2 a1 a0];
1028               
1029            otherwise
1030                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
1031                %k = 0;
1032                %MagnetType = '';
1033                %return
1034        end
1035
1036        % compute B-field = int(Bdl)/Leff
1037        C = A/ Leff;
1038
1039        MagnetType = upper(MagnetType);
1040
1041    otherwise
1042        error('Unknown accelerator name %s', AcceleratorName);
1043end
Note: See TracBrowser for help on using the repository browser.