1 | function [C, Leff, MagnetType, A] = magnetcoefficients4booster(MagnetCoreType) |
---|
2 | %MAGNETCOEFFICIENTS - Retrieves coefficient dor converion 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 |
---|
12 | % 3. MagnetType |
---|
13 | % 4. A - vector coefficients for the polynomial expansion of the magnet field |
---|
14 | % 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: |
---|
24 | % (a7/I0)*I^8+(a6/I0)*I^7+(a5/I0)*I^6+(a4/I0)*I^5+(a3/I0)*I^4+(a2/I0)*I^3+(a1/I0)*I^2+a0*I = B*Leff or B'*Leff or B"*Leff |
---|
25 | % A = [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 = [c8 c7 c6 c5 c4 c3 c2 c1 c0] |
---|
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 | % |
---|
44 | % Written by M. Yoon 4/8/03 |
---|
45 | % Modified By Laurent Nadolski |
---|
46 | |
---|
47 | % NOTE: The skew quad magnets need to be updated |
---|
48 | % NOTE: The skew quad magnet is distributed on two types of core, |
---|
49 | % therefore might need to pass in device list |
---|
50 | % same could be true with quadshunt (current switched into many types of cores) |
---|
51 | % NOTE: All 'C' coefficients divided by Leff at bottom of program: C/Leff |
---|
52 | % NOTE: Make sure the sign on the 'C' coefficients is reversed where positive current generates negative K-values |
---|
53 | |
---|
54 | |
---|
55 | if nargin < 1 |
---|
56 | error('MagnetCoreType input required'); |
---|
57 | end |
---|
58 | |
---|
59 | |
---|
60 | % For a string matrix |
---|
61 | if iscell(MagnetCoreType) |
---|
62 | for i = 1:size(MagnetCoreType,1) |
---|
63 | for j = 1:size(MagnetCoreType,2) |
---|
64 | [C{i,j}, Leff{i,j}, MagnetType{i,j}, A{i,j}] = magnetcoefficients(MagnetCoreType{i}); |
---|
65 | end |
---|
66 | end |
---|
67 | return |
---|
68 | end |
---|
69 | |
---|
70 | % For a string matrix |
---|
71 | if size(MagnetCoreType,1) > 1 |
---|
72 | C=[]; Leff=[]; MagnetType=[]; A=[]; |
---|
73 | for i = 1:size(MagnetCoreType,1) |
---|
74 | [C1, Leff1, MagnetType1, A1] = magnetcoefficients(MagnetCoreType(i,:)); |
---|
75 | C(i,:) = C1; |
---|
76 | Leff(i,:) = Leff1; |
---|
77 | MagnetType = strvcat(MagnetType, MagnetType1); |
---|
78 | A(i,:) = A1; |
---|
79 | end |
---|
80 | return |
---|
81 | end |
---|
82 | |
---|
83 | %%%% |
---|
84 | switch upper(deblank(MagnetCoreType)) |
---|
85 | |
---|
86 | case 'BEND' % 1052.43 mm |
---|
87 | i0= 525.0; % 525 A <--> (1.71 T) <--> 2.75 GeV |
---|
88 | Leff=1.05243; |
---|
89 | a7= 0.0; |
---|
90 | a6=-0.0; |
---|
91 | a5= 0.0; |
---|
92 | a4=-0.0; |
---|
93 | a3= 0.0; |
---|
94 | a2=-0.0; |
---|
95 | a1= 0.0; |
---|
96 | a0= 1.71*Leff/i0; |
---|
97 | |
---|
98 | c8 = -a7/(i0^7); %negative signs added for defocusing |
---|
99 | c7 = -a6/(i0^6); |
---|
100 | c6 = -a5/(i0^5); |
---|
101 | c5 = -a4/(i0^4); |
---|
102 | c4 = -a3/(i0^3); |
---|
103 | c3 = -a2/(i0^2); |
---|
104 | c2 = a1/i0; |
---|
105 | c1 = a0; |
---|
106 | c0 = 0.0; |
---|
107 | MagnetType = 'BEND'; |
---|
108 | |
---|
109 | case {'QF','QD'} % 320 mm quadrupole |
---|
110 | % Find the current from the given polynomial for B'Leff |
---|
111 | Leff=0.320; |
---|
112 | i0= 260; |
---|
113 | a7= 0.0; |
---|
114 | a6= 0.0; |
---|
115 | a5= 0.0; |
---|
116 | a4= 0.0; |
---|
117 | a3= 0.0; |
---|
118 | a2= 0.0; |
---|
119 | a1= 0.0; |
---|
120 | a0= 2.15*Leff*getbrho/i0; % K= 2.15 m-2 <--> 260 A |
---|
121 | |
---|
122 | c8 = 0.0; |
---|
123 | c7 = 0.0; |
---|
124 | c6 = a5/(i0^5); |
---|
125 | c5 = a4/(i0^4); |
---|
126 | c4 = a3/(i0^3); |
---|
127 | c3 = a2/(i0^2); |
---|
128 | c2 = a1/i0; |
---|
129 | c1 = a0; |
---|
130 | c0 = 0.0; |
---|
131 | MagnetType = 'quad'; |
---|
132 | |
---|
133 | case {'SF','SD'} % 160 mm focusing sextupole |
---|
134 | % Find the current from the given polynomial for B''Leff |
---|
135 | a7= 0.0; |
---|
136 | a6= 0.0; |
---|
137 | a5= -0.0; |
---|
138 | a4= 0.0; |
---|
139 | a3= -0.0; |
---|
140 | a2= 0.0; |
---|
141 | a1= 0.0; |
---|
142 | a0= 4.1327e+06; |
---|
143 | i0= 100.0; |
---|
144 | |
---|
145 | c8 = 0.0; |
---|
146 | c7 = 0.0; |
---|
147 | c6 = a5/(i0^5); |
---|
148 | c5 = a4/(i0^4); |
---|
149 | c4 = a3/(i0^3); |
---|
150 | c3 = a2/(i0^2); |
---|
151 | c2 = a1/i0; |
---|
152 | c1 = a0; |
---|
153 | c0 = 0.0; |
---|
154 | MagnetType = 'sext'; |
---|
155 | Leff=0.160; |
---|
156 | |
---|
157 | case {'HCOR'} % 16 cm horizontal corrector |
---|
158 | % Magnet Spec: Theta = 0.8e-3 radians @ 2.75 GeV and 10 amps |
---|
159 | % Theta = BLeff / Brho [radians] |
---|
160 | % Therefore, |
---|
161 | % Theta = ((BLeff/Amp)/ Brho) * I |
---|
162 | % BLeff/Amp = 0.8e-3 * getbrho(2.75) / 10 |
---|
163 | % B*Leff = a0 * I => a0 = 0.8e-3 * getbrho(2.75) / 10 |
---|
164 | % |
---|
165 | % The C coefficients are w.r.t B |
---|
166 | % B = c0 + c1*I = (0 + a0*I)/Leff |
---|
167 | % However, AT uses Theta in radians so the A coefficients |
---|
168 | % must be used for correctors with the middle layer with |
---|
169 | % the addition of the DC term |
---|
170 | |
---|
171 | % Find the current from the given polynomial for BLeff and B |
---|
172 | % NOTE: AT used BLeff (A) for correctors |
---|
173 | Leff = .16; |
---|
174 | imax = 10; |
---|
175 | cormax = 0.8e-3 ; % 0.8 mrad for imax = 10 A |
---|
176 | MagnetType = 'COR'; |
---|
177 | A = [0 cormax*getbrho(2.75)/imax]; |
---|
178 | C = [0 A 0] / Leff; |
---|
179 | return |
---|
180 | |
---|
181 | case {'VCOR'} % 16 cm vertical corrector |
---|
182 | % Find the current from the given polynomial for BLeff and B |
---|
183 | Leff = .16; |
---|
184 | imax = 10; |
---|
185 | cormax = 0.8e-3 ; % 0.8 mrad for imax = 10 A |
---|
186 | MagnetType = 'COR'; |
---|
187 | A = [0 cormax*getbrho(2.75)/imax]; |
---|
188 | C = [0 A 0] / Leff; |
---|
189 | return |
---|
190 | |
---|
191 | otherwise |
---|
192 | error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType)); |
---|
193 | %k = 0; |
---|
194 | %MagnetType = ''; |
---|
195 | %return |
---|
196 | end |
---|
197 | |
---|
198 | A = [a7 a6 a5 a4 a3 a2 a1 a0]; |
---|
199 | C = [c8 c7 c6 c5 c4 c3 c2 c1 c0] / Leff; |
---|
200 | |
---|
201 | MagnetType = upper(MagnetType); |
---|
202 | |
---|
203 | |
---|
204 | % Power Series Denominator (Factoral) be AT compatible |
---|
205 | if strcmpi(MagnetType,'SEXT') |
---|
206 | C = C / 2; |
---|
207 | end |
---|