0001 function [rbump,hs,vs]=BumpAtBPM4D(ring0,inCOD,bumph,bumpv,indBPMbump,indHCor,indVCor,doplot)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
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
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);
0069 rbump=atmatch(rbump,VariabV,ConstrV,10^-10,50,0,@lsqnonlin);
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