Calculates the electric field at given points for PWE For PWE, we have: |m|=1; a,c even in m; b,d odd in m. The 4 Mie coefficients in stAabcdn1 must be the relevant ones at all the point positions. This function is to be used for a few points only. To compute the fields at many points on the surface or in a volume, use PweEsurf or PweEmap instead. Parameters: - lambda: column vector [L x 1] wavelengths in nm - epsilon: scalar or column vector [L x 1] epsilon of dielectric where field is evaluated - stAbcdn1: structure with 4 fields, an1, bn1, cn1, dn1, each a matrix [L x nNmax] containing the Mie coefficients a_{n,1}, b_{n,1}, c_{n,1} and d_{n,1} relevant at the points positions - stPtArray: array of stPt structures, each with fields (r, theta, phi) or (x,y,z) - sRegion: string 'outside', 'inside', 'scattering, or otherwise, 'all' is assumed: * if 'outside': the points should be in the outside region (outside the largest sphere). The regular part of the field (coeffs a and b) is then known and not computed from the plane wave incident field (faster). * if 'scattering': the regular part of the field (coeffs a and b) is set to zero (no a and b needed) * if 'inside': the points should be in the inside region (containing the origin), then the irregular part of the field is zero (no coeffs c and d needed). * otherwise: all of a,b,c,d are used. Returns: stEptArray, array of structures stEpt, each with fields - stEpt.Er: [L x 1] column vector with Er - stEpt.Etheta: [L x 1] column vector with Etheta - stEpt.Ephi: [L x 1] column vector with Ephi - stEpt.MLoc: [L x 1] column vector with MLoc This file is part of the SPlaC v1.0 package (copyright 2008) Check the README file for further information
0001 global noCheckSum; 0002 if (isempty(noCheckSum) || ~noCheckSum) 0003 disp 'PweEpts: CheckSum ON' 0004 else 0005 disp 'PweEpts: CheckSum OFF' 0006 end 0007 0008 % loop through points 0009 nNbPts=length(stPtArray); 0010 for nn=1:nNbPts 0011 % get r,theta, and phi. stPts contains either r,theta,phi or x,y,z 0012 if (isfield(stPtArray(nn),'r')) && (~isempty(stPtArray(nn).r)) 0013 r=stPtArray(nn).r; 0014 theta=stPtArray(nn).theta; 0015 phi=stPtArray(nn).phi; 0016 else 0017 % pts is in Cartesian coordinates 0018 stPtSph=GenGetStPtSph(stPtArray(nn)); 0019 r=stPtSph.r; % scalar 0020 theta=stPtSph.theta; % scalar 0021 phi=stPtSph.phi; % scalar 0022 end 0023 % calculate regular VSH expansion (coeffs a,b) 0024 if strcmpi(sRegion,'outside') 0025 % get regular field from known plane wave expression of incident field 0026 stEAllPhiReg=PweEincThetaAllPhi(lambda,epsilon,r,theta); 0027 else 0028 if strcmpi(sRegion,'scattering') 0029 % scattering only: regular VSH expansion is zero 0030 stEAllPhiReg.Ecr=0; 0031 stEAllPhiReg.Ect=0; 0032 stEAllPhiReg.Esf=0; 0033 else 0034 % computing regular VSH expansions (coeffs a,b) 0035 stEAllPhiReg=PweEgenThetaAllPhi(lambda,epsilon,stAbcdn1.an1,stAbcdn1.bn1,r,theta,'j'); 0036 end 0037 end 0038 if strcmpi(sRegion,'inside') 0039 % inside: Irregular VSH expansions is zero 0040 stEAllPhiIrr.Ecr=0; 0041 stEAllPhiIrr.Ect=0; 0042 stEAllPhiIrr.Esf=0; 0043 else 0044 % calculate irregular VSH expansion (coeffs c,d) 0045 stEAllPhiIrr=PweEgenThetaAllPhi(lambda,epsilon,stAbcdn1.cn1,stAbcdn1.dn1,r,theta,'h1'); 0046 end 0047 0048 % Ecr, Ect, and Esf are [L x 1] 0049 Ecr=GenCheckSum2Mat(stEAllPhiReg.Ecr,stEAllPhiIrr.Ecr,'Ecr',['PweEpts, point wih index ' int2str(nn)]); 0050 Ect=GenCheckSum2Mat(stEAllPhiReg.Ect,stEAllPhiIrr.Ect,'Ect',['PweEpts, point wih index ' int2str(nn)]); 0051 Esf=GenCheckSum2Mat(stEAllPhiReg.Esf,stEAllPhiIrr.Esf,'Esf',['PweEpts, point wih index ' int2str(nn)]); 0052 0053 stEptArray(nn).Er=Ecr*cos(phi); 0054 stEptArray(nn).Etheta=Ect*cos(phi); 0055 stEptArray(nn).Ephi=Esf*sin(phi); 0056 stEptArray(nn).MLoc=abs(stEptArray(nn).Er).^2 + ... 0057 abs(stEptArray(nn).Etheta).^2 + ... 0058 abs(stEptArray(nn).Ephi).^2; 0059 end