Low-level function to calculate VSH expansions for PWE for a fixed r0>0, but many theta and lambda The VSHs used can either be of type 1 (sBessel='j') or type 3 (sBessel='h1') Use r0=Inf (with 'h1') to obtain far-field properties. For PWE, we have: |m|=1, c_{n,1}=c_{n,-1}, d_{n,1}=-d_{n,-1}). The fields Ecr, Ect, Esf given in the results are discussed in the supplementary information. 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 - cn1, dn1: 2 matrices [L x nNmax] containing the Mie coefficients c_{n,1} and d_{n,1} for the field expansion of M^(i)_{n,1} and N^(i)_{n,1}, respectively - r0: scalar [1 x 1] possibly zero (if sBessel='j') spherical coordinate r (in nm) of points r0 can be Inf to obtain far-field radiation profile - theta: possibly row vector [1 x T] with spherical coordinate theta of points - sBessel: string defining the Bessel function to be used sBessel='j' for or sBessel='h1' - 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: stEAllPhi, structure with 3 fields containing matrices [L x T] representing the three components E_{cr}, E_{ct}, E_{sf} such as: of E = E_{cr} cos(phi) e_r + E_{ct} cos(phi) e_theta + E_{sf} sin(phi) e_phi - stEAllPhi.Ecr is E_{cr} - stEAllPhi.Ect is E_{ct} - stEAllPhi.Esf is E_{sf} This file is part of the SPlaC v1.0 package (copyright 2008) Check the README file for further information
0001 nNmax=size(cn1,2); 0002 nNbLambda=length(lambda); 0003 nNbTheta=length(theta); 0004 0005 n=1:nNmax; %[1 x nNmax] 0006 % need n-dep coeff for series (mu_n *n *(n+1) and mu_n) 0007 cffnr=sqrt((2*n+1)/(4*pi)); %[1 x nNmax] for Er 0008 mun=cffnr./(n.*(n+1)); % mu_n [1 x nNmax] for Et and Ef 0009 0010 if r0==0 0011 % special case where r0=0 0012 % the following is equivalent to \mathbf{E}=-4/3 * mu_1 *d11 \mathbf{e}_x 0013 coef1=dn1(:,1)/sqrt(3*pi); % [L x 1] 0014 % Results are all [L x T] matrices 0015 stEAllPhi.Ecr=-coef1 * sin(theta); 0016 stEAllPhi.Ect=-coef1 * cos(theta); 0017 stEAllPhi.Esf=coef1 * ones(1,nNbTheta); 0018 disp 'r0=0 in PweEgenThetaAllPhi'; 0019 return 0020 end 0021 0022 0023 % get Zn(rho) for radial dependence and derived functions 0024 if (r0==Inf) 0025 % for far-field radiation profile 0026 dn1Z1=zeros(nNbLambda,1); % [L x 1] 0027 icn1Z0=cn1; % [L x nNmax] 0028 dn1Z2=dn1; % [L x nNmax] 0029 mun=mun.*((-i).^(n+1)); 0030 else 0031 rho=2*pi* sqrt(epsilon) ./lambda * r0; % column [L x 1] 0032 stZnAll=GenZnAll(nNmax,rho,sBessel); % fields are [L x nNmax] 0033 dn1Z1=dn1.*stZnAll.Z1; % [L x nNmax] 0034 icn1Z0=i*cn1.*stZnAll.Z0; % [L x nNmax] 0035 dn1Z2=dn1.*stZnAll.Z2; % [L x nNmax] 0036 clear stZnAll; % for memory 0037 end 0038 % get theta dependence if not provided 0039 if nargin < 8 0040 stPinTaun=PwePinTaun(nNmax,transpose(theta)); % fields are [T x nNmax] 0041 end 0042 0043 0044 % loop over lambda to avoid using 3-dimension matrices: 0045 % At a fixed lambda, the sum over n for all theta can be carried out 0046 % using a matrix product of the theta-and-n-dependent [T x nNmax] matrix 0047 % by a n-dependent column vector [nNmax x 1] 0048 % the result, a [T x 1] matrix is then transposed to a [1 x T] line 0049 Ersum=zeros(nNbLambda,nNbTheta); 0050 Etsum=zeros(nNbLambda,nNbTheta); 0051 Efsum=zeros(nNbLambda,nNbTheta); 0052 for ll=1:nNbLambda 0053 % for Er, vecN=d_{n,1} * Z_n^1(rho) * mu_n * n *(n+1) 0054 vecNdep=transpose(dn1Z1(ll,:).*cffnr); % [nNmax x 1] 0055 % Ersum=sum_n(pi_n(t) * vecN_n) 0056 % Do the sum as a matrix product (and check for loss of precision) 0057 Ersum(ll,:)=transpose(GenCheckSumMatVec(stPinTaun.pin, vecNdep, ... 0058 'Ersum','PweEgenThetaAllPhi')); % [1 x T] 0059 % for Et and Ef 0060 vecNdep=transpose(icn1Z0(ll,:).*mun); % [nNmax x 1] 0061 vecNdep2=transpose(dn1Z2(ll,:).*mun); % [nNmax x 1] 0062 % Do the sums and check for loss of precision 0063 tmp1=GenCheckSumMatVec(stPinTaun.pin, vecNdep, ... 0064 'tmp1_1','PweEgenThetaAllPhi'); 0065 tmp2=GenCheckSumMatVec(stPinTaun.taun, vecNdep2, ... 0066 'tmp2_1','PweEgenThetaAllPhi'); 0067 Etsum(ll,:)=transpose(GenCheckSum2Mat(tmp1,tmp2, ... 0068 'Etsum','PweEgenThetaAllPhi')); % [1 x T] 0069 0070 tmp1=GenCheckSumMatVec(stPinTaun.taun, vecNdep, ... 0071 'tmp1_2','PweEgenThetaAllPhi'); 0072 tmp2=GenCheckSumMatVec(stPinTaun.pin, vecNdep2, ... 0073 'tmp2_2','PweEgenThetaAllPhi'); 0074 Efsum(ll,:)=transpose(GenCheckSum2Mat(tmp1,tmp2, ... 0075 'Efsum','PweEgenThetaAllPhi')); % [1 x T] 0076 0077 end 0078 0079 % Results are all [L x T] matrices 0080 stEAllPhi.Ecr=-2*repmat(sin(theta),nNbLambda,1).*Ersum; 0081 stEAllPhi.Ect=-2*Etsum; % corresponds to S_2 if r0==Inf 0082 stEAllPhi.Esf=2*Efsum; % corresponds to (-S_1) if r0==Inf 0083