1 | function z=sbend(fname,L,A,A1,A2,K,method) |
---|
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 | |
---|
17 | ElemData.FamName = fname; % add check for identical family names |
---|
18 | ElemData.Length = L; |
---|
19 | ElemData.MaxOrder = 3; |
---|
20 | ElemData.NumIntSteps = 10; |
---|
21 | ElemData.BendingAngle = A; |
---|
22 | ElemData.EntranceAngle = A1; |
---|
23 | ElemData.ExitAngle = A2; |
---|
24 | ElemData.ByError = 0; |
---|
25 | ElemData.K = K; |
---|
26 | |
---|
27 | ElemData.R1 = diag(ones(6,1)); |
---|
28 | ElemData.R2 = diag(ones(6,1)); |
---|
29 | ElemData.T1 = zeros(1,6); |
---|
30 | ElemData.T2 = zeros(1,6); |
---|
31 | |
---|
32 | ElemData.PolynomA = [0 0 0 0]; |
---|
33 | ElemData.PolynomB = [0 K 0 0]; |
---|
34 | |
---|
35 | ElemData.PassMethod = method; |
---|
36 | |
---|
37 | global FAMLIST |
---|
38 | z = length(FAMLIST)+1; % number of declare families including this one |
---|
39 | FAMLIST{z}.FamName = fname; |
---|
40 | FAMLIST{z}.NumKids = 0; |
---|
41 | FAMLIST{z}.KidsList= []; |
---|
42 | FAMLIST{z}.ElemData= ElemData; |
---|
43 | |
---|