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

testorbitcorrection

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 
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 
0015 modelrmfile=fullfile(pwd,['RMmodel' speclab '.mat']);%
0016 
0017 if ~exist([modelrmfile],'file')
0018     
0019     ModelRM...
0020         =getresponsematrices(...
0021         ring,...
0022         indBPM,...
0023         indHCor,...
0024         indVCor,...
0025         indSCor,...
0026         indQCor,...
0027         [],...
0028         [0 0 0 0 0 0]',...
0029         [1 2 3]);
0030     
0031     save([modelrmfile],'ModelRM');
0032 else
0033     load([modelrmfile],'ModelRM');
0034 end
0035 
0036 % set errors
0037 ind=find(atgetcells(ring,'Class','Quadrupole','Sextupole'));
0038 dx=5e-6*randn(size(ind));
0039 dy=5e-6*randn(size(ind));
0040 
0041 rerr=atsetshift(ring,ind,dx,dy);
0042 
0043 %% apply correction
0044 
0045 % no steerers limit, no reference orbit
0046 [rcor,inCOD,hs,vs]=atcorrectorbit(rerr,...
0047     indBPM,...
0048     indHCor,...
0049     indVCor,...
0050     [0 0 0 0 0 0]',...
0051     [50 50],...
0052     [false true],...
0053     1.0,...
0054     ModelRM,...
0055     zeros(2,length(indBPM)),...
0056     [],...
0057     true);
0058 
0059 % steerers limited, increase eigenvectors number and changing RF frequency
0060 [rcor,...           % corrected lattice
0061     inCOD,....      % initial orbit guess after correction
0062     hs,...          % total horizontal steerers strenghts
0063     vs....          % total vertical steerers strengths
0064     ]=atcorrectorbit(....
0065     rerr,...        % lattice to be corrected
0066     indBPM,...      % BPM indexes
0067     indHCor,...     % horizontal steerers indexes
0068     indVCor,...     % vertical steerers indexes
0069     inCOD,...       % input 6D closed orbit guess
0070     [...            % several correction iterations 
0071     [10 20];...     % with different number of eigenvectors 
0072     [30 40];...     % for horizontal and vertical plane
0073     [50 60];...     % <-- iter 3, use 50 eig hor., 60 eig ver.
0074     [70 70];...     % <-- iter 4, use 70 eig hor., 70 eig ver.
0075     [80 80];...     % <-- iter 5, use 80 eig hor., 80 eig ver.
0076     [97 96];...
0077     [97 96]...
0078     ],...
0079     [true true],... % [do dpp correction, keep average of correctors zero] 
0080     1.0,...         % scale factor for correction
0081     ModelRM,...     % response matrix, if [], compute it 
0082     zeros(2,length(indBPM)),... % reference orbit to correct to
0083     [0.5e-3 0.5e-3],... % sterrer strengths limits
0084     true);          % verbosity flag
0085 
0086 
0087 o=findorbit6Err(rerr,indBPM,inCOD);
0088 oxe=o(1,:);
0089 oye=o(3,:);
0090 
0091 o=findorbit6Err(rcor,indBPM,inCOD);
0092 oxc=o(1,:);
0093 oyc=o(3,:);
0094 
0095 sBPM=findspos(rcor,indBPM);
0096 figure;subplot(2,1,1);
0097 plot(sBPM,oxe,'.-');hold on; plot(sBPM,oxc,'.-');
0098 legend('before','after');
0099 xlabel('s [m]');
0100 ylabel('hor. COD');
0101 subplot(2,1,2);
0102 plot(sBPM,oye,'.-');hold on; plot(sBPM,oyc,'.-');
0103 legend('before','after');
0104 xlabel('s [m]');
0105 ylabel('ver. COD');
0106 saveas(gca,'OrbitCor.fig');
0107 % export_fig('OrbitCor.jpg','-r300');
0108 
0109 
0110 % plot output
0111 
0112 figure;
0113 subplot(2,1,1);bar(hs);ylabel('hor.')
0114 subplot(2,1,2);bar(vs);ylabel('ver.')
0115 
0116 inCOD(5)
0117 
0118 rcor0=rcor;

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