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