Home > pubtools > LatticeTuningFunctions > correction > orbitbumps > matching > BumpAtBPM.m

BumpAtBPM

PURPOSE ^

function roff=BumpAtBPM(...

SYNOPSIS ^

function [rbump,hs,vs]=BumpAtBPM(ring0,inCOD,bumph,bumpv,indBPMbump,indHCor,indVCor)

DESCRIPTION ^

 function roff=BumpAtBPM(...
     ring0,... AT lattice structure
     inCOD,... initial 6x1 coordinate guess 
     bumph,... hor. bump value at indBPMbump
     bumpv,... ver. bump value at indBPMbump
     indBPMbump, bump position
     indHCor,.... 1x3 correctors to generate bump. last is used for COD=0
     indVCor.... 1x3 correctors to generate bump. last is used for COD=0
     )

 ex:
      % order of correctors does not metter as far as the bpm is within
      the three correctors. last corrector index is used to match the
      postion and angle back to zero
      roff=BumpAtBPM(ring0,0.0,1e-3,50,[4 78 90],[89 34 1]);

      % to match bump at first bpm, use last corrector,
      roff=BumpAtBPM(ring0,1e-3,1e-7,1,indHCor([end,1,2]),indVCor([end,1,2]));
 
see also: atmatch findorbit6Err

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [rbump,hs,vs]=BumpAtBPM(ring0,inCOD,bumph,bumpv,indBPMbump,indHCor,indVCor)
0002 % function roff=BumpAtBPM(...
0003 %     ring0,... AT lattice structure
0004 %     inCOD,... initial 6x1 coordinate guess
0005 %     bumph,... hor. bump value at indBPMbump
0006 %     bumpv,... ver. bump value at indBPMbump
0007 %     indBPMbump, bump position
0008 %     indHCor,.... 1x3 correctors to generate bump. last is used for COD=0
0009 %     indVCor.... 1x3 correctors to generate bump. last is used for COD=0
0010 %     )
0011 %
0012 % ex:
0013 %      % order of correctors does not metter as far as the bpm is within
0014 %      the three correctors. last corrector index is used to match the
0015 %      postion and angle back to zero
0016 %      roff=BumpAtBPM(ring0,0.0,1e-3,50,[4 78 90],[89 34 1]);
0017 %
0018 %      % to match bump at first bpm, use last corrector,
0019 %      roff=BumpAtBPM(ring0,1e-3,1e-7,1,indHCor([end,1,2]),indVCor([end,1,2]));
0020 %
0021 %see also: atmatch findorbit6Err
0022 
0023 if size(indBPMbump)~=[1 1]
0024     error('indBPMbump must be size 1x1')
0025 end
0026 if size(indHCor)~=[1 3]
0027     error('indHCor must be size 1x3')
0028 end
0029 if size(indVCor)~=[1 3]
0030     error('indVCor must be size 1x3')
0031 end
0032 
0033 h1=atVariableBuilder(ring0,indHCor(1),{'PolynomB',{1,1}});
0034 h2=atVariableBuilder(ring0,indHCor(2),{'PolynomB',{1,1}});
0035 h3=atVariableBuilder(ring0,indHCor(3),{'PolynomB',{1,1}});
0036 v1=atVariableBuilder(ring0,indVCor(1),{'PolynomA',{1,1}});
0037 v2=atVariableBuilder(ring0,indVCor(2),{'PolynomA',{1,1}});
0038 v3=atVariableBuilder(ring0,indVCor(3),{'PolynomA',{1,1}});
0039 VariabH=[h1 h2 h3];
0040 VariabV=[v1 v2 v3];
0041 
0042 % 6D orbit
0043 ConstrH6D=struct(...
0044     'Fun',@(r,~,~)get6dx(r,indBPMbump,indHCor(end)+1,inCOD),...
0045     'Weight',[1e-6 1e-6 1e-6],...
0046     'RefPoints',1,...
0047     'Min',[bumph 0.0 0.0],...
0048     'Max',[bumph 0.0 0.0]);
0049 
0050 ConstrV6D=struct(...
0051     'Fun',@(r,~,~)get6dy(r,indBPMbump,indHCor(end)+1,inCOD),...
0052     'Weight',[1e-6 1e-6 1e-6],...
0053     'RefPoints',1,...
0054     'Min',[bumpv 0.0 0.0],...
0055     'Max',[bumpv 0.0 0.0]);
0056 
0057 
0058 rbump=ring0;
0059 
0060 try
0061     rbump=atmatch(rbump,VariabH,ConstrH6D,10^-16,10,3,@lsqnonlin);%,'fminsearch');%
0062     rbump=atmatch(rbump,VariabV,ConstrV6D,10^-16,10,3,@lsqnonlin);%,'fminsearch');%
0063 catch
0064     rbump=atmatch(rbump,VariabH,ConstrH6D,10^-10,40,3);%,'fminsearch');%
0065     rbump=atmatch(rbump,VariabV,ConstrV6D,10^-10,40,3);%,'fminsearch');%
0066     rbump=atmatch(rbump,VariabH,ConstrH6D,10^-16,10,3,@lsqnonlin);%,'fminsearch');%
0067     rbump=atmatch(rbump,VariabV,ConstrV6D,10^-16,10,3,@lsqnonlin);%,'fminsearch');%
0068 end
0069 
0070 % plot corrector values.
0071 hs=atgetfieldvalues(rbump,indHCor,'PolynomB',{1,1});
0072 vs=atgetfieldvalues(rbump,indVCor,'PolynomA',{1,1});
0073 
0074 end
0075 
0076 
0077 function x=get6dx(r,ind1,ind2,inCOD)
0078 o1=findorbit6Err(r,ind1,inCOD);
0079 o2=findorbit6Err(r,ind2,inCOD);
0080 x=[o1(1,1),o2(1,1),o2(2,1)]; % orbit at ind1, orbit and angle at ind2
0081 end
0082 
0083 function x=get6dy(r,ind1,ind2,inCOD)
0084 o1=findorbit6Err(r,ind1,inCOD);
0085 o2=findorbit6Err(r,ind2,inCOD);
0086 x=[o1(3,1),o2(3,1),o2(4,1)]; % orbit at ind1, orbit and angle at ind2
0087 end
0088

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