matlab: enable 'x', 'y' or 'z' as port direction char

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
pull/10/head
Thorsten Liebig 2013-07-22 15:06:52 +02:00
parent 61a595519b
commit a6f6baff2e
4 changed files with 13 additions and 21 deletions

View File

@ -7,7 +7,7 @@ function [CSX,port] = AddMSLPort( CSX, prio, portnr, materialname, start, stop,
% materialname: property for the MSL (created by AddMetal()) % materialname: property for the MSL (created by AddMetal())
% 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 of wave propagation (choices: 0 1 2) % dir: direction of wave propagation (choices: 0, 1, 2 or 'x','y','z')
% 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:
@ -18,10 +18,8 @@ function [CSX,port] = AddMSLPort( CSX, prio, portnr, materialname, start, stop,
% 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
% port resistance --> port has to end in an ABC. % port resistance --> port has to end in an ABC.
% Only active if 'ExcitePort' is set!
% 'MeasPlaneShift' Shift the measurement plane from start t a given distance % 'MeasPlaneShift' Shift the measurement plane from start t a given distance
% in drawing units. Default is the middle of start/stop. % in drawing units. Default is the middle of start/stop.
% Only active if 'ExcitePort' is set!
% 'PortNamePrefix' a prefix to the port name % 'PortNamePrefix' a prefix to the port name
% %
% the mesh must be already initialized % the mesh must be already initialized
@ -47,15 +45,13 @@ function [CSX,port] = AddMSLPort( CSX, prio, portnr, materialname, start, stop,
%check mesh %check mesh
if ~isfield(CSX,'RectilinearGrid') if ~isfield(CSX,'RectilinearGrid')
error 'mesh needs to be defined! Use DefineRectGrid() first!'; error 'mesh needs to be defined! Use DefineRectGrid() first!';
end
if (~isfield(CSX.RectilinearGrid,'XLines') || ~isfield(CSX.RectilinearGrid,'YLines') || ~isfield(CSX.RectilinearGrid,'ZLines')) if (~isfield(CSX.RectilinearGrid,'XLines') || ~isfield(CSX.RectilinearGrid,'YLines') || ~isfield(CSX.RectilinearGrid,'ZLines'))
error 'mesh needs to be defined! Use DefineRectGrid() first!'; error 'mesh needs to be defined! Use DefineRectGrid() first!';
end end
end
% check dir % check dir
if ~( (dir >= 0) && (dir <= 2) ) dir = DirChar2Int(dir);
error 'dir must have exactly one component ~= 0'
end
% check evec % check evec
if ~(evec(1) == evec(2) == 0) && ~(evec(1) == evec(3) == 0) && ~(evec(2) == evec(3) == 0) || (sum(evec) == 0) if ~(evec(1) == evec(2) == 0) && ~(evec(1) == evec(3) == 0) && ~(evec(2) == evec(3) == 0) || (sum(evec) == 0)
@ -63,9 +59,6 @@ if ~(evec(1) == evec(2) == 0) && ~(evec(1) == evec(3) == 0) && ~(evec(2) == evec
end end
evec0 = evec ./ sum(evec); % evec0 is a unit vector evec0 = evec ./ sum(evec); % evec0 is a unit vector
%% read optional arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n_conv_arg = 8; % number of conventional arguments
%set defaults %set defaults
feed_shift = 0; feed_shift = 0;
feed_R = inf; %(default is open, no resitance) feed_R = inf; %(default is open, no resitance)
@ -75,6 +68,7 @@ PortNamePrefix = '';
excite_args = {}; excite_args = {};
%% read optional arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for n=1:2:numel(varargin) for n=1:2:numel(varargin)
if (strcmp(varargin{n},'FeedShift')==1); if (strcmp(varargin{n},'FeedShift')==1);
feed_shift = varargin{n+1}; feed_shift = varargin{n+1};

View File

@ -11,7 +11,7 @@ function [CSX,port] = AddRectWaveGuidePort( CSX, prio, portnr, start, stop, dir,
% prio: priority of primitives % prio: priority of primitives
% start: start coordinates of waveguide port box % start: start coordinates of waveguide port box
% stop: stop coordinates of waveguide port box % stop: stop coordinates of waveguide port box
% dir: direction of port (0/1/2 for x/y/z-direction) % dir: direction of port (0/1/2 or 'x'/'y'/'z'-direction)
% a,b: rectangular waveguide width and height (in meter) % a,b: rectangular waveguide width and height (in meter)
% mode_name: mode name, e.g. 'TE11' or 'TM21' % mode_name: mode name, e.g. 'TE11' or 'TM21'
% exc_amp: excitation amplitude (set 0 to be passive) % exc_amp: excitation amplitude (set 0 to be passive)
@ -58,8 +58,8 @@ if ~isfield(CSX,'RectilinearGrid')
end end
unit = CSX.RectilinearGrid.ATTRIBUTE.DeltaUnit; unit = CSX.RectilinearGrid.ATTRIBUTE.DeltaUnit;
kc_draw = kc*unit;
dir = DirChar2Int(dir);
dir_names={'x','y','z'}; dir_names={'x','y','z'};
dirP = mod((dir+1),3)+1; dirP = mod((dir+1),3)+1;

View File

@ -11,7 +11,7 @@ function [CSX,port] = AddWaveGuidePort( CSX, prio, portnr, start, stop, dir, E_W
% prio: priority of primitives % prio: priority of primitives
% start: start coordinates of waveguide port box % start: start coordinates of waveguide port box
% stop: stop coordinates of waveguide port box % stop: stop coordinates of waveguide port box
% dir: direction of port (0/1/2 for x/y/z-direction) % dir: direction of port (0/1/2 or 'x'/'y'/'z'-direction)
% E_WG_func: electric field mode profile function as a string % E_WG_func: electric field mode profile function as a string
% H_WG_func: magnetic field mode profile function as a string % H_WG_func: magnetic field mode profile function as a string
% kc: cutoff wavenumber (defined by the waveguide dimensions) % kc: cutoff wavenumber (defined by the waveguide dimensions)
@ -56,16 +56,14 @@ if ~isfield(CSX,'RectilinearGrid')
error 'mesh needs to be defined! Use DefineRectGrid() first!'; error 'mesh needs to be defined! Use DefineRectGrid() first!';
end end
dir = DirChar2Int(dir);
port.type='WaveGuide'; port.type='WaveGuide';
port.nr=portnr; port.nr=portnr;
port.kc = kc; port.kc = kc;
port.dir = dir; port.dir = dir;
port.drawingunit = CSX.RectilinearGrid.ATTRIBUTE.DeltaUnit; port.drawingunit = CSX.RectilinearGrid.ATTRIBUTE.DeltaUnit;
if ~( (dir==0) || (dir==1) || (dir==2) )
error 'dir must be 0, 1 or 2'
end
PortNamePrefix = ''; PortNamePrefix = '';
varargin_tmp = varargin; varargin_tmp = varargin;

View File

@ -50,11 +50,11 @@ CSX = DefineRectGrid(CSX, unit,mesh);
%% apply the waveguide port %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% apply the waveguide port %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start=[mesh.x(1) mesh.y(1) mesh.z(8)]; start=[mesh.x(1) mesh.y(1) mesh.z(8)];
stop =[mesh.x(end) mesh.y(end) mesh.z(15)]; stop =[mesh.x(end) mesh.y(end) mesh.z(15)];
[CSX, port{1}] = AddRectWaveGuidePort( CSX, 0, 1, start, stop, 2, a*unit, b*unit, TE_mode, 1); [CSX, port{1}] = AddRectWaveGuidePort( CSX, 0, 1, start, stop, 'z', a*unit, b*unit, TE_mode, 1);
start=[mesh.x(1) mesh.y(1) mesh.z(end-13)]; start=[mesh.x(1) mesh.y(1) mesh.z(end-13)];
stop =[mesh.x(end) mesh.y(end) mesh.z(end-14)]; stop =[mesh.x(end) mesh.y(end) mesh.z(end-14)];
[CSX, port{2}] = AddRectWaveGuidePort( CSX, 0, 2, start, stop, 2, a*unit, b*unit, TE_mode); [CSX, port{2}] = AddRectWaveGuidePort( CSX, 0, 2, start, stop, 'z', a*unit, b*unit, TE_mode);
%% define dump box... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% define dump box... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CSX = AddDump(CSX,'Et','FileType',1,'SubSampling','4,4,4'); CSX = AddDump(CSX,'Et','FileType',1,'SubSampling','4,4,4');