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

BumpAtBPM4D

PURPOSE ^

function roff=BumpAtBPM(...

SYNOPSIS ^

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

DESCRIPTION ^

 function roff=BumpAtBPM(...
     ring0,...     1) AT lattice structure
     inCOD,...     2) initial 6x1 coordinate guess (unused)
     bumph,...     3) hor. bump value at indBPMbump
     bumpv,...     4) ver. bump value at indBPMbump
     indBPMbump,...5) bump position
     indHCor,....  6) 3x1 correctors to generate bump. last is used for COD=0
     indVCor,....  7) 3x1 correctors to generate bump. last is used for COD=0
     doplot)      %8) output figure

 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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [rbump,hs,vs]=BumpAtBPM4D(ring0,inCOD,bumph,bumpv,indBPMbump,indHCor,indVCor,doplot)
0002 % function roff=BumpAtBPM(...
0003 %     ring0,...     1) AT lattice structure
0004 %     inCOD,...     2) initial 6x1 coordinate guess (unused)
0005 %     bumph,...     3) hor. bump value at indBPMbump
0006 %     bumpv,...     4) ver. bump value at indBPMbump
0007 %     indBPMbump,...5) bump position
0008 %     indHCor,....  6) 3x1 correctors to generate bump. last is used for COD=0
0009 %     indVCor,....  7) 3x1 correctors to generate bump. last is used for COD=0
0010 %     doplot)      %8) output figure
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
0022 if nargin<8
0023     doplot=false;
0024 end
0025 
0026 h1=atVariableBuilder(ring0,indHCor(1),{'PolynomB',{1,1}});
0027 h2=atVariableBuilder(ring0,indHCor(2),{'PolynomB',{1,1}});
0028 h3=atVariableBuilder(ring0,indHCor(3),{'PolynomB',{1,1}});
0029 v1=atVariableBuilder(ring0,indVCor(1),{'PolynomA',{1,1}});
0030 v2=atVariableBuilder(ring0,indVCor(2),{'PolynomA',{1,1}});
0031 v3=atVariableBuilder(ring0,indVCor(3),{'PolynomA',{1,1}});
0032 VariabH=[h1 h2 h3];
0033 VariabV=[v1 v2 v3];
0034 
0035 % 4D orbit
0036 LinConstr1h=atlinconstraint(...
0037     indBPMbump,...
0038     {{'ClosedOrbit',{1}}},...
0039     bumph,...
0040     bumph,...
0041     1e-6);
0042 
0043 LinConstr2h=atlinconstraint(...
0044     indHCor(end)+1,...
0045     {{'ClosedOrbit',{1}},{'ClosedOrbit',{2}}},...
0046     [0,0],...
0047     [0,0],...
0048     [1e-6 1e-6]);
0049 
0050 LinConstr1v=atlinconstraint(...
0051     indBPMbump,...
0052     {{'ClosedOrbit',{3}}},...
0053     bumpv,...
0054     bumpv,...
0055     1e-6);
0056 
0057 LinConstr2v=atlinconstraint(...
0058     indVCor(end)+1,...
0059     {{'ClosedOrbit',{3}},{'ClosedOrbit',{4}}},...
0060     [0,0],...
0061     [0,0],...
0062     [1e-6 1e-6]);
0063 ConstrH=[LinConstr1h,LinConstr2h];
0064 ConstrV=[LinConstr1v,LinConstr2v];
0065 
0066 
0067 rbump=ring0;
0068 rbump=atmatch(rbump,VariabH,ConstrH,10^-10,50,3,@lsqnonlin);%,'fminsearch');%
0069 rbump=atmatch(rbump,VariabV,ConstrV,10^-10,50,0,@lsqnonlin);%,'fminsearch');%
0070 
0071 if doplot
0072 ib=findcells(ring0,'Class','Monitor');
0073 
0074     figure;
0075     o0=findorbit4Err(ring0,0,ib);
0076     o=findorbit4Err(rbump,0,ib);
0077     s=findspos(ring0,ib);
0078     plot(s,(o-o0)');
0079     legend('x','xp','y','yp');
0080     xlabel('s [m]');
0081     ylabel('4D coordinates')
0082     
0083 end
0084 
0085 end

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