source: MML/trunk/machine/SOLEIL/StorageRing/Lattices/magnetcoefficients_alphaby10_from_nomopt_positif_juin2011.m

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

To have a stable version on the server.

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