matlab: update tutorials and examples

Signed-off-by: Stefan Mahr <stefan.mahr@sphairon.com>
This commit is contained in:
Stefan Mahr 2013-06-14 18:05:48 +02:00
parent 214f9ecdb2
commit 74535823eb
3 changed files with 28 additions and 50 deletions

View File

@ -41,7 +41,7 @@ f_stop = 20e9;
f0 = 15e9;
%% setup FDTD parameter & excitation function
FDTD = InitFDTD( 30000, 1e-4 );
FDTD = InitFDTD( 'NrTS', 30000, 'EndCriteria', 1e-4 );
FDTD = SetGaussExcite(FDTD,0.5*(f_start+f_stop),0.5*(f_stop-f_start));
BC = {'PML_8' 'PML_8' 'PML_8' 'PML_8' 'PML_8' 'PML_8'}; % boundary conditions
FDTD = SetBoundaryCond( FDTD, BC );
@ -140,7 +140,6 @@ drawnow
% calculate the far field at phi=0 degrees and at phi=90 degrees
thetaRange = (0:2:359) - 180;
r = 1; % evaluate fields at radius r
disp( 'calculating far field at phi=[0 90] deg...' );
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f0, thetaRange*pi/180, [0 90]*pi/180);
@ -153,24 +152,20 @@ disp( ['radiated power: Prad = ' num2str(nf2ff.Prad) ' Watt']);
disp( ['directivity: Dmax = ' num2str(Dlog) ' dBi'] );
disp( ['aperture efficiency: e_a = ' num2str(e_a*100) '%'] );
%%
% 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
plot( nf2ff.theta, D_log(:,1) ,'k-' );
xlabel( 'theta (deg)' );
ylabel( 'directivity (dBi)');
grid on;
hold on;
plot( nf2ff.theta, D_log(:,2) ,'r-' );
legend('phi=0','phi=90')
plotFFdB(nf2ff,'xaxis','theta','param',[1 2]);
drawnow
% D_log = 20*log10(nf2ff.E_norm{1}/max(max(nf2ff.E_norm{1})));
% D_log = D_log + 10*log10(nf2ff.Dmax);
% plot( nf2ff.theta, D_log(:,1) ,'k-', nf2ff.theta, D_log(:,2) ,'r-' );
% polar plot
figure
polarFF(nf2ff,'xaxis','theta','param',[1 2],'logscale',[-40 20], 'xtics', 12);
drawnow
% polar( nf2ff.theta, nf2ff.E_norm{1}(:,1) )
%% calculate 3D pattern
phiRange = sort( unique( [-180:5:-100 -100:2.5:-50 -50:1:50 50:2.5:100 100:5:180] ) );
@ -183,4 +178,5 @@ figure
plotFF3D(nf2ff); % plot liear 3D far field
%%
E_far_normalized = nf2ff.E_norm{1}/max(nf2ff.E_norm{1}(:));
DumpFF2VTK([Sim_Path '/Conical_Horn_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);

View File

@ -175,21 +175,18 @@ disp( ['aperture efficiency: e_a = ' num2str(e_a*100) '%'] );
%%
% 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
plot( nf2ff.theta, D_log(:,1) ,'k-' );
xlabel( 'theta (deg)' );
ylabel( 'directivity (dBi)');
grid on;
hold on;
plot( nf2ff.theta, D_log(:,2) ,'r-' );
legend('phi=0','phi=90')
plotFFdB(nf2ff,'xaxis','theta','param',[1 2]);
drawnow
% D_log = 20*log10(nf2ff.E_norm{1}/max(max(nf2ff.E_norm{1})));
% D_log = D_log + 10*log10(nf2ff.Dmax);
% plot( nf2ff.theta, D_log(:,1) ,'k-', nf2ff.theta, D_log(:,2) ,'r-' );
% polar plot
figure
polarFF(nf2ff,'xaxis','theta','param',[1 2],'logscale',[-40 20], 'xtics', 12);
drawnow
% polar( nf2ff.theta, nf2ff.E_norm{1}(:,1) )
%% calculate 3D pattern
phiRange = sort( unique( [-180:5:-100 -100:2.5:-50 -50:1:50 50:2.5:100 100:5:180] ) );
@ -202,4 +199,5 @@ figure
plotFF3D(nf2ff);
%%
E_far_normalized = nf2ff.E_norm{1}/max(nf2ff.E_norm{1}(:));
DumpFF2VTK([Sim_Path '/Horn_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);

View File

@ -57,7 +57,7 @@ if ~postprocessing_only
% setup FDTD parameters & excitation function
max_timesteps = 2000;
min_decrement = 1e-6;
FDTD = InitFDTD( max_timesteps, min_decrement, 'OverSampling',10 );
FDTD = InitFDTD( 'NrTS', max_timesteps, 'EndCriteria', min_decrement, 'OverSampling',10 );
FDTD = SetGaussExcite( FDTD, f_max/2, f_max/2 );
BC = {'PML_8' 'PML_8' 'PML_8' 'PML_8' 'PML_8' 'PML_8'};
FDTD = SetBoundaryCond( FDTD, BC );
@ -94,34 +94,18 @@ disp( ['radiated power: Prad = ' num2str(Prad)] );
disp( ['directivity: Dmax = ' num2str(Dmax)] );
disp( ['theta_HPBW = ' num2str(theta_HPBW) ' °']);
% display polar plot for the e-field magnitude for phi = 0 deg
% display polar plot for the e-field magnitude for phi = 0 & 90 deg
figure
polar( thetaRange/180*pi, nf2ff.E_norm{1}(:,1)' );
ylabel( 'theta / deg' );
title( 'electrical far field (V/m); r=1 m phi=0 deg' );
legend( 'e-field magnitude', 'Location', 'BestOutside' );
% display polar plot for the e-field magnitude for phi = 90 deg
figure
polar( thetaRange/180*pi, nf2ff.E_norm{1}(:,2)' );
ylabel( 'theta / deg' );
title( 'electrical far field (V/m); r=1 m phi=90 deg' );
legend( 'e-field magnitude', 'Location', 'BestOutside' );
polarFF(nf2ff,'xaxis','theta','param',[1 2]);
%% calculate the far field at theta=90 degrees
phiRange = 0:2:359;
disp( 'calculating far field at theta=90 deg..' );
nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, 90, phiRange/180*pi, 'Mode', 1 );
Prad = nf2ff.Prad;
Dmax = nf2ff.Dmax;
nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, 90/180*pi, phiRange/180*pi, 'Mode', 1 );
% display polar plot
figure
polar( phiRange/180*pi, nf2ff.E_norm{1} );
ylabel( 'phi / deg' );
title( 'electrical far field (V/m); r=1 m theta=90 deg' );
legend( 'e-field magnitude', 'Location', 'BestOutside' );
polarFF(nf2ff,'xaxis','phi','param',1);
%% calculate 3D pattern
phiRange = 0:5:360;