Tutorials: update to use the new port and meshing functions

pull/1/head
Thorsten Liebig 2012-11-09 15:41:59 +01:00
parent 7b3ded8f22
commit ebc6930132
5 changed files with 26 additions and 42 deletions

View File

@ -38,7 +38,7 @@ f_start = 0.8e9;
f_stop = 6e9;
%% setup FDTD parameters & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%
FDTD = InitFDTD( 20000 );
FDTD = InitFDTD();
FDTD = SetGaussExcite( FDTD, (f_start+f_stop)/2, (f_stop-f_start)/2 );
BC = {'PML_8' 'PML_8' 'MUR' 'MUR' 'PEC' 'PML_8'};
FDTD = SetBoundaryCond( FDTD, BC );
@ -56,9 +56,7 @@ mesh.z = [0 cumsum(substrate_thickness) linspace(substratelines(end-1),substrate
[CSX mesh] = CreateCRLH(CSX, mesh, CRLH, resolution/4);
% Smooth the given mesh
mesh.x = SmoothMeshLines(mesh.x, resolution, 1.5, 0);
mesh.y = SmoothMeshLines(mesh.y, resolution, 1.5, 0);
mesh.z = SmoothMeshLines(mesh.z, resolution, 1.5, 0);
mesh = SmoothMesh(mesh, resolution, 1.5);
CSX = DefineRectGrid( CSX, unit, mesh );
%% Setup the substrate layer
@ -75,11 +73,11 @@ end
CSX = AddMetal( CSX, 'PEC' );
portstart = [ mesh.x(1) , -CRLH.LW/2, substratelines(end)];
portstop = [ -CRLH.LL/2, CRLH.LW/2, 0];
[CSX,portstruct{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', 'excite', 'FeedShift', 10*resolution(1), 'MeasPlaneShift', feed_length/2);
[CSX,port{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', 'excite', 'FeedShift', 10*resolution(1), 'MeasPlaneShift', feed_length/2);
portstart = [ mesh.x(end) , -CRLH.LW/2, substratelines(end)];
portstop = [ +CRLH.LL/2, CRLH.LW/2, 0];
[CSX,portstruct{2}] = AddMSLPort( CSX, 999, 2, 'PEC', portstart, portstop, 0, [0 0 -1], 'MeasPlaneShift', feed_length/2 );
[CSX,port{2}] = AddMSLPort( CSX, 999, 2, 'PEC', portstart, portstop, 0, [0 0 -1], 'MeasPlaneShift', feed_length/2 );
%% write/show/run the openEMS compatible xml-file
Sim_Path = 'tmp';
@ -95,8 +93,7 @@ RunOpenEMS( Sim_Path, Sim_CSX );
%% post-processing
close all
f = linspace( f_start, f_stop, 1601 );
port{1} = calcPort( portstruct{1}, Sim_Path, f, 'RefPlaneShift', feed_length);
port{2} = calcPort( portstruct{2}, Sim_Path, f, 'RefPlaneShift', feed_length);
port = calcPort( port, Sim_Path, f, 'RefPlaneShift', feed_length);
s11 = port{1}.uf.ref./ port{1}.uf.inc;
s21 = port{2}.uf.ref./ port{1}.uf.inc;
@ -113,7 +110,7 @@ ylim([-40 2]);
%% extract parameter
A = ((1+s11).*(1-s11) + s21.*s21)./(2*s21);
C = ((1-s11).*(1-s11) - s21.*s21)./(2*s21) ./ port{1}.ZL;
C = ((1-s11).*(1-s11) - s21.*s21)./(2*s21) ./ port{2}.ZL;
Y = C;
Z = 2*(A-1)./C;

View File

@ -70,9 +70,7 @@ for n=1:N_Cells
end
% Smooth the given mesh
mesh.x = SmoothMeshLines(mesh.x, resolution, 1.5, 0);
mesh.y = SmoothMeshLines(mesh.y, resolution, 1.5, 0);
mesh.z = SmoothMeshLines(mesh.z, resolution, 1.5, 0);
mesh = SmoothMesh(mesh, resolution, 1.5);
CSX = DefineRectGrid( CSX, unit, mesh );
%% Setup the substrate layer
@ -95,11 +93,11 @@ CSX = AddBox( CSX, 'ground', 0, start, stop );
CSX = AddMetal( CSX, 'PEC' );
portstart = [ -feed_length-(N_Cells*CRLH.LL)/2 , -CRLH.LW/2, substratelines(end)];
portstop = [ -(N_Cells*CRLH.LL)/2, CRLH.LW/2, 0];
[CSX,portstruct{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', 'excite', 'MeasPlaneShift', feed_length/2, 'Feed_R', 50);
[CSX,port{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', true, 'MeasPlaneShift', feed_length/2, 'Feed_R', 50);
portstart = [ feed_length+(N_Cells*CRLH.LL)/2 , -CRLH.LW/2, substratelines(end)];
portstop = [ +(N_Cells*CRLH.LL)/2, CRLH.LW/2, 0];
[CSX,portstruct{2}] = AddMSLPort( CSX, 999, 2, 'PEC', portstart, portstop, 0, [0 0 -1], 'MeasPlaneShift', feed_length/2, 'Feed_R', 50 );
[CSX,port{2}] = AddMSLPort( CSX, 999, 2, 'PEC', portstart, portstop, 0, [0 0 -1], 'MeasPlaneShift', feed_length/2, 'Feed_R', 50 );
%% nf2ff calc
start = [mesh.x(1) mesh.y(1) mesh.z(1) ] + 10*resolution;
@ -120,8 +118,7 @@ RunOpenEMS( Sim_Path, Sim_CSX );
%% post-processing
close all
f = linspace( f_start, f_stop, 1601 );
port{1} = calcPort( portstruct{1}, Sim_Path, f, 'RefPlaneShift', feed_length*unit);
port{2} = calcPort( portstruct{2}, Sim_Path, f, 'RefPlaneShift', feed_length*unit);
port = calcPort( port, Sim_Path, f, 'RefPlaneShift', feed_length*unit);
s11 = port{1}.uf.ref./ port{1}.uf.inc;
s21 = port{2}.uf.ref./ port{1}.uf.inc;

View File

@ -97,7 +97,7 @@ CSX = AddCylinder(CSX,'gnd',10,start,stop,gnd.radius);
%% apply the excitation & resist as a current source
start = [Helix.radius-feed.width/2 -feed.width/2 0];
stop = [Helix.radius+feed.width/2 +feed.width/2 feed.heigth];
[CSX] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], 'excite');
[CSX port] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], true);
%%nf2ff calc
start = [mesh.x(11) mesh.y(11) mesh.z(11)];
@ -124,12 +124,14 @@ end
%% postprocessing & do the plots
freq = linspace( f0-fc, f0+fc, 501 );
U = ReadUI( {'port_ut1','et'}, Sim_Path, freq ); % time domain/freq domain voltage
I = ReadUI( 'port_it1', Sim_Path, freq ); % time domain/freq domain current (half time step is corrected)
port = calcPort(port, Sim_Path, freq);
Zin = port.uf.tot ./ port.if.tot;
s11 = port.uf.ref ./ port.uf.inc;
P_in = 0.5 * port.uf.inc .* conj( port.if.inc ); % antenna feed power
% plot feed point impedance
figure
Zin = U.FD{1}.val ./ I.FD{1}.val;
plot( freq/1e6, real(Zin), 'k-', 'Linewidth', 2 );
hold on
grid on
@ -141,19 +143,12 @@ legend( 'real', 'imag' );
% plot reflection coefficient S11
figure
uf_inc = 0.5*(U.FD{1}.val + I.FD{1}.val * feed.R);
if_inc = 0.5*(I.FD{1}.val + U.FD{1}.val / feed.R);
uf_ref = U.FD{1}.val - uf_inc;
if_ref = if_inc - I.FD{1}.val;
s11 = uf_ref ./ uf_inc;
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}|' );
P_in = 0.5*uf_inc .* conj( if_inc ); % accepted antenna feed power
drawnow
%% NFFF contour plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -166,7 +161,7 @@ P_in_0 = interp1(freq, P_in, f0);
% calculate the far field at phi=0 degrees and at phi=90 degrees
thetaRange = unique([0:0.5:90 90:180]);
phiRange = (0:2:360) - 180;
disp( 'calculating far field at phi=[0 90] deg...' );
disp( 'calculating the 3D far field...' );
nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_res, thetaRange*pi/180, phiRange*pi/180,'Mode',1,'Outfile','3D_Pattern.h5','Verbose',1);

View File

@ -51,11 +51,11 @@ CSX = AddBox( CSX, 'RO4350B', 0, start, stop );
CSX = AddMetal( CSX, 'PEC' );
portstart = [ mesh.x(1), -MSL_width/2, substrate_thickness];
portstop = [ 0, MSL_width/2, 0];
[CSX,portstruct{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', true, 'FeedShift', 10*resolution, 'MeasPlaneShift', MSL_length/3);
[CSX,port{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', true, 'FeedShift', 10*resolution, 'MeasPlaneShift', MSL_length/3);
portstart = [mesh.x(end), -MSL_width/2, substrate_thickness];
portstop = [0 , MSL_width/2, 0];
[CSX,portstruct{2}] = AddMSLPort( CSX, 999, 2, 'PEC', portstart, portstop, 0, [0 0 -1], 'MeasPlaneShift', MSL_length/3 );
[CSX,port{2}] = AddMSLPort( CSX, 999, 2, 'PEC', portstart, portstop, 0, [0 0 -1], 'MeasPlaneShift', MSL_length/3 );
%% Filter-stub
start = [-MSL_width/2, MSL_width/2, substrate_thickness];
@ -76,8 +76,7 @@ RunOpenEMS( Sim_Path, Sim_CSX );
%% post-processing
close all
f = linspace( 1e6, f_max, 1601 );
port{1} = calcPort( portstruct{1}, Sim_Path, f, 'RefImpedance', 50);
port{2} = calcPort( portstruct{2}, Sim_Path, f, 'RefImpedance', 50);
port = calcPort( port, Sim_Path, f, 'RefImpedance', 50);
s11 = port{1}.uf.ref./ port{1}.uf.inc;
s21 = port{2}.uf.ref./ port{1}.uf.inc;

View File

@ -80,7 +80,7 @@ CSX = AddBox(CSX,'gnd',10,start,stop);
%% apply the excitation & resist as a current source
start = [feed.pos-feed.width/2 -feed.width/2 0];
stop = [feed.pos+feed.width/2 +feed.width/2 substrate.thickness];
[CSX] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], true);
[CSX port] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], true);
%% finalize the mesh
% generate a smooth mesh with max. cell size: lambda_min / 20
@ -111,12 +111,14 @@ RunOpenEMS( Sim_Path, Sim_CSX);
%% postprocessing & do the plots
freq = linspace( max([1e9,f0-fc]), f0+fc, 501 );
U = ReadUI( {'port_ut1','et'}, Sim_Path, freq ); % time domain/freq domain voltage
I = ReadUI( 'port_it1', Sim_Path, freq ); % time domain/freq domain current (half time step is corrected)
port = calcPort(port, Sim_Path, freq);
Zin = port.uf.tot ./ port.if.tot;
s11 = port.uf.ref ./ port.uf.inc;
P_in = 0.5 * port.uf.inc .* conj( port.if.inc ); % antenna feed power
% plot feed point impedance
figure
Zin = U.FD{1}.val ./ I.FD{1}.val;
plot( freq/1e6, real(Zin), 'k-', 'Linewidth', 2 );
hold on
grid on
@ -128,18 +130,12 @@ legend( 'real', 'imag' );
% plot reflection coefficient S11
figure
uf_inc = 0.5*(U.FD{1}.val + I.FD{1}.val * 50);
if_inc = 0.5*(I.FD{1}.val + U.FD{1}.val / 50);
uf_ref = U.FD{1}.val - uf_inc;
if_ref = if_inc - I.FD{1}.val;
s11 = uf_ref ./ uf_inc;
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}|' );
P_in = 0.5*U.FD{1}.val .* conj( I.FD{1}.val ); % antenna feed power
drawnow