Home > pubtools > LatticeTuningFunctions > correction > orbit > testorbitbump.m

testorbitbump

PURPOSE ^

test errors and correction functions

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 test errors and correction functions

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % test errors and correction functions
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 load ESRFLattice.mat
0010 
0011 %% get RM
0012 speclab='OrbitESRF';
0013 
0014 modelrmfile=fullfile(pwd,['RMmodel' speclab '.mat']);%
0015 
0016 if ~exist([modelrmfile],'file')
0017     
0018     ModelRM...
0019         =getresponsematrices(...
0020         ring,...
0021         indBPM,...
0022         indHCor,...
0023         indVCor,...
0024         indSCor,...
0025         indQCor,...
0026         [],...
0027         [0 0 0 0 0 0]',...
0028         [1 2 3]);
0029     
0030     save([modelrmfile],'ModelRM');
0031 else
0032     load([modelrmfile],'ModelRM');
0033 end
0034 
0035 inCOD=[0 0 0 0 0 0]';
0036 
0037 %% correct to reference orbit ( bump )
0038 
0039 refx=zeros(size(indBPM));
0040 refy=zeros(size(indBPM));
0041 
0042 refx([7 8])=1e-4; % horizontal bump in position
0043 refy([7 8])=[1e-4 -1e-4];  % vertical bump in angle
0044 
0045 % get current orbit
0046 o=findorbit6Err(ring,indBPM,inCOD);
0047 oxc=o(1,:);
0048 oyc=o(3,:);
0049 
0050 % correct restrictig response matrices
0051 selbpm=[2  3    7 8   12 13]; % 9 and 12 missing in purpose
0052 selcor=[2  3           4  5];
0053 
0054 ModelRMbump.OrbHCor{1}=ModelRM.OrbHCor{1}(selbpm,selcor);
0055 ModelRMbump.OrbVCor{3}=ModelRM.OrbVCor{3}(selbpm,selcor);
0056 ModelRMbump.OrbHDPP=ModelRM.OrbHDPP;
0057 ModelRMbump.OrbVDPP=ModelRM.OrbVDPP;
0058 ModelRMbump.kval=ModelRM.kval;
0059 ModelRMbump.delta=ModelRM.delta;
0060 
0061 [rcor,inCOD]=atcorrectorbit(ring,...
0062     indBPM(selbpm),...
0063     indHCor(selcor),...
0064     indVCor(selcor),...
0065     inCOD,...
0066     repmat([4 4],3,1),...
0067     [false false],...
0068     1.0,...
0069     ModelRMbump,...
0070     [refx(selbpm);...
0071     refy(selbpm)],...
0072     [],...
0073     true);
0074 
0075 o=findorbit6Err(rcor,indBPM,inCOD);
0076 oxb=o(1,:);
0077 oyb=o(3,:);
0078 
0079 sBPM=findspos(rcor,indBPM);
0080 figure;
0081 plot(sBPM,refx,':');hold on; plot(sBPM,refy,':');
0082 plot(sBPM,oxb-oxc);hold on; plot(sBPM,oyb-oyc);
0083 legend('ref hor.','ref ver.','hor.','ver.');
0084 xlabel('BPM #');
0085 ylabel('COD - COD_0')
0086 xlim([0,100])
0087 export_fig('CODbump.jpg')
0088 %%
0089 % recompute RM for subset of bpms and correctors.
0090 [rcor,inCOD]=atcorrectorbit(ring,...
0091     indBPM(selbpm),...
0092     indHCor(selcor),...
0093     indVCor(selcor),...
0094     inCOD,...
0095     repmat([4 4],10,1),...
0096     [false true],... correctors average non zero and no frequency correction
0097     1.0,...
0098     [],...  <-- no RM, default is to compute it
0099     [refx(selbpm);...
0100     refy(selbpm)],...
0101     [],...
0102     true);
0103 
0104 
0105 o=findorbit6Err(rcor,indBPM,inCOD);
0106 oxb=o(1,:);
0107 oyb=o(3,:);
0108 
0109 sBPM=findspos(rcor,indBPM);
0110 figure;
0111 plot(sBPM,refx,':');hold on; plot(sBPM,refy,':');
0112 plot(sBPM,oxb-oxc);hold on; plot(sBPM,oyb-oyc);
0113 legend('ref hor.','ref ver.','hor.','ver.');
0114 xlabel('BPM #');
0115 xlim([0,100])
0116 ylabel('COD - COD_0')
0117 
0118 
0119 %% set bump in lattice without errors
0120 o=findorbit6Err(ring,indBPM,inCOD);
0121 oxc=o(1,:);
0122 oyc=o(3,:);
0123 
0124 % recompute RM for subset of bpms and correctors.
0125 [rcor,inCOD]=atcorrectorbit(ring,...
0126     indBPM(selbpm),...
0127     indHCor(selcor),...
0128     indVCor(selcor),...
0129     inCOD,...
0130     repmat([4 4],5,1),...
0131     [false false],...
0132     1.0,...
0133     [],...  <-- no RM, default is to compute it
0134     [refx(selbpm);...
0135     refy(selbpm)],...
0136     [],...
0137     false);
0138 
0139 o=findorbit6Err(rcor,indBPM,inCOD);
0140 oxb=o(1,:);
0141 oyb=o(3,:);
0142 
0143 sBPM=findspos(rcor,indBPM);
0144 figure;
0145 plot(sBPM,refx);hold on; plot(sBPM,refy);
0146 plot(sBPM,oxb-oxc);hold on; plot(sBPM,oyb-oyc);
0147 legend('ref hor.','ref ver.','hor.','ver.');
0148 xlabel('BPM #');
0149 ylabel('COD - COD_0')
0150 
0151

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005