Home > atdemos > atmatchExamples > ExampleATMATCH > runtotest_atmatch.m

runtotest_atmatch

PURPOSE ^

macro match dba test lattice beta functions and dispersion using

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 macro match dba test lattice beta functions and dispersion using
 quadrupoles.

 this macro shows the available functionalities of atmatch. 
 
 various variable and constraint input constructions are shown

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % macro match dba test lattice beta functions and dispersion using
0002 % quadrupoles.
0003 %
0004 % this macro shows the available functionalities of atmatch.
0005 %
0006 % various variable and constraint input constructions are shown
0007 
0008 clear all
0009 load('dba.mat','RING');
0010 addpath(fullfile(pwd,'..'))
0011 
0012 %%  VARIABLES
0013 
0014 % Variab1=struct('Indx',{findcells(RING,'FamName','QD'),findcells(RING,'FamName','QF')},...
0015 %     'LowLim',{[],[]},...
0016 %     'HighLim',{[],[]},...
0017 %     'Parameter',{{'PolynomB',{1,2}},{'PolynomB',{1,2}}}...
0018 %     );
0019 
0020 % or
0021 
0022 Variab1=atVariableBuilder(RING,{'QD','QF'},{{'PolynomB',{1,2}},{'PolynomB',{1,2}}});
0023 
0024 
0025 k1start=getcellstruct(RING,'PolynomB',findcells(RING,'FamName','QDM'),1,2);
0026 
0027 Variab2=struct('Indx',{findcells(RING,'FamName','QFM'),@(RING,K1Val)VaryQuadFam(RING,K1Val,'QDM')},...
0028     'LowLim',{[],[]},...
0029     'HighLim',{[],[]},...
0030     'Parameter',{{'PolynomB',{1,2}},k1start(1)}...
0031     );
0032 
0033 Variab=[Variab1,Variab2];
0034 
0035 
0036 %%  CONSTRAINTS
0037 qfmindx=findcells(RING,'FamName','QFM');
0038 Constr1=struct('Fun',@(RING,~,~)dispx(RING,1),...
0039     'Min',0,...
0040     'Max',0,...
0041     'RefPoints',[],...
0042     'Weight',1);
0043 disp('Horizontal dispersion at straigth section= 0')
0044 
0045 Constr2=struct('Fun',@(RING,~,~)betx(RING,qfmindx(2)),...
0046     'Min',17.3,...
0047     'Max',17.3,...
0048     'RefPoints',[],...
0049     'Weight',1);
0050 disp('Horizontal beta at QFM= 17.3')
0051 
0052 Constr3=struct('Fun',{@(RING,~,~)bety(RING,qfmindx(2)),@(~,ld,~)mux(ld)},...
0053     'Min',{0.58,4.35},...
0054     'Max',{0.58,4.35},...
0055     'RefPoints',{[],[1:length(RING)+1]},...
0056     'Weight',{1,1});
0057 disp('Vertical beta at QFM= 0.58')
0058 disp('Horizontal phase advance = 4.35')
0059 
0060 Constr=[Constr1,Constr2,Constr3];
0061 
0062 %% MATCHING
0063  disp('wait few iterations')
0064 RING_matched=atmatch(RING,Variab,Constr,10^-20,1000,3,@lsqnonlin);
0065 
0066 %return
0067 c1=atlinconstraint(qfmindx(2),...
0068     {{'beta',{1}},{'beta',{2}}},...
0069     [17.3,0.58],...
0070     [17.3,0.58],...
0071     [1 1]);
0072 
0073 c2=atlinconstraint(1,...
0074     {{'Dispersion',{1}},{'tune',{1}}},...
0075     [0,0.35],...
0076     [0,0.35],...
0077     [1 1]);
0078 
0079 c=[c1,c2];
0080 
0081 RING_matched_optconstr=atmatch(RING,Variab,c,10^-6,1000,3);%
0082 
0083 figure;atplot(RING);% export_fig('ringdba.pdf','-transparent');
0084 figure;atplot(RING_matched);% export_fig('ringdba_matched.pdf','-transparent');
0085 figure;atplot(RING_matched_optconstr);% export_fig('ringdba_matched.pdf','-transparent');

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