2010-12-20 12:15:51 +00:00
|
|
|
%
|
|
|
|
% infinitesimal dipole example
|
|
|
|
%
|
|
|
|
|
|
|
|
close all
|
|
|
|
clear
|
|
|
|
clc
|
|
|
|
|
2011-11-28 13:12:16 +00:00
|
|
|
postprocessing_only = 0;
|
2010-12-20 12:15:51 +00:00
|
|
|
|
|
|
|
physical_constants
|
|
|
|
|
|
|
|
% setup the simulation
|
2011-11-28 13:12:16 +00:00
|
|
|
drawingunit = 1e-6; % specify everything in um
|
|
|
|
Sim_Path = 'tmp';
|
|
|
|
Sim_CSX = 'tmp.xml';
|
2010-12-20 12:15:51 +00:00
|
|
|
|
2011-11-28 13:12:16 +00:00
|
|
|
f_max = 1e9;
|
|
|
|
lambda = c0/f_max;
|
2010-12-20 12:15:51 +00:00
|
|
|
|
|
|
|
% setup geometry values
|
2011-11-28 13:12:16 +00:00
|
|
|
dipole_length = lambda/50 /drawingunit;
|
2010-12-20 12:15:51 +00:00
|
|
|
|
|
|
|
|
2011-11-28 13:12:16 +00:00
|
|
|
dipole_orientation = 3; % 1,2,3: x,y,z
|
2010-12-20 12:15:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
CSX = InitCSX();
|
|
|
|
|
|
|
|
% create an equidistant mesh
|
2011-11-28 13:12:16 +00:00
|
|
|
mesh.x = -dipole_length*10:dipole_length/2:dipole_length*10;
|
|
|
|
mesh.y = -dipole_length*10:dipole_length/2:dipole_length*10;
|
|
|
|
mesh.z = -dipole_length*10:dipole_length/2:dipole_length*10;
|
2010-12-20 12:15:51 +00:00
|
|
|
|
|
|
|
% excitation
|
|
|
|
ex_vector = [0 0 0];
|
|
|
|
ex_vector(dipole_orientation) = 1;
|
2011-11-28 13:12:16 +00:00
|
|
|
start = ex_vector * -dipole_length/2;
|
|
|
|
stop = ex_vector * dipole_length/2;
|
2010-12-20 12:15:51 +00:00
|
|
|
CSX = AddExcitation( CSX, 'infDipole', 1, ex_vector );
|
2012-09-30 12:07:56 +00:00
|
|
|
% 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;
|
2010-12-20 12:15:51 +00:00
|
|
|
CSX = AddBox( CSX, 'infDipole', 1, start, stop );
|
|
|
|
|
|
|
|
% NFFF contour
|
2012-09-30 12:07:56 +00:00
|
|
|
start = [mesh.x(1) mesh.y(1) mesh.z(1) ];
|
|
|
|
stop = [mesh.x(end) mesh.y(end) mesh.z(end) ];
|
2011-11-28 13:12:16 +00:00
|
|
|
[CSX nf2ff] = CreateNF2FFBox(CSX, 'nf2ff', start, stop);
|
2010-12-20 12:15:51 +00:00
|
|
|
|
2011-11-28 13:12:16 +00:00
|
|
|
% add space for PML
|
|
|
|
mesh = AddPML( mesh, [8 8 8 8 8 8] );
|
|
|
|
% define the mesh
|
|
|
|
CSX = DefineRectGrid( CSX, drawingunit, mesh );
|
2010-12-20 12:15:51 +00:00
|
|
|
|
2011-11-28 13:12:16 +00:00
|
|
|
if ~postprocessing_only
|
|
|
|
% setup FDTD parameters & excitation function
|
|
|
|
max_timesteps = 2000;
|
|
|
|
min_decrement = 1e-6;
|
2013-06-14 16:05:48 +00:00
|
|
|
FDTD = InitFDTD( 'NrTS', max_timesteps, 'EndCriteria', min_decrement, 'OverSampling',10 );
|
2011-11-28 13:12:16 +00:00
|
|
|
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 );
|
|
|
|
|
|
|
|
% Write openEMS compatible xml-file
|
|
|
|
[~,~,~] = rmdir(Sim_Path,'s');
|
|
|
|
[~,~,~] = mkdir(Sim_Path);
|
|
|
|
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
|
|
|
|
2012-09-30 12:07:56 +00:00
|
|
|
% take a view at the "structure"
|
|
|
|
CSXGeomPlot( [Sim_Path '/' Sim_CSX] );
|
|
|
|
|
2011-11-28 13:12:16 +00:00
|
|
|
% define openEMS options and start simulation
|
|
|
|
openEMS_opts = '';
|
|
|
|
RunOpenEMS( Sim_Path, Sim_CSX, openEMS_opts );
|
|
|
|
end
|
2010-12-20 12:15:51 +00:00
|
|
|
|
2011-11-28 13:12:16 +00:00
|
|
|
%% post processing
|
2010-12-20 12:15:51 +00:00
|
|
|
disp( ' ' );
|
|
|
|
disp( ' ********************************************************** ' );
|
|
|
|
disp( ' ' );
|
|
|
|
|
|
|
|
% calculate the far field at phi=0 degrees and at phi=90 degrees
|
2013-01-02 18:23:48 +00:00
|
|
|
thetaRange = 0:0.5:359;
|
2011-11-28 13:12:16 +00:00
|
|
|
disp( 'calculating far field at phi=[0 90] deg..' );
|
2012-09-30 12:07:56 +00:00
|
|
|
nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, thetaRange/180*pi, [0 pi/2], 'Mode', 1 );
|
|
|
|
Prad = nf2ff.Prad;
|
|
|
|
Dmax = nf2ff.Dmax;
|
2013-01-02 18:23:48 +00:00
|
|
|
|
|
|
|
theta_HPBW = interp1(nf2ff.E_norm{1}(find(thetaRange<90),1)/max(nf2ff.E_norm{1}(find(thetaRange<90),1)),thetaRange(find(thetaRange<90)),1/sqrt(2))*2;
|
2010-12-20 12:15:51 +00:00
|
|
|
|
|
|
|
% display power and directivity
|
|
|
|
disp( ['radiated power: Prad = ' num2str(Prad)] );
|
|
|
|
disp( ['directivity: Dmax = ' num2str(Dmax)] );
|
2013-01-02 18:23:48 +00:00
|
|
|
disp( ['theta_HPBW = ' num2str(theta_HPBW) ' °']);
|
2010-12-20 12:15:51 +00:00
|
|
|
|
2013-06-14 16:05:48 +00:00
|
|
|
% display polar plot for the e-field magnitude for phi = 0 & 90 deg
|
2010-12-20 12:15:51 +00:00
|
|
|
figure
|
2013-06-14 16:05:48 +00:00
|
|
|
polarFF(nf2ff,'xaxis','theta','param',[1 2]);
|
2010-12-20 12:15:51 +00:00
|
|
|
|
2013-01-02 18:23:48 +00:00
|
|
|
%% calculate the far field at theta=90 degrees
|
2010-12-20 12:15:51 +00:00
|
|
|
phiRange = 0:2:359;
|
2011-11-28 13:12:16 +00:00
|
|
|
disp( 'calculating far field at theta=90 deg..' );
|
2013-06-14 16:05:48 +00:00
|
|
|
nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, 90/180*pi, phiRange/180*pi, 'Mode', 1 );
|
2010-12-20 12:15:51 +00:00
|
|
|
|
|
|
|
% display polar plot
|
|
|
|
figure
|
2013-06-14 16:05:48 +00:00
|
|
|
polarFF(nf2ff,'xaxis','phi','param',1);
|
2010-12-20 12:15:51 +00:00
|
|
|
|
2013-01-02 18:23:48 +00:00
|
|
|
%% calculate 3D pattern
|
|
|
|
phiRange = 0:5:360;
|
|
|
|
thetaRange = 0:5:180;
|
2010-12-20 12:15:51 +00:00
|
|
|
disp( 'calculating 3D far field...' );
|
2012-09-30 12:07:56 +00:00
|
|
|
nf2ff = CalcNF2FF( nf2ff, Sim_Path, f_max, thetaRange/180*pi, phiRange/180*pi, 'Mode', 1 );
|
2010-12-20 12:15:51 +00:00
|
|
|
figure
|
2013-06-04 22:45:55 +00:00
|
|
|
plotFF3D(nf2ff)
|
2011-11-28 13:12:16 +00:00
|
|
|
|
2013-01-02 18:23:48 +00:00
|
|
|
%%
|
2013-06-05 14:03:04 +00:00
|
|
|
E_far_normalized = nf2ff.E_norm{1} / max(nf2ff.E_norm{1}(:));
|
2011-11-28 13:12:16 +00:00
|
|
|
DumpFF2VTK([Sim_Path '/FF_pattern.vtk'],E_far_normalized, thetaRange, phiRange);
|
|
|
|
disp(['view the farfield pattern "' Sim_Path '/FF_pattern.vtk" using paraview' ]);
|