matlab: port API changed, excitation now with automatic name
- some tutorial examples updated Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>pull/1/head
parent
211e7170e4
commit
89edc9eb25
|
@ -1,5 +1,5 @@
|
||||||
function [CSX,port] = AddCurvePort( CSX, prio, portnr, R, start, stop, excitename )
|
function [CSX,port] = AddCurvePort( CSX, prio, portnr, R, start, stop, excite, varargin )
|
||||||
%[CSX,port] = AddCurvePort( CSX, prio, portnr, R, start, stop [, excitename] )
|
%[CSX,port] = AddCurvePort( CSX, prio, portnr, R, start, stop [, excite, varargin] )
|
||||||
%
|
%
|
||||||
% Creates a curve port (1-dimensional).
|
% Creates a curve port (1-dimensional).
|
||||||
% The mesh must already be initialized.
|
% The mesh must already be initialized.
|
||||||
|
@ -11,7 +11,9 @@ function [CSX,port] = AddCurvePort( CSX, prio, portnr, R, start, stop, excitenam
|
||||||
% R: internal resistance of the port
|
% R: internal resistance of the port
|
||||||
% start: 3D start rowvector for port definition
|
% start: 3D start rowvector for port definition
|
||||||
% stop: 3D end rowvector for port definition
|
% stop: 3D end rowvector for port definition
|
||||||
% excitename (optional): if specified, the port will be switched on (see AddExcitation())
|
% excite (optional): if true, the port will be switched on (see AddExcitation())
|
||||||
|
% Note: for legacy support a string will be accepted
|
||||||
|
% varargin (optional): additional excitations options, see also AddExcitation
|
||||||
%
|
%
|
||||||
% output:
|
% output:
|
||||||
% CSX:
|
% CSX:
|
||||||
|
@ -137,12 +139,26 @@ port.drawingunit = unit;
|
||||||
% port.idx1 = idx1;
|
% port.idx1 = idx1;
|
||||||
port.excite = 0;
|
port.excite = 0;
|
||||||
|
|
||||||
|
if (nargin < 7)
|
||||||
|
excite = false;
|
||||||
|
end
|
||||||
|
|
||||||
|
% legacy support, will be removed at some point
|
||||||
|
if ischar(excite)
|
||||||
|
warning('CSXCAD:AddCurvePort','depreceated: a string as excite option is no longer supported and will be removed in the future, please use true or false');
|
||||||
|
if ~isempty(excite)
|
||||||
|
excite = true;
|
||||||
|
else
|
||||||
|
excite = false;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
% create excitation
|
% create excitation
|
||||||
if (nargin >= 7) && ~isempty(excitename)
|
if (excite)
|
||||||
% excitation of this port is enabled
|
% excitation of this port is enabled
|
||||||
port.excite = 1;
|
port.excite = 1;
|
||||||
e_start = v_start;
|
e_start = v_start;
|
||||||
e_stop = v_stop;
|
e_stop = v_stop;
|
||||||
CSX = AddExcitation( CSX, excitename, 0, start_idx ~= stop_idx );
|
CSX = AddExcitation( CSX, ['port_excite_' num2str(portnr)], 0, start_idx ~= stop_idx, varargin{:});
|
||||||
CSX = AddBox( CSX, excitename, prio, e_start, e_stop );
|
CSX = AddBox( CSX, ['port_excite_' num2str(portnr)], prio, e_start, e_stop );
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function [CSX] = AddLumpedPort( CSX, prio, portnr, R, start, stop, dir, excitename, varargin )
|
function [CSX] = AddLumpedPort( CSX, prio, portnr, R, start, stop, dir, excite, varargin )
|
||||||
% [CSX] = AddLumpedPort( CSX, prio, portnr, R, start, stop, dir, excitename, varargin )
|
% [CSX] = AddLumpedPort( CSX, prio, portnr, R, start, stop, dir, excite, varargin )
|
||||||
%
|
%
|
||||||
% Add a 3D lumped port as an excitation.
|
% Add a 3D lumped port as an excitation.
|
||||||
%
|
%
|
||||||
|
@ -10,7 +10,8 @@ function [CSX] = AddLumpedPort( CSX, prio, portnr, R, start, stop, dir, excitena
|
||||||
% start: 3D start rowvector for port definition
|
% start: 3D start rowvector for port definition
|
||||||
% stop: 3D end rowvector for port definition
|
% stop: 3D end rowvector for port definition
|
||||||
% dir: direction/amplitude of port (e.g.: [1 0 0], [0 1 0] or [0 0 1])
|
% dir: direction/amplitude of port (e.g.: [1 0 0], [0 1 0] or [0 0 1])
|
||||||
% excitename (optional): if specified, the port will be switched on (see AddExcitation())
|
% excite (optional): if true, the port will be switched on (see AddExcitation())
|
||||||
|
% Note: for legacy support a string will be accepted
|
||||||
% varargin (optional): additional excitations options, see also AddExcitation
|
% varargin (optional): additional excitations options, see also AddExcitation
|
||||||
%
|
%
|
||||||
% example:
|
% example:
|
||||||
|
@ -58,10 +59,25 @@ elseif (R<=0)
|
||||||
CSX = AddBox(CSX,['port_resist_' int2str(portnr)], prio, start, stop);
|
CSX = AddBox(CSX,['port_resist_' int2str(portnr)], prio, start, stop);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (nargin < 8)
|
||||||
|
excite = false;
|
||||||
|
end
|
||||||
|
|
||||||
|
% legacy support, will be removed at some point
|
||||||
|
if ischar(excite)
|
||||||
|
warning('CSXCAD:AddLumpedPort','depreceated: a string as excite option is no longer supported and will be removed in the future, please use true or false');
|
||||||
|
if ~isempty(excite)
|
||||||
|
excite = true;
|
||||||
|
else
|
||||||
|
excite = false;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
% create excitation
|
% create excitation
|
||||||
if (nargin >= 8) && ~isempty(excitename)
|
if (excite)
|
||||||
CSX = AddExcitation( CSX, excitename, 0, -dir*direction, varargin{:});
|
CSX = AddExcitation( CSX, ['port_excite_' num2str(portnr)], 0, -dir*direction, varargin{:});
|
||||||
CSX = AddBox( CSX, excitename, prio, start, stop );
|
CSX = AddBox( CSX, ['port_excite_' num2str(portnr)], prio, start, stop );
|
||||||
end
|
end
|
||||||
|
|
||||||
u_start = 0.5*(start + stop);
|
u_start = 0.5*(start + stop);
|
||||||
|
|
|
@ -11,7 +11,8 @@ function [CSX,port] = AddMSLPort( CSX, prio, portnr, materialname, start, stop,
|
||||||
% evec: excitation vector, which defines the direction of the e-field (must be the same as used in AddExcitation())
|
% evec: excitation vector, which defines the direction of the e-field (must be the same as used in AddExcitation())
|
||||||
%
|
%
|
||||||
% variable input:
|
% variable input:
|
||||||
% 'ExcitePort' necessary excitation name to make the port an active feeding port
|
% 'ExcitePort' true/false to make the port an active feeding port (default
|
||||||
|
% is false)
|
||||||
% 'FeedShift' shift to port from start by a given distance in drawing
|
% 'FeedShift' shift to port from start by a given distance in drawing
|
||||||
% units. Default is 0. Only active if 'ExcitePort' is set!
|
% units. Default is 0. Only active if 'ExcitePort' is set!
|
||||||
% 'Feed_R' Specifiy a lumped port resistance. Default is no lumped
|
% 'Feed_R' Specifiy a lumped port resistance. Default is no lumped
|
||||||
|
@ -66,35 +67,41 @@ n_conv_arg = 8; % number of conventional arguments
|
||||||
%set defaults
|
%set defaults
|
||||||
feed_shift = 0;
|
feed_shift = 0;
|
||||||
feed_R = 0;
|
feed_R = 0;
|
||||||
excitename = '';
|
excite = false;
|
||||||
measplanepos = nan;
|
measplanepos = nan;
|
||||||
|
|
||||||
if (nargin>n_conv_arg)
|
excite_args = {};
|
||||||
for n=1:2:(nargin-n_conv_arg)
|
|
||||||
if (strcmp(varargin{n},'FeedShift')==1);
|
for n=1:2:numel(varargin)
|
||||||
feed_shift = varargin{n+1};
|
if (strcmp(varargin{n},'FeedShift')==1);
|
||||||
if (numel(feed_shift)>1)
|
feed_shift = varargin{n+1};
|
||||||
error 'FeedShift must be a scalar value'
|
if (numel(feed_shift)>1)
|
||||||
|
error 'FeedShift must be a scalar value'
|
||||||
|
end
|
||||||
|
elseif (strcmp(varargin{n},'Feed_R')==1);
|
||||||
|
feed_R = varargin{n+1};
|
||||||
|
if (numel(feed_shift)>1)
|
||||||
|
error 'Feed_R must be a scalar value'
|
||||||
|
end
|
||||||
|
elseif (strcmp(varargin{n},'MeasPlaneShift')==1);
|
||||||
|
measplanepos = varargin{n+1};
|
||||||
|
if (numel(feed_shift)>1)
|
||||||
|
error 'MeasPlaneShift must be a scalar value'
|
||||||
|
end
|
||||||
|
elseif (strcmp(varargin{n},'ExcitePort')==1);
|
||||||
|
if ischar(varargin{n+1})
|
||||||
|
warning('CSXCAD:AddMSLPort','depreceated: a string as excite option is no longer supported and will be removed in the future, please use true or false');
|
||||||
|
if ~isempty(excite)
|
||||||
|
excite = true;
|
||||||
|
else
|
||||||
|
excite = false;
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
excite = varargin{n+1};
|
||||||
end
|
end
|
||||||
|
else
|
||||||
if (strcmp(varargin{n},'Feed_R')==1);
|
excite_args{end+1} = varargin{n};
|
||||||
feed_R = varargin{n+1};
|
excite_args{end+1} = varargin{n+1};
|
||||||
if (numel(feed_shift)>1)
|
|
||||||
error 'Feed_R must be a scalar value'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (strcmp(varargin{n},'MeasPlaneShift')==1);
|
|
||||||
measplanepos = varargin{n+1};
|
|
||||||
if (numel(feed_shift)>1)
|
|
||||||
error 'MeasPlaneShift must be a scalar value'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (strcmp(varargin{n},'ExcitePort')==1);
|
|
||||||
excitename = varargin{n+1};
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -227,9 +234,9 @@ ex_stop(idx_prop) = ex_start(idx_prop);
|
||||||
ex_stop(idx_width) = nstop(idx_width);
|
ex_stop(idx_width) = nstop(idx_width);
|
||||||
ex_stop(idx_height) = nstop(idx_height);
|
ex_stop(idx_height) = nstop(idx_height);
|
||||||
|
|
||||||
if ~isempty(excitename)
|
if excite
|
||||||
CSX = AddExcitation( CSX, excitename, 0, evec );
|
CSX = AddExcitation( CSX, ['port_excite_' num2str(portnr)], 0, evec, excite_args{:} );
|
||||||
CSX = AddBox( CSX, excitename, prio, ex_start, ex_stop );
|
CSX = AddBox( CSX, ['port_excite_' num2str(portnr)], prio, ex_start, ex_stop );
|
||||||
end
|
end
|
||||||
if feed_R > 0
|
if feed_R > 0
|
||||||
CSX = AddLumpedElement( CSX, 'port_R', idx_height-1, 'R', feed_R );
|
CSX = AddLumpedElement( CSX, 'port_R', idx_height-1, 'R', feed_R );
|
||||||
|
|
|
@ -51,7 +51,7 @@ CSX = AddBox( CSX, 'RO4350B', 0, start, stop );
|
||||||
CSX = AddMetal( CSX, 'PEC' );
|
CSX = AddMetal( CSX, 'PEC' );
|
||||||
portstart = [ mesh.x(1), -MSL_width/2, substrate_thickness];
|
portstart = [ mesh.x(1), -MSL_width/2, substrate_thickness];
|
||||||
portstop = [ 0, MSL_width/2, 0];
|
portstop = [ 0, MSL_width/2, 0];
|
||||||
[CSX,portstruct{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', 'excite', 'FeedShift', 10*resolution, 'MeasPlaneShift', MSL_length/3);
|
[CSX,portstruct{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];
|
portstart = [mesh.x(end), -MSL_width/2, substrate_thickness];
|
||||||
portstop = [0 , MSL_width/2, 0];
|
portstop = [0 , MSL_width/2, 0];
|
||||||
|
|
|
@ -49,21 +49,15 @@ FDTD = SetBoundaryCond( FDTD, BC );
|
||||||
|
|
||||||
%% setup CSXCAD geometry & mesh
|
%% setup CSXCAD geometry & mesh
|
||||||
% currently, openEMS cannot automatically generate a mesh
|
% currently, openEMS cannot automatically generate a mesh
|
||||||
max_res = c0 / (f0+fc) / unit / 20; % cell size: lambda/20
|
|
||||||
CSX = InitCSX();
|
CSX = InitCSX();
|
||||||
|
|
||||||
%create fixed lines for the simulation box, substrate and port
|
%create fixed lines for the simulation box, substrate and port
|
||||||
mesh.x = [-SimBox(1)/2 SimBox(1)/2 -substrate.width/2 substrate.width/2 -patch.width/2 patch.width/2 feed.pos+[-feed.width/2 feed.width/2]];
|
mesh.x = [-SimBox(1)/2 SimBox(1)/2 -substrate.width/2 substrate.width/2 -patch.width/2 patch.width/2 feed.pos+[-feed.width/2 feed.width/2]];
|
||||||
mesh.x = SmoothMeshLines( mesh.x, max_res, 1.4); % create a smooth mesh between specified fixed mesh lines
|
mesh.y = [-SimBox(2)/2 SimBox(2)/2 -substrate.length/2 substrate.length/2 -feed.width/2 feed.width/2 -patch.length/2 patch.length/2];
|
||||||
|
mesh.z = [-SimBox(3)/3 SimBox(3)*2/3 linspace(0,substrate.thickness,substrate.cells) ];
|
||||||
mesh.y = [-SimBox(2)/2 SimBox(2)/2 -substrate.length/2 substrate.length/2 -feed.width/2 feed.width/2 -patch.length/2 patch.length/2];
|
% generate a smooth mesh with max. cell size: lambda_min / 20
|
||||||
mesh.y = SmoothMeshLines( mesh.y, max_res, 1.4 );
|
mesh = SmoothMesh(mesh, c0 / (f0+fc) / unit / 20);
|
||||||
|
CSX = DefineRectGrid(CSX, unit, mesh);
|
||||||
%create fixed lines for the simulation box and given number of lines inside the substrate
|
|
||||||
mesh.z = [-SimBox(3)/3 linspace(0,substrate.thickness,substrate.cells) SimBox(3)*2/3 ];
|
|
||||||
mesh.z = SmoothMeshLines( mesh.z, max_res, 1.4 );
|
|
||||||
|
|
||||||
CSX = DefineRectGrid( CSX, unit, mesh );
|
|
||||||
|
|
||||||
%% create patch
|
%% create patch
|
||||||
CSX = AddMetal( CSX, 'patch' ); % create a perfect electric conductor (PEC)
|
CSX = AddMetal( CSX, 'patch' ); % create a perfect electric conductor (PEC)
|
||||||
|
@ -87,7 +81,7 @@ CSX = AddBox(CSX,'gnd',10,start,stop);
|
||||||
%% apply the excitation & resist as a current source
|
%% apply the excitation & resist as a current source
|
||||||
start = [feed.pos-feed.width/2 -feed.width/2 0];
|
start = [feed.pos-feed.width/2 -feed.width/2 0];
|
||||||
stop = [feed.pos+feed.width/2 +feed.width/2 substrate.thickness];
|
stop = [feed.pos+feed.width/2 +feed.width/2 substrate.thickness];
|
||||||
[CSX] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], 'excite');
|
[CSX] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], true);
|
||||||
|
|
||||||
%%nf2ff calc
|
%%nf2ff calc
|
||||||
start = [mesh.x(4) mesh.y(4) mesh.z(4)];
|
start = [mesh.x(4) mesh.y(4) mesh.z(4)];
|
||||||
|
|
Loading…
Reference in New Issue