source: MML/trunk/machine/SOLEIL/StorageRing/Lattices/lowalpha_dec08/magnetcoefficients_new_calib_new_modele_low_alpha_oct2010_auto1.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 35.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% ON A RAJOUTE LA FAMILLE S11 (janvier 2011)
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         
229%                 % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 0 et 50A
230%                 % POLARITE -
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 {'Q1'} 
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 {'Q3','Q4'}
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                case {'Q8'}
274                % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
275                % POLARITE - pour le courant MAIS POLARITE + pour le gradient
276                Leff=LtotQC;
277                a7=  0.0;
278                a6=  0.0;
279                a5=  0.0;
280                a4=  0.0;
281                a3=  0.0;
282                a2=  -1.72242E-6*(1.003)*bob;
283                a1=  2.78608E-2*(-1)*(1.003)*bob;
284                a0=  4.86245E-3*(1.003)*bob;       
285                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
286                MagnetType = 'quad';
287               
288                case {'Q6', 'Q9'}
289                % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 150 et 200A
290                % POLARITE -
291                Leff=LtotQC;
292                a7=  0.0;
293                a6=  0.0;
294                a5=  0.0;
295                a4=  0.0;
296                a3=  0.0;
297                a2=  -9.77342E-6*(-1)*(1.003)*bob;
298                a1=  3.03524E-2*(1.003)*bob;
299                a0=  -1.88248E-1*(-1)*(1.003)*bob;       
300                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
301                MagnetType = 'quad';
302               
303                case {'Q10','Q5'}
304                % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 200 et 230A
305                % POLARITE +
306                Leff=LtotQC;
307                a7=  0.0;
308                a6=  0.0;
309                a5=  0.0;
310                a4=  0.0;
311                a3=  0.0;
312                a2=  -5.40235E-5*(1.003)*bob;
313                a1=  4.82385E-2*(1.003)*bob;
314                a0=  -1.99661*(1.003)*bob;       
315                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
316                MagnetType = 'quad';
317               
318%                 % CAS DU QUADRUPOLE COURT DONT LE COURANT EST COMPRIS ENTRE 230 et 250A
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=  -1.51646E-4*(1.003)*bob;
327%                 a1=  9.16800E-2*(1.003)*bob;
328%                 a0=  -6.82533*(1.003)*bob;       
329%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
330%                 MagnetType = 'quad';
331               
332   
333% QUADRUPOLES LONGS
334%Correction des coefficients des QL de + 1.55 10-2 (manque de longueur du capteur BMS)
335           
336%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 0 et 50A
337%                 % POLARITE +
338%                 Leff=LtotQL;
339%                 a7=  0.0;
340%                 a6=  0.0;
341%                 a5=  0.0;
342%                 a4=  0.0;
343%                 a3=  0.0;
344%                 a2=  2.08013E-6*(1.0155)*bob;
345%                 a1=  4.44797E-2*(1.0155)*bob;
346%                 a0=  2.79903E-2*(1.0155)*bob;       
347%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
348%                 MagnetType = 'quad';
349%                 
350%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 50 et 100A
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=  -3.60748E-7*(1.0155)*bob;
359%                 a1=  4.46626E-2*(1.0155)*bob;
360%                 a0=  2.47397E-2*(1.0155)*bob;       
361%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
362%                 MagnetType = 'quad';
363%                 
364               case {'Q2'}
365%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
366%                 % POLARITE +
367                Leff=LtotQL;
368                a7=  0.0;
369                a6=  0.0;
370                a5=  0.0;
371                a4=  0.0;
372                a3=  0.0;
373                a2=  -4.70168E-6*(1.0155)*bob;
374                a1=  4.55728E-2*(1.0155)*bob;
375                a0=  -2.30870E-2*(1.0155)*bob;       
376                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
377                MagnetType = 'quad';
378               
379                 case {'Q7'}
380%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 80 et 135A
381%                 % POLARITE +
382                Leff=LtotQL;
383                a7=  0.0;
384                a6=  0.0;
385                a5=  0.0;
386                a4=  0.0;
387                a3=  0.0;
388                a2=  -2.55217E-6*(1.0155)*bob;
389                a1=  4.50695E-2*(1.0155)*bob;
390                a0=  6.10246E-3*(1.0155)*bob;       
391                A = [a7 a6 a5 a4 a3 a2 a1 a0];               
392                MagnetType = 'quad';
393               
394%                 case {''}
395%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 150 et 180A
396%                 % POLARITE +
397%                 Leff=LtotQL;
398%                 a7=  0.0;
399%                 a6=  0.0;
400%                 a5=  0.0;
401%                 a4=  0.0;
402%                 a3=  0.0;
403%                 a2=  -1.92014E-5*(1.0155)*bob;
404%                 a1=  4.99176E-2*(1.0155)*bob;
405%                 a0=  -3.48990E-1*(1.0155)*bob;       
406%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
407%                 MagnetType = 'quad';
408             
409%                 case {''}
410%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 180 et 220A
411%                 % POLARITE +
412%                 Leff=LtotQL;
413%                 a7=  0.0;
414%                 a6=  0.0;
415%                 a5=  0.0;
416%                 a4=  -2.41754E-8*(1.0155)*bob;
417%                 a3=  1.69646E-5*(1.0155)*bob;
418%                 a2=  -4.49256E-3*(1.0155)*bob;
419%                 a1=  5.75113E-1*(1.0155)*bob;
420%                 a0=  -2.35068E+1*(1.0155)*bob;       
421%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
422%                 MagnetType = 'quad';
423               
424%                 % CAS DU QUADRUPOLE LONG DONT LE COURANT EST COMPRIS ENTRE 220 et 250A
425%                 % POLARITE +
426%                 Leff=LtotQL;
427%                 a7=  0.0;
428%                 a6=  0.0;
429%                 a5=  0.0;
430%                 a4=  0.0;
431%                 a3=  1.34349E-6*(1.0155)*bob;
432%                 a2=  -1.13030E-3*(1.0155)*bob;
433%                 a1=  3.35009E-1*(1.0155)*bob;
434%                 a0=  -2.37155E+1*(1.0155)*bob;       
435%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];               
436%                 MagnetType = 'quad';
437
438 % SEXTUPOLES : on multiplie les coefficients par 2 car ils sont exprimes en B"L et non B"L/2
439                % REPARTITION par intervalle de courant.
440                % les intervalles de courant non utilises sont commentes.
441               
442                % ON A RAJOUTE LA FAMILLE S11 (janvier 2011)
443
444            case{'S1','S11','S2'}
445                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 0 et 60A
446                % POLARITE (courant) + mais H - car alimentation sextupole "retournée"
447                Leff=LtotSX;
448                a7=  0.0;
449                a6=  0.0;
450                a5=  0.0;
451                a4=  0.0;
452                a3=  0.0;
453                a2=  (-1)*-5.7905804E-6;
454                a1=  (-1)* 1.5465642E-1;
455                a0=  (-1)*2.4064497E-1;
456                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
457                MagnetType = 'SEXT';
458
459           
460                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 60 et 100A
461                % POLARITE -
462%                 Leff=LtotSX;
463%                 a7=  0.0;
464%                 a6=  0.0;
465%                 a5=  0.0;
466%                 a4=  0.0;
467%                 a3=  0.0;
468%                 a2=  (-1)*-2.8698688E-6;
469%                 a1=   1.5442027E-1;
470%                 a0=  (-1)*2.4480159E-1;
471%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
472%                 MagnetType = 'SEXT';
473
474            case{'S5','S7'}
475                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
476                % POLARITE -
477                Leff=LtotSX;
478                a7=  0.0;
479                a6=  0.0;
480                a5=  0.0;
481                a4=  0.0;
482                a3=  0.0;
483                a2=  -4.8549355E-6*(-1);
484                a1=   1.5483805E-1;
485                a0=   2.2290378E-1*(-1);
486                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
487                MagnetType = 'SEXT';
488
489            case{'S6','S8'}
490                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 100 et 150A
491                % POLARITE +
492                Leff=LtotSX;
493                a7=  0.0;
494                a6=  0.0;
495                a5=  0.0;
496                a4=  0.0;
497                a3=  0.0;
498                a2=  -4.8549355E-6;
499                a1=   1.5483805E-1;
500                a0=   2.2290378E-1;
501                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
502                MagnetType = 'SEXT';
503
504           
505%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 150 et 200A
506%                 % POLARITE +
507%                 Leff=LtotSX;
508%                 a7=  0.0;
509%                 a6=  0.0;
510%                 a5=  0.0;
511%                 a4=  0.0;
512%                 a3=  0.0;
513%                 a2=  -6.1567262E-6;
514%                 a1=   1.5520734E-1;
515%                 a0=   1.9694261E-1;
516%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
517%                 MagnetType = 'SEXT';
518
519            case{'S3','S9'}
520                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 200 et 250A
521                % POLARITE -
522                Leff=LtotSX;
523                a7=  0.0;
524                a6=  0.0;
525                a5=  0.0;
526                a4=  0.0;
527                a3=  0.0;
528                a2=  -1.3881816E-5*(-1);
529                a1=   1.5827135E-1;
530                a0=  -1.0713717E-1*(-1);
531                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
532                MagnetType = 'SEXT';
533
534            case {'S4','S10'}
535                % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 200 et 250A
536                % POLARITE +
537                Leff=LtotSX;
538                a7=  0.0;
539                a6=  0.0;
540                a5=  0.0;
541                a4=  0.0;
542                a3=  0.0;
543                a2=  -1.3881816E-5;
544                a1=   1.5827135E-1;
545                a0=  -1.0713717E-1;
546                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
547                MagnetType = 'SEXT';
548
549
550%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 250 et 300A
551%                 % POLARITE -
552%                 Leff=LtotSX;
553%                 a7=  0.0;
554%                 a6=  0.0;
555%                 a5=  0.0;
556%                 a4=  0.0;
557%                 a3=  0.0;
558%                 a2=  -4.0540578E-5*(-1);
559%                 a1=   1.7188604E-1;
560%                 a0=  -1.8459591E+0*(-1);
561%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
562%                 MagnetType = 'SEXT';
563
564           
565%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 250 et 300A
566%                 % POLARITE +
567%                 Leff=LtotSX;
568%                 a7=  0.0;
569%                 a6=  0.0;
570%                 a5=  0.0;
571%                 a4=  0.0;
572%                 a3=  0.0;
573%                 a2=  -4.0540578E-5;
574%                 a1=   1.7188604E-1;
575%                 a0=  -1.8459591E+0;
576%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
577%                 MagnetType = 'SEXT';
578
579%                 % CAS DU SEXTUPOLE DONT LE COURANT EST COMPRIS ENTRE 300 et 350A
580%                 Leff=LtotSX;
581%                 a7=  0.0;
582%                 a6=  0.0;
583%                 a5=  0.0;
584%                 a4=  0.0;
585%                 a3=  -4.4295939E-6;
586%                 a2=  -4.0682266E-3;
587%                 a1=  -1.0997217E+0;
588%                 a0=   1.2944731E+2;
589%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
590%                 MagnetType = 'SEXT';         
591
592%%               
593               
594            case 'QT'    % 160 mm dans sextupole
595                % Etalonnage: moyenne sur les 32 sextupï¿œles incluant un QT.
596                % Efficacite = 3 G.m/A @ R=32mm; soit 93.83 G/A
597                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
598                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
599                Leff = 1e-8;
600                a7= 0.0;
601                a6= 0.0;
602                a5= 0.0;
603                a4= 0.0;
604                a3= 0.0;
605                a2= 0.0;
606                a1= 93.83E-4;
607                a0= 0.0;
608                A = [a7 a6 a5 a4 a3 a2 a1 a0];
609
610                MagnetType = 'QT';
611
612             case 'SQ'   % 160 mm dans sextupole
613                % Etalonnage: moyenne sur les 32 sextupï¿œles incluant un QT.
614                % Efficacitee = 3 G.m/A @ R=32mm; soit 93.83 G/A
615                % Le signe du courant est donnee par le DeviceServer (Tango)
616                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
617                Leff = 1e-8;
618                a7= 0.0;
619                a6= 0.0;
620                a5= 0.0;
621                a4= 0.0;
622                a3= 0.0;
623                a2= 0.0;
624                a1= 93.83E-4;
625                a0= 0.0;
626                A = [a7 a6 a5 a4 a3 a2 a1 a0];
627
628                MagnetType = 'QT';               
629               
630            case {'HCOR'}    % 16 cm horizontal corrector
631                % Etalonnage: moyenne sur les 56 sextupï¿œles incluant un CORH.
632                % Efficacitï¿œ = 8.143 G.m/A
633                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
634                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
635                Leff = 0.16;
636                a7= 0.0;
637                a6= 0.0;
638                a5= 0.0;
639                a4= 0.0;
640                a3= 0.0;
641                a2= 0.0;
642                a1= 8.143E-4;
643                a0= 0.0;
644                A = [a7 a6 a5 a4 a3 a2 a1 a0];
645
646                MagnetType = 'COR';
647               
648
649            case {'FHCOR'}    % 10 cm horizontal corrector
650                % Magnet Spec: Theta = 280e-6 radians @ 2.75 GeV and 10 amps
651                % Theta = BLeff / Brho    [radians]
652                % Therefore,
653                %       Theta = ((BLeff/Amp)/ Brho) * I
654                %       BLeff/Amp = 280e-6 * getbrho(2.75) / 10
655                %       B*Leff = a0 * I   => a0 = 0.8e-3 * getbrho(2.75) / 10
656                %
657                % The C coefficients are w.r.t B
658                %       B = c0 + c1*I = (0 + a0*I)/Leff
659                % However, AT uses Theta in radians so the A coefficients
660                % must be used for correctors with the middle layer with
661                % the addition of the DC term
662
663                % Find the current from the given polynomial for BLeff and B
664                % NOTE: AT used BLeff (A) for correctors
665                Leff = .10;
666                imax = 10;
667                cormax = 28e-6 ; % 28 urad for imax = 10 A
668                MagnetType = 'COR';
669                A = [0 cormax*getbrho(2.75)/imax 0];
670
671            case {'VCOR'}    % 16 cm vertical corrector
672                % Etalonnage: moyenne sur les 56 sextupï¿œles incluant un CORV.
673                % Efficacitï¿œ = 4.642 G.m/A
674                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
675                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
676                Leff = 0.16;
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= 4.642E-4;
684                a0= 0.0;
685                A = [a7 a6 a5 a4 a3 a2 a1 a0];
686
687                MagnetType = 'COR';
688
689            case {'FVCOR'}    % 10 cm vertical corrector
690                % Find the current from the given polynomial for BLeff and B
691                Leff = .10;
692                imax = 10;
693                cormax = 23e-6 ; % 23 urad for imax = 10 A
694                MagnetType = 'COR';
695                A = [0 cormax*getbrho(2.75)/imax 0];
696
697            case {'K_INJ'}
698                % Kicker d'injection
699                % étalonnage provisoire
700                % attention l'element n'etant pas dans le modele,definition
701                % de A ambigue
702                Leff = .6;
703                vmax = 8000;
704                alphamax = 8e-3 ; % 8 mrad pour 8000 V
705                MagnetType = 'K_INJ';
706                A = [0 alphamax*getbrho(2.75)/vmax 0]*Leff;
707               
708             case {'K_INJ1'}
709                % Kickers d'injection 1 et 4
710                Leff = .6;
711                vmax = 7500; % tension de mesure
712                SBDL = 75.230e-3 ; % somme de Bdl mesurée
713                MagnetType = 'K_INJ1';
714                A = [0 -SBDL/vmax 0]*Leff;
715               
716             case {'K_INJ2'}
717                % Kickers d'injection 2 et 3
718                Leff = .6;
719                vmax = 7500;% tension de mesure
720                SBDL = 74.800e-3 ; % somme de Bdl mesurée
721                MagnetType = 'K_INJ2'; 
722                A = [0 SBDL/vmax 0]*Leff;
723               
724            case {'SEP_P'}
725                % Septum passif d'injection
726                Leff = .6;
727                vmax = 547; % tension de mesure V
728                SBDL = 263e-3; % somme de Bdl mesurée
729                MagnetType = 'SEP_P';
730                A = [0 SBDL/vmax 0]*Leff;
731               
732             case {'SEP_A'}
733                % Septum actif d'injection
734                Leff = 1.;
735                vmax = 111;
736                MagnetType = 'SEP_A';
737                SBDL = 1147.8e-3 ; % Somme de Bdl mesurée à 111 V
738                A = [0 SBDL/vmax 0]*Leff;
739
740            otherwise
741                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
742                k = 0;
743                MagnetType = '';
744                return
745        end
746
747        % compute B-field = int(Bdl)/Leff
748        C = A / Leff;
749
750        MagnetType = upper(MagnetType);
751
752
753        % Power Series Denominator (Factoral) be AT compatible
754        if strcmpi(MagnetType,'SEXT')
755            C = C / 2;
756        end
757        if strcmpi(MagnetType,'OCTO')
758            C = C / 6;
759        end
760        return;
761       
762    case 'Booster'
763        %%%%
764        switch upper(deblank(MagnetCoreType))
765
766            case 'BEND'   
767                % B[T] = 0.00020 + 0.0013516 I[A]
768                % B[T] = 0.00020 + (0.0013051 + 0.00005/540 I) I[A] Alex
769                Leff = 2.160; % 2160 mm               
770                a8 =  0.0;
771                a7 =  0.0;
772                a6 =  0.0;
773                a5 =  0.0;
774                a4 =  0.0;
775                a3 =  0.0;
776                a2 =  9.2e-8*Leff;
777                a1 =  0.0013051*Leff;
778                a0 =  2.0e-3*Leff;
779
780                A = [a8 a7 a6 a5 a4 a3 a2 a1 a0];
781                MagnetType = 'BEND';
782
783            case {'QF'}   % 400 mm quadrupole
784                % Find the current from the given polynomial for B'Leff
785                % G[T/m] = 0.0465 + 0.0516 I[A] Alex
786                Leff=0.400;
787                a8 =  0.0;
788                a7 =  0.0;
789                a6 =  0.0;
790                a5 =  0.0;
791                a4 =  0.0;
792                a3 =  0.0;
793                a2 =  0.0;
794                a1 =  0.0516*Leff;
795                a0 =  0.0465*Leff;
796               
797                A = [a7 a6 a5 a4 a3 a2 a1 a0]; %*getbrho(0.1);
798                MagnetType = 'QUAD';
799
800            case {'QD'}   % 400 mm quadrupole
801                % Find the current from the given polynomial for B'Leff
802                % G[T/m] = 0.0485 + 0.0518 I[A] Alex
803                Leff=0.400;
804                a8 =  0.0;
805                a7 =  0.0;
806                a6 =  0.0;
807                a5 =  0.0;
808                a4 =  0.0;
809                a3 =  0.0;
810                a2 =  0.0;
811                a1 =  -0.0518*Leff;
812                a0 =  -0.0485*Leff;
813               
814                A = [a7 a6 a5 a4 a3 a2 a1 a0]; %*getbrho(0.1);
815                MagnetType = 'QUAD';
816
817            case {'SF', 'SD'}   % 150 mm sextupole
818                % Find the current from the given polynomial for B'Leff
819                % HL [T/m] = 0.2 I [A] (deja intï¿œgrï¿œ)
820                Leff=1.e-8; % thin lens;
821                a8 =  0.0;
822                a7 =  0.0;
823                a6 =  0.0;
824                a5 =  0.0;
825                a4 =  0.0;
826                a3 =  0.0;
827                a2 =  0.0;
828                a1 =  0.2*2;
829                a0 =  0.0;
830               
831                A = [a7 a6 a5 a4 a3 a2 a1 a0];
832                MagnetType = 'SEXT';
833               
834            case {'HCOR','VCOR'}    % ?? cm horizontal corrector
835                % Magnet Spec: Theta = 0.8e-3 radians @ 2.75 GeV and 10 amps
836                % Theta = BLeff / Brho    [radians]
837                % Therefore,
838                %       Theta = ((BLeff/Amp)/ Brho) * I
839                %       BLeff/Amp = 0.8e-3 * getbrho(2.75) / 10
840                %       B*Leff = a0 * I   => a0 = 0.8e-3 * getbrho(2.75) / 10
841                %
842                % The C coefficients are w.r.t B
843                %       B = c0 + c1*I = (0 + a0*I)/Leff
844                % However, AT uses Theta in radians so the A coefficients
845                % must be used for correctors with the middle layer with
846                % the addition of the DC term
847
848                % Find the current from the given polynomial for BLeff and B
849                % NOTE: AT used BLeff (A) for correctors
850                MagnetType = 'COR';
851                % theta [mrad] = 1.34 I[A] @ 0.1 GeV
852                Leff = 1e-6;
853                a8 =  0.0;
854                a7 =  0.0;
855                a6 =  0.0;
856                a5 =  0.0;
857                a4 =  0.0;
858                a3 =  0.0;
859                a2 =  0.0;
860                a1 =  1.34e-3*getbrho(0.1);
861                a0 =  0;
862                A = [a7 a6 a5 a4 a3 a2 a1 a0];
863               
864            otherwise
865                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
866                %k = 0;
867                %MagnetType = '';
868                %return
869        end
870
871        % compute B-field = int(Bdl)/Leff
872        C = A/ Leff;
873 
874        % Power Series Denominator (Factoral) be AT compatible
875        if strcmpi(MagnetType,'SEXT')
876            C = C / 2;
877        end
878 
879        MagnetType = upper(MagnetType);
880
881    case 'LT2'
882        %%%%
883        switch upper(deblank(MagnetCoreType))
884
885            case 'BEND'   
886                % les coefficients et longueur magnétique sont recopiés de l'anneau
887                Leff=1.052433;
888                a7= 0.0;
889                a6=-0.0;
890                a5= 0.0;
891                a4=-0.0;
892                a3= 0.0;
893                a2=-9.7816E-6*(1-1.8e-3)*Leff*(1.055548/1.052433);
894                a1= 1.26066E-02*(1-1.8E-3)*Leff*(1.055548/1.052433);
895                a0= -2.24944*(1-1.8E-3)*Leff*(1.055548/1.052433);
896                A = [a7 a6 a5 a4 a3 a2 a1 a0];
897               
898
899                MagnetType = 'BEND';
900
901            case {'QP'}   % 400 mm quadrupole
902                % Find the current from the given polynomial for B'Leff
903               
904                % G[T/m] = 0.1175 + 0.0517 I[A]
905                % le rémanent est + fort que pour les quad Booster car les
906                % courants max sont + eleves
907                Leff=0.400;
908%                 a8 =  0.0;
909%                 a7 =  0.0;
910%                 a6 =  0.0;
911%                 a5 =  0.0;
912%                 a4 =  0.0;
913%                 a3 =  0.0;
914%                 a2 =  0.0;
915%                 a1 =  0.0517*Leff;
916%                 a0 =  0.1175*Leff;
917               
918                a8 =  0.0;
919                a7 =  0.0;
920                a6 =  0.0;
921                a5 =  0.0;
922                a4 =  -1.3345e-10;
923                a3 =  8.1746e-8;
924                a2 =  -1.6548e-5;
925                a1 =  2.197e-2;
926                a0 =  2.73e-2;
927                A = [a7 a6 a5 a4 a3 a2 a1 a0];
928                MagnetType = 'QUAD';
929
930            case {'CH','CV'}    % 16 cm horizontal corrector
931               
932
933               
934                % Magnet Spec: Theta = environ 1 mradians @ 2.75 GeV and 10 amps
935                % Theta = BLeff / Brho    [radians]
936                % Therefore,
937                %       Theta = ((BLeff/Amp)/ Brho) * I
938                %       BLeff/Amp = 1.e-3 * getbrho(2.75) / 10
939                %       B*Leff = a1 * I   => a1 = 1.e-3 * getbrho(2.75) / 10
940                %
941                % The C coefficients are w.r.t B
942                %       B = c0 + c1*I = (0 + a0*I)/Leff
943                % However, AT uses Theta in radians so the A coefficients
944                % must be used for correctors with the middle layer with
945                % the addition of the DC term
946
947                % Find the current from the given polynomial for BLeff and B
948                % NOTE: AT used BLeff (A) for correctors
949               
950                % environ 32 cm  corrector
951                % Efficacitï¿œ = 11.06 G.m/A
952                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
953                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) =
954                % magnetcoefficien
955               
956                MagnetType = 'COR';
957               
958                Leff = 1e-6; % 0.1577 m
959                a8 =  0.0;
960                a7 =  0.0;
961                a6 =  0.0;
962                a5 =  0.0;
963                a4 =  0.0;
964                a3 =  0.0;
965                a2 =  0.0;
966                a1 =  110.6e-4/10;
967                a0 =  0;
968                A = [a7 a6 a5 a4 a3 a2 a1 a0];
969               
970            otherwise
971                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
972                %k = 0;
973                %MagnetType = '';
974                %return
975        end
976
977        % compute B-field = int(Bdl)/Leff
978        C = A/ Leff;
979
980        MagnetType = upper(MagnetType);
981
982    otherwise
983        error('Unknown accelerator name %s', AcceleratorName);
984end
Note: See TracBrowser for help on using the repository browser.