2017-02-11 18:46:26 +00:00
|
|
|
%% Simple Patch Antenna Tutorial
|
2011-09-14 14:30:32 +00:00
|
|
|
%
|
2011-09-14 14:34:31 +00:00
|
|
|
% Describtion at:
|
2017-02-11 18:46:26 +00:00
|
|
|
% <http://openems.de/index.php/Tutorial:_Simple_Patch_Antenna>
|
2011-09-14 14:30:32 +00:00
|
|
|
%
|
|
|
|
% Tested with
|
2015-06-16 19:13:25 +00:00
|
|
|
% - Matlab 2013a / Octave 4.0
|
2017-02-11 18:46:26 +00:00
|
|
|
% - openEMS v0.0.35
|
2011-09-14 14:30:32 +00:00
|
|
|
%
|
2017-02-11 18:46:26 +00:00
|
|
|
% (C) 2010-2017 Thorsten Liebig <thorsten.liebig@uni-due.de>
|
|
|
|
%%
|
2011-09-14 14:30:32 +00:00
|
|
|
|
|
|
|
close all
|
|
|
|
clear
|
|
|
|
clc
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
%% Setup the Simulation
|
2011-09-14 14:30:32 +00:00
|
|
|
physical_constants;
|
|
|
|
unit = 1e-3; % all length in mm
|
|
|
|
|
|
|
|
% patch width in x-direction
|
2013-08-15 14:55:51 +00:00
|
|
|
patch.width = 32; % resonant length
|
2011-09-14 14:30:32 +00:00
|
|
|
% patch length in y-direction
|
|
|
|
patch.length = 40;
|
|
|
|
|
|
|
|
%substrate setup
|
|
|
|
substrate.epsR = 3.38;
|
|
|
|
substrate.kappa = 1e-3 * 2*pi*2.45e9 * EPS0*substrate.epsR;
|
|
|
|
substrate.width = 60;
|
|
|
|
substrate.length = 60;
|
|
|
|
substrate.thickness = 1.524;
|
|
|
|
substrate.cells = 4;
|
|
|
|
|
|
|
|
%setup feeding
|
|
|
|
feed.pos = -6; %feeding position in x-direction
|
|
|
|
feed.R = 50; %feed resistance
|
|
|
|
|
|
|
|
% size of the simulation box
|
2012-02-21 09:59:19 +00:00
|
|
|
SimBox = [200 200 150];
|
2011-09-14 14:30:32 +00:00
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
%% Setup FDTD Parameter & Excitation Function
|
2012-01-17 14:49:37 +00:00
|
|
|
f0 = 2e9; % center frequency
|
|
|
|
fc = 1e9; % 20 dB corner frequency
|
2013-06-04 22:45:55 +00:00
|
|
|
FDTD = InitFDTD( 'NrTs', 30000 );
|
2011-09-14 14:30:32 +00:00
|
|
|
FDTD = SetGaussExcite( FDTD, f0, fc );
|
|
|
|
BC = {'MUR' 'MUR' 'MUR' 'MUR' 'MUR' 'MUR'}; % boundary conditions
|
|
|
|
FDTD = SetBoundaryCond( FDTD, BC );
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
%% Setup CSXCAD Geometry & Mesh
|
2011-09-14 14:30:32 +00:00
|
|
|
CSX = InitCSX();
|
|
|
|
|
2012-11-07 13:09:48 +00:00
|
|
|
%initialize the mesh with the "air-box" dimensions
|
|
|
|
mesh.x = [-SimBox(1)/2 SimBox(1)/2];
|
|
|
|
mesh.y = [-SimBox(2)/2 SimBox(2)/2];
|
|
|
|
mesh.z = [-SimBox(3)/3 SimBox(3)*2/3];
|
2011-09-14 14:30:32 +00:00
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% Create Patch
|
2011-09-14 14:30:32 +00:00
|
|
|
CSX = AddMetal( CSX, 'patch' ); % create a perfect electric conductor (PEC)
|
|
|
|
start = [-patch.width/2 -patch.length/2 substrate.thickness];
|
|
|
|
stop = [ patch.width/2 patch.length/2 substrate.thickness];
|
|
|
|
CSX = AddBox(CSX,'patch',10,start,stop); % add a box-primitive to the metal property 'patch'
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% Create Substrate
|
2011-09-14 14:30:32 +00:00
|
|
|
CSX = AddMaterial( CSX, 'substrate' );
|
|
|
|
CSX = SetMaterialProperty( CSX, 'substrate', 'Epsilon', substrate.epsR, 'Kappa', substrate.kappa );
|
|
|
|
start = [-substrate.width/2 -substrate.length/2 0];
|
|
|
|
stop = [ substrate.width/2 substrate.length/2 substrate.thickness];
|
|
|
|
CSX = AddBox( CSX, 'substrate', 0, start, stop );
|
|
|
|
|
2012-11-07 13:09:48 +00:00
|
|
|
% add extra cells to discretize the substrate thickness
|
|
|
|
mesh.z = [linspace(0,substrate.thickness,substrate.cells+1) mesh.z];
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% Create Ground same size as substrate
|
2011-09-14 14:30:32 +00:00
|
|
|
CSX = AddMetal( CSX, 'gnd' ); % create a perfect electric conductor (PEC)
|
|
|
|
start(3)=0;
|
|
|
|
stop(3) =0;
|
|
|
|
CSX = AddBox(CSX,'gnd',10,start,stop);
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% Apply the Excitation & Resist as a Current Source
|
2013-01-22 08:22:01 +00:00
|
|
|
start = [feed.pos 0 0];
|
|
|
|
stop = [feed.pos 0 substrate.thickness];
|
2012-11-09 14:41:59 +00:00
|
|
|
[CSX port] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], true);
|
2011-09-14 14:30:32 +00:00
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% Finalize the Mesh
|
2013-08-15 14:55:51 +00:00
|
|
|
% detect all edges except of the patch
|
|
|
|
mesh = DetectEdges(CSX, mesh,'ExcludeProperty','patch');
|
|
|
|
% detect and set a special 2D metal edge mesh for the patch
|
|
|
|
mesh = DetectEdges(CSX, mesh,'SetProperty','patch','2D_Metal_Edge_Res', c0/(f0+fc)/unit/50);
|
2012-11-07 13:09:48 +00:00
|
|
|
% generate a smooth mesh with max. cell size: lambda_min / 20
|
2013-08-15 14:55:51 +00:00
|
|
|
mesh = SmoothMesh(mesh, c0/(f0+fc)/unit/20);
|
2012-11-07 13:09:48 +00:00
|
|
|
CSX = DefineRectGrid(CSX, unit, mesh);
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
CSX = AddDump(CSX,'Hf', 'DumpType', 11, 'Frequency',[2.4e9]);
|
|
|
|
CSX = AddBox(CSX,'Hf',10,[-substrate.width -substrate.length -10*substrate.thickness],[substrate.width +substrate.length 10*substrate.thickness]); %assign box
|
|
|
|
|
|
|
|
% add a nf2ff calc box; size is 3 cells away from MUR boundary condition
|
2012-02-21 09:59:19 +00:00
|
|
|
start = [mesh.x(4) mesh.y(4) mesh.z(4)];
|
|
|
|
stop = [mesh.x(end-3) mesh.y(end-3) mesh.z(end-3)];
|
|
|
|
[CSX nf2ff] = CreateNF2FFBox(CSX, 'nf2ff', start, stop);
|
2011-09-14 14:30:32 +00:00
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
%% Prepare and Run Simulation
|
2012-02-07 09:13:50 +00:00
|
|
|
Sim_Path = 'tmp_Patch_Ant';
|
2011-09-14 14:30:32 +00:00
|
|
|
Sim_CSX = 'patch_ant.xml';
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% create an empty working directory
|
2011-09-14 14:30:32 +00:00
|
|
|
[status, message, messageid] = rmdir( Sim_Path, 's' ); % clear previous directory
|
|
|
|
[status, message, messageid] = mkdir( Sim_Path ); % create empty simulation folder
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% write openEMS compatible xml-file
|
2011-09-14 14:30:32 +00:00
|
|
|
WriteOpenEMS( [Sim_Path '/' Sim_CSX], FDTD, CSX );
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% show the structure
|
2011-09-14 14:30:32 +00:00
|
|
|
CSXGeomPlot( [Sim_Path '/' Sim_CSX] );
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% run openEMS
|
2012-02-07 09:13:50 +00:00
|
|
|
RunOpenEMS( Sim_Path, Sim_CSX);
|
2011-09-14 14:30:32 +00:00
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
%% Postprocessing & Plots
|
2011-09-14 14:30:32 +00:00
|
|
|
freq = linspace( max([1e9,f0-fc]), f0+fc, 501 );
|
2012-11-09 14:41:59 +00:00
|
|
|
port = calcPort(port, Sim_Path, freq);
|
|
|
|
|
2016-11-29 19:54:34 +00:00
|
|
|
%% Smith chart port reflection
|
|
|
|
plotRefl(port, 'threshold', -10)
|
|
|
|
title( 'reflection coefficient' );
|
2011-09-14 14:30:32 +00:00
|
|
|
|
|
|
|
% plot feed point impedance
|
2016-11-29 19:54:34 +00:00
|
|
|
Zin = port.uf.tot ./ port.if.tot;
|
2011-09-14 14:30:32 +00:00
|
|
|
figure
|
|
|
|
plot( freq/1e6, real(Zin), 'k-', 'Linewidth', 2 );
|
|
|
|
hold on
|
|
|
|
grid on
|
|
|
|
plot( freq/1e6, imag(Zin), 'r--', 'Linewidth', 2 );
|
|
|
|
title( 'feed point impedance' );
|
|
|
|
xlabel( 'frequency f / MHz' );
|
|
|
|
ylabel( 'impedance Z_{in} / Ohm' );
|
|
|
|
legend( 'real', 'imag' );
|
|
|
|
|
|
|
|
% plot reflection coefficient S11
|
2016-11-29 19:54:34 +00:00
|
|
|
s11 = port.uf.ref ./ port.uf.inc;
|
2011-09-14 14:30:32 +00:00
|
|
|
figure
|
|
|
|
plot( freq/1e6, 20*log10(abs(s11)), 'k-', 'Linewidth', 2 );
|
|
|
|
grid on
|
|
|
|
title( 'reflection coefficient S_{11}' );
|
|
|
|
xlabel( 'frequency f / MHz' );
|
|
|
|
ylabel( 'reflection coefficient |S_{11}|' );
|
|
|
|
|
2012-01-17 14:49:37 +00:00
|
|
|
drawnow
|
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
%% NFFF Plots
|
2011-09-14 14:30:32 +00:00
|
|
|
%find resonance frequncy from s11
|
|
|
|
f_res_ind = find(s11==min(s11));
|
|
|
|
f_res = freq(f_res_ind);
|
|
|
|
|
|
|
|
% calculate the far field at phi=0 degrees and at phi=90 degrees
|
|
|
|
disp( 'calculating far field at phi=[0 90] deg...' );
|
|
|
|
|
2012-02-21 09:59:19 +00:00
|
|
|
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_res, [-180:2:180]*pi/180, [0 90]*pi/180);
|
2011-09-14 14:30:32 +00:00
|
|
|
|
|
|
|
% display power and directivity
|
2012-02-07 09:13:50 +00:00
|
|
|
disp( ['radiated power: Prad = ' num2str(nf2ff.Prad) ' Watt']);
|
|
|
|
disp( ['directivity: Dmax = ' num2str(nf2ff.Dmax) ' (' num2str(10*log10(nf2ff.Dmax)) ' dBi)'] );
|
2013-12-09 13:31:20 +00:00
|
|
|
disp( ['efficiency: nu_rad = ' num2str(100*nf2ff.Prad./port.P_inc(f_res_ind)) ' %']);
|
2011-09-14 14:30:32 +00:00
|
|
|
|
2013-08-22 09:43:04 +00:00
|
|
|
% normalized directivity as polar plot
|
|
|
|
figure
|
|
|
|
polarFF(nf2ff,'xaxis','theta','param',[1 2],'normalize',1)
|
|
|
|
|
2013-08-22 09:37:54 +00:00
|
|
|
% log-scale directivity plot
|
2013-08-15 14:55:51 +00:00
|
|
|
figure
|
2013-08-22 09:37:54 +00:00
|
|
|
plotFFdB(nf2ff,'xaxis','theta','param',[1 2])
|
|
|
|
% conventional plot approach
|
|
|
|
% plot( nf2ff.theta*180/pi, 20*log10(nf2ff.E_norm{1}/max(nf2ff.E_norm{1}(:)))+10*log10(nf2ff.Dmax));
|
2013-06-04 22:45:55 +00:00
|
|
|
|
2013-08-15 14:55:51 +00:00
|
|
|
drawnow
|
2011-09-14 14:30:32 +00:00
|
|
|
|
2017-02-11 18:46:26 +00:00
|
|
|
% Show 3D pattern
|
2012-02-21 09:59:19 +00:00
|
|
|
disp( 'calculating 3D far field pattern and dumping to vtk (use Paraview to visualize)...' );
|
|
|
|
thetaRange = (0:2: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');
|
2013-08-15 14:55:51 +00:00
|
|
|
|
2013-06-04 22:45:55 +00:00
|
|
|
figure
|
2013-08-15 14:55:51 +00:00
|
|
|
plotFF3D(nf2ff,'logscale',-20);
|
2013-06-04 22:45:55 +00:00
|
|
|
|
2012-02-21 09:59:19 +00:00
|
|
|
|
|
|
|
E_far_normalized = nf2ff.E_norm{1} / max(nf2ff.E_norm{1}(:)) * nf2ff.Dmax;
|
2013-05-29 12:05:46 +00:00
|
|
|
DumpFF2VTK([Sim_Path '/3D_Pattern.vtk'],E_far_normalized,thetaRange,phiRange,'scale',1e-3);
|