1 | function M66 = findelemm66(ELEM, MethodName, orbit_in); |
---|
2 | %FINDELEMM66 numerically finds the 6x6 transfer matrix of an element |
---|
3 | % FINDELEM66(ELEM, METHODNAME, ORBITIN) |
---|
4 | % ELEM - the element data structure |
---|
5 | % METHODNAME - name of the pass-method function |
---|
6 | % ORBITIN - 6-by-1 phase space coordinates at the entrance |
---|
7 | % |
---|
8 | % See also FINDELEMM44 |
---|
9 | |
---|
10 | % See if step size for numerical differentiation |
---|
11 | % is set globally. Otherwise use 1e-7 |
---|
12 | global NUMDIFPARAMS |
---|
13 | % Transverse |
---|
14 | if isfield(NUMDIFPARAMS,'XYStep') |
---|
15 | dt = NUMDIFPARAMS.XYStep'; |
---|
16 | else |
---|
17 | dt = 1e-7; |
---|
18 | end |
---|
19 | % Longitudinal |
---|
20 | if isfield(NUMDIFPARAMS,'DPStep') |
---|
21 | dl = NUMDIFPARAMS.DPStep'; |
---|
22 | else |
---|
23 | dl = 1e-7; |
---|
24 | end |
---|
25 | |
---|
26 | % Build a diagonal matrix of initial conditions |
---|
27 | D6 = [dt*eye(4),zeros(4,2);zeros(2,4), dl*eye(2)]; |
---|
28 | % Add to the orbit_in |
---|
29 | RIN = orbit_in*ones(1,12) + [D6, -D6]; |
---|
30 | % Propagate through the element |
---|
31 | ROUT = feval(MethodName,ELEM,RIN); |
---|
32 | % Calculate numerical derivative |
---|
33 | M66 = [(ROUT(:,1:4)-ROUT(:,7:10))./(2*dt), (ROUT(:,5:6)-ROUT(:,11:12))./(2*dl)]; |
---|