1 | function z=rbend(fname,L,A,A1,A2,K,method, varargin) |
---|
2 | %BEND('FAMILYNAME', Length[m], BendingAngle[rad], EntranceAngle[rad], |
---|
3 | % ExitAngle[rad], K, 'METHOD') |
---|
4 | % creates a new family in the FAMLIST - a structure with fields |
---|
5 | % FamName family name |
---|
6 | % Length length of the arc for an on-energy particle [m] |
---|
7 | % BendingAngle total bending angle [rad] |
---|
8 | % EntranceAngle [rad] (0 - for sector bends) |
---|
9 | % ExitAngle [rad] (0 - for sector bends) |
---|
10 | % ByError error in the dipole field relative to the design value |
---|
11 | % K quadrupole K-value for combined funtion bends |
---|
12 | % PassMethod name of the function to use for tracking |
---|
13 | % returns assigned address in the FAMLIST that is uniquely identifies |
---|
14 | % the family |
---|
15 | % |
---|
16 | % Eugene 29/08/05 modified to be able to input Polynom data. |
---|
17 | |
---|
18 | |
---|
19 | ElemData.FamName = fname; % add check for identical family names |
---|
20 | ElemData.Length = L; |
---|
21 | ElemData.MaxOrder = 3; |
---|
22 | ElemData.NumIntSteps = 10; |
---|
23 | ElemData.BendingAngle = A; |
---|
24 | ElemData.EntranceAngle = A1; |
---|
25 | ElemData.ExitAngle = A2; |
---|
26 | ElemData.ByError = 0; |
---|
27 | ElemData.K = K; |
---|
28 | |
---|
29 | ElemData.R1 = diag(ones(6,1)); |
---|
30 | ElemData.R2 = diag(ones(6,1)); |
---|
31 | ElemData.T1 = zeros(1,6); |
---|
32 | ElemData.T2 = zeros(1,6); |
---|
33 | |
---|
34 | if nargin > 7 |
---|
35 | PolynomA = varargin{1}; |
---|
36 | else |
---|
37 | PolynomA = [0 0 0 0]; |
---|
38 | end |
---|
39 | if nargin > 8 |
---|
40 | PolynomB = varargin{2}; |
---|
41 | else |
---|
42 | PolynomB = [0 K 0 0]; |
---|
43 | end |
---|
44 | |
---|
45 | ElemData.PolynomA = PolynomA; |
---|
46 | ElemData.PolynomB = PolynomB; |
---|
47 | |
---|
48 | % Eugene test s rotation method 25/08/05 |
---|
49 | % theta = pi/4; |
---|
50 | % PolynomA = [0 0 0 0]; |
---|
51 | % PolynomB = [ElemData.BendingAngle/ElemData.Length K 0 0]; |
---|
52 | % ElemData.PolynomA= imag(exp(i*theta)*complex(PolynomB,PolynomA)); |
---|
53 | % ElemData.PolynomB= real(exp(i*theta)*complex(PolynomB,PolynomA)) - [ElemData.BendingAngle/ElemData.Length 0 0 0]; |
---|
54 | |
---|
55 | ElemData.PassMethod = method; |
---|
56 | |
---|
57 | global FAMLIST |
---|
58 | z = length(FAMLIST)+1; % number of declare families including this one |
---|
59 | FAMLIST{z}.FamName = fname; |
---|
60 | FAMLIST{z}.NumKids = 0; |
---|
61 | FAMLIST{z}.KidsList= []; |
---|
62 | FAMLIST{z}.ElemData= ElemData; |
---|
63 | |
---|