Calculates several properties as a function of r and theta for PWE at a single wavelength 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 in the region considered. ONLY ONE WAVELENGTH for this function. lambda0 must be scalar. The fields Ecr, Ect, Esf given in the results are discussed in the supplementary information. Parameters: - lambda0: SCALAR [1 x 1] wavelength in nm - epsilon: SCALAR [1 x 1] epsilon of dielectric where field is evaluated - stAbcdn1: structure with 4 fields, an1, bn1, cn1, dn1, each a matrix [1 x nNmax] containing the Mie coefficients a_{n1,}, b_{n,1}, c_{n,1} and d_{n,1} for the FOR THE RELEVANT WAVELENGTH ONLY - r: column vector [R x 1] with possibly zero-component distance from origin (in nm) - nNbTheta: integer scalar number of theta points used for computations - 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. - stPinTaun: structure (optional) with functions of theta pi_n and tau_n if omitted, then the functions are computed from scrath it is faster to pass this structure as argument if these functions have already been calculated Returns: structure stEmap with fields - stEmap.theta: [1 x T] row vector with theta's - stEmap.r: [R x 1] column vector with r's - stEmap.lambda0: [1 x 1] scalar - stEmap.Ecr: [R x T] r-and-theta-dependent Ecr - stEmap.Ect: [R x T] r-and-theta-dependent Ect - stEmap.Esf: [R x T] r-and-theta-dependent Esf - stEmap.MLocParaAve: [R x 1] r-dependent average MLocPara - stEmap.MLocPerpAve: [R x 1] r-dependent average MLocPerp - stEmap.MLocAve: [R x 1] r-dependent average MLoc - stEmap.F0E4Ave: [R x 1] r-dependent average SERS EF F^0_{E4} - stEmap.F0E4PerpAve: [R x 1] r-dependent average SERS EF F^0_{E4} for perpendicular component - stEmap.F0E4ParaAve: [R x 1] r-dependent average SERS EF F^0_{E4} for parallel component 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 'PweEmap: CheckSum ON' 0004 else 0005 disp 'PweEmap: CheckSum OFF' 0006 end 0007 0008 if isfield(stAbcdn1,'an1') 0009 nNmax=size(stAbcdn1.an1,2); 0010 if ~(size(stAbcdn1.an1,1)==1) 0011 disp 'Error in PweEmap: only one wavelength allowed, an1 should be ROW vector.') 0012 end; 0013 else 0014 if isfield(stAbcdn1,'cn1') 0015 nNmax=size(stAbcdn1.cn1,2); 0016 if ~(size(stAbcdn1.cn1,1)==1) 0017 disp 'Error in PweEmap: only one wavelength allowed, cn1 should be ROW vector.') 0018 end; 0019 else 0020 disp 'Error in PweEmap: cannot recognize stAbcdn1 structure fields') 0021 end 0022 end 0023 0024 % check that only one lambda 0025 if ~(size(lambda0,1)==1) 0026 disp 'Error in PweEmap: only one wavelength allowed, lambda0 should be scalar.') 0027 end; 0028 0029 if (nNbTheta<91) 0030 disp 'Warning in PweEmap: nNbTheta must be large for averages to be meaningful' 0031 end 0032 0033 theta=linspace(0,pi,nNbTheta); % row [1 x T] 0034 0035 % get theta dependence if not provided 0036 if nargin < 7 0037 stPinTaun=PwePinTaun(nNmax,transpose(theta)); % fields are [T x nNmax] 0038 end 0039 0040 % calculate regular VSH expansion (coeffs a,b) 0041 if strcmpi(sRegion,'outside') 0042 % get regular field from known plane wave expression of incident field 0043 disp 'PweEmap: Outside region: get regular field from PW expression' 0044 stEAllPhiReg=PweEincRThetaAllPhi(lambda0,epsilon,r,theta); 0045 else 0046 if strcmpi(sRegion,'scattering') 0047 disp 'PweEmap: scattering only: regular VSH expansion is zero...' 0048 stEAllPhiReg.Ecr=0; 0049 stEAllPhiReg.Ect=0; 0050 stEAllPhiReg.Esf=0; 0051 else 0052 disp 'PweEmap: Computing regular VSH expansions (coeffs a,b)...' 0053 stEAllPhiReg=PweEgenRThetaAllPhi(lambda0,epsilon,stAbcdn1.an1,stAbcdn1.bn1,r,theta,'j',stPinTaun); 0054 end 0055 end 0056 if strcmpi(sRegion,'inside') 0057 disp 'PweEmap: Inside: Irregular VSH expansions is zero...' 0058 stEAllPhiIrr.Ecr=0; 0059 stEAllPhiIrr.Ect=0; 0060 stEAllPhiIrr.Esf=0; 0061 else 0062 % calculate irregular VSH expansion (coeffs c,d) 0063 disp 'PweEmap: Computing irregular VSH expansions (coeffs c,d)...' 0064 stEAllPhiIrr=PweEgenRThetaAllPhi(lambda0,epsilon,stAbcdn1.cn1,stAbcdn1.dn1,r,theta,'h1',stPinTaun); 0065 end 0066 0067 disp 'PweEmap: Compiling results and averages...' 0068 % Ecr, Ect, and Esf are [R x T] 0069 stEmap.Ecr=GenCheckSum2Mat(stEAllPhiReg.Ecr,stEAllPhiIrr.Ecr,'Ecr','PweEmap'); 0070 stEmap.Ect=GenCheckSum2Mat(stEAllPhiReg.Ect,stEAllPhiIrr.Ect,'Ect','PweEmap'); 0071 stEmap.Esf=GenCheckSum2Mat(stEAllPhiReg.Esf,stEAllPhiIrr.Esf,'Esf','PweEmap'); 0072 0073 clear stEAllPhiReg stEAllPhiIrr; 0074 0075 stEmap.theta=theta; 0076 stEmap.r=r; 0077 stEmap.lambda0=lambda0; 0078 0079 % computes surface-averages 0080 stEmap=PweEFaverages(stEmap); 0081 0082 disp 'PweEmap: done...' 0083 disp ' ' 0084 0085