MAGNETCOEFFICIENTS - Retrieves coefficient dor converion between Physics and Hardware units [C, Leff, MagnetType, A] = magnetcoefficients(MagnetCoreType) INPUTS 1. MagnetCoreType - Family name or type of magnet OUTPUTS 1. C vector coefficients for the polynomial expansion of the magnet field based on magnet measurements 2. Leff - Effective length 3. MagnetType 4. A - vector coefficients for the polynomial expansion of the magnet field based on magnet measurements C and A are vector coefficients for the polynomial expansion of the magnet field based on magnet measurements. The amp2k and k2amp functions convert between the two types of units. amp2k returns BLeff, B'Leff, or B"Leff scaled by Brho if A-coefficients are used. amp2k returns B , B' , or B" scaled by Brho if C-coefficients are used. The A coefficients are direct from magnet measurements: (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 A = [a7 a6 a5 a4 a3 a2 a1 a0] C coefficients have been scaled to field (AT units, except correctors) and includes a DC term: 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" C = [c8 c7 c6 c5 c4 c3 c2 c1 c0] For dipole: k = B / Brho (for AT: KickAngle = BLeff / Brho) For quadrupole: k = B'/ Brho For sextupole: k = B"/ Brho / 2 (to be compatible with AT) (all coefficients all divided by 2 for sextupoles) MagnetCoreType is the magnet measurements name for the magnet core (string, string matrix, or cell) For SOLEIL: BEND Q1 - Q10 S1 - S10, QT, HCOR, VCOR, FHCOR, FVCOR Leff is the effective length of the magnet
0001 function [C, Leff, MagnetType, A] = magnetcoefficients4booster(MagnetCoreType) 0002 %MAGNETCOEFFICIENTS - Retrieves coefficient dor converion between Physics and Hardware units 0003 %[C, Leff, MagnetType, A] = magnetcoefficients(MagnetCoreType) 0004 % 0005 % INPUTS 0006 % 1. MagnetCoreType - Family name or type of magnet 0007 % 0008 % OUTPUTS 0009 % 1. C vector coefficients for the polynomial expansion of the magnet field 0010 % based on magnet measurements 0011 % 2. Leff - Effective length 0012 % 3. MagnetType 0013 % 4. A - vector coefficients for the polynomial expansion of the magnet field 0014 % based on magnet measurements 0015 % 0016 % C and A are vector coefficients for the polynomial expansion of the magnet field 0017 % based on magnet measurements. 0018 % 0019 % The amp2k and k2amp functions convert between the two types of units. 0020 % amp2k returns BLeff, B'Leff, or B"Leff scaled by Brho if A-coefficients are used. 0021 % amp2k returns B , B' , or B" scaled by Brho if C-coefficients are used. 0022 % 0023 % The A coefficients are direct from magnet measurements: 0024 % (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 0025 % A = [a7 a6 a5 a4 a3 a2 a1 a0] 0026 % 0027 % C coefficients have been scaled to field (AT units, except correctors) and includes a DC term: 0028 % 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" 0029 % C = [c8 c7 c6 c5 c4 c3 c2 c1 c0] 0030 % 0031 % For dipole: k = B / Brho (for AT: KickAngle = BLeff / Brho) 0032 % For quadrupole: k = B'/ Brho 0033 % For sextupole: k = B"/ Brho / 2 (to be compatible with AT) 0034 % (all coefficients all divided by 2 for sextupoles) 0035 % 0036 % MagnetCoreType is the magnet measurements name for the magnet core (string, string matrix, or cell) 0037 % For SOLEIL: BEND 0038 % Q1 - Q10 S1 - S10, 0039 % QT, HCOR, VCOR, FHCOR, FVCOR 0040 % 0041 % Leff is the effective length of the magnet 0042 0043 % 0044 % Written by M. Yoon 4/8/03 0045 % Modified By Laurent Nadolski 0046 0047 % NOTE: The skew quad magnets need to be updated 0048 % NOTE: The skew quad magnet is distributed on two types of core, 0049 % therefore might need to pass in device list 0050 % same could be true with quadshunt (current switched into many types of cores) 0051 % NOTE: All 'C' coefficients divided by Leff at bottom of program: C/Leff 0052 % NOTE: Make sure the sign on the 'C' coefficients is reversed where positive current generates negative K-values 0053 0054 0055 if nargin < 1 0056 error('MagnetCoreType input required'); 0057 end 0058 0059 0060 % For a string matrix 0061 if iscell(MagnetCoreType) 0062 for i = 1:size(MagnetCoreType,1) 0063 for j = 1:size(MagnetCoreType,2) 0064 [C{i,j}, Leff{i,j}, MagnetType{i,j}, A{i,j}] = magnetcoefficients(MagnetCoreType{i}); 0065 end 0066 end 0067 return 0068 end 0069 0070 % For a string matrix 0071 if size(MagnetCoreType,1) > 1 0072 C=[]; Leff=[]; MagnetType=[]; A=[]; 0073 for i = 1:size(MagnetCoreType,1) 0074 [C1, Leff1, MagnetType1, A1] = magnetcoefficients(MagnetCoreType(i,:)); 0075 C(i,:) = C1; 0076 Leff(i,:) = Leff1; 0077 MagnetType = strvcat(MagnetType, MagnetType1); 0078 A(i,:) = A1; 0079 end 0080 return 0081 end 0082 0083 %%%% 0084 switch upper(deblank(MagnetCoreType)) 0085 0086 case 'BEND' % 1052.43 mm 0087 i0= 525.0; % 525 A <--> (1.71 T) <--> 2.75 GeV 0088 Leff=1.05243; 0089 a7= 0.0; 0090 a6=-0.0; 0091 a5= 0.0; 0092 a4=-0.0; 0093 a3= 0.0; 0094 a2=-0.0; 0095 a1= 0.0; 0096 a0= 1.71*Leff/i0; 0097 0098 c8 = -a7/(i0^7); %negative signs added for defocusing 0099 c7 = -a6/(i0^6); 0100 c6 = -a5/(i0^5); 0101 c5 = -a4/(i0^4); 0102 c4 = -a3/(i0^3); 0103 c3 = -a2/(i0^2); 0104 c2 = a1/i0; 0105 c1 = a0; 0106 c0 = 0.0; 0107 MagnetType = 'BEND'; 0108 0109 case {'QF','QD'} % 320 mm quadrupole 0110 % Find the current from the given polynomial for B'Leff 0111 Leff=0.320; 0112 i0= 260; 0113 a7= 0.0; 0114 a6= 0.0; 0115 a5= 0.0; 0116 a4= 0.0; 0117 a3= 0.0; 0118 a2= 0.0; 0119 a1= 0.0; 0120 a0= 2.15*Leff*getbrho/i0; % K= 2.15 m-2 <--> 260 A 0121 0122 c8 = 0.0; 0123 c7 = 0.0; 0124 c6 = a5/(i0^5); 0125 c5 = a4/(i0^4); 0126 c4 = a3/(i0^3); 0127 c3 = a2/(i0^2); 0128 c2 = a1/i0; 0129 c1 = a0; 0130 c0 = 0.0; 0131 MagnetType = 'quad'; 0132 0133 case {'SF','SD'} % 160 mm focusing sextupole 0134 % Find the current from the given polynomial for B''Leff 0135 a7= 0.0; 0136 a6= 0.0; 0137 a5= -0.0; 0138 a4= 0.0; 0139 a3= -0.0; 0140 a2= 0.0; 0141 a1= 0.0; 0142 a0= 4.1327e+06; 0143 i0= 100.0; 0144 0145 c8 = 0.0; 0146 c7 = 0.0; 0147 c6 = a5/(i0^5); 0148 c5 = a4/(i0^4); 0149 c4 = a3/(i0^3); 0150 c3 = a2/(i0^2); 0151 c2 = a1/i0; 0152 c1 = a0; 0153 c0 = 0.0; 0154 MagnetType = 'sext'; 0155 Leff=0.160; 0156 0157 case {'HCOR'} % 16 cm horizontal corrector 0158 % Magnet Spec: Theta = 0.8e-3 radians @ 2.75 GeV and 10 amps 0159 % Theta = BLeff / Brho [radians] 0160 % Therefore, 0161 % Theta = ((BLeff/Amp)/ Brho) * I 0162 % BLeff/Amp = 0.8e-3 * getbrho(2.75) / 10 0163 % B*Leff = a0 * I => a0 = 0.8e-3 * getbrho(2.75) / 10 0164 % 0165 % The C coefficients are w.r.t B 0166 % B = c0 + c1*I = (0 + a0*I)/Leff 0167 % However, AT uses Theta in radians so the A coefficients 0168 % must be used for correctors with the middle layer with 0169 % the addition of the DC term 0170 0171 % Find the current from the given polynomial for BLeff and B 0172 % NOTE: AT used BLeff (A) for correctors 0173 Leff = .16; 0174 imax = 10; 0175 cormax = 0.8e-3 ; % 0.8 mrad for imax = 10 A 0176 MagnetType = 'COR'; 0177 A = [0 cormax*getbrho(2.75)/imax]; 0178 C = [0 A 0] / Leff; 0179 return 0180 0181 case {'VCOR'} % 16 cm vertical corrector 0182 % Find the current from the given polynomial for BLeff and B 0183 Leff = .16; 0184 imax = 10; 0185 cormax = 0.8e-3 ; % 0.8 mrad for imax = 10 A 0186 MagnetType = 'COR'; 0187 A = [0 cormax*getbrho(2.75)/imax]; 0188 C = [0 A 0] / Leff; 0189 return 0190 0191 otherwise 0192 error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType)); 0193 %k = 0; 0194 %MagnetType = ''; 0195 %return 0196 end 0197 0198 A = [a7 a6 a5 a4 a3 a2 a1 a0]; 0199 C = [c8 c7 c6 c5 c4 c3 c2 c1 c0] / Leff; 0200 0201 MagnetType = upper(MagnetType); 0202 0203 0204 % Power Series Denominator (Factoral) be AT compatible 0205 if strcmpi(MagnetType,'SEXT') 0206 C = C / 2; 0207 end