0001 function [rbump,hs,vs]=BumpAtBPM(ring0,inCOD,bumph,bumpv,indBPMbump,indHCor,indVCor)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
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
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);
0062 rbump=atmatch(rbump,VariabV,ConstrV6D,10^-16,10,3,@lsqnonlin);
0063 catch
0064 rbump=atmatch(rbump,VariabH,ConstrH6D,10^-10,40,3);
0065 rbump=atmatch(rbump,VariabV,ConstrV6D,10^-10,40,3);
0066 rbump=atmatch(rbump,VariabH,ConstrH6D,10^-16,10,3,@lsqnonlin);
0067 rbump=atmatch(rbump,VariabV,ConstrV6D,10^-16,10,3,@lsqnonlin);
0068 end
0069
0070
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)];
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)];
0087 end
0088