BEND('FAMILYNAME', Length[m], BendingAngle[rad], EntranceAngle[rad], ExitAngle[rad], K, 'METHOD') creates a new family in the FAMLIST - a structure with fields FamName family name Length length of the arc for an on-energy particle [m] BendingAngle total bending angle [rad] EntranceAngle [rad] (0 - for sector bends) ExitAngle [rad] (0 - for sector bends) ByError error in the dipole field relative to the design value K quadrupole K-value for combined funtion bends PassMethod name of the function to use for tracking returns assigned address in the FAMLIST that is uniquely identifies the family Eugene 29/08/05 modified to be able to input Polynom data.
0001 function z=rbend(fname,L,A,A1,A2,K,method, varargin) 0002 %BEND('FAMILYNAME', Length[m], BendingAngle[rad], EntranceAngle[rad], 0003 % ExitAngle[rad], K, 'METHOD') 0004 % creates a new family in the FAMLIST - a structure with fields 0005 % FamName family name 0006 % Length length of the arc for an on-energy particle [m] 0007 % BendingAngle total bending angle [rad] 0008 % EntranceAngle [rad] (0 - for sector bends) 0009 % ExitAngle [rad] (0 - for sector bends) 0010 % ByError error in the dipole field relative to the design value 0011 % K quadrupole K-value for combined funtion bends 0012 % PassMethod name of the function to use for tracking 0013 % returns assigned address in the FAMLIST that is uniquely identifies 0014 % the family 0015 % 0016 % Eugene 29/08/05 modified to be able to input Polynom data. 0017 0018 0019 ElemData.FamName = fname; % add check for identical family names 0020 ElemData.Length = L; 0021 ElemData.MaxOrder = 3; 0022 ElemData.NumIntSteps = 10; 0023 ElemData.BendingAngle = A; 0024 ElemData.EntranceAngle = A1; 0025 ElemData.ExitAngle = A2; 0026 ElemData.ByError = 0; 0027 ElemData.K = K; 0028 0029 ElemData.R1 = diag(ones(6,1)); 0030 ElemData.R2 = diag(ones(6,1)); 0031 ElemData.T1 = zeros(1,6); 0032 ElemData.T2 = zeros(1,6); 0033 0034 if nargin > 7 0035 PolynomA = varargin{1}; 0036 else 0037 PolynomA = [0 0 0 0]; 0038 end 0039 if nargin > 8 0040 PolynomB = varargin{2}; 0041 else 0042 PolynomB = [0 K 0 0]; 0043 end 0044 0045 ElemData.PolynomA = PolynomA; 0046 ElemData.PolynomB = PolynomB; 0047 0048 % Eugene test s rotation method 25/08/05 0049 % theta = pi/4; 0050 % PolynomA = [0 0 0 0]; 0051 % PolynomB = [ElemData.BendingAngle/ElemData.Length K 0 0]; 0052 % ElemData.PolynomA= imag(exp(i*theta)*complex(PolynomB,PolynomA)); 0053 % ElemData.PolynomB= real(exp(i*theta)*complex(PolynomB,PolynomA)) - [ElemData.BendingAngle/ElemData.Length 0 0 0]; 0054 0055 ElemData.PassMethod = method; 0056 0057 global FAMLIST 0058 z = length(FAMLIST)+1; % number of declare families including this one 0059 FAMLIST{z}.FamName = fname; 0060 FAMLIST{z}.NumKids = 0; 0061 FAMLIST{z}.KidsList= []; 0062 FAMLIST{z}.ElemData= ElemData; 0063