Home > SPlaC v1_0 > Mie > DIP > DipPlotEfarForP.m

DipPlotEfarForP

PURPOSE ^

Plots the dipole radiation profiles at a few wavelengths for a given px,pz and for 2 phi's

SYNOPSIS ^

function DipPlotEfarForP(stEfarAllP, lambda0,px,pz,phi1,phi2)

DESCRIPTION ^

 Plots the dipole radiation profiles at a few wavelengths for a given px,pz and for 2 phi's
 These are plotted as theta dependent functions for a fixed phi (0 or pi/2 as default).
 For phi=0 (i.e. plot in xOz),
 the dipole arrow is shown on the plot.

EXAMPLE OF OUTPUT ^

Example figure output

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Parameters:
0002 % - stEfarScaForP: obtained from DipFarFieldForP
0003 % - lambda0: scalar or vector (short vector otherwise plot would be messy)
0004 %            wavelength(s) in nm for which the plots are done
0005 % - px,pz: scalars [1 x 1]
0006 %          component of dipole
0007 % - phi1,phi2: scalars [1 x 1]
0008 %            phi's (IN RADIAN) for which the two plots are produced (default is 0 and
0009 %            pi/2)
0010 %
0011 % This file is part of the SPlaC v1.0 package (copyright 2008)
0012 % Check the README file for further information
0013 
0014 if nargin<5, phiarray=[0,pi/2]; end;
0015 if nargin==5, phiarray=[0,phi1]; end;
0016 if nargin==6, phiarray=[phi1,phi2]; end;
0017 
0018 lambda=stEfarAllP.lambda;
0019 theta=stEfarAllP.theta;
0020 nNbTheta=length(theta);
0021 indPosTheta=1:length(theta);
0022 indNegTheta=length(theta):-1:2;
0023 %indAllTheta=[indNegTheta,indPosTheta];
0024 thetaAll=[-theta(indNegTheta), theta];
0025 
0026 sLegend=cell(1,length(lambda0));
0027 MdRadPhi=zeros(length(lambda0),nNbTheta);
0028 MdRadPhippi=zeros(length(lambda0),nNbTheta);
0029 
0030 pnorm=sqrt(px^2+pz^2);
0031 pxnorm=px/pnorm;
0032 pznorm=pz/pnorm;
0033 
0034 % create, position, and resize figure
0035 scrsz = get(0,'ScreenSize'); % scrsz(3) contains screen width
0036 figAspectRatio=2;
0037 figWidth=scrsz(3)-100;
0038 figHeight=figWidth/figAspectRatio;
0039 figure('Name','Radiation profiles', ...
0040     'Position',[(scrsz(3)-figWidth)/2 50 figWidth figHeight]);
0041 % length of dipole arrow in relative units
0042 plength=0.6;
0043 % define four colors
0044 scol='brgm';
0045 
0046 
0047 for indphi=1:2
0048     phi=phiarray(indphi);
0049     MdMax=0;
0050     for ll=1:length(lambda0)
0051         ind=find(lambda==lambda0(ll),1);
0052         if isempty(ind)
0053             disp(['DipPlotEfarForP: lambda=' num2str(lambda0(ll)) ...
0054                 ' cannot be found. Using lambda=' num2str(lambda(1)) ' instead']);
0055             ind=1;
0056         end
0057         Er2Phi=abs(pxnorm*cos(phi)*stEfarAllP.Ecr(ind,:)+pznorm*stEfarAllP.Em0r(ind,:)).^2;
0058         Et2Phi=abs(pxnorm*cos(phi)*stEfarAllP.Ect(ind,:)+pznorm*stEfarAllP.Em0t(ind,:)).^2;
0059         Ef2Phi=pxnorm^2*sin(phi)^2* abs(stEfarAllP.Esf(ind,:)).^2;
0060         MdRadPhi(ll,:)=(8*pi)/3*(Er2Phi+Et2Phi+Ef2Phi);
0061         MdMax=max(MdMax,max(MdRadPhi(ll,:))); % find limits for axis scale
0062         % theta-dependent MdRad for phi
0063         % note that the symmetry around the z axis is lost in this case
0064         % For theta<0, the value must be obtained from |theta| and phi=phi+pi, i.e.
0065         Er2Phippi=abs(-pxnorm*cos(phi)*stEfarAllP.Ecr(ind,:)+pznorm*stEfarAllP.Em0r(ind,:)).^2;
0066         Et2Phippi=abs(-pxnorm*cos(phi)*stEfarAllP.Ect(ind,:)+pznorm*stEfarAllP.Em0t(ind,:)).^2;
0067         MdRadPhippi(ll,:)=(8*pi)/3*(Er2Phippi+Et2Phippi+Ef2Phi);
0068         MdMax=max(MdMax,max(MdRadPhippi(ll,:))); % find limits for axis scale
0069         % prepare legend for figure
0070         MRad=pxnorm^2*stEfarAllP.MRadPara(ind)+pznorm^2*stEfarAllP.MRadPerp(ind);
0071         if indphi==1
0072             sLegend{ll}=['\lambda=' num2str(lambda(ind)) 'nm'];
0073         else
0074             sLegend{ll}=['M_{Rad}=' num2str(MRad)];
0075         end
0076     end
0077 
0078     hpl=subplot(1,2,indphi);
0079     set(hpl,'Outerposition',[0.5*(indphi-1),0,0.5,1]);
0080 
0081     h = polar([0 2*pi], [0 MdMax]);
0082     delete(h);
0083     hold on;
0084     for ll=1:length(lambda0)
0085         % note that the symmetry around the z axis is lost in this case
0086         % For theta<0, the value must be obtained from |theta| and phi=pi, i.e.
0087         h=polar(thetaAll,[MdRadPhippi(ll,indNegTheta), MdRadPhi(ll,indPosTheta)],scol(1+mod(ll-1,4)));
0088     end
0089     if(phi==0) % plot dipole only if in xOz plane
0090         curxlim=get(gca,'XLim');
0091         plength2=plength*curxlim(2);
0092         quiver(-pznorm/2*plength2,-pxnorm/2*plength2, ...
0093             pznorm*plength2,pxnorm*plength2,'Color',[0.5;0;0.5],'LineWidth',1.5,'MaxHeadSize',0.8);
0094     end
0095     rectangle('Position',curxlim(2)*[-0.5,-0.1,0.2,0.2],'Curvature',[1,1],...
0096           'FaceColor',[0.8 0.8 0.8]);
0097     hold off;
0098     title(['M^d_{Rad}(\theta,\phi=' num2str(phi) ') px=' num2str(px) ', pz=' num2str(pz)]);
0099     %xlabel('Theta [degrees]'); ylabel('M^d_{Rad}');
0100     legend(sLegend,'Location','NorthEastOutside');
0101 end

This web page is part of the SPlaC package © 2008. Contact: Eric Le Ru
Generated on Wed 03-Dec-2008 11:10:14 by m2html © 2003 (adapted)