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