0001
0002 close all
0003 clear all
0004 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions');
0005 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/correction/response matrix')
0006 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/correction/');
0007 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/errors/');
0008
0009
0010 load ESRFLattice.mat
0011
0012
0013
0014 inCOD=[0 0 0 0 0 0]';
0015
0016 speclab='RF';
0017
0018 modelrmfile=fullfile(pwd,['RMmodel' speclab '.mat']);
0019
0020 if ~exist([modelrmfile],'file')
0021
0022 ModelRM...
0023 =getresponsematrices(...
0024 ring,...
0025 indBPM,...
0026 [],...
0027 [],...
0028 [],...
0029 [],...
0030 [],...
0031 inCOD,...
0032 [3]);
0033
0034 save([modelrmfile],'ModelRM');
0035 else
0036 load([modelrmfile],'ModelRM');
0037 end
0038
0039
0040 ind=find(atgetcells(ring,'Class','Quadrupole','Sextupole'));
0041 dx=1.0e-6*randn(size(ind));
0042 dy=1.0e-6*randn(size(ind));
0043 dr=1.0e-6*randn(size(ind));
0044
0045 rerr=atsetshift(ring,ind,dx,dy);
0046 rerr=atsettilt(rerr,ind,dr);
0047
0048
0049
0050 rfv=9.0e6; harm=992;
0051
0052 [rerr]=atsetRFCavity(rerr,rfv,1,harm,0);
0053
0054 [...
0055 rcor,...
0056 inCODcor,...
0057 fc...
0058 ]=atRFcorrection(...
0059 rerr,...
0060 indBPM,...
0061 inCOD,...
0062 [1 1 1 1 1],...
0063 1,...
0064 ModelRM,...
0065 zeros(2,length(indBPM)),...
0066 true);
0067
0068
0069 o=findorbit6Err(rerr,indBPM,inCOD);
0070 oxe=o(5,:);
0071 oye=o(6,:);
0072
0073 o=findorbit6Err(rcor,indBPM,inCODcor);
0074 oxc=o(5,:);
0075 oyc=o(6,:);
0076
0077 sBPM=findspos(rcor,indBPM);
0078 figure;subplot(2,1,1);
0079 plot(sBPM,oxe,'.-');hold on; plot(sBPM,oxc,'.-');
0080 legend('before','after');
0081 xlabel('s [m]');
0082 ylabel('energy deviation');
0083 subplot(2,1,2);
0084 plot(sBPM,oye,'.-');hold on; plot(sBPM,oyc,'.-');
0085 legend('before','after');
0086 xlabel('s [m]');
0087 ylabel('time lag');
0088 saveas(gca,'RFCor.fig');
0089 export_fig('RFCor.jpg');
0090
0091 return