0001 clear all
0002 close all
0003 addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/errors')
0004
0005 load ../../ESRFLattice.mat
0006
0007
0008
0009 indc=indHCor(45);
0010 ring0=ring;
0011
0012
0013 kick=1e-5;
0014
0015 ringcor=atsetfieldvalues(ring,indc,'PolynomB',{1,1},kick);
0016
0017 br=getBrho(ring);
0018 L=ring{indc}.Length;
0019 ringdip=ring;
0020 ringdip=atsetfieldvalues(ringdip,indc,'BendingAngle',{1,1},kick*L);
0021 ringdip=atsetfieldvalues(ringdip,indc,'EntranceAngle',{1,1},0);
0022 ringdip=atsetfieldvalues(ringdip,indc,'ExitAngle',{1,1},0);
0023 ringdip=atsetfieldvalues(ringdip,indc,'PassMethod','BndMPoleSymplectic4FrgFPass');
0024
0025
0026
0027 dt=1e-4;
0028
0029
0030 ringcortilt=atsettilt(ringcor,indc,dt);
0031 ringdiptiltref=atsettilt(ringdip,indc,dt);
0032 ringdiptilt=atsettiltdipole(ringdip,indc,dt);
0033
0034
0035
0036 [twin,~,~]=atlinopt(ring0,0,1);
0037 indall=1:length(ring)+1;
0038 lcor=twissline(ringcor,0.0,twin,indall,'chrom');
0039 ldip=twissline(ringdip,0.0,twin,indall,'chrom');
0040 lcortilt=twissline(ringcortilt,0.0,twin,indall,'chrom');
0041 ldiptilt=twissline(ringdiptilt,0.0,twin,indall,'chrom');
0042 ldiptiltref=twissline(ringdiptiltref,0.0,twin,indall,'chrom');
0043
0044 oxcor=arrayfun(@(a)a.ClosedOrbit(1),lcor,'un',1);
0045 oycor=arrayfun(@(a)a.ClosedOrbit(3),lcor,'un',1);
0046 dxcor=arrayfun(@(a)a.Dispersion(1),lcor,'un',1);
0047 dycor=arrayfun(@(a)a.Dispersion(3),lcor,'un',1);
0048
0049 oxdip=arrayfun(@(a)a.ClosedOrbit(1),ldip,'un',1);
0050 oydip=arrayfun(@(a)a.ClosedOrbit(3),ldip,'un',1);
0051 dxdip=arrayfun(@(a)a.Dispersion(1),ldip,'un',1);
0052 dydip=arrayfun(@(a)a.Dispersion(3),ldip,'un',1);
0053
0054 oxcortilt=arrayfun(@(a)a.ClosedOrbit(1),lcortilt,'un',1);
0055 oycortilt=arrayfun(@(a)a.ClosedOrbit(3),lcortilt,'un',1);
0056 dxcortilt=arrayfun(@(a)a.Dispersion(1),lcortilt,'un',1);
0057 dycortilt=arrayfun(@(a)a.Dispersion(3),lcortilt,'un',1);
0058
0059 oxdiptilt=arrayfun(@(a)a.ClosedOrbit(1),ldiptilt,'un',1);
0060 oydiptilt=arrayfun(@(a)a.ClosedOrbit(3),ldiptilt,'un',1);
0061 dxdiptilt=arrayfun(@(a)a.Dispersion(1),ldiptilt,'un',1);
0062 dydiptilt=arrayfun(@(a)a.Dispersion(3),ldiptilt,'un',1);
0063
0064 oxdiptiltref=arrayfun(@(a)a.ClosedOrbit(1),ldiptiltref,'un',1);
0065 oydiptiltref=arrayfun(@(a)a.ClosedOrbit(3),ldiptiltref,'un',1);
0066 dxdiptiltref=arrayfun(@(a)a.Dispersion(1),ldiptiltref,'un',1);
0067 dydiptiltref=arrayfun(@(a)a.Dispersion(3),ldiptiltref,'un',1);
0068
0069
0070 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispCor')
0071 s=findspos(ring,indall);
0072 yyaxis left
0073 plot(s,oxcor,'b');hold on;
0074 plot(s,oycor,'r');
0075 xlabel('s [m]');
0076 ylabel('orbit [m]');
0077 yyaxis right
0078 plot(s,dxcor,'c');hold on;
0079 plot(s,dycor,'m');
0080 xlabel('s [m]');
0081 ylabel('dispersion [m]');
0082 legend('x','y','\eta_x','\eta_y')
0083 saveas(gca,'OrbitDispCor.fig')
0084 export_fig('OrbitDispCor.jpg','-r300')
0085
0086 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispDip')
0087 s=findspos(ring,indall);
0088 yyaxis left
0089 plot(s,oxdip,'b');hold on;
0090 plot(s,oydip,'r');
0091 xlabel('s [m]');
0092 ylabel('orbit [m]');
0093 yyaxis right
0094 plot(s,dxdip,'c');hold on;
0095 plot(s,dydip,'m');
0096 xlabel('s [m]');
0097 ylabel('dispersion [m]');
0098 legend('x','y','\eta_x','\eta_y')
0099 saveas(gca,'OrbitDispDip.fig')
0100 export_fig('OrbitDispDip.jpg','-r300')
0101
0102
0103 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispCorTilt')
0104 s=findspos(ring,indall);
0105 yyaxis left
0106 plot(s,oxcortilt,'b');hold on;
0107 plot(s,oycortilt,'r');
0108 xlabel('s [m]');
0109 ylabel('orbit [m]');
0110 yyaxis right
0111 plot(s,dxcortilt,'c');hold on;
0112 plot(s,dycortilt,'m');
0113 xlabel('s [m]');
0114 ylabel('dispersion [m]');
0115 legend('x','y','\eta_x','\eta_y')
0116 saveas(gca,'OrbitDispCorTilt.fig')
0117 export_fig('OrbitDispCorTilt.jpg','-r300')
0118
0119 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispDipTilt')
0120 s=findspos(ring,indall);
0121 yyaxis left
0122 plot(s,oxdiptilt,'b');hold on;
0123 plot(s,oydiptilt,'r');
0124 xlabel('s [m]');
0125 ylabel('orbit [m]');
0126 yyaxis right
0127 plot(s,dxdiptilt,'c');hold on;
0128 plot(s,dydiptilt,'m');
0129 xlabel('s [m]');
0130 ylabel('dispersion [m]');
0131 legend('x','y','\eta_x','\eta_y')
0132 saveas(gca,'OrbitDispDipTilt.fig')
0133 export_fig('OrbitDispDipTilt.jpg','-r300')
0134
0135 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispDipTiltRef')
0136 s=findspos(ring,indall);
0137 yyaxis left
0138 plot(s,oxdiptiltref,'b');hold on;
0139 plot(s,oydiptiltref,'r');
0140 xlabel('s [m]');
0141 ylabel('orbit [m]');
0142 yyaxis right
0143 plot(s,dxdiptiltref,'c');hold on;
0144 plot(s,dydiptiltref,'m');
0145 xlabel('s [m]');
0146 ylabel('dispersion [m]');
0147 legend('x','y','\eta_x','\eta_y')
0148 saveas(gca,'OrbitDispDipTiltRef.fig')
0149 export_fig('OrbitDispDipTiltRef.jpg','-r300')
0150
0151
0152 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispCorTiltVar')
0153 s=findspos(ring,indall);
0154 yyaxis left
0155 plot(s,oxcortilt-oxcor,'b');hold on;
0156 plot(s,oycortilt-oycor,'r');
0157 ax=gca;
0158 ax1ylim=ax.YLim;
0159 xlabel('s [m]');
0160 ylabel('orbit [m]');
0161 yyaxis right
0162 plot(s,dxcortilt-dxcor,'c');hold on;
0163 plot(s,dycortilt-dycor,'m');
0164 ax=gca;
0165 ax2ylim=ax.YLim;
0166 xlabel('s [m]');
0167 ylabel('dispersion [m]');
0168 legend('x','y','\eta_x','\eta_y')
0169 saveas(gca,'OrbitDispCorTiltVar.fig')
0170 export_fig('OrbitDispCorTiltVar.jpg','-r300')
0171
0172 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispDipTiltVar')
0173 s=findspos(ring,indall);
0174 yyaxis left
0175 plot(s,oxdiptilt-oxdip,'b');hold on;
0176 plot(s,oydiptilt-oydip,'r');
0177 xlabel('s [m]');
0178 ylabel('orbit [m]');
0179 ax=gca;
0180 ax.YLim=ax1ylim;
0181
0182 yyaxis right
0183 plot(s,dxdiptilt-dxdip,'c');hold on;
0184 plot(s,dydiptilt-dydip,'m');
0185 ax=gca;
0186 ax.YLim=ax2ylim;
0187
0188 xlabel('s [m]');
0189 ylabel('dispersion [m]');
0190 legend('x','y','\eta_x','\eta_y')
0191 saveas(gca,'OrbitDispDipTiltVar.fig')
0192 export_fig('OrbitDispDipTiltVar.jpg','-r300')
0193
0194 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispDipTiltVarRef')
0195 s=findspos(ring,indall);
0196 yyaxis left
0197 plot(s,oxdiptiltref-oxdip,'b');hold on;
0198 plot(s,oydiptiltref-oydip,'r');
0199 xlabel('s [m]');
0200 ylabel('orbit [m]');
0201 ax=gca;
0202 ax.YLim=ax1ylim;
0203
0204 yyaxis right
0205 plot(s,dxdiptiltref-dxdip,'c');hold on;
0206 plot(s,dydiptiltref-dydip,'m');
0207 ax=gca;
0208 ax.YLim=ax2ylim;
0209
0210 xlabel('s [m]');
0211 ylabel('dispersion [m]');
0212 legend('x','y','\eta_x','\eta_y')
0213 saveas(gca,'OrbitDispDipTiltVarRef.fig')
0214 export_fig('OrbitDispDipTiltVarRef.jpg','-r300')
0215
0216
0217 figure('units','normalized','position',[0.3 0.3 0.45 0.35],'name','OrbitDispDipVsTiltVar')
0218 s=findspos(ring,indall);
0219 yyaxis left
0220 plot(s,(oxdiptilt-oxdip)-(oxcortilt-oxcor),'b');hold on;
0221 plot(s,(oydiptilt-oydip)-(oycortilt-oycor),'r');
0222 ax=gca;
0223 ax.YLim=ax1ylim;
0224
0225 xlabel('s [m]');
0226 ylabel('orbit [m]');
0227 yyaxis right
0228 plot(s,(dxdiptilt-dxdip)-(dxcortilt-dxcor),'c');hold on;
0229 plot(s,(dydiptilt-dydip)-(dycortilt-dycor),'m');
0230 ax=gca;
0231 ax.YLim=ax2ylim;
0232 xlabel('s [m]');
0233 ylabel('dispersion [m]');
0234 legend('x','y','\eta_x','\eta_y')
0235 saveas(gca,'OrbitDispDipVsTiltVar.fig')
0236 export_fig('OrbitDispDipVsTiltVar.jpg','-r300')
0237
0238
0239 return
0240
0241
0242