source: MML/trunk/machine/SOLEIL/StorageRing/orbit/fofb_data.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 3.2 KB
Line 
1%% FOFB - data ans small scripts
2
3%%  48x48
4IDBPM = getidbpmlist;
5
6[betax betaz] = modeltwiss('beta', 'BPMx', IDBPM);
7[mux muz] = modeltwiss('mu', 'BPMx', IDBPM);
8R0 = measbpmresp('BPMx',IDBPM, 'BPMz', IDBPM, 'FHCOR', 'FVCOR', 'Model','Struct');
9Rinv0H= inv(R0(1,1).Data);
10Rinv0V= inv(R0(2,2).Data);
11%save 'fofbdata96x96' betax betaz mux muz Rinv
12
13%% 120x48
14BPM = family2dev('BPMx');
15
16[betax betaz] = modeltwiss('beta', 'BPMx');
17[mux muz] = modeltwiss('mu', 'BPMx');
18R1 = measbpmresp('BPMx',BPM, 'BPMz', BPM, 'FHCOR', 'FVCOR', 'Model','Struct');
19Rinv1H= pinv(R1(1,1).Data);
20Rinv1V= pinv(R1(2,2).Data);
21%Rinv1= pinv(R1);
22
23save 'fofbdata240x96' betax betaz mux muz Rinv
24
25%% SVD
26
27h=figure;
28set(h,'Position',[223 311 1087 420])
29[U, S, V] = svd(R0(1,1).Data, 0);  %'econ');
30S = diag(S);
31
32subplot(1,2,1)
33semilogy(S)
34xlabel('Singular value number')
35ylabel('Singular value amplitude')
36grid on
37xaxis([0 48])
38title('H-plane')
39
40subplot(1,2,2)
41[U, S, V] = svd(R0(2,2).Data, 0);  %'econ');
42S = diag(S);
43semilogy(S)
44xlabel('Singular value number')
45ylabel('Singular value amplitude')
46grid on
47xaxis([0 48])
48title('V-plane')
49
50suptitle('FOFB 96x96')
51
52%% 48 * 48 avec Rf
53   
54Eta = modeldisp('BPMx',IDBPM);
55Smat = R0(1,1).Data;
56
57RFWeight = 10 * mean(std(Smat)) / std(Eta);
58Smat = [R0(1,1).Data RFWeight*Eta];
59
60[U, S, V] = svd(Smat, 0);  %'econ');
61S = diag(S);
62
63subplot(1,2,1)
64semilogy(S)
65xlabel('Singular value number')
66ylabel('Singular value amplitude')
67grid on
68xaxis([0 48]); hold on;
69title('H-plane')
70
71SVDIndex = 1:48;
72RinvH = V(:,SVDIndex)*diag(S(SVDIndex).^(-1)) * U(:,SVDIndex)';
73
74subplot(1,2,2)
75[U, S, V] = svd(R0(2,2).Data, 0);  %'econ');
76S = diag(S);
77semilogy(S)
78xlabel('Singular value number')
79ylabel('Singular value amplitude')
80grid on
81xaxis([0 48])
82title('V-plane')
83
84suptitle('FOFB 96x96 + RF')
85
86
87%% SVD 120x48
88h=figure;
89set(h,'Position',[223 311 1087 420])
90[U, S, V] = svd(R1(1,1).Data, 0);  %'econ');
91S = diag(S);
92
93subplot(1,2,1)
94semilogy(S)
95xlabel('Singular value number')
96ylabel('Singular value amplitude')
97grid on
98xaxis([0 48])
99title('H-plane')
100
101subplot(1,2,2)
102[U, S, V] = svd(R1(2,2).Data, 0);  %'econ');
103S = diag(S);
104semilogy(S)
105xlabel('Singular value number')
106ylabel('Singular value amplitude')
107grid on
108xaxis([0 48])
109title('V-plane')
110
111suptitle('FOFB 96x96')
112
113% Correction with 48 singular values
114%% H-correction
115dI = -pinv(R0(1,1).Data)*(getx(IDBPM)-GoalOrbitVec); stepsp('FHCOR',dI)
116
117%% V-correction
118dI = -pinv(R0(2,2).Data)*(getz(IDBPM) - GoalZOrbitVec); stepsp('FVCOR',dI)
119
120%%
121% Correction with n singular values
122[U, S, V] = svd(R0(1,1).Data, 0);
123S = diag(S);
124%GoalOrbitVec = getgolden('BPMx', IDBPM)*0;
125GoalOrbitVec = getgolden('BPMx', IDBPM);
126
127%% H-correction
128SVDIndex = 1:48;
129
130b = U(:,SVDIndex)' * (GoalOrbitVec - getx(IDBPM));
131b = diag(S(SVDIndex).^(-1)) * b;
132
133% Convert the b vector back to coefficents of response matrix
134Delcm = V(:,SVDIndex) * b;
135
136stepsp('FHCOR', Delcm)
137
138%%
139clf
140plot(getspos('BPMx', IDBPM), getx(IDBPM)); hold on
141plot(getspos('BPMx', IDBPM), GoalOrbitVec,'k');
142
143%%
144clf
145plot(getspos('BPMx', IDBPM), getx(IDBPM)-GoalOrbitVec); hold on
146
147%%
148Rinv = pinv(R0(1,1).Data);
149Rinvfull=zeros(48,120);
150
151Rinvfull(:,dev2elem('BPMx',IDBPM)) = Rinv;
152
153%%
154%A/mm = µA/nm
155%(Rinvfull(4,:)*1714.412*1.77)*(getz - GoalZOrbitVec)/36000*10
Note: See TracBrowser for help on using the repository browser.