Home > atdemos > atmatchExamples > bump > run_BumpFit.m

run_BumpFit

PURPOSE ^

fit a bump using correctors

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 fit a bump using correctors

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % fit a bump using correctors
0002 clear all
0003 
0004 load('dba.mat','RING');
0005 addpath(fullfile(pwd,'..'))
0006 
0007 %correctors and BPM
0008 C=atcorrector('C',0,0);
0009 M=atmarker('BPM');
0010 
0011 % get one cell and add elements
0012 arc=[{M};RING(1:18);RING(128:end)];
0013 
0014 indq=findcells(arc,'Class','Quadrupole');
0015 for iq=2:2:length(indq)
0016     arc=[arc(1:indq(iq)-1);M;C;arc(indq(iq):end)];
0017     indq=findcells(arc,'Class','Quadrupole');
0018 end
0019 
0020 % build variables
0021 hcor=findcells(arc,'FamName','C');
0022 
0023 Variab=atVariableBuilder(arc,...
0024     {[hcor(1), hcor(end)],[hcor(2),hcor(end-1)]},...
0025     {{'KickAngle'}});
0026 
0027 % build constraints
0028 bpm=findcells(arc,'FamName','BPM');       
0029           
0030 c1=atlinconstraint(...
0031     [bpm(1)],...
0032     {{'ClosedOrbit',{1}},{'ClosedOrbit',{2}}},...
0033     [1e-3,0],...
0034     [1e-3,0],...
0035     [1e-2 1e-2]);
0036 
0037 c2=atlinconstraint(...
0038     [bpm(2:end-1)],{{'ClosedOrbit',{1}}},0,0,1e-2); %#ok<*NBRAK>
0039 
0040 c=[c1,c2];
0041 
0042 % perform matching
0043 arc_bump=atmatch(arc,Variab,c,10^-15,1000,3,@lsqnonlin);%'fminsearch',3);%
0044 figure;atplot(arc_bump,@plClosedOrbit);
0045 
0046

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