source: MML/trunk/machine/SOLEIL/StorageRing/Lattices/lowalpha_dec08/magnetcoefficients_new_cal_lowalphaMAHER_Linterm.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: 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
60if nargin < 1
61    error('MagnetCoreType input required');
62end
63
64if nargin < 2
65    Amps = 230;  % not sure!!!
66end
67
68if nargin < 3
69    InputType = 'Amps';
70end
71
72
73
74% For a string matrix
75if iscell(MagnetCoreType)
76    for i = 1:size(MagnetCoreType,1)
77        for j = 1:size(MagnetCoreType,2)
78            [C{i,j}, Leff{i,j}, MagnetType{i,j}, A{i,j}] = magnetcoefficients(MagnetCoreType{i});
79        end
80    end
81    return
82end
83
84% For a string matrix
85if size(MagnetCoreType,1) > 1
86    C=[]; Leff=[]; MagnetType=[]; A=[];
87    for i = 1:size(MagnetCoreType,1)
88        [C1, Leff1, MagnetType1, A1] = magnetcoefficients(MagnetCoreType(i,:));
89        C(i,:) = C1;
90        Leff(i,:) = Leff1;
91        MagnetType = strvcat(MagnetType, MagnetType1);
92        A(i,:) = A1;
93    end
94    return
95end
96
97%% get accelerator name
98AcceleratorName = getfamilydata('SubMachine');
99
100switch AcceleratorName
101    case 'LT1'
102        %%%%
103        switch upper(deblank(MagnetCoreType))
104
105            case 'BEND'   
106                Leff = 0.30; % 300 mm
107                % B = 1e-4 * (0.0004 Iï¿œ + 16.334 I + 1.7202)
108                a8 =  0.0;
109                a7 =  0.0;
110                a6 =  0.0;
111                a5 =  0.0;
112                a4 =  0.0;
113                a3 =  0.0;
114                a2 =  0.0;
115                a1 =  4.8861e-4;
116                a0 =  1.19e-4;
117
118                A = [a8 a7 a6 a5 a4 a3 a2 a1 a0];
119                MagnetType = 'BEND';
120
121            case {'QP'}   % 150 mm quadrupole
122                % Find the current from the given polynomial for B'Leff
123                Leff=0.150; % 162 mm;
124                a8 =  0.0;
125                a7 =  0.0;
126                a6 =  0.0;
127                a5 =  0.0;
128%                 a4 =  1.49e-6;
129%                 a3 =  2.59e-5;
130%                 a2 =  1.93e-4;
131%                 a1 =  4.98e-2;
132%                 a0 =  0.0;
133                a4 =  -1.49e-6;
134                a3 =  2.59e-5;
135                a2 =  -1.93e-4;
136                a1 =  4.98e-2;
137                a0 =  8.13e-4;             
138               
139                A = [a7 a6 a5 a4 a3 a2 a1 a0];
140                MagnetType = 'QUAD';
141
142            case {'CH','CV'}    % 16 cm horizontal corrector
143                % Magnet Spec: Theta = 0.8e-3 radians @ 2.75 GeV and 10 amps
144                % Theta = BLeff / Brho    [radians]
145                % Therefore,
146                %       Theta = ((BLeff/Amp)/ Brho) * I
147                %       BLeff/Amp = 0.8e-3 * getbrho(2.75) / 10
148                %       B*Leff = a0 * I   => a0 = 0.8e-3 * getbrho(2.75) / 10
149                %
150                % The C coefficients are w.r.t B
151                %       B = c0 + c1*I = (0 + a0*I)/Leff
152                % However, AT uses Theta in radians so the A coefficients
153                % must be used for correctors with the middle layer with
154                % the addition of the DC term
155
156                % Find the current from the given polynomial for BLeff and B
157                % NOTE: AT used BLeff (A) for correctors
158                MagnetType = 'COR';
159               
160                Leff = 1e-6; % 0.1577 m
161                a8 =  0.0;
162                a7 =  0.0;
163                a6 =  0.0;
164                a5 =  0.0;
165                a4 =  0.0;
166                a3 =  0.0;
167                a2 =  0.0;
168                a1 =  4.49e-4;
169                a0 =  0;
170                A = [a7 a6 a5 a4 a3 a2 a1 a0];
171               
172            otherwise
173                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
174                %k = 0;
175                %MagnetType = '';
176                %return
177        end
178
179        % compute B-field = int(Bdl)/Leff
180        C = A/ Leff;
181
182        MagnetType = upper(MagnetType);
183   
184    case 'StorageRing'
185        %%%%
186        coeffQ = 0e-3 ; %0e-3  ;     %  0e-3     %  0e-3 ;   %  0e-3      ;  %  8e-3  ;   % appliquï¿œ sur le premier faisceau
187        LtotQC = 0.3602 ; %0.3539 ;    %  0.3696   % 0.3539;   %  0.3695814 ;  %  0.320 ;   % longueur effective Qpole court
188        LtotQL = 0.4962  ; %0.4917 ;    %  0.5028   % 0.4917;   %  0.5027758 ;  %  0.460 ;   % longueur effective Qpole long
189        switch upper(deblank(MagnetCoreType))
190
191             
192           
193            case 'BEND'   
194                % Moyenne des longueurs magnï¿œtiques mesurï¿œes = 1055.548mm
195                % Décalage en champ entre le dipï¿œle de référence et les
196                % dipï¿œles de l'Anneau = DB/B= +1.8e-03.
197                % On part de l'ï¿œtalonnage B(I) effectuï¿œ sur le dipï¿œle de
198                % rï¿œfï¿œrence dans la zone de courant 516 - 558 A
199                % les coefficients du fit doivent ï¿œtre affectï¿œs du facteur
200                % (1-1.8e-3) pour passer du dipï¿œle de rï¿œfï¿œrence ï¿œ l'Anneau
201                % et du facteur Leff pour passer ï¿œ l'intï¿œgrale de champ.
202                %
203               
204                % B=1.7063474 T correspond ï¿œ 2.75 GeV
205                % ?  longueur magnétique du model : Leff = 1.052433;
206%                 Leff=1.055548;
207%                 a7= 0.0;
208%                 a6=-0.0;
209%                 a5= 0.0;
210%                 a4=-0.0;
211%                 a3= 0.0;
212%                 a2=-9.7816E-6*(1-1.8e-3)*Leff;
213%                 a1= 1.26066E-02*(1-1.8E-3)*Leff;
214%                 a0= -2.24944*(1-1.8E-3)*Leff;
215%                 A = [a7 a6 a5 a4 a3 a2 a1 a0];
216               
217                Leff=1.052433;
218                a7= 0.0;
219                a6=-0.0;
220                a5= 0.0;
221                a4=-0.0;
222                a3= 0.0;
223                a2=-9.7816E-6*(1-1.8e-3)*Leff*(1.055548/1.052433);
224                a1= 1.26066E-02*(1-1.8E-3)*Leff*(1.055548/1.052433);
225                a0= -2.24944*(1-1.8E-3)*Leff*(1.055548/1.052433);
226                A = [a7 a6 a5 a4 a3 a2 a1 a0];
227               
228
229                MagnetType = 'BEND';
230
231            case {'Q3','Q4'} 
232                % Familles Q1 et Q6 l= 320 mm
233                % Etalonnage GL(I) sur 90 - 150 A quadrupï¿œle court
234                % le courant remontï¿œ est nï¿œgatif car Q1 et Q6 dï¿œfocalisants
235                % il faut donc un k < 0. Les coefficients du fit a0, a2,
236                % a4,...sont multipliï¿œs par -1.
237               
238                % Correction des coefficients des QC de + 3 10-3 (manque
239                % capteur BMS)
240               
241                %correction offset capteur BMS -2.310-3 P. Brunelle 30/05/06
242                bob=0.9977*(1-coeffQ);
243                % Find the current from the given polynomial for B'Leff
244                Leff=LtotQC;
245               
246                a7=  0.0; % old Q6 Q1 nominal
247                a6=  0.0;
248                a5=  0.0;
249                a4=  0.0;
250                a3=  0.0;
251                a2=  -1.6291E-6*(-1)*(1.003)*bob;
252                a1=  2.7836E-2*(1.003)*bob;
253                a0=  6.4464E-3*(-1)*(1.003)*bob;
254
255  % ancien ï¿œtalonnage               
256%                 a7=  0.0;
257%                 a6=  0.0;
258%                 a5=  0.0;
259%                 a4=  0.0;
260%                 a3=  0.0;
261%                 a2=  -8.6E-7*(-1)*(1.003)*bob;
262%                 a1=  2.7664E-2*(1.003)*bob;
263%                 a0=  -3.3E-3*(-1)*(1.003)*bob;
264
265         
266                A = [a7 a6 a5 a4 a3 a2 a1 a0];
267               
268                MagnetType = 'quad';
269               
270             case {'Q6'} 
271                % Familles Q8 et Q9 l= 320 mm
272                % Etalonnage GL(I) sur 160 - 200 A quadrupï¿œle court
273                % le courant remontï¿œ est nï¿œgatif car Q8 et Q9 dï¿œfocalisants
274                % il faut donc un k < 0. Les coefficients du fit a0, a2,
275                % a4,...sont multipliï¿œs par -1.
276               
277                % Correction des coefficients des QC de + 3 10-3 (manque
278                % capteur BMS)
279               
280                %correction offset capteur BMS -2.310-3 P. Brunelle 30/05/06
281                bob=0.9977*(1-coeffQ);
282
283                % Find the current from the given polynomial for B'Leff
284                Leff=LtotQC; % old Q9 nominal
285                a7=  0.0;
286                a6=  0.0;
287                a5=  0.0;
288                a4=  0.0;
289                a3=  -1.2923E-7*(1.003)*bob;
290                a2=  5.8239E-5*(-1)*(1.003)*bob;
291                a1=  1.8473E-2*(1.003)*bob;
292                a0=  5.0028E-1*(-1)*(1.003)*bob;
293               
294% %                 a7=  0.0;
295% %                 a6=  0.0;
296% %                 a5=  0.0;
297% %                 a4=  0.0;
298% %                 a3=  -8.843E-8*(1.003)*bob;
299% %                 a2=  3.6389E-5*(-1)*(1.003)*bob;
300% %                 a1=  2.2448E-2*(1.003)*bob;
301% %                 a0=  2.382E-1*(-1)*(1.003)*bob; 
302
303                A = [a7 a6 a5 a4 a3 a2 a1 a0];
304               
305                MagnetType = 'quad'; 
306               
307            case {'Q1'} 
308                % Famille Q3 l= 320 mm
309                % Etalonnage GL(I) sur 50 - 100 A quadrupï¿œle court
310                % le courant remontï¿œ est nï¿œgatif car Q3 est dï¿œfocalisant
311                % il faut donc un k < 0. Les coefficients du fit a0, a2,
312                % a4,...sont multipliï¿œs par -1.
313               
314                %Correction des coefficients des QC de + 3 10-3 (manque
315                % capteur BMS)
316               
317                %correction offset capteur BMS -2.310-3 P. Brunelle 30/05/06
318                bob=0.9977*(1-coeffQ);
319
320                % Find the current from the given polynomial for B'Leff
321                Leff=LtotQC;
322                a7=  0.0; % old Q3
323                a6=  0.0;
324                a5=  0.0;
325                a4=  0.0;
326                a3=  0.;
327                a2=  -1.6947E-7*(-1)*(1.003)*bob;
328                a1=  2.7565E-2*(+1)*(1.003)*bob;
329                a0=  1.9108E-2*(-1)*(1.003)*bob;
330
331%                 a7=  0.0;
332%                 a6=  0.0;
333%                 a5=  0.0;
334%                 a4=  0.0;
335%                 a3=  0.;
336%                 a2=  1.4E-7*(-1)*(1.003)*bob;
337%                 a1=  2.7471E-2*(1.003)*bob;
338%                 a0=  5.83E-3*(-1)*(1.003)*bob;
339
340                A = [a7 a6 a5 a4 a3 a2 a1 a0];
341               
342                MagnetType = 'quad';
343     
344                case {'Q8'} 
345                % Famille Q3 l= 320 mm
346                % Etalonnage GL(I) sur 50 - 100 A quadrupï¿œle court
347                % le courant remontï¿œ est nï¿œgatif car Q3 est dï¿œfocalisant
348                % il faut donc un k < 0. Les coefficients du fit a0, a2,
349                % a4,...sont multipliï¿œs par -1.
350               
351                %Correction des coefficients des QC de + 3 10-3 (manque
352                % capteur BMS)
353               
354                %correction offset capteur BMS -2.310-3 P. Brunelle 30/05/06
355                bob=0.9977*(1-coeffQ);
356
357                % Find the current from the given polynomial for B'Leff
358                Leff=LtotQC;
359                a7=  0.0;
360                a6=  0.0;
361                a5=  0.0;
362                a4=  0.0;
363                a3=  0.;
364                a2=  -1.6947E-7*(+1)*(1.003)*bob;
365                a1=  2.7565E-2*(-1)*(1.003)*bob;
366                a0=  1.9108E-2*(+1)*(1.003)*bob;
367
368%                 a7=  0.0;
369%                 a6=  0.0;
370%                 a5=  0.0;
371%                 a4=  0.0;
372%                 a3=  0.;
373%                 a2=  1.4E-7*(-1)*(1.003)*bob;
374%                 a1=  2.7471E-2*(1.003)*bob;
375%                 a0=  5.83E-3*(-1)*(1.003)*bob;
376
377                A = [a7 a6 a5 a4 a3 a2 a1 a0];
378               
379                MagnetType = 'quad';
380               
381             case {'Q9'} 
382                % Famille Q4 l= 320 mm
383                % Etalonnage GL(I) sur 120 - 170 A quadrupï¿œle court
384                % le courant remontï¿œ est nï¿œgatif car Q4 est dï¿œfocalisant
385                % il faut donc un k < 0. Les coefficients du fit a0, a2,
386                % a4,...sont multipliï¿œs par -1.
387               
388                %Correction des coefficients des QC de + 3 10-3 (manque
389                % capteur BMS)
390               
391                %correction offset capteur BMS -2.310-3 P. Brunelle 30/05/06
392                bob=0.9977*(1-coeffQ);
393               
394                % Find the current from the given polynomial for B'Leff
395                Leff=LtotQC; % old Q4 nominal
396                a7=  0.0;
397                a6=  0.0;
398                a5=  0.0;
399                a4=  0.0;
400                a3=  -4.1218E-8*(1.003)*bob;
401                a2=  1.4210E-5*(-1)*(1.003)*bob;
402                a1=  2.5819E-2*(1.003)*bob;
403                a0=  9.1648E-2*(-1)*(1.003)*bob;
404               
405% %                 a7=  0.0;
406% %                 a6=  0.0;
407% %                 a5=  0.0;
408% %                 a4=  0.0;
409% %                 a3=  -5.2680E-8*(1.003)*bob;
410% %                 a2=  1.9620E-5*(-1)*(1.003)*bob;
411% %                 a1=  2.5016E-2*(1.003)*bob;
412% %                 a0=  1.1046E-1*(-1)*(1.003)*bob;             
413               
414                A = [a7 a6 a5 a4 a3 a2 a1 a0];
415               
416                MagnetType = 'quad';
417               
418            case {'Q5','Q10'}   % 320 mm quadrupole
419                 % Familles Q5 et Q10 l= 320 mm
420                % Etalonnage GL(I) sur 180 - 230 A quadrupï¿œle court
421                % le courant remontï¿œ est nï¿œgatif car Q5 et Q10 sont
422                % focalisants
423               
424                %Correction des coefficients des QC de + 3 10-3 (manque
425                % capteur BMS)
426               
427                %correction offset capteur BMS -2.310-3 P. Brunelle 30/05/06
428                bob=0.9977*(1-coeffQ);
429               
430                % Find the current from the given polynomial for B'Leff
431                Leff=LtotQC;
432                a7=  0.0;
433                a6=  0.0;
434                a5=  0.0;
435                a4=  -1.016107E-08*(1.003)*bob;
436                a3=  7.728562E-06*(1.003)*bob;
437                a2=  -2.220046E-03*(1.003)*bob;
438                a1=  3.119852E-01*(1.003)*bob;
439                a0=  -1.367539E+01*(1.003)*bob;
440               
441%                 a7=  0.0;
442%                 a6=  0.0;
443%                 a5=  0.0;
444%                 a4=  -8.0497E-09*(1.003)*bob;
445%                 a3= 6.01284E-06*(1.003)*bob;
446%                 a2=  -1.696898E-03*(1.003)*bob;
447%                 a1=  2.41175E-01*(1.003)*bob;
448%                 a0=  -1.01064E+01*(1.003)*bob;               
449               
450                  A = [a7 a6 a5 a4 a3 a2 a1 a0];
451
452                MagnetType = 'quad';   
453                   
454            case {'Q2'}   % l= 460 mm
455                % quadrupï¿œle focalisant
456                % Etalonnage GL(I) sur 140 - 190 A quadrupï¿œle long
457               
458               
459                %Correction des coefficients des QL de + 1.55 10-2 (manque
460                % capteur BMS)
461               
462                %correction offset capteur BMS -2.310-3 P. Brunelle 30/05/06
463                bob=0.9977*(1-coeffQ);
464
465                % Find the current from the given polynomial for B'Leff
466                Leff=LtotQL;
467                a7=  0.0;
468                a6=  0.0;
469                a5= -0.0;
470                a4=  0.0;
471                a3= -2.58099E-7*(1.0155)*bob;
472                a2=  1.070688E-4*(1.0155)*bob;
473                a1=  2.938E-2*(1.0155)*bob;
474                a0=  7.6201E-1*(1.0155)*bob;
475               
476%                 a7=  0.0;
477%                 a6=  0.0;
478%                 a5= -0.0;
479%                 a4=  0.0;
480%                 a3= -2.7609E-7*(1.0155)*bob;
481%                 a2=  1.17098E-4*(1.0155)*bob;
482%                 a1=  2.7718E-2*(1.0155)*bob;
483%                 a0=  8.2470E-1*(1.0155)*bob;               
484                         
485                A = [a7 a6 a5 a4 a3 a2 a1 a0];
486               
487                MagnetType = 'quad';
488
489            case {'Q7'}   % l= 460 mm
490                % quadrupï¿œle focalisant
491                % Etalonnage GL(I) sur 190 - 230 A quadrupï¿œle long
492               
493                %Correction des coefficients des QL de + 1.55 10-2 (manque
494                % capteur BMS)
495               
496                %correction offset capteur BMS -2.310-3 P. Brunelle 30/05/06
497                bob=0.9977*(1-coeffQ);
498
499                % Find the current from the given polynomial for B'Leff
500                Leff=LtotQL;
501                a7=  0.0;
502                a6=  0.0;
503                a5=  0.0;
504                a4=  0.0;
505                a3=  0.0;
506                a2=  -3.00540384E-06*(1.0155)*bob;
507                a1=  4.5165446E-02*(1.0155)*bob;
508                a0=  8.27807998E-04*(1.0155)*bob;
509               
510%                 a7=  0.0;
511%                 a6=  0.0;
512%                 a5= 1.50427350E-9*(1.0155)*bob;
513%                 a4=  -1.52722610E-6*(1.0155)*bob;
514%                 a3= 6.16874120E-4*(1.0155)*bob;
515%                 a2=  -1.24044936E-1*(1.0155)*bob;
516%                 a1=  1.24707096E+01*(1.0155)*bob;
517%                 a0=  -4.96304380E+02*(1.0155)*bob;               
518               
519                A = [a7 a6 a5 a4 a3 a2 a1 a0];
520               
521                MagnetType = 'quad';
522
523                % Sextupï¿œles : on multiplie les coefficients par 2 car ils
524                % sont exprimï¿œs en B"L et non B"L/2
525               
526            case {'S1'}   
527                % l= 160 mm focalisants
528                % Etalonnage HL(I) sur 40 - 160 A
529                % Find the current from the given polynomial for B''Leff
530                Leff=1e-8; % modeled as thin length;
531                a7=  0.0;
532                a6=  0.0;
533                a5=  0.0;
534                a4=  0.0;
535                a3=  0.0;
536                a2=  (-1)*-3.773E-6; % maille MAHER S1 retournï¿œ
537                a1=  (-1)*1.5476E-1;
538                a0=  (-1)*2.36991E-1;
539                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
540                MagnetType = 'SEXT';
541               
542               
543            case {'S2','S5','S7'}   
544                % l= 160 mm dï¿œfocalisants
545                % Etalonnage HL(I) sur 80 - 250 A
546                % Find the current from the given polynomial for B''Leff
547                Leff=1e-8; % modeled as thin length;
548                a7=  0.0;
549                a6=  0.0;
550                a5=  0.0;
551                a4=  0.0;
552                a3=  -2.6735E-8;   % anciennement intervalle de S3 S9
553                a2=  5.8793E-6*(-1);
554                a1=  1.5364E-1;
555                a0=  2.7867E-1*(-1);
556                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
557                MagnetType = 'SEXT';
558               
559             case {'S6','S8'}   
560                % l= 160 mm focalisant
561                % Etalonnage HL(I) sur 80 - 250 A
562                % Find the current from the given polynomial for B''Leff
563                Leff=1e-8; % modeled as thin length;
564                a7=  0.0;
565                a6=  0.0;
566                a5=  0.0;
567                a4=  0.0;
568                a3=  -2.6735E-8; % anciennement intervalle de S6 seulement
569                a2=  5.8793E-6;
570                a1=  1.5364E-1;
571                a0=  2.7867E-1;
572                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
573                MagnetType = 'SEXT';
574
575               
576              case {'S4','S10'}   
577                % l= 160 mm focalisants
578                % Etalonnage HL(I) sur 170 - 300 A
579                % Find the current from the given polynomial for B''Leff
580                Leff=1e-8; % modeled as thin length;
581                a7=  0.0;
582                a6=  0.0;
583                a5=  0.0;
584                a4=  -8.8836E-10; % anicennement S4 S8
585                a3=  7.1089E-7;
586                a2=  -2.2277E-4;
587                a1=  1.8501E-1;
588                a0=  -1.329;
589                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
590                MagnetType = 'SEXT';
591
592             case {'S3','S9'}   
593                % l= 160 mm dï¿œfocalisants
594                % Etalonnage HL(I) sur 170 - 300 A
595                % Find the current from the given polynomial for B''Leff
596                Leff=1e-8; % modeled as thin length;
597                a7=  0.0;
598                a6=  0.0;
599                a5=  0.0;
600                a4=  -8.8836E-10*(-1);  % anciennement S5 S2
601                a3=  7.1089E-7;
602                a2=  -2.2277E-4*(-1);
603                a1=  1.8501E-1;
604                a0=  -1.329*(-1);
605                A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
606                MagnetType = 'SEXT';   
607       
608%               case {'S7'}   
609%                 % l= 160 mm dï¿œfocalisant
610%                 % Etalonnage HL(I) sur 250 - 350 A
611%                 % Find the current from the given polynomial for B''Leff
612%                 Leff=1e-8; % modeled as thin length;
613%                 a7=  0.0;
614%                 a6=  0.0;
615%                 a5=  -2.613556E-10;
616%                 a4=  3.730258E-7*(-1);
617%                 a3=  -2.1301205E-4;
618%                 a2=  6.077561E-2*(-1);
619%                 a1=  -8.5069349;
620%                 a0=  4.933E+2*(-1);
621%                 A = [a7 a6 a5 a4 a3 a2 a1 a0]*2;
622%                 MagnetType = 'SEXT';
623               
624            case 'QT'    % 160 mm dans sextupole
625                % Etalonnage: moyenne sur les 32 sextupï¿œles incluant un QT.
626                % Efficacite = 3 G.m/A @ R=32mm; soit 93.83 G/A
627                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
628                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
629                Leff = 1e-8;
630                a7= 0.0;
631                a6= 0.0;
632                a5= 0.0;
633                a4= 0.0;
634                a3= 0.0;
635                a2= 0.0;
636                a1= 93.83E-4;
637                a0= 0.0;
638                A = [a7 a6 a5 a4 a3 a2 a1 a0];
639
640                MagnetType = 'QT';
641
642             case 'SQ'   % 160 mm dans sextupole
643                % Etalonnage: moyenne sur les 32 sextupï¿œles incluant un QT.
644                % Efficacitee = 3 G.m/A @ R=32mm; soit 93.83 G/A
645                % Le signe du courant est donnee par le DeviceServer (Tango)
646                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
647                Leff = 1e-8;
648                a7= 0.0;
649                a6= 0.0;
650                a5= 0.0;
651                a4= 0.0;
652                a3= 0.0;
653                a2= 0.0;
654                a1= 93.83E-4;
655                a0= 0.0;
656                A = [a7 a6 a5 a4 a3 a2 a1 a0];
657
658                MagnetType = 'QT';               
659               
660            case {'HCOR'}    % 16 cm horizontal corrector
661                % Etalonnage: moyenne sur les 56 sextupï¿œles incluant un CORH.
662                % Efficacitï¿œ = 8.143 G.m/A
663                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
664                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
665                Leff = 0.16;
666                a7= 0.0;
667                a6= 0.0;
668                a5= 0.0;
669                a4= 0.0;
670                a3= 0.0;
671                a2= 0.0;
672                a1= 8.143E-4;
673                a0= 0.0;
674                A = [a7 a6 a5 a4 a3 a2 a1 a0];
675
676                MagnetType = 'COR';
677               
678
679            case {'FHCOR'}    % 10 cm horizontal corrector
680                % Magnet Spec: Theta = 280e-6 radians @ 2.75 GeV and 10 amps
681                % Theta = BLeff / Brho    [radians]
682                % Therefore,
683                %       Theta = ((BLeff/Amp)/ Brho) * I
684                %       BLeff/Amp = 280e-6 * getbrho(2.75) / 10
685                %       B*Leff = a0 * I   => a0 = 0.8e-3 * getbrho(2.75) / 10
686                %
687                % The C coefficients are w.r.t B
688                %       B = c0 + c1*I = (0 + a0*I)/Leff
689                % However, AT uses Theta in radians so the A coefficients
690                % must be used for correctors with the middle layer with
691                % the addition of the DC term
692
693                % Find the current from the given polynomial for BLeff and B
694                % NOTE: AT used BLeff (A) for correctors
695                Leff = .10;
696                imax = 10;
697                cormax = 28e-6 ; % 28 urad for imax = 10 A
698                MagnetType = 'COR';
699                A = [0 cormax*getbrho(2.75)/imax 0];
700
701            case {'VCOR'}    % 16 cm vertical corrector
702                % Etalonnage: moyenne sur les 56 sextupï¿œles incluant un CORV.
703                % Efficacitï¿œ = 4.642 G.m/A
704                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
705                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) = magnetcoefficients(AO.(ifam).FamilyName );
706                Leff = 0.16;
707                a7= 0.0;
708                a6= 0.0;
709                a5= 0.0;
710                a4= 0.0;
711                a3= 0.0;
712                a2= 0.0;
713                a1= 4.642E-4;
714                a0= 0.0;
715                A = [a7 a6 a5 a4 a3 a2 a1 a0];
716
717                MagnetType = 'COR';
718
719            case {'FVCOR'}    % 10 cm vertical corrector
720                % Find the current from the given polynomial for BLeff and B
721                Leff = .10;
722                imax = 10;
723                cormax = 23e-6 ; % 23 urad for imax = 10 A
724                MagnetType = 'COR';
725                A = [0 cormax*getbrho(2.75)/imax 0];
726
727            case {'K_INJ'}
728                % Kicker d'injection
729                % étalonnage provisoire
730                % attention l'element n'etant pas dans le modele,definition
731                % de A ambigue
732                Leff = .6;
733                vmax = 8000;
734                alphamax = 8e-3 ; % 8 mrad pour 8000 V
735                MagnetType = 'K_INJ';
736                A = [0 alphamax*getbrho(2.75)/vmax 0]*Leff;
737               
738             case {'K_INJ1'}
739                % Kickers d'injection 1 et 4
740                Leff = .6;
741                vmax = 7500; % tension de mesure
742                SBDL = 75.230e-3 ; % somme de Bdl mesurée
743                MagnetType = 'K_INJ1';
744                A = [0 -SBDL/vmax 0]*Leff;
745               
746             case {'K_INJ2'}
747                % Kickers d'injection 2 et 3
748                Leff = .6;
749                vmax = 7500;% tension de mesure
750                SBDL = 74.800e-3 ; % somme de Bdl mesurée
751                MagnetType = 'K_INJ2'; 
752                A = [0 SBDL/vmax 0]*Leff;
753               
754            case {'SEP_P'}
755                % Septum passif d'injection
756                Leff = .6;
757                vmax = 547; % tension de mesure V
758                SBDL = 263e-3; % somme de Bdl mesurée
759                MagnetType = 'SEP_P';
760                A = [0 SBDL/vmax 0]*Leff;
761               
762             case {'SEP_A'}
763                % Septum actif d'injection
764                Leff = 1.;
765                vmax = 111;
766                MagnetType = 'SEP_A';
767                SBDL = 1147.8e-3 ; % Somme de Bdl mesurée à 111 V
768                A = [0 SBDL/vmax 0]*Leff;
769
770            otherwise
771                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
772                k = 0;
773                MagnetType = '';
774                return
775        end
776
777        % compute B-field = int(Bdl)/Leff
778        C = A / Leff;
779
780        MagnetType = upper(MagnetType);
781
782
783        % Power Series Denominator (Factoral) be AT compatible
784        if strcmpi(MagnetType,'SEXT')
785            C = C / 2;
786        end
787        if strcmpi(MagnetType,'OCTO')
788            C = C / 6;
789        end
790        return;
791    case 'Booster'
792        %%%%
793        switch upper(deblank(MagnetCoreType))
794
795            case 'BEND'   
796                % B[T] = 0.00020 + 0.0013516 I[A]
797                % B[T] = 0.00020 + (0.0013051 + 0.00005/540 I) I[A] Alex
798                Leff = 2.160; % 2160 mm               
799                a8 =  0.0;
800                a7 =  0.0;
801                a6 =  0.0;
802                a5 =  0.0;
803                a4 =  0.0;
804                a3 =  0.0;
805                a2 =  9.2e-8*Leff;
806                a1 =  0.0013051*Leff;
807                a0 =  2.0e-3*Leff;
808
809                A = [a8 a7 a6 a5 a4 a3 a2 a1 a0];
810                MagnetType = 'BEND';
811
812            case {'QF'}   % 400 mm quadrupole
813                % Find the current from the given polynomial for B'Leff
814                % G[T/m] = 0.0465 + 0.0516 I[A] Alex
815                Leff=0.400;
816                a8 =  0.0;
817                a7 =  0.0;
818                a6 =  0.0;
819                a5 =  0.0;
820                a4 =  0.0;
821                a3 =  0.0;
822                a2 =  0.0;
823                a1 =  0.0516*Leff;
824                a0 =  0.0465*Leff;
825               
826                A = [a7 a6 a5 a4 a3 a2 a1 a0]; %*getbrho(0.1);
827                MagnetType = 'QUAD';
828
829            case {'QD'}   % 400 mm quadrupole
830                % Find the current from the given polynomial for B'Leff
831                % G[T/m] = 0.0485 + 0.0518 I[A] Alex
832                Leff=0.400;
833                a8 =  0.0;
834                a7 =  0.0;
835                a6 =  0.0;
836                a5 =  0.0;
837                a4 =  0.0;
838                a3 =  0.0;
839                a2 =  0.0;
840                a1 =  -0.0518*Leff;
841                a0 =  -0.0485*Leff;
842               
843                A = [a7 a6 a5 a4 a3 a2 a1 a0]; %*getbrho(0.1);
844                MagnetType = 'QUAD';
845
846            case {'SF', 'SD'}   % 150 mm sextupole
847                % Find the current from the given polynomial for B'Leff
848                % HL [T/m] = 0.2 I [A] (deja intï¿œgrï¿œ)
849                Leff=1.e-8; % thin lens;
850                a8 =  0.0;
851                a7 =  0.0;
852                a6 =  0.0;
853                a5 =  0.0;
854                a4 =  0.0;
855                a3 =  0.0;
856                a2 =  0.0;
857                a1 =  0.2*2;
858                a0 =  0.0;
859               
860                A = [a7 a6 a5 a4 a3 a2 a1 a0];
861                MagnetType = 'SEXT';
862               
863            case {'HCOR','VCOR'}    % ?? cm horizontal corrector
864                % Magnet Spec: Theta = 0.8e-3 radians @ 2.75 GeV and 10 amps
865                % Theta = BLeff / Brho    [radians]
866                % Therefore,
867                %       Theta = ((BLeff/Amp)/ Brho) * I
868                %       BLeff/Amp = 0.8e-3 * getbrho(2.75) / 10
869                %       B*Leff = a0 * I   => a0 = 0.8e-3 * getbrho(2.75) / 10
870                %
871                % The C coefficients are w.r.t B
872                %       B = c0 + c1*I = (0 + a0*I)/Leff
873                % However, AT uses Theta in radians so the A coefficients
874                % must be used for correctors with the middle layer with
875                % the addition of the DC term
876
877                % Find the current from the given polynomial for BLeff and B
878                % NOTE: AT used BLeff (A) for correctors
879                MagnetType = 'COR';
880                % theta [mrad] = 1.34 I[A] @ 0.1 GeV
881                Leff = 1e-6;
882                a8 =  0.0;
883                a7 =  0.0;
884                a6 =  0.0;
885                a5 =  0.0;
886                a4 =  0.0;
887                a3 =  0.0;
888                a2 =  0.0;
889                a1 =  1.34e-3*getbrho(0.1);
890                a0 =  0;
891                A = [a7 a6 a5 a4 a3 a2 a1 a0];
892               
893            otherwise
894                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
895                %k = 0;
896                %MagnetType = '';
897                %return
898        end
899
900        % compute B-field = int(Bdl)/Leff
901        C = A/ Leff;
902 
903        % Power Series Denominator (Factoral) be AT compatible
904        if strcmpi(MagnetType,'SEXT')
905            C = C / 2;
906        end
907 
908        MagnetType = upper(MagnetType);
909
910    case 'LT2'
911        %%%%
912        switch upper(deblank(MagnetCoreType))
913
914            case 'BEND'   
915                % les coefficients et longueur magnétique sont recopiés de l'anneau
916                Leff=1.052433;
917                a7= 0.0;
918                a6=-0.0;
919                a5= 0.0;
920                a4=-0.0;
921                a3= 0.0;
922                a2=-9.7816E-6*(1-1.8e-3)*Leff*(1.055548/1.052433);
923                a1= 1.26066E-02*(1-1.8E-3)*Leff*(1.055548/1.052433);
924                a0= -2.24944*(1-1.8E-3)*Leff*(1.055548/1.052433);
925                A = [a7 a6 a5 a4 a3 a2 a1 a0];
926               
927
928                MagnetType = 'BEND';
929
930            case {'QP'}   % 400 mm quadrupole
931                % Find the current from the given polynomial for B'Leff
932               
933                % G[T/m] = 0.1175 + 0.0517 I[A]
934                % le rémanent est + fort que pour les quad Booster car les
935                % courants max sont + eleves
936                Leff=0.400;
937%                 a8 =  0.0;
938%                 a7 =  0.0;
939%                 a6 =  0.0;
940%                 a5 =  0.0;
941%                 a4 =  0.0;
942%                 a3 =  0.0;
943%                 a2 =  0.0;
944%                 a1 =  0.0517*Leff;
945%                 a0 =  0.1175*Leff;
946               
947                a8 =  0.0;
948                a7 =  0.0;
949                a6 =  0.0;
950                a5 =  0.0;
951                a4 =  -1.3345e-10;
952                a3 =  8.1746e-8;
953                a2 =  -1.6548e-5;
954                a1 =  2.197e-2;
955                a0 =  2.73e-2;
956                A = [a7 a6 a5 a4 a3 a2 a1 a0];
957                MagnetType = 'QUAD';
958
959            case {'CH','CV'}    % 16 cm horizontal corrector
960               
961
962               
963                % Magnet Spec: Theta = environ 1 mradians @ 2.75 GeV and 10 amps
964                % Theta = BLeff / Brho    [radians]
965                % Therefore,
966                %       Theta = ((BLeff/Amp)/ Brho) * I
967                %       BLeff/Amp = 1.e-3 * getbrho(2.75) / 10
968                %       B*Leff = a1 * I   => a1 = 1.e-3 * getbrho(2.75) / 10
969                %
970                % The C coefficients are w.r.t B
971                %       B = c0 + c1*I = (0 + a0*I)/Leff
972                % However, AT uses Theta in radians so the A coefficients
973                % must be used for correctors with the middle layer with
974                % the addition of the DC term
975
976                % Find the current from the given polynomial for BLeff and B
977                % NOTE: AT used BLeff (A) for correctors
978               
979                % environ 32 cm  corrector
980                % Efficacitï¿œ = 11.06 G.m/A
981                % Le signe du courant est donnï¿œ par le DeviceServer (Tango)
982                % Find the currAO.(ifam).Monitor.HW2PhysicsParams{1}(1,:) =
983                % magnetcoefficien
984               
985                MagnetType = 'COR';
986               
987                Leff = 1e-6; % 0.1577 m
988                a8 =  0.0;
989                a7 =  0.0;
990                a6 =  0.0;
991                a5 =  0.0;
992                a4 =  0.0;
993                a3 =  0.0;
994                a2 =  0.0;
995                a1 =  110.6e-4/10;
996                a0 =  0;
997                A = [a7 a6 a5 a4 a3 a2 a1 a0];
998               
999            otherwise
1000                error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
1001                %k = 0;
1002                %MagnetType = '';
1003                %return
1004        end
1005
1006        % compute B-field = int(Bdl)/Leff
1007        C = A/ Leff;
1008
1009        MagnetType = upper(MagnetType);
1010
1011    otherwise
1012        error('Unknown accelerator name %s', AcceleratorName);
1013end
Note: See TracBrowser for help on using the repository browser.