0001 function RDT=computeRDT(ring, index, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 naddvar=length(varargin);
0023 chromatic=0;
0024 coupling=0;
0025 geometric1=0;
0026 geometric2=0;
0027 tuneshifts=0;
0028 for ii=1:naddvar
0029 switch varargin{ii}
0030 case 'chromatic'
0031 chromatic=1;
0032 case 'coupling'
0033 coupling=1;
0034 case 'geometric1'
0035 geometric1=1;
0036 case 'geometric2'
0037 geometric2=1;
0038 case 'tuneshifts'
0039 tuneshifts=1;
0040 otherwise
0041 disp(['The input number ' num2str(ii+2) ' must be one of these:']);
0042 disp('''chromatic'', ''coupling'', ''geometric1'',''geometric2'', ''tuneshifts''');
0043 disp('your input will be ignored');
0044 end
0045 end
0046
0047 if naddvar==0
0048 chromatic=1;
0049 coupling=1;
0050 geometric1=1;
0051 geometric2=1;
0052 tuneshifts=1;
0053 end
0054
0055
0056 indDQSO=findcells(ring,'Class','Bend','Quadrupole','Sextupole','Octupole');
0057
0058
0059
0060 [~,AVEBETA,AVEMU,AVEDISP,~,~]=atavedata(ring,0,1:length(ring));
0061
0062 Lin=atlinopt(ring,0,1:length(ring));
0063
0064
0065 sIndex=findspos(ring,indDQSO);
0066 s=findspos(ring,1:length(ring));
0067 sEnd=findspos(ring,length(ring)+1);
0068 betax=AVEBETA(indDQSO,1);
0069 betay=AVEBETA(indDQSO,2);
0070 etax=AVEDISP(indDQSO,1);
0071 phix=AVEMU(indDQSO,1);
0072 phiy=AVEMU(indDQSO,2);
0073 a2L=getcellstruct(ring,'PolynomA',indDQSO,1,2).*getcellstruct(ring,'Length',indDQSO);
0074 a2L(isnan(a2L))=0;
0075 b2L=getcellstruct(ring,'PolynomB',indDQSO,1,2).*getcellstruct(ring,'Length',indDQSO);
0076 b2L(isnan(b2L))=0;
0077 b3L=getcellstruct(ring,'PolynomB',indDQSO,1,3).*getcellstruct(ring,'Length',indDQSO);
0078 b3L(isnan(b3L))=0;
0079 b4L=getcellstruct(ring,'PolynomB',indDQSO,1,4).*getcellstruct(ring,'Length',indDQSO);
0080 b4L(isnan(b4L))=0;
0081 Mux=Lin(length(ring)).mu(1);
0082 Tunex=Mux/2/pi;
0083 Muy=Lin(length(ring)).mu(2);
0084 Tuney=Muy/2/pi;
0085 nElem=length(indDQSO);
0086
0087 for ii=1:length(index)
0088 FromindexDQSO=sum(indDQSO<index(ii))+1;
0089 betax_Fromindex=[betax(FromindexDQSO:end);betax(1:FromindexDQSO-1)];
0090 betay_Fromindex=[betay(FromindexDQSO:end);betay(1:FromindexDQSO-1)];
0091 etax_Fromindex=[etax(FromindexDQSO:end);etax(1:FromindexDQSO-1)];
0092 phix_Fromindex=[phix(FromindexDQSO:end)-AVEMU(index(ii),1);phix(1:FromindexDQSO-1)+Mux-AVEMU(index(ii),1)];
0093 phiy_Fromindex=[phiy(FromindexDQSO:end)-AVEMU(index(ii),2);phiy(1:FromindexDQSO-1)+Muy-AVEMU(index(ii),2)];
0094 s_Fromindex=[sIndex(FromindexDQSO:end)-s(index(ii)),sIndex(1:FromindexDQSO-1)+sEnd-s(index(ii))];
0095 a2L_Fromindex=[a2L(FromindexDQSO:end);a2L(1:FromindexDQSO-1)];
0096 b2L_Fromindex=[b2L(FromindexDQSO:end);b2L(1:FromindexDQSO-1)];
0097 b3L_Fromindex=[b3L(FromindexDQSO:end);b3L(1:FromindexDQSO-1)];
0098 b4L_Fromindex=[b4L(FromindexDQSO:end);b4L(1:FromindexDQSO-1)];
0099 [ReRDT, ImRDT, TSwA]=RDTelegantAT(s_Fromindex,betax_Fromindex,betay_Fromindex,...
0100 etax_Fromindex,phix_Fromindex,phiy_Fromindex,a2L_Fromindex,b2L_Fromindex,...
0101 b3L_Fromindex,b4L_Fromindex,Tunex,Tuney,nElem,...
0102 chromatic,coupling,geometric1,geometric2,tuneshifts);
0103
0104 if(chromatic)
0105 RDT(ii).h11001=ReRDT(6)+1i*ImRDT(6);
0106 RDT(ii).h00111=ReRDT(7)+1i*ImRDT(7);
0107 RDT(ii).h20001=ReRDT(8)+1i*ImRDT(8);
0108 RDT(ii).h00201=ReRDT(9)+1i*ImRDT(9);
0109 RDT(ii).h10002=ReRDT(10)+1i*ImRDT(10);
0110 end
0111
0112 if(coupling)
0113 RDT(ii).h10010=ReRDT(11)+1i*ImRDT(11);
0114 RDT(ii).h10100=ReRDT(12)+1i*ImRDT(12);
0115 end
0116
0117 if(geometric1)
0118 RDT(ii).h21000=ReRDT(1)+1i*ImRDT(1);
0119 RDT(ii).h30000=ReRDT(2)+1i*ImRDT(2);
0120 RDT(ii).h10110=ReRDT(3)+1i*ImRDT(3);
0121 RDT(ii).h10020=ReRDT(4)+1i*ImRDT(4);
0122 RDT(ii).h10200=ReRDT(5)+1i*ImRDT(5);
0123 end
0124
0125 if(geometric2)
0126 RDT(ii).h22000=ReRDT(13)+1i*ImRDT(13);
0127 RDT(ii).h11110=ReRDT(14)+1i*ImRDT(14);
0128 RDT(ii).h00220=ReRDT(15)+1i*ImRDT(15);
0129 RDT(ii).h31000=ReRDT(16)+1i*ImRDT(16);
0130 RDT(ii).h40000=ReRDT(17)+1i*ImRDT(17);
0131 RDT(ii).h20110=ReRDT(18)+1i*ImRDT(18);
0132 RDT(ii).h11200=ReRDT(19)+1i*ImRDT(19);
0133 RDT(ii).h20020=ReRDT(20)+1i*ImRDT(20);
0134 RDT(ii).h20200=ReRDT(21)+1i*ImRDT(21);
0135 RDT(ii).h00310=ReRDT(22)+1i*ImRDT(22);
0136 RDT(ii).h00400=ReRDT(23)+1i*ImRDT(23);
0137 end
0138
0139 if(tuneshifts)
0140 RDT(ii).dnux_dJx=TSwA(1);
0141 RDT(ii).dnux_dJy=TSwA(2);
0142 RDT(ii).dnuy_dJy=TSwA(3);
0143 end
0144 end