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