0001
0002
0003
0004
0005
0006
0007
0008 clear all
0009 load('dba.mat','RING');
0010 addpath(fullfile(pwd,'..'))
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
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
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
0063 disp('wait few iterations')
0064 RING_matched=atmatch(RING,Variab,Constr,10^-20,1000,3,@lsqnonlin);
0065
0066
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);
0084 figure;atplot(RING_matched);
0085 figure;atplot(RING_matched_optconstr);