Home > atdemos > atmatchExamples > FitQuadrupoleLength > MatchQuadLengthForEqualK1.m

MatchQuadLengthForEqualK1

PURPOSE ^

adjusts length of QFA6 QFA8 to have the same K1

SYNOPSIS ^

function arc1=MatchQuadLengthForEqualK1(arc,d)

DESCRIPTION ^

 adjusts length of QFA6 QFA8 to have the same K1

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function arc1=MatchQuadLengthForEqualK1(arc,d)
0002 % adjusts length of QFA6 QFA8 to have the same K1
0003 indQF=findcells(arc,'FamName','QF');
0004 indQFM=findcells(arc,'FamName','QFM');
0005 indQD=findcells(arc,'FamName','QD');
0006 indQDM=findcells(arc,'FamName','QDM');
0007 
0008 arc=matchingDBA(arc,17.3,0.58,0.0,0.35,...
0009     indQF,indQD,indQFM,indQDM);
0010 
0011 Variab1=atVariableBuilder(arc,...
0012     {@(ar,dl)VaryMagLength(ar,dl,indQF,indQFM)},{0.001});
0013 
0014 % empty varaible. Performs rematch at every iteration of the minimizer
0015 Variab2=atVariableBuilder(arc,...
0016     {@(r,~)matchingDBA(r,17.3,0.58,0.0,0.35,...
0017     indQF,indQD,indQFM,indQDM)},{[]});
0018 
0019 Variab=[Variab1, Variab2];
0020 
0021 %% constraints
0022 Constr=struct(...
0023     'Fun',@(r,~,~)compK1(r,indQFM,indQF),...
0024     'Min',d,...
0025     'Max',d,...
0026     'RefPoints',1,...
0027     'Weight',1); %
0028 
0029 %% matching
0030 
0031 tol=1e-6;
0032 [arc1,~,currentvalues]=atmatch(arc,Variab,Constr,tol,100,3,@lsqnonlin);%'fminsearch',3);%
0033 
0034 return
0035 
0036 
0037 
0038 
0039 
0040 function RING_matched=matchingDBA(RING,bxDb,byDb,DDb,Qx,...
0041     indQF,indQD,indQFM,indQDM)
0042 
0043 V=atVariableBuilder(RING,...
0044     {indQF,indQD,indQDM,indQFM},{{'PolynomB',{1,2}}});
0045 
0046 c1=atlinconstraint(indQFM(2),...
0047     {{'beta',{1}},{'beta',{2}}},...
0048     [bxDb,byDb],...
0049     [bxDb,byDb],...
0050     [1 1]);
0051 
0052 c2=atlinconstraint(1,...
0053     {{'Dispersion',{1}},{'tune',{1}}},...
0054     [DDb,Qx],...
0055     [DDb,Qx],...
0056     [1 1]);
0057 
0058 c=[c1,c2];
0059 
0060 RING_matched=atmatch(RING,V,c,10^-6,1000,0,@lsqnonlin);%
0061 
0062 
0063 return

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