diff --git a/matlab/PlotParticleTrajectory.m b/matlab/PlotParticleTrajectory.m index beece81..f871a83 100644 --- a/matlab/PlotParticleTrajectory.m +++ b/matlab/PlotParticleTrajectory.m @@ -1,114 +1,117 @@ function PlotParticleTrajectory(M,partnumber,t,text) %PlotParticleTrajectory Plots the trajectory of the particles of given % partnumber for the time steps t. -% text +% text is added to the filename of the figure if (nargin<4) text=''; else text=['_',text]; end if isa(M,'h5parts') geomstruct=M.parent; else geomstruct=M; end f=figure(); time=M.tpart(t(1):t(end)); ax1=subplot(1,2,1); hold(ax1); % Magnetic field lines Blines=geomstruct.rAthet; levels=linspace(min(min(Blines(:,2:end))),max(max(Blines(:,:))),10); [~,h1]=contour(ax1,geomstruct.zgrid*1000,geomstruct.rgrid*1000,Blines,real(levels),'r-.','linewidth',1.5,'Displayname','Magnetic field lines'); ax2=subplot(1,2,2); hold(ax2); Msize=8; Z=M.Z(partnumber,t,true)*1000; R=M.R(partnumber,t,true)*1000; THET=M.THET(partnumber,t,true); j=0; % For each particle we plot the trajectory for i=1:length(partnumber) Zl=Z(i,R(i,:)>0); Rl=R(i,R(i,:)>0); THETl=THET(i,R(i,:)>0); if length(Rl)<=0 continue end - j=j+1 + j=j+1; +% R Z p1(j)=plot(ax1,Zl,Rl,'x-.','Linewidth',1.1,... 'Displayname',sprintf('part=%d',partnumber(i)),'MarkerIndices',1,... 'Markersize',Msize); plot(ax1,Zl(end),Rl(end),'^','Linewidth',1.1,... 'Displayname',sprintf('part=%d',partnumber(i)),'MarkerIndices',1,... 'Markersize',Msize,'color',p1(j).Color) + +% X Y x=Rl.*cos(THETl); y=Rl.*sin(THETl); -%pp=spline(x,y); p2=plot(ax2,x,y,'x-.','Linewidth',1.1,... 'Displayname',sprintf('part=%d',partnumber(i)),'MarkerIndices',1,... 'Markersize',Msize); plot(ax2,Rl(end).*cos(THETl(end)),Rl(end).*sin(THETl(end)),'^',... 'Linewidth',1.1,'Displayname',sprintf('part=%d',partnumber(i)),'MarkerIndices',1,... 'Markersize',Msize,'color',p2.Color) end % legends and labels xlabel(ax1,'z [mm]') ylabel(ax1,'r [mm]') sgtitle(sprintf('Position between t=[%3.2f-%3.2f] ns',time(1)*1e9,time(end)*1e9)) xlim(ax1,[M.zgrid(1) M.zgrid(end)]*1e3) ylim(ax1,[M.rgrid(1) M.rgrid(end)]*1e3) grid(ax1,'on'); xlabel(ax2,'x [mm]') ylabel(ax2,'y [mm]') -t=2*pi*linspace(0,1,100); + % We add the inner and outer electrode in x,y plot % +t=2*pi*linspace(0,1,100); if(geomstruct.conformgeom) xin=geomstruct.rgrid(1)*cos(t)*1e3; yin=geomstruct.rgrid(1)*sin(t)*1e3; plot(ax2,xin,yin,'k-') xout=geomstruct.rgrid(end)*cos(t)*1e3; yout=geomstruct.rgrid(end)*sin(t)*1e3; plot(ax2,xout,yout,'k-') plot(ax1,geomstruct.zgrid*1e3,geomstruct.rgrid(1)*ones(size(geomstruct.zgrid))*1e3,'k-') plot(ax1,geomstruct.zgrid*1e3,geomstruct.rgrid(end)*ones(size(geomstruct.zgrid))*1e3,'k-') else subplot(1,2,1) contour(geomstruct.zgrid*1e3,geomstruct.rgrid*1e3,geomstruct.geomweight(:,:,1),[0 0],'k-') [~,rgrid]=meshgrid(geomstruct.zgrid*1e3,geomstruct.rgrid*1e3); rlims=rgrid(geomstruct.geomweight(:,:,1)<0); xin=geomstruct.rgrid(1)*cos(t)*1e3; yin=geomstruct.rgrid(1)*sin(t)*1e3; plot(ax2,xin,yin,'k-') xout=min(rlims)*cos(t); yout=min(rlims)*sin(t); plot(ax2,xout,yout,'k-') end % Legend and axis changes for clear display legend(ax1,p1(1:j)) legend('location','southwest') axis(ax2,'equal') grid(ax2,'on'); % We save the data to file f.PaperOrientation='landscape'; [~, name, ~] = fileparts(M.fullpath); f.PaperUnits='centimeters'; f.PaperSize=[16 9]; print(f,sprintf('%sTrajectories%s',name,text),'-dpdf','-fillpage') savefig(f,sprintf('%sTrajectories%s',name,text)) end