Home > pubtools > LatticeTuningFunctions > correction > correction_chain > testcorrectionchain.m

testcorrectionchain

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(genpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/correction/'));
0007 addpath(genpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/errors/'));
0008 
0009 % load lattice
0010 load ESRFLattice.mat
0011 speclab='ChainESRF';
0012 
0013 modelrmfile=fullfile(pwd,['RMmodel' speclab '.mat']);%
0014 
0015 if ~exist([modelrmfile],'file')
0016     
0017     ModelRM...
0018         =getresponsematrices(...
0019         ring,...
0020         indBPM,...
0021         indHCor,...
0022         indVCor,...
0023         indSCor,...
0024         indQCor,...
0025         [],...
0026         [0 0 0 0 0 0]',...
0027         [1 2 3 4 5 6 7 8 9 10 11 12]); % all RM
0028     
0029     save([modelrmfile],'ModelRM');
0030 else
0031     load([modelrmfile],'ModelRM');
0032 end
0033 
0034 
0035 % mark quadrupoles to use for tune matching
0036 indqf1=find(atgetcells(ring,'FamName','QF1\w*'));
0037 ring=atsetfieldvalues(ring,indqf1,'ForTuneF',1);                
0038 indqd2=find(atgetcells(ring,'FamName','QD2\w*'));
0039 ring=atsetfieldvalues(ring,indqd2,'ForTuneD',1);                
0040 
0041 inddq=find(atgetcells(ring,'FamName','DQ\w*'))';
0042 inddl=find(atgetcells(ring,'FamName','DL\w*_3\w*'))';
0043 ring=atsetfieldvalues(ring,[inddq inddl],'FitElement',1);     %mark as fitting point only some dipoles central ones.
0044 
0045 indDip=find(atgetcells(ring,'Class','Bend') & atgetcells(ring,'FitElement') )';
0046 
0047 r0=ring;
0048 
0049 % set errors, large, AT does not find a closed orbit
0050 ind=find(atgetcells(ring,'Class','Quadrupole','Sextupole'));
0051 dx=0.5e-4*randn(size(ind));
0052 dy=0.5e-4*randn(size(ind));
0053 dr=1.0e-4*randn(size(ind));
0054 % truncate errors (quick wrong way, distribution not gaussian)
0055 dx(abs(dx)>2.5*0.5e-4)=0.5e-4;
0056 dy(abs(dy)>2.5*0.5e-4)=0.5e-4;
0057 dr(abs(dr)>2.5*1.0e-4)=1.0e-4;
0058 
0059 rerr=atsetshift(ring,ind,dx,dy);
0060 rerr=atsettilt(rerr,ind,dr);
0061 
0062 %% correction chain
0063 
0064 neigenvectors=[...
0065     200,... % n eig orbit H
0066     200,... % n eig orbit V
0067     200,... % skew quadrupole 
0068     250,... % normal quadrupole 
0069     250,... % fit normal quadrupole 
0070     100,... % fit dipole 
0071     250,... % fit skew quadrupole 
0072     ]; % number of eigenvectors
0073 
0074 diary('CorrChain7RF.txt');
0075 cororder=[0 1 2 3 6 6 -1];
0076 %  '(-1 ): RF cavity frequency and time lag tuning '...
0077 %  '( 0 ): open trajectory (finds closed orbit) '...
0078 %  '( 1 ): orbit '...
0079 %  '( 2 ): tune '...
0080 %  '( 3 ): chromaticity '...
0081 %  '( 4 ): dispersion '...
0082 %  '( 5 ): dispersion free steering '...
0083 %  '( 6 ): rdt + dispersion correction '...
0084 
0085 rcor=CorrectionChain(...
0086     rerr,...            %1  initial lattice
0087     r0,...              %2  model lattice
0088     indBPM,...          %3  bpm index
0089     indHCor,...         %4  h steerers index
0090     indVCor,...         %5  v steerers index
0091     indSCor,...  %6  skew quad index
0092     indQCor,...      %7  quadrupole correctors index
0093     neigenvectors,...            %8  number of eigen vectors [NeigorbitH, NeigorbitV, NeigQuadrdt, Neigdispv, Neigdisph,neig rdt corr, SkewQuadRDT]
0094     cororder,...       %9  correction order 1: orbit, 2: tune, 3: skewquad disp v 4: quad disp h 5: quad RDT 6: skew RDT
0095     ModelRM,...          %10 response matrices
0096     '',...          %11 response matrices
0097     true);
0098 
0099 diary off
0100 
0101 
0102 return
0103 %%

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