1 | %FINDRESPMDEMO response matrix demo |
---|
2 | % This script illustrates the use of AT function FINDRESPM |
---|
3 | |
---|
4 | spear2 |
---|
5 | % The most common RM is corrector-to-BPM |
---|
6 | % In this demonstration we will not use the actual correctors |
---|
7 | % to keep the lattice simple. |
---|
8 | |
---|
9 | % We will use all focusing quadrupoles as correctors: |
---|
10 | % In order to do this we need to use StrMPolesymplectic4 pass-method |
---|
11 | % for them. This mehod looks at all terms of the polynomial |
---|
12 | % expansion of transverse magnetic field. |
---|
13 | % (QuadLinearPass only looks at field 'K') |
---|
14 | % PolynomB(1) gives horizontal kick |
---|
15 | % PolynomA(1) gives a vertical kick |
---|
16 | |
---|
17 | % Find indexes of elements that belong to QF Q1 Q2 Q3 families |
---|
18 | % We will use them as corrector elements |
---|
19 | QFI = findcells(THERING,'FamName','QF'); |
---|
20 | Q1I = findcells(THERING,'FamName','Q1'); |
---|
21 | Q2I = findcells(THERING,'FamName','Q2'); |
---|
22 | Q3I = findcells(THERING,'FamName','Q3'); |
---|
23 | CORRINDEX = sort([ QFI Q1I Q2I Q3I]); |
---|
24 | % Install the new pass-method 'StrMPoleSymplectic4Pass' |
---|
25 | THERING = setcellstruct(THERING,'PassMethod',CORRINDEX,'StrMPoleSymplectic4Pass'); |
---|
26 | |
---|
27 | % We will use etrance points of all bending magnets as observation points (BPMs) |
---|
28 | BPMINDEX = findcells(THERING,'BendingAngle'); |
---|
29 | |
---|
30 | NBPM = length(BPMINDEX); |
---|
31 | NCOR = length(CORRINDEX); |
---|
32 | |
---|
33 | % Prepare input parameters for FINDRESPM that will tell it, which |
---|
34 | % parameters to use as orbit perturbations |
---|
35 | % See help for FINDRESPM |
---|
36 | |
---|
37 | % Set the size of a parameter change for numeric differentiation |
---|
38 | KICKSIZE = 1e-5; |
---|
39 | |
---|
40 | RX = findrespm(THERING,BPMINDEX ,CORRINDEX, KICKSIZE, 'PolynomB',1,1); |
---|
41 | RY = findrespm(THERING,BPMINDEX ,CORRINDEX, KICKSIZE, 'PolynomA',1,1); |
---|
42 | % Build the response matrix |
---|
43 | % In the form |
---|
44 | % |
---|
45 | % | HH HV | |
---|
46 | % | VH VV | |
---|
47 | % |
---|
48 | % HH - Horizontal BPM response to horizontal orbit kicks |
---|
49 | % HV - Horizontal BPM response to vertical orbit kicks |
---|
50 | % VH - vertical BPM response to horizontal orbit kicks |
---|
51 | % VV - vertical BPM response to vertical orbit kicks |
---|
52 | RespM_XY = [RX{1} RY{1}; RX{3} RY{3}]; |
---|
53 | figure(1); |
---|
54 | mesh(RespM_XY); |
---|
55 | colormap('copper'); |
---|
56 | xlabel('Corrector Number') |
---|
57 | ylabel('BPM Number'); |
---|
58 | zlabel('Normalized Orbit Response'); |
---|
59 | title('Orbit Response Matrix - uncoupled lattice') |
---|
60 | |
---|
61 | % Now we wish to introduce coupling: |
---|
62 | QDI = findcells(THERING,'FamName','QD'); |
---|
63 | % Generate random rotations: |
---|
64 | QDTILTS = 1*(pi/180)*randn(1,length(QDI)); |
---|
65 | % Put random values in the ring |
---|
66 | settilt(QDI,QDTILTS); |
---|
67 | |
---|
68 | % Generate the new response matrix for the lattice with errors |
---|
69 | RX = findrespm(THERING,BPMINDEX ,CORRINDEX, KICKSIZE, 'PolynomB',1,1); |
---|
70 | RY = findrespm(THERING,BPMINDEX ,CORRINDEX, KICKSIZE, 'PolynomA',1,1); |
---|
71 | |
---|
72 | RespM_XY_Coupled = [RX{1} RY{1}; RX{3} RY{3}]; |
---|
73 | figure(2); |
---|
74 | mesh(RespM_XY_Coupled); |
---|
75 | colormap('copper'); |
---|
76 | title('Orbit Response Matrix - coupled lattice') |
---|
77 | xlabel('Corrector Number') |
---|
78 | ylabel('BPM Number'); |
---|
79 | zlabel('Normalized Orbit Response'); |
---|
80 | |
---|