Home > pubtools > LatticeTuningFunctions > correction > tune > atmatchtunedelta.m

atmatchtunedelta

PURPOSE ^

function arcchrom0=atmatchtunedelta(arc,c,quadfams)

SYNOPSIS ^

function arctune0=atmatchtunedelta(arc,tune,quadfams)

DESCRIPTION ^

 function arcchrom0=atmatchtunedelta(arc,c,quadfams)
 
 arc    : at lattice 
 tune      : tune to get (with integer part) size(tune)=[2,1]
 quadfams: {[findcells(arc,'FamName','QF1','QF2')],...
          [findcells(arc,'FamName','QD1','QD2')] }
 
 delta on quadrupole families 

 fits the tune to the desired values, including the integer part.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function arctune0=atmatchtunedelta(arc,tune,quadfams)
0002 % function arcchrom0=atmatchtunedelta(arc,c,quadfams)
0003 %
0004 % arc    : at lattice
0005 % tune      : tune to get (with integer part) size(tune)=[2,1]
0006 % quadfams: {[findcells(arc,'FamName','QF1','QF2')],...
0007 %          [findcells(arc,'FamName','QD1','QD2')] }
0008 %
0009 % delta on quadrupole families
0010 %
0011 % fits the tune to the desired values, including the integer part.
0012 
0013 %disp('match tunes')
0014 
0015 variabs=[];
0016 
0017 for iquadfams=1:length(quadfams)
0018   KQ=cellfun(@(a)a.PolynomB(2),arc(quadfams{iquadfams}),'un',1);
0019   variabs=[variabs, atVariableBuilder(arc,...
0020     {@(r,DKquad)setcellstruct(r,'PolynomB',quadfams{iquadfams},KQ+DKquad,1,2)},...
0021     {[1e-8]})]; %#ok<*AGROW>
0022 end
0023 
0024 ConstrQX=struct(...
0025     'Fun',@(~,ld,~)mux(ld),...
0026     'Weight',1,...
0027     'RefPoints',[1:length(arc)+1],...
0028     'Min',tune(1),...
0029     'Max',tune(1));
0030 
0031 ConstrQY=struct(...
0032     'Fun',@(~,ld,~)muy(ld),...
0033     'Weight',1,...
0034     'RefPoints',[1:length(arc)+1],...
0035     'Min',tune(2),...
0036     'Max',tune(2));
0037 
0038 % tol=1e-6;
0039 % arctune0=atmatch(arc,variabs,[ConstrQX ConstrQY],tol,5,3);%,@lsqnonlin); %
0040 
0041  tol=1e-8;
0042  arctune0=arc;
0043  arctune0=atmatch(arctune0,variabs,[ConstrQX ConstrQY],tol,50,3); %);%
0044 % arctune0=atmatch(arctune0,variabs,[ConstrQX ConstrQY],tol,50,3,@lsqnonlin); %);%
0045 
0046 return
0047 
0048 function m=muy(lindata)
0049 
0050 m=lindata(end).mu(2)/2/pi;
0051 
0052 return
0053 
0054 function m=mux(lindata)
0055 
0056 m=lindata(end).mu(1)/2/pi;
0057 
0058 return

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