matlab API change: ports now need a priority!
This commit is contained in:
parent
02f929aa53
commit
9a77f18637
@ -1,15 +1,16 @@
|
||||
function [CSX,port] = AddCurvePort( CSX, portnr, R, start, stop, excitename )
|
||||
%[CSX,port] = AddCurvePort( CSX, portnr, R, start, stop [, excitename] )
|
||||
function [CSX,port] = AddCurvePort( CSX, prio, portnr, R, start, stop, excitename )
|
||||
%[CSX,port] = AddCurvePort( CSX, prio, portnr, R, start, stop [, excitename] )
|
||||
%
|
||||
% Creates a curve port (1-dimensional).
|
||||
% The mesh must already be initialized.
|
||||
%
|
||||
% input:
|
||||
% CSX: CSX-object created by InitCSX()
|
||||
% CSX: CSX-object created by InitCSX()
|
||||
% prio: priority for excitation, metal, sheet and probe boxes
|
||||
% portnr: (integer) number of the port
|
||||
% R: internal resistance of the port
|
||||
% start: 3D start rowvector for port definition
|
||||
% stop: 3D end rowvector for port definition
|
||||
% R: internal resistance of the port
|
||||
% start: 3D start rowvector for port definition
|
||||
% stop: 3D end rowvector for port definition
|
||||
% excitename (optional): if specified, the port will be switched on (see AddExcitation())
|
||||
%
|
||||
% output:
|
||||
@ -75,8 +76,8 @@ if abs(start_idx(dir) - stop_idx(dir)) ~= 1
|
||||
port_stop_idx(dir2) = idx2;
|
||||
metalname = ['port' num2str(portnr) '_PEC'];
|
||||
CSX = AddMetal( CSX, metalname );
|
||||
CSX = AddCurve( CSX, metalname, 999, [nstart.' [mesh{1}(port_start_idx(1));mesh{2}(port_start_idx(2));mesh{3}(port_start_idx(3))]] );
|
||||
CSX = AddCurve( CSX, metalname, 999, [nstop.' [mesh{1}(port_stop_idx(1));mesh{2}(port_stop_idx(2));mesh{3}(port_stop_idx(3))]] );
|
||||
CSX = AddCurve( CSX, metalname, prio, [nstart.' [mesh{1}(port_start_idx(1));mesh{2}(port_start_idx(2));mesh{3}(port_start_idx(3))]] );
|
||||
CSX = AddCurve( CSX, metalname, prio, [nstop.' [mesh{1}(port_stop_idx(1));mesh{2}(port_stop_idx(2));mesh{3}(port_stop_idx(3))]] );
|
||||
end
|
||||
|
||||
% calculate position of resistive material
|
||||
@ -106,7 +107,7 @@ CSX = AddMaterial( CSX, materialname );%, 'Isotropy', 0 );
|
||||
% kappa_cell{dir} = kappa;
|
||||
kappa_cell = kappa;
|
||||
CSX = SetMaterialProperty( CSX, materialname, 'Kappa', kappa_cell );
|
||||
CSX = AddBox( CSX, materialname, 999, m_start, m_stop );
|
||||
CSX = AddBox( CSX, materialname, prio, m_start, m_stop );
|
||||
|
||||
% calculate position of the voltage probe
|
||||
v_start = [mesh{1}(port_start_idx(1)), mesh{2}(port_start_idx(2)), mesh{3}(port_start_idx(3))];
|
||||
@ -122,11 +123,11 @@ i_stop(dir) = i_start(dir);
|
||||
name = ['port_ut' num2str(portnr)];
|
||||
weight = -1;
|
||||
CSX = AddProbe( CSX, name, 0, weight );
|
||||
CSX = AddBox( CSX, name, 999, v_start, v_stop );
|
||||
CSX = AddBox( CSX, name, prio, v_start, v_stop );
|
||||
name = ['port_it' num2str(portnr)];
|
||||
weight = 1;
|
||||
CSX = AddProbe( CSX, name, 1, weight );
|
||||
CSX = AddBox( CSX, name, 999, i_start, i_stop );
|
||||
CSX = AddBox( CSX, name, prio, i_start, i_stop );
|
||||
|
||||
% create port structure
|
||||
port.nr = portnr;
|
||||
@ -151,5 +152,5 @@ if (nargin >= 6) && ~isempty(excitename)
|
||||
e_start = v_start;
|
||||
e_stop = v_stop;
|
||||
CSX = AddExcitation( CSX, excitename, 0, start_idx ~= stop_idx );
|
||||
CSX = AddBox( CSX, excitename, 999, e_start, e_stop );
|
||||
CSX = AddBox( CSX, excitename, prio, e_start, e_stop );
|
||||
end
|
||||
|
@ -1,12 +1,13 @@
|
||||
function [CSX,port] = AddLumpedPort( CSX, portnr, R, start, stop, dir, excitename )
|
||||
% [CSX,port] = AddLumpedPort( CSX, portnr, R, start, stop, dir, excitename )
|
||||
function [CSX,port] = AddLumpedPort( CSX, prio, portnr, R, start, stop, dir, excitename )
|
||||
% [CSX,port] = AddLumpedPort( CSX, prio, portnr, R, start, stop, dir, excitename )
|
||||
%
|
||||
% CSX: CSX-object created by InitCSX()
|
||||
% portnr: (integer) number of the port
|
||||
% R: internal resistance of the port
|
||||
% start: 3D start rowvector for port definition
|
||||
% stop: 3D end rowvector for port definition
|
||||
% dir: direction of of port (choices: [1 0 0], [0 1 0] or [0 0 1])
|
||||
% CSX: CSX-object created by InitCSX()
|
||||
% prio: priority for substrate and probe boxes
|
||||
% portnr: (integer) number of the port
|
||||
% R: internal resistance of the port
|
||||
% start: 3D start rowvector for port definition
|
||||
% stop: 3D end rowvector for port definition
|
||||
% dir: direction of of port (choices: [1 0 0], [0 1 0] or [0 0 1])
|
||||
% excitename (optional): if specified, the port will be switched on (see AddExcitation())
|
||||
%
|
||||
% the mesh must be already initialized
|
||||
@ -27,6 +28,10 @@ if ~(dir(1) == dir(2) == 0) && ~(dir(1) == dir(3) == 0) && ~(dir(2) == dir(3) ==
|
||||
end
|
||||
dir = dir ./ sum(dir); % dir is now a unit vector
|
||||
|
||||
if (~isfield(CSX,'RectilinearGrid'))
|
||||
error('openEMS:AddLumpedPort','Mesh not found in CSX structure... use DefineRectGrid() first!!');
|
||||
end
|
||||
|
||||
% get grid
|
||||
mesh{1} = sort(CSX.RectilinearGrid.XLines);
|
||||
mesh{2} = sort(CSX.RectilinearGrid.YLines);
|
||||
@ -87,7 +92,7 @@ kappa_cell{1} = kappa*dir(1);
|
||||
kappa_cell{2} = kappa*dir(2);
|
||||
kappa_cell{3} = kappa*dir(3);
|
||||
CSX = SetMaterialProperty( CSX, ['port' num2str(portnr) '_sheet_resistance'], 'Kappa', kappa_cell );
|
||||
CSX = AddBox( CSX, ['port' num2str(portnr) '_sheet_resistance'], 999, m_start, m_stop );
|
||||
CSX = AddBox( CSX, ['port' num2str(portnr) '_sheet_resistance'], prio, m_start, m_stop );
|
||||
|
||||
% calculate position of the voltage probe
|
||||
v_start(idx_plane) = start(idx_plane);
|
||||
@ -115,11 +120,11 @@ i_stop(idx_plane) = nstop(idx_plane) + delta2_p/2;
|
||||
name = ['port_ut' num2str(portnr)];
|
||||
weight = -direction;
|
||||
CSX = AddProbe( CSX, name, 0, weight );
|
||||
CSX = AddBox( CSX, name, 999, v_start, v_stop );
|
||||
CSX = AddBox( CSX, name, prio, v_start, v_stop );
|
||||
name = ['port_it' num2str(portnr)];
|
||||
weight = direction;
|
||||
CSX = AddProbe( CSX, name, 1, weight );
|
||||
CSX = AddBox( CSX, name, 999, i_start, i_stop );
|
||||
CSX = AddBox( CSX, name, prio, i_start, i_stop );
|
||||
|
||||
% create port structure
|
||||
port.nr = portnr;
|
||||
@ -146,5 +151,5 @@ if (nargin >= 7) && ~isempty(excitename)
|
||||
e_start(idx_plane) = start(idx_plane); % excitation-plane is determined by start vector
|
||||
e_stop(idx_plane) = start(idx_plane);
|
||||
CSX = AddExcitation( CSX, excitename, 0, -dir*direction);
|
||||
CSX = AddBox( CSX, excitename, 999, e_start, e_stop );
|
||||
CSX = AddBox( CSX, excitename, prio, e_start, e_stop );
|
||||
end
|
||||
|
@ -1,13 +1,14 @@
|
||||
function [CSX,port] = AddMSLPort( CSX, portnr, materialname, start, stop, dir, evec, refplaneshift, excitename )
|
||||
% [CSX,port] = AddMSLPort( CSX, portnr, materialname, start, stop, dir, evec, refplaneshift, excitename )
|
||||
function [CSX,port] = AddMSLPort( CSX, prio, portnr, materialname, start, stop, dir, evec, refplaneshift, excitename )
|
||||
% [CSX,port] = AddMSLPort( CSX, prio, portnr, materialname, start, stop, dir, evec, refplaneshift, excitename )
|
||||
%
|
||||
% CSX: CSX-object created by InitCSX()
|
||||
% portnr: (integer) number of the port
|
||||
% CSX: CSX-object created by InitCSX()
|
||||
% prio: priority for excitation and probe boxes
|
||||
% portnr: (integer) number of the port
|
||||
% materialname: property for the MSL (created by AddMetal() or AddMaterial())
|
||||
% start: 3D start rowvector for port definition
|
||||
% stop: 3D end rowvector for port definition
|
||||
% dir: direction of wave propagation (choices: [1 0 0], [0 1 0] or [0 0 1])
|
||||
% evec: excitation vector, which defines the direction of the e-field (must be the same as used in AddExcitation())
|
||||
% start: 3D start rowvector for port definition
|
||||
% stop: 3D end rowvector for port definition
|
||||
% dir: direction of wave propagation (choices: [1 0 0], [0 1 0] or [0 0 1])
|
||||
% evec: excitation vector, which defines the direction of the e-field (must be the same as used in AddExcitation())
|
||||
% refplaneshift (optional): if not specified or empty, the measurement
|
||||
% plane is used; if specified, reference plane is shifted by
|
||||
% <refplaneshift> starting from <start> (thus refplaneshift is normally
|
||||
@ -63,7 +64,7 @@ end
|
||||
MSL_start = start;
|
||||
MSL_stop = stop;
|
||||
MSL_stop(idx_height) = MSL_start(idx_height);
|
||||
CSX = AddBox( CSX, materialname, 999, MSL_start, MSL_stop );
|
||||
CSX = AddBox( CSX, materialname, prio, MSL_start, MSL_stop );
|
||||
|
||||
% FIXME
|
||||
% openEMS v0.0.7 does not snap PEC
|
||||
@ -112,20 +113,20 @@ i2_stop(idx_prop) = i2_start(idx_prop);
|
||||
name = ['port_ut' num2str(portnr) 'A'];
|
||||
weight = sum(evec);
|
||||
CSX = AddProbe( CSX, name, 0, weight );
|
||||
CSX = AddBox( CSX, name, 999, v1_start, v1_stop );
|
||||
CSX = AddBox( CSX, name, prio, v1_start, v1_stop );
|
||||
name = ['port_ut' num2str(portnr) 'B'];
|
||||
CSX = AddProbe( CSX, name, 0, weight );
|
||||
CSX = AddBox( CSX, name, 999, v2_start, v2_stop );
|
||||
CSX = AddBox( CSX, name, prio, v2_start, v2_stop );
|
||||
name = ['port_ut' num2str(portnr) 'C'];
|
||||
CSX = AddProbe( CSX, name, 0, weight );
|
||||
CSX = AddBox( CSX, name, 999, v3_start, v3_stop );
|
||||
CSX = AddBox( CSX, name, prio, v3_start, v3_stop );
|
||||
name = ['port_it' num2str(portnr) 'A'];
|
||||
weight = direction;
|
||||
CSX = AddProbe( CSX, name, 1, weight );
|
||||
CSX = AddBox( CSX, name, 999, i1_start, i1_stop );
|
||||
CSX = AddBox( CSX, name, prio, i1_start, i1_stop );
|
||||
name = ['port_it' num2str(portnr) 'B'];
|
||||
CSX = AddProbe( CSX, name, 1, weight );
|
||||
CSX = AddBox( CSX, name, 999, i2_start, i2_stop );
|
||||
CSX = AddBox( CSX, name, prio, i2_start, i2_stop );
|
||||
|
||||
% create port structure
|
||||
port.nr = portnr;
|
||||
@ -171,5 +172,5 @@ if nargin >= 9
|
||||
ex_stop(idx_width) = nstop(idx_width);
|
||||
ex_stop(idx_height) = nstop(idx_height);
|
||||
CSX = AddExcitation( CSX, excitename, 0, evec );
|
||||
CSX = AddBox( CSX, excitename, 999, ex_start, ex_stop );
|
||||
CSX = AddBox( CSX, excitename, prio, ex_start, ex_stop );
|
||||
end
|
||||
|
@ -106,7 +106,7 @@ CSX = AddBox(CSX,'gnd',10,start,stop);
|
||||
%% apply the excitation & resist as a current source
|
||||
start = [feed.pos -feed.width/2 0];
|
||||
stop = [feed.pos +feed.width/2 substrate.thickness];
|
||||
[CSX port] = AddLumpedPort(CSX,1,feed.R, start, stop,[0 0 1],'excite');
|
||||
[CSX port] = AddLumpedPort(CSX,5,1,feed.R, start, stop,[0 0 1],'excite');
|
||||
|
||||
%% dump magnetic field over the patch antenna
|
||||
CSX = AddDump( CSX, 'Ht_', 'DumpType', 1, 'DumpMode', 2); % cell interpolated
|
||||
|
@ -133,7 +133,7 @@ for xn=1:array.xn
|
||||
% apply the excitation & resist as a current source
|
||||
start = [midX+feed.pos midY-feed.width/2 0];
|
||||
stop = [midX+feed.pos midY+feed.width/2 substrate.thickness];
|
||||
[CSX port] = AddLumpedPort(CSX,number,feed.R, start, stop,[0 0 1],['excite_' int2str(xn) '_' int2str(yn)]);
|
||||
[CSX port] = AddLumpedPort(CSX, 5, number,feed.R, start, stop,[0 0 1],['excite_' int2str(xn) '_' int2str(yn)]);
|
||||
number=number+1;
|
||||
end
|
||||
end
|
||||
|
@ -75,7 +75,7 @@ CSX = AddBox( CSX, 'RO4350B', 0, start, stop );
|
||||
CSX = AddMetal( CSX, 'PEC' );
|
||||
portstart = [ 0, -MSL_width/2, substrate_thickness];
|
||||
portstop = [ MSL_length, MSL_width/2, 0];
|
||||
[CSX,portstruct] = AddMSLPort( CSX, 1, 'PEC', portstart, portstop, [1 0 0], [0 0 1], [], 'excite' );
|
||||
[CSX,portstruct] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, [1 0 0], [0 0 1], [], 'excite' );
|
||||
|
||||
%% MSL
|
||||
start = [-MSL_length, -MSL_width/2, substrate_thickness];
|
||||
|
@ -132,19 +132,19 @@ portexcite{simnr} = 'excite';
|
||||
% port 1: input port
|
||||
start = [-msl1.w/2, 0, pcb1.t];
|
||||
stop = [-msl1.w/2, 0, 0];
|
||||
[CSX ports{1}] = AddCurvePort( CSX, 1, 50, start, stop, portexcite{1} );
|
||||
[CSX ports{1}] = AddCurvePort( CSX, 999, 1, 50, start, stop, portexcite{1} );
|
||||
% port 2: output port
|
||||
start = [msl1.w/2, 0, pcb1.t];
|
||||
stop = [msl1.w/2, 0, 0];
|
||||
[CSX ports{2}] = AddCurvePort( CSX, 2, 50, start, stop, portexcite{2} );
|
||||
[CSX ports{2}] = AddCurvePort( CSX, 999, 2, 50, start, stop, portexcite{2} );
|
||||
% port 3: coupled port
|
||||
start = [-msl2.w/2+msl2.h/2, -pcb2.h/2, pcb1.t+pcb2.t];
|
||||
stop = [-msl2.w/2+msl2.h/2, -pcb2.h/2, 0];
|
||||
[CSX ports{3}] = AddCurvePort( CSX, 3, 50, start, stop, portexcite{3} );
|
||||
[CSX ports{3}] = AddCurvePort( CSX, 999, 3, 50, start, stop, portexcite{3} );
|
||||
% port 4: isolated port
|
||||
start = [msl2.w/2-msl2.h/2, -pcb2.h/2, pcb1.t+pcb2.t];
|
||||
stop = [msl2.w/2-msl2.h/2, -pcb2.h/2, 0];
|
||||
[CSX ports{4}] = AddCurvePort( CSX, 4, 50, start, stop, portexcite{4} );
|
||||
[CSX ports{4}] = AddCurvePort( CSX, 999, 4, 50, start, stop, portexcite{4} );
|
||||
|
||||
%% setup FDTD parameters & excitation function
|
||||
max_timesteps = 50000;
|
||||
|
Loading…
Reference in New Issue
Block a user