diff --git a/matlab/AnalyzeNF2FF.m b/matlab/AnalyzeNF2FF.m index 2a0f4eb..bc88b72 100644 --- a/matlab/AnalyzeNF2FF.m +++ b/matlab/AnalyzeNF2FF.m @@ -31,7 +31,7 @@ if ~isscalar(f) error 'Currently only one frequency is supported. Call this function multiple times.' end -warning('openEMS:AnalyzeNF2FF','This function is depreciated , use CalcNF2FF instead'); +warning('openEMS:AnalyzeNF2FF','This function is deprecated, use CalcNF2FF instead'); filenames_E = nf2ff.filenames_E; filenames_H = nf2ff.filenames_H; @@ -44,7 +44,7 @@ end for n=find(nf2ff.directions==1) [Ef{n}, E_mesh{n}] = ReadHDF5Dump( [Sim_Path '/' filenames_E{n} '.h5'], 'Frequency', f ); - if (Ef{n}.FD.freq(1) ~= f) + if (Ef{n}.FD.frequency(1) ~= f) error 'frequency mismach' end diff --git a/matlab/CalcNF2FF.m b/matlab/CalcNF2FF.m index 35c11c7..198dd90 100644 --- a/matlab/CalcNF2FF.m +++ b/matlab/CalcNF2FF.m @@ -12,7 +12,7 @@ function nf2ff = CalcNF2FF(nf2ff, Sim_Path, freq, theta, phi, varargin) % nf2ff: data structure created by CreateNF2FFBox % Sim_Path: path to simulation data % freq: array of frequencies to analyse -% theta,phi: spherical coordinates to evaluate the far-field on +% theta,phi: spherical coordinates to evaluate the far-field on (in radians) % % optional paramater: % 'Center': nf2ff phase center, default is [0 0 0] diff --git a/matlab/examples/NF2FF/infDipol.m b/matlab/examples/NF2FF/infDipol.m index ae00183..156de05 100644 --- a/matlab/examples/NF2FF/infDipol.m +++ b/matlab/examples/NF2FF/infDipol.m @@ -38,11 +38,14 @@ ex_vector(dipole_orientation) = 1; start = ex_vector * -dipole_length/2; stop = ex_vector * dipole_length/2; CSX = AddExcitation( CSX, 'infDipole', 1, ex_vector ); +% enlarge the box to be sure that one mesh line is covered by it +start = start - [0.1 0.1 0.1] * dipole_length/2; +stop = stop + [0.1 0.1 0.1] * dipole_length/2; CSX = AddBox( CSX, 'infDipole', 1, start, stop ); % NFFF contour -start = [mesh.x(1) mesh.y(1) mesh.z(1) ] -stop = [mesh.x(end) mesh.y(end) mesh.z(end) ] +start = [mesh.x(1) mesh.y(1) mesh.z(1) ]; +stop = [mesh.x(end) mesh.y(end) mesh.z(end) ]; [CSX nf2ff] = CreateNF2FFBox(CSX, 'nf2ff', start, stop); % add space for PML @@ -64,6 +67,9 @@ if ~postprocessing_only [~,~,~] = mkdir(Sim_Path); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); + % take a view at the "structure" + CSXGeomPlot( [Sim_Path '/' Sim_CSX] ); + % define openEMS options and start simulation openEMS_opts = ''; RunOpenEMS( Sim_Path, Sim_CSX, openEMS_opts ); @@ -76,9 +82,14 @@ disp( ' ' ); % calculate the far field at phi=0 degrees and at phi=90 degrees thetaRange = 0:2:359; -r = 1; % evaluate fields at radius r disp( 'calculating far field at phi=[0 90] deg..' ); -[E_far_theta,E_far_phi,Prad,Dmax] = AnalyzeNF2FF( Sim_Path, nf2ff, f_max, thetaRange, [0 90], r ); +%[E_far_theta,E_far_phi,Prad,Dmax] = AnalyzeNF2FF( Sim_Path, nf2ff, f_max, thetaRange, [0 90], 1 ); +nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, thetaRange/180*pi, [0 pi/2], 'Mode', 1 ); +Prad = nf2ff.Prad; +Dmax = nf2ff.Dmax; +f_idx = 1; +E_far_theta = nf2ff.E_theta{f_idx}; +E_far_phi = nf2ff.E_phi{f_idx}; % display power and directivity disp( ['radiated power: Prad = ' num2str(Prad)] ); @@ -94,7 +105,7 @@ end figure polar( thetaRange/180*pi, E_phi0_far ); ylabel( 'theta / deg' ); -title( ['electrical far field (V/m) @r=' num2str(r) ' m phi=0 deg'] ); +title( ['electrical far field (V/m); r=1 m phi=0 deg'] ); legend( 'e-field magnitude', 'Location', 'BestOutside' ); % calculate the e-field magnitude for phi = 90 deg @@ -107,14 +118,19 @@ end figure polar( thetaRange/180*pi, E_phi90_far ); ylabel( 'theta / deg' ); -title( ['electrical far field (V/m) @r=' num2str(r) ' m phi=90 deg'] ); +title( ['electrical far field (V/m); r=1 m phi=90 deg'] ); legend( 'e-field magnitude', 'Location', 'BestOutside' ); % calculate the far field at theta=90 degrees phiRange = 0:2:359; -r = 1; % evaluate fields at radius r disp( 'calculating far field at theta=90 deg..' ); -[E_far_theta,E_far_phi] = AnalyzeNF2FF( Sim_Path, nf2ff, f_max, 90, phiRange, r ); +%[E_far_theta,E_far_phi] = AnalyzeNF2FF( Sim_Path, nf2ff, f_max, 90, phiRange, 1 ); +nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, 90, phiRange/180*pi, 'Mode', 1 ); +Prad = nf2ff.Prad; +Dmax = nf2ff.Dmax; +f_idx = 1; +E_far_theta = nf2ff.E_theta{f_idx}; +E_far_phi = nf2ff.E_phi{f_idx}; E_theta90_far = zeros(1,numel(phiRange)); for n=1:numel(phiRange) @@ -125,16 +141,20 @@ end figure polar( phiRange/180*pi, E_theta90_far ); ylabel( 'phi / deg' ); -title( ['electrical far field (V/m) @r=' num2str(r) ' m theta=90 deg'] ); +title( ['electrical far field (V/m); r=1 m theta=90 deg'] ); legend( 'e-field magnitude', 'Location', 'BestOutside' ); % calculate 3D pattern phiRange = 0:15:360; thetaRange = 0:10:180; -r = 1; % evaluate fields at radius r disp( 'calculating 3D far field...' ); -[E_far_theta,E_far_phi] = AnalyzeNF2FF( Sim_Path, nf2ff, f_max, thetaRange, phiRange, r ); +%[E_far_theta,E_far_phi] = AnalyzeNF2FF( Sim_Path, nf2ff, f_max, thetaRange, phiRange, 1 ); +nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, thetaRange/180*pi, phiRange/180*pi, 'Mode', 1 ); +f_idx = 1; +E_far_theta = nf2ff.E_theta{f_idx}; +E_far_phi = nf2ff.E_phi{f_idx}; + E_far = sqrt( abs(E_far_theta).^2 + abs(E_far_phi).^2 ); E_far_normalized = E_far / max(E_far(:)); [theta,phi] = ndgrid(thetaRange/180*pi,phiRange/180*pi);