Home > pubtools > LatticeTuningFunctions > correction > trajectory > testtrajectorycorrection.m

testtrajectorycorrection

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 
0005 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions');
0006 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/correction/response matrix')
0007 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/correction/');
0008 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/errors/');
0009 
0010 % load lattice
0011 load ESRFLattice.mat
0012 r0=ring;
0013 %% get RM
0014 speclab='TrajectoryDppESRF';
0015 
0016 modelrmfile=fullfile(pwd,['RMmodel' speclab '.mat']);%
0017 
0018 if ~exist([modelrmfile],'file')
0019     
0020     ModelRM...
0021         =getresponsematrices(...
0022         ring,...
0023         indBPM,...
0024         indHCor,...
0025         indVCor,...
0026         indSCor,...
0027         indQCor,...
0028         [],...
0029         [0 0 0 0 0 0]',...
0030         [4 5 6]);
0031     
0032     save([modelrmfile],'ModelRM');
0033 else
0034     load([modelrmfile],'ModelRM');
0035 end
0036 
0037 % set errors, large, AT does not find a closed orbit
0038 ind=find(atgetcells(ring,'Class','Quadrupole'));
0039 dx=1.0e-4*randn(size(ind));
0040 dy=1.0e-4*randn(size(ind));
0041 
0042 rerr=atsetshift(ring,ind,dx,dy);
0043 
0044 %% apply correction
0045 inCOD=[0 0 0 0 0 0]';
0046 
0047 [rcor,inCOD]=atfirstturntrajectory(...
0048     rerr,...
0049     inCOD,...
0050     indBPM,...
0051     indHCor,...
0052     indVCor,...
0053     0.5e-2,...
0054     30,...
0055     [false true],...
0056     ModelRM,...
0057     zeros(2,length(indBPM)),...
0058     []);
0059 % X: 568.781 -> 256.872 um
0060 % Y: 350.971 -> 155.680 um
0061 
0062 o=findtrajectory6Err(rerr,indBPM,inCOD);
0063 oxe=o(1,:);
0064 oye=o(3,:);
0065 
0066 o=findtrajectory6Err(rcor,indBPM,inCOD);
0067 oxc=o(1,:);
0068 oyc=o(3,:);
0069 
0070 sBPM=findspos(rcor,indBPM);
0071 figure;subplot(2,1,1);
0072 plot(sBPM,oxe,'.-');hold on; plot(sBPM,oxc,'.-');
0073 legend('before','after');
0074 xlabel('s [m]');
0075 ylabel('hor. COD');
0076 subplot(2,1,2);
0077 plot(sBPM,oye,'.-');hold on; plot(sBPM,oyc,'.-');
0078 legend('before','after');
0079 xlabel('s [m]');
0080 ylabel('ver. COD');
0081 saveas(gca,'TrajCor.fig');
0082 % export_fig('TrajCor.jpg','-r300');
0083 % return
0084 
0085 return
0086 
0087 [rcor,inCOD]=atfirstturntrajectory(...
0088     rerr,...
0089     inCOD,...
0090     indBPM,...
0091     indHCor,...
0092     indVCor,...
0093     2.0e-3,...
0094     60,...
0095     [true false],...
0096     ModelRM,...
0097     zeros(2,length(indBPM)),...
0098     [5e-3 5e-3]);
0099 % X: 407.753 -> 216.807 um
0100 % Y: 300.986 -> 146.863 um
0101 
0102 [rcor,inCOD]=atfirstturntrajectory(...
0103     rerr,...
0104     inCOD,...
0105     indBPM,...
0106     indHCor,...
0107     indVCor,...
0108     2.0e-3,...
0109     60,...
0110     [false true],...
0111     ModelRM,...
0112     zeros(2,length(indBPM)),...
0113     [5e-3 5e-3]);
0114 % X: 502.317 -> 247.443 um
0115 % Y: 343.767 -> 157.849 um
0116 
0117 [rcor,inCOD]=atfirstturntrajectory(...
0118     rerr,...
0119     inCOD,...
0120     indBPM,...
0121     indHCor,...
0122     indVCor,...
0123     2.0e-3,...
0124     60,...
0125     [false false],...
0126     ModelRM,...
0127     zeros(2,length(indBPM)),...
0128     [5e-3 5e-3]);
0129 % X: 614.390 -> 259.440 um
0130 % Y: 361.596 -> 166.576 um
0131 
0132 
0133 %% no input ModelRM, pass r0 to compute it!
0134 [rcor,inCOD]=atfirstturntrajectory(...
0135     rerr,...
0136     inCOD,...
0137     indBPM,...
0138     indHCor,...
0139     indVCor,...
0140     2.0e-3,...
0141     60,...
0142     [true false],...
0143     r0);
0144

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