Merge remote-tracking branch 'dac/master' + Matlab compat fix
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
This commit is contained in:
commit
5644d86836
@ -24,7 +24,7 @@ function DumpFF2VTK2(filename, farfield, thetaRange, phiRange, varargin)
|
|||||||
%
|
%
|
||||||
% see also examples/NF2FF/infDipol.m
|
% see also examples/NF2FF/infDipol.m
|
||||||
%
|
%
|
||||||
% See also CreateNF2FFBox, AnalyzeNF2FF
|
% See also CreateNF2FFBox, CalcNF2FF
|
||||||
%
|
%
|
||||||
% openEMS matlab interface
|
% openEMS matlab interface
|
||||||
% -----------------------
|
% -----------------------
|
||||||
|
@ -179,19 +179,8 @@ thetaRange = sort( unique([ 0:1:50 50:2.:100 100:5:180 ]));
|
|||||||
disp( 'calculating 3D far field...' );
|
disp( 'calculating 3D far field...' );
|
||||||
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f0, thetaRange*pi/180, phiRange*pi/180, 'Verbose',2,'Outfile','nf2ff_3D.h5');
|
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f0, thetaRange*pi/180, phiRange*pi/180, 'Verbose',2,'Outfile','nf2ff_3D.h5');
|
||||||
|
|
||||||
E_far_normalized = nf2ff.E_norm{1} / max(nf2ff.E_norm{1}(:)) * nf2ff.Dmax;
|
|
||||||
|
|
||||||
[theta,phi] = ndgrid(thetaRange/180*pi,phiRange/180*pi);
|
|
||||||
x = E_far_normalized .* sin(theta) .* cos(phi);
|
|
||||||
y = E_far_normalized .* sin(theta) .* sin(phi);
|
|
||||||
z = E_far_normalized .* cos(theta);
|
|
||||||
figure
|
figure
|
||||||
surf( x,y,z, E_far_normalized, 'EdgeColor','none' );
|
plotFF3D(nf2ff); % plot liear 3D far field
|
||||||
axis equal
|
|
||||||
axis off
|
|
||||||
xlabel( 'x' );
|
|
||||||
ylabel( 'y' );
|
|
||||||
zlabel( 'z' );
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
DumpFF2VTK([Sim_Path '/Conical_Horn_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);
|
DumpFF2VTK([Sim_Path '/Conical_Horn_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);
|
||||||
|
@ -198,19 +198,8 @@ thetaRange = sort( unique([ 0:1:50 50:2.:100 100:5:180 ]));
|
|||||||
disp( 'calculating 3D far field...' );
|
disp( 'calculating 3D far field...' );
|
||||||
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f0, thetaRange*pi/180, phiRange*pi/180, 'Verbose',2,'Outfile','nf2ff_3D.h5');
|
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f0, thetaRange*pi/180, phiRange*pi/180, 'Verbose',2,'Outfile','nf2ff_3D.h5');
|
||||||
|
|
||||||
E_far_normalized = nf2ff.E_norm{1} / max(nf2ff.E_norm{1}(:)) * nf2ff.Dmax;
|
|
||||||
|
|
||||||
[theta,phi] = ndgrid(thetaRange/180*pi,phiRange/180*pi);
|
|
||||||
x = E_far_normalized .* sin(theta) .* cos(phi);
|
|
||||||
y = E_far_normalized .* sin(theta) .* sin(phi);
|
|
||||||
z = E_far_normalized .* cos(theta);
|
|
||||||
figure
|
figure
|
||||||
surf( x,y,z, E_far_normalized, 'EdgeColor','none' );
|
plotFF3D(nf2ff);
|
||||||
axis equal
|
|
||||||
axis off
|
|
||||||
xlabel( 'x' );
|
|
||||||
ylabel( 'y' );
|
|
||||||
zlabel( 'z' );
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
DumpFF2VTK([Sim_Path '/Horn_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);
|
DumpFF2VTK([Sim_Path '/Horn_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);
|
||||||
|
@ -41,7 +41,7 @@ SimBox = [200 200 150];
|
|||||||
%% setup FDTD parameter & excitation function
|
%% setup FDTD parameter & excitation function
|
||||||
f0 = 2e9; % center frequency
|
f0 = 2e9; % center frequency
|
||||||
fc = 1e9; % 20 dB corner frequency
|
fc = 1e9; % 20 dB corner frequency
|
||||||
FDTD = InitFDTD( 30000 );
|
FDTD = InitFDTD( 'NrTs', 30000 );
|
||||||
FDTD = SetGaussExcite( FDTD, f0, fc );
|
FDTD = SetGaussExcite( FDTD, f0, fc );
|
||||||
BC = {'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'}; % boundary conditions
|
BC = {'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'}; % boundary conditions
|
||||||
FDTD = SetBoundaryCond( FDTD, BC );
|
FDTD = SetBoundaryCond( FDTD, BC );
|
||||||
@ -154,25 +154,21 @@ disp( ['directivity: Dmax = ' num2str(nf2ff.Dmax) ' (' num2str(10*log10(nf2ff.Dm
|
|||||||
disp( ['efficiency: nu_rad = ' num2str(100*nf2ff.Prad./real(P_in(f_res_ind))) ' %']);
|
disp( ['efficiency: nu_rad = ' num2str(100*nf2ff.Prad./real(P_in(f_res_ind))) ' %']);
|
||||||
|
|
||||||
% normalized directivity
|
% normalized directivity
|
||||||
D_log = 20*log10(nf2ff.E_norm{1}/max(max(nf2ff.E_norm{1})));
|
|
||||||
% directivity
|
|
||||||
D_log = D_log + 10*log10(nf2ff.Dmax);
|
|
||||||
|
|
||||||
%% display polar plot
|
|
||||||
figure
|
figure
|
||||||
plot( nf2ff.theta, D_log(:,1) ,'k-' );
|
plotFFdB(nf2ff,'xaxis','theta','param',[1 2])
|
||||||
xlabel( 'theta (deg)' );
|
% D_log = 20*log10(nf2ff.E_norm{1}/max(max(nf2ff.E_norm{1})));
|
||||||
ylabel( 'directivity (dBi)');
|
% D_log = D_log + 10*log10(nf2ff.Dmax);
|
||||||
grid on;
|
% plot( nf2ff.theta, D_log(:,1) ,'k-' );
|
||||||
hold on;
|
|
||||||
plot( nf2ff.theta, D_log(:,2) ,'r-' );
|
|
||||||
legend('phi=0','phi=90')
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
disp( 'calculating 3D far field pattern and dumping to vtk (use Paraview to visualize)...' );
|
disp( 'calculating 3D far field pattern and dumping to vtk (use Paraview to visualize)...' );
|
||||||
thetaRange = (0:2:180);
|
thetaRange = (0:2:180);
|
||||||
phiRange = (0:2:360) - 180;
|
phiRange = (0:2:360) - 180;
|
||||||
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_res, thetaRange*pi/180, phiRange*pi/180,'Verbose',1,'Outfile','3D_Pattern.h5');
|
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_res, thetaRange*pi/180, phiRange*pi/180,'Verbose',1,'Outfile','3D_Pattern.h5');
|
||||||
|
figure
|
||||||
|
plotFF3D(nf2ff);
|
||||||
|
|
||||||
|
|
||||||
E_far_normalized = nf2ff.E_norm{1} / max(nf2ff.E_norm{1}(:)) * nf2ff.Dmax;
|
E_far_normalized = nf2ff.E_norm{1} / max(nf2ff.E_norm{1}(:)) * nf2ff.Dmax;
|
||||||
DumpFF2VTK([Sim_Path '/3D_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);
|
DumpFF2VTK([Sim_Path '/3D_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);
|
||||||
|
@ -59,7 +59,7 @@ max_timesteps = 30000;
|
|||||||
min_decrement = 1e-5; % equivalent to -50 dB
|
min_decrement = 1e-5; % equivalent to -50 dB
|
||||||
f0 = 0e9; % center frequency
|
f0 = 0e9; % center frequency
|
||||||
fc = 3e9; % 20 dB corner frequency (in this case 0 Hz - 3e9 Hz)
|
fc = 3e9; % 20 dB corner frequency (in this case 0 Hz - 3e9 Hz)
|
||||||
FDTD = InitFDTD( max_timesteps, min_decrement );
|
FDTD = InitFDTD( 'NrTS', max_timesteps, 'EndCriteria', min_decrement );
|
||||||
FDTD = SetGaussExcite( FDTD, f0, fc );
|
FDTD = SetGaussExcite( FDTD, f0, fc );
|
||||||
BC = {'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'}; % boundary conditions
|
BC = {'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'}; % boundary conditions
|
||||||
if (use_pml>0)
|
if (use_pml>0)
|
||||||
@ -106,7 +106,7 @@ CSX = AddBox(CSX,'gnd',10,start,stop);
|
|||||||
%% apply the excitation & resist as a current source
|
%% apply the excitation & resist as a current source
|
||||||
start = [feed.pos-.1 -feed.width/2 0];
|
start = [feed.pos-.1 -feed.width/2 0];
|
||||||
stop = [feed.pos+.1 +feed.width/2 substrate.thickness];
|
stop = [feed.pos+.1 +feed.width/2 substrate.thickness];
|
||||||
[CSX] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], 'excite');
|
[CSX] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], true);
|
||||||
|
|
||||||
%% dump magnetic field over the patch antenna
|
%% dump magnetic field over the patch antenna
|
||||||
CSX = AddDump( CSX, 'Ht_', 'DumpType', 1, 'DumpMode', 2); % cell interpolated
|
CSX = AddDump( CSX, 'Ht_', 'DumpType', 1, 'DumpMode', 2); % cell interpolated
|
||||||
@ -184,69 +184,33 @@ f_res = freq(f_res_ind);
|
|||||||
|
|
||||||
% calculate the far field at phi=0 degrees and at phi=90 degrees
|
% calculate the far field at phi=0 degrees and at phi=90 degrees
|
||||||
thetaRange = (0:2:359) - 180;
|
thetaRange = (0:2:359) - 180;
|
||||||
r = 1; % evaluate fields at radius r
|
phiRange = [0 90];
|
||||||
disp( 'calculating far field at phi=[0 90] deg...' );
|
disp( 'calculating far field at phi=[0 90] deg...' );
|
||||||
[E_far_theta,E_far_phi,Prad,Dmax] = AnalyzeNF2FF( Sim_Path, nf2ff, f_res, thetaRange, [0 90], r );
|
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_res, thetaRange*pi/180, phiRange*pi/180);
|
||||||
|
|
||||||
Dlog=10*log10(Dmax);
|
Dlog=10*log10(nf2ff.Dmax);
|
||||||
|
|
||||||
% display power and directivity
|
% display power and directivity
|
||||||
disp( ['radiated power: Prad = ' num2str(Prad) ' Watt']);
|
disp( ['radiated power: Prad = ' num2str(nf2ff.Prad) ' Watt']);
|
||||||
disp( ['directivity: Dmax = ' num2str(Dlog) ' dBi'] );
|
disp( ['directivity: Dmax = ' num2str(Dlog) ' dBi'] );
|
||||||
disp( ['efficiency: nu_rad = ' num2str(100*Prad./real(P_in(f_res_ind))) ' %']);
|
disp( ['efficiency: nu_rad = ' num2str(100*nf2ff.Prad./real(P_in(f_res_ind))) ' %']);
|
||||||
|
|
||||||
% calculate the e-field magnitude for phi = 0 deg
|
% display phi
|
||||||
E_phi0_far = zeros(1,numel(thetaRange));
|
|
||||||
for n=1:numel(thetaRange)
|
|
||||||
E_phi0_far(n) = norm( [E_far_theta(n,1) E_far_phi(n,1)] );
|
|
||||||
end
|
|
||||||
|
|
||||||
E_phi0_far_log = 20*log10(abs(E_phi0_far)/max(abs(E_phi0_far)));
|
|
||||||
E_phi0_far_log = E_phi0_far_log + Dlog;
|
|
||||||
|
|
||||||
% display polar plot
|
|
||||||
figure
|
figure
|
||||||
plot( thetaRange, E_phi0_far_log ,'k-' );
|
plotFFdB(nf2ff,'xaxis','theta','param',[1 2]);
|
||||||
xlabel( 'theta (deg)' );
|
drawnow
|
||||||
ylabel( 'directivity (dBi)');
|
|
||||||
grid on;
|
|
||||||
hold on;
|
|
||||||
|
|
||||||
% calculate the e-field magnitude for phi = 90 deg
|
|
||||||
E_phi90_far = zeros(1,numel(thetaRange));
|
|
||||||
for n=1:numel(thetaRange)
|
|
||||||
E_phi90_far(n) = norm([E_far_theta(n,2) E_far_phi(n,2)]);
|
|
||||||
end
|
|
||||||
|
|
||||||
E_phi90_far_log = 20*log10(abs(E_phi90_far)/max(abs(E_phi90_far)));
|
|
||||||
E_phi90_far_log = E_phi90_far_log + Dlog;
|
|
||||||
|
|
||||||
% display polar plot
|
|
||||||
plot( thetaRange, E_phi90_far_log ,'r-' );
|
|
||||||
legend('phi=0','phi=90')
|
|
||||||
|
|
||||||
if (draw_3d_pattern==0)
|
if (draw_3d_pattern==0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
%% 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_res, thetaRange, phiRange, r );
|
|
||||||
E_far = sqrt( abs(E_far_theta).^2 + abs(E_far_phi).^2 );
|
|
||||||
E_far_normalized = E_far / max(E_far(:)) * Dmax;
|
|
||||||
|
|
||||||
[theta,phi] = ndgrid(thetaRange/180*pi,phiRange/180*pi);
|
%% calculate 3D pattern
|
||||||
x = E_far_normalized .* sin(theta) .* cos(phi);
|
phiRange = 0:2:360;
|
||||||
y = E_far_normalized .* sin(theta) .* sin(phi);
|
thetaRange = 0:2:180;
|
||||||
z = E_far_normalized .* cos(theta);
|
disp( 'calculating 3D far field...' );
|
||||||
|
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_res, thetaRange*pi/180, phiRange*pi/180, 'Verbose',2,'Outfile','nf2ff_3D.h5');
|
||||||
figure
|
figure
|
||||||
surf( x,y,z, E_far_normalized );
|
plotFF3D(nf2ff);
|
||||||
axis equal
|
|
||||||
xlabel( 'x' );
|
|
||||||
ylabel( 'y' );
|
|
||||||
zlabel( 'z' );
|
|
||||||
|
|
||||||
|
|
||||||
%% visualize magnetic fields
|
%% visualize magnetic fields
|
||||||
|
@ -65,7 +65,7 @@ max_timesteps = 30000;
|
|||||||
min_decrement = 1e-5; % equivalent to -50 dB
|
min_decrement = 1e-5; % equivalent to -50 dB
|
||||||
f0 = 0e9; % center frequency
|
f0 = 0e9; % center frequency
|
||||||
fc = 3e9; % 10 dB corner frequency (in this case 0 Hz - 3e9 Hz)
|
fc = 3e9; % 10 dB corner frequency (in this case 0 Hz - 3e9 Hz)
|
||||||
FDTD = InitFDTD( max_timesteps, min_decrement );
|
FDTD = InitFDTD( 'NrTS', max_timesteps, 'EndCriteria', min_decrement );
|
||||||
FDTD = SetGaussExcite( FDTD, f0, fc );
|
FDTD = SetGaussExcite( FDTD, f0, fc );
|
||||||
BC = {'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'}; % boundary conditions
|
BC = {'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'}; % boundary conditions
|
||||||
if (use_pml>0)
|
if (use_pml>0)
|
||||||
@ -133,7 +133,7 @@ for xn=1:array.xn
|
|||||||
% apply the excitation & resist as a current source
|
% apply the excitation & resist as a current source
|
||||||
start = [midX+feed.pos-feed.width/2 midY-feed.width/2 0];
|
start = [midX+feed.pos-feed.width/2 midY-feed.width/2 0];
|
||||||
stop = [midX+feed.pos+feed.width/2 midY+feed.width/2 substrate.thickness];
|
stop = [midX+feed.pos+feed.width/2 midY+feed.width/2 substrate.thickness];
|
||||||
[CSX] = AddLumpedPort(CSX, 5, number,feed.R, start, stop,[0 0 1],['excite_' int2str(xn) '_' int2str(yn)]);
|
[CSX] = AddLumpedPort(CSX, 5, number,feed.R, start, stop,[0 0 1],true);
|
||||||
number=number+1;
|
number=number+1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -221,74 +221,35 @@ f_res = freq(f_res_ind);
|
|||||||
|
|
||||||
% calculate the far field at phi=0 degrees and at phi=90 degrees
|
% calculate the far field at phi=0 degrees and at phi=90 degrees
|
||||||
thetaRange = (0:2:359) - 180;
|
thetaRange = (0:2:359) - 180;
|
||||||
|
phiRange = [0 90];
|
||||||
r = 1; % evaluate fields at radius r
|
r = 1; % evaluate fields at radius r
|
||||||
disp( 'calculating far field at phi=[0 90] deg...' );
|
disp( 'calculating far field at phi=[0 90] deg...' );
|
||||||
[E_far_theta,E_far_phi,Prad,Dmax] = AnalyzeNF2FF( Sim_Path, nf2ff, f_res, thetaRange, [0 90], r );
|
|
||||||
|
|
||||||
Dlog=10*log10(Dmax);
|
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_res, thetaRange*pi/180, phiRange*pi/180);
|
||||||
|
|
||||||
|
Dlog=10*log10(nf2ff.Dmax);
|
||||||
|
|
||||||
% display power and directivity
|
% display power and directivity
|
||||||
disp( ['radiated power: Prad = ' num2str(Prad) ' Watt']);
|
disp( ['radiated power: Prad = ' num2str(nf2ff.Prad) ' Watt']);
|
||||||
disp( ['directivity: Dmax = ' num2str(Dlog) ' dBi'] );
|
disp( ['directivity: Dmax = ' num2str(Dlog) ' dBi'] );
|
||||||
disp( ['efficiency: nu_rad = ' num2str(100*Prad./real(P_in(f_res_ind))) ' %']);
|
disp( ['efficiency: nu_rad = ' num2str(100*nf2ff.Prad./real(P_in(f_res_ind))) ' %']);
|
||||||
|
|
||||||
% calculate the e-field magnitude for phi = 0 deg
|
% display phi
|
||||||
E_phi0_far = zeros(1,numel(thetaRange));
|
|
||||||
for n=1:numel(thetaRange)
|
|
||||||
E_phi0_far(n) = norm( [E_far_theta(n,1) E_far_phi(n,1)] );
|
|
||||||
end
|
|
||||||
|
|
||||||
E_phi0_far_log = 20*log10(abs(E_phi0_far)/max(abs(E_phi0_far)));
|
|
||||||
E_phi0_far_log = E_phi0_far_log + Dlog;
|
|
||||||
|
|
||||||
% display radiation pattern
|
|
||||||
figure
|
figure
|
||||||
plot( thetaRange, E_phi0_far_log ,'k-' );
|
plotFFdB(nf2ff,'xaxis','theta','param',[1 2]);
|
||||||
xlabel( 'theta (deg)' );
|
|
||||||
ylabel( 'directivity (dBi)');
|
|
||||||
grid on;
|
|
||||||
hold on;
|
|
||||||
|
|
||||||
% calculate the e-field magnitude for phi = 90 deg
|
|
||||||
E_phi90_far = zeros(1,numel(thetaRange));
|
|
||||||
for n=1:numel(thetaRange)
|
|
||||||
E_phi90_far(n) = norm([E_far_theta(n,2) E_far_phi(n,2)]);
|
|
||||||
end
|
|
||||||
|
|
||||||
E_phi90_far_log = 20*log10(abs(E_phi90_far)/max(abs(E_phi90_far)));
|
|
||||||
E_phi90_far_log = E_phi90_far_log + Dlog;
|
|
||||||
|
|
||||||
plot( thetaRange, E_phi90_far_log ,'r-' );
|
|
||||||
legend('phi=0','phi=90')
|
|
||||||
|
|
||||||
drawnow
|
drawnow
|
||||||
|
|
||||||
if (draw_3d_pattern==0)
|
if (draw_3d_pattern==0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
%% calculate 3D pattern
|
%% calculate 3D pattern
|
||||||
tic
|
|
||||||
phiRange = 0:3:360;
|
phiRange = 0:3:360;
|
||||||
thetaRange = unique([0:0.5:15 10:3:180]);
|
thetaRange = unique([0:0.5:15 10:3:180]);
|
||||||
r = 1; % evaluate fields at radius r
|
|
||||||
disp( 'calculating 3D far field...' );
|
disp( 'calculating 3D far field...' );
|
||||||
[E_far_theta,E_far_phi] = AnalyzeNF2FF( Sim_Path, nf2ff, f_res, thetaRange, phiRange, r );
|
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_res, thetaRange*pi/180, phiRange*pi/180, 'Verbose',2,'Outfile','nf2ff_3D.h5');
|
||||||
E_far = sqrt( abs(E_far_theta).^2 + abs(E_far_phi).^2 );
|
|
||||||
|
|
||||||
E_far_normalized = E_far / max(E_far(:)) * Dmax;
|
|
||||||
[theta,phi] = ndgrid(thetaRange/180*pi,phiRange/180*pi);
|
|
||||||
x = E_far_normalized .* sin(theta) .* cos(phi);
|
|
||||||
y = E_far_normalized .* sin(theta) .* sin(phi);
|
|
||||||
z = E_far_normalized .* cos(theta);
|
|
||||||
|
|
||||||
%%
|
|
||||||
figure
|
figure
|
||||||
surf( x,y,z, E_far_normalized );
|
plotFF3D(nf2ff);
|
||||||
axis equal
|
|
||||||
xlabel( 'x' );
|
|
||||||
ylabel( 'y' );
|
|
||||||
zlabel( 'z' );
|
|
||||||
toc
|
|
||||||
|
|
||||||
%% visualize magnetic fields
|
%% visualize magnetic fields
|
||||||
% you will find vtk dump files in the simulation folder (tmp/)
|
% you will find vtk dump files in the simulation folder (tmp/)
|
||||||
|
@ -111,7 +111,6 @@ legend( 'e-field magnitude', 'Location', 'BestOutside' );
|
|||||||
%% calculate the far field at theta=90 degrees
|
%% calculate the far field at theta=90 degrees
|
||||||
phiRange = 0:2:359;
|
phiRange = 0:2:359;
|
||||||
disp( 'calculating far field at theta=90 deg..' );
|
disp( 'calculating far field at theta=90 deg..' );
|
||||||
%[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 );
|
nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, 90, phiRange/180*pi, 'Mode', 1 );
|
||||||
Prad = nf2ff.Prad;
|
Prad = nf2ff.Prad;
|
||||||
Dmax = nf2ff.Dmax;
|
Dmax = nf2ff.Dmax;
|
||||||
@ -129,20 +128,10 @@ phiRange = 0:5:360;
|
|||||||
thetaRange = 0:5:180;
|
thetaRange = 0:5:180;
|
||||||
disp( 'calculating 3D far field...' );
|
disp( 'calculating 3D far field...' );
|
||||||
nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, thetaRange/180*pi, phiRange/180*pi, 'Mode', 1 );
|
nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, thetaRange/180*pi, phiRange/180*pi, 'Mode', 1 );
|
||||||
|
|
||||||
E_far = nf2ff.E_norm{1};
|
|
||||||
E_far_normalized = E_far / max(E_far(:));
|
|
||||||
[theta,phi] = ndgrid(thetaRange/180*pi,phiRange/180*pi);
|
|
||||||
x = E_far_normalized .* sin(theta) .* cos(phi);
|
|
||||||
y = E_far_normalized .* sin(theta) .* sin(phi);
|
|
||||||
z = E_far_normalized .* cos(theta);
|
|
||||||
figure
|
figure
|
||||||
surf( x,y,z, E_far_normalized );
|
plotFF3D(nf2ff)
|
||||||
axis equal
|
|
||||||
xlabel( 'x' );
|
|
||||||
ylabel( 'y' );
|
|
||||||
zlabel( 'z' );
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
E_far_normalized = nf2ff.E_norm{1} / max(nf2ff.E_norm{1}(:));
|
||||||
DumpFF2VTK([Sim_Path '/FF_pattern.vtk'],E_far_normalized, thetaRange, phiRange);
|
DumpFF2VTK([Sim_Path '/FF_pattern.vtk'],E_far_normalized, thetaRange, phiRange);
|
||||||
disp(['view the farfield pattern "' Sim_Path '/FF_pattern.vtk" using paraview' ]);
|
disp(['view the farfield pattern "' Sim_Path '/FF_pattern.vtk" using paraview' ]);
|
||||||
|
68
matlab/plotFF3D.m
Normal file
68
matlab/plotFF3D.m
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
function h = plotFF3D(nf2ff,varargin)
|
||||||
|
% h = plotFF3D(nf2ff,varargin)
|
||||||
|
%
|
||||||
|
% plot normalized 3D far field pattern
|
||||||
|
%
|
||||||
|
% input:
|
||||||
|
% nf2ff: output of CalcNF2FF
|
||||||
|
%
|
||||||
|
% variable input:
|
||||||
|
% 'cellelement': - use element from cell array
|
||||||
|
% - default is 1
|
||||||
|
% 'logscale': - if set, show farfield with logarithmic scale
|
||||||
|
% - set the dB value for point of origin
|
||||||
|
% - values below will be clamped
|
||||||
|
%
|
||||||
|
% example:
|
||||||
|
% plotFF3D(nf2ff, 'cellelement', 2, 'logscale', -20)
|
||||||
|
%
|
||||||
|
% see examples/NF2FF/infDipol.m
|
||||||
|
%
|
||||||
|
% See also CalcNF2FF
|
||||||
|
%
|
||||||
|
% openEMS matlab interface
|
||||||
|
% -----------------------
|
||||||
|
% author: Thorsten Liebig, Stefan Mahr
|
||||||
|
|
||||||
|
% defaults
|
||||||
|
logscale = [];
|
||||||
|
cellelement = 1;
|
||||||
|
|
||||||
|
for n=1:2:numel(varargin)
|
||||||
|
if (strcmp(varargin{n},'logscale')==1);
|
||||||
|
logscale = varargin{n+1};
|
||||||
|
elseif (strcmp(varargin{n},'cellelement')==1);
|
||||||
|
cellelement = varargin{n+1};
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
E_far_normalized = nf2ff.E_norm{cellelement} / max(nf2ff.E_norm{cellelement}(:));
|
||||||
|
|
||||||
|
if ~isempty(logscale)
|
||||||
|
E_far_normalized = 20*log10(E_far_normalized)/-logscale + 1;
|
||||||
|
ind = find ( E_far_normalized < 0 );
|
||||||
|
E_far_normalized(ind) = 0;
|
||||||
|
titletext = sprintf('electrical far field [dB] @ f = %e Hz',nf2ff.freq(cellelement));
|
||||||
|
else
|
||||||
|
titletext = sprintf('electrical far field [V/m] @ f = %e Hz',nf2ff.freq(cellelement));
|
||||||
|
end
|
||||||
|
|
||||||
|
[theta,phi] = ndgrid(nf2ff.theta,nf2ff.phi);
|
||||||
|
x = E_far_normalized .* sin(theta) .* cos(phi);
|
||||||
|
y = E_far_normalized .* sin(theta) .* sin(phi);
|
||||||
|
z = E_far_normalized .* cos(theta);
|
||||||
|
%figure
|
||||||
|
h = surf( x,y,z, E_far_normalized );
|
||||||
|
set(h,'EdgeColor','none');
|
||||||
|
axis equal
|
||||||
|
|
||||||
|
title( titletext );
|
||||||
|
xlabel( 'x' );
|
||||||
|
ylabel( 'y' );
|
||||||
|
zlabel( 'z' );
|
||||||
|
|
||||||
|
if (nargout == 0)
|
||||||
|
clear h;
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
74
matlab/plotFFdB.m
Normal file
74
matlab/plotFFdB.m
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
function h = plotFFdB(nf2ff,varargin)
|
||||||
|
% h = plotFFdB(nf2ff,varargin)
|
||||||
|
%
|
||||||
|
% plot far field pattern in dBi
|
||||||
|
%
|
||||||
|
% input:
|
||||||
|
% nf2ff: output of CalcNF2FF
|
||||||
|
%
|
||||||
|
% variable input:
|
||||||
|
% 'cellelement': - use element from cell array
|
||||||
|
% - default is 1
|
||||||
|
% 'xaxis': - 'phi' (default) or 'theta'
|
||||||
|
% 'param': - array positions of parametric plot
|
||||||
|
% - if xaxis='phi', theta is parameter, and vice versa
|
||||||
|
% - default is 1
|
||||||
|
%
|
||||||
|
% example:
|
||||||
|
% plotFFdB(nf2ff, 'cellelement', 2, ...
|
||||||
|
% 'xaxis', 'phi', 'param', [1 46 91])
|
||||||
|
%
|
||||||
|
% see examples/NF2FF/infDipol.m
|
||||||
|
%
|
||||||
|
% See also CalcNF2FF
|
||||||
|
%
|
||||||
|
% openEMS matlab interface
|
||||||
|
% -----------------------
|
||||||
|
% author: Thorsten Liebig, Stefan Mahr
|
||||||
|
|
||||||
|
% defaults
|
||||||
|
cellelement = 1;
|
||||||
|
xaxis = 'phi';
|
||||||
|
param = 1;
|
||||||
|
|
||||||
|
for n=1:2:numel(varargin)
|
||||||
|
if (strcmp(varargin{n},'cellelement')==1);
|
||||||
|
cellelement = varargin{n+1};
|
||||||
|
elseif (strcmp(varargin{n},'xaxis')==1);
|
||||||
|
xaxis = varargin{n+1};
|
||||||
|
elseif (strcmp(varargin{n},'param')==1);
|
||||||
|
param = varargin{n+1};
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
D_log = nf2ff.E_norm{cellelement} / max(nf2ff.E_norm{cellelement}(:));
|
||||||
|
D_log = 20*log10(D_log) + 10*log10(nf2ff.Dmax);
|
||||||
|
|
||||||
|
if (strcmp(xaxis,'theta')==1);
|
||||||
|
xax = nf2ff.theta;
|
||||||
|
yax = D_log(:,param);
|
||||||
|
parval = nf2ff.phi(param);
|
||||||
|
param = 'phi';
|
||||||
|
elseif (strcmp(xaxis,'phi')==1);
|
||||||
|
xax = nf2ff.phi;
|
||||||
|
yax = D_log(param,:);
|
||||||
|
parval = nf2ff.theta(param);
|
||||||
|
param = 'theta';
|
||||||
|
end
|
||||||
|
|
||||||
|
%figure
|
||||||
|
h = plot( xax / pi * 180 , yax );
|
||||||
|
xlabel( sprintf('%s (deg)',xaxis ));
|
||||||
|
ylabel( 'directivity (dBi)');
|
||||||
|
|
||||||
|
createlegend = @(d)sprintf('%s = %3.1f',param,d / pi * 180);
|
||||||
|
legendtext = arrayfun(createlegend,parval,'UniformOutput',0);
|
||||||
|
legend( legendtext );
|
||||||
|
title( sprintf('far field pattern @ f = %e Hz',nf2ff.freq(cellelement)) );
|
||||||
|
grid on;
|
||||||
|
|
||||||
|
if (nargout == 0)
|
||||||
|
clear h;
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user