2011-09-19 08:14:27 +00:00
|
|
|
function [port] = calcPort( port, SimDir, f, varargin)
|
2012-02-22 09:14:38 +00:00
|
|
|
% [port] = calcPort( port, SimDir, f, varargin)
|
2010-05-21 09:41:33 +00:00
|
|
|
%
|
2012-11-09 14:41:18 +00:00
|
|
|
% Calculate:
|
|
|
|
% - voltages and currents
|
|
|
|
% - the propagation constant and the characteristic impedance (if applicable)
|
|
|
|
%
|
|
|
|
% The port has to be created by e.g. AddMSLPort(), AddLumpedPort() or AddCurvePort
|
2010-05-21 09:41:33 +00:00
|
|
|
%
|
2010-10-04 08:16:05 +00:00
|
|
|
% input:
|
2011-09-19 08:14:27 +00:00
|
|
|
% port: return value of AddMSLPort()
|
2010-10-04 08:16:05 +00:00
|
|
|
% SimDir: directory, where the simulation files are
|
2011-09-19 08:14:27 +00:00
|
|
|
% f: frequency vector for DFT
|
|
|
|
%
|
|
|
|
% variable input:
|
2012-02-22 09:14:38 +00:00
|
|
|
% 'RefImpedance': - use a given reference impedance to calculate inc and
|
|
|
|
% ref voltages and currents
|
|
|
|
% - default is given port or calculated line impedance
|
2012-11-09 14:41:18 +00:00
|
|
|
% 'RefPlaneShift': for transmission lines only, See also calcTLPort for
|
|
|
|
% more details
|
2013-03-22 15:30:55 +00:00
|
|
|
% 'SwitchDirection': 0/1, switch assumed direction of propagation
|
2015-12-13 15:27:10 +00:00
|
|
|
% 'SignalType': 'pulse' (default) or 'periodic'
|
2010-05-21 09:41:33 +00:00
|
|
|
%
|
2011-09-19 08:14:27 +00:00
|
|
|
% output:
|
2013-12-28 20:41:19 +00:00
|
|
|
% % output signals/values in time domain (TD):
|
|
|
|
% port.ut.tot total voltage (time-domain)
|
|
|
|
% port.ut.time voltage time vector
|
|
|
|
% port.it.tot total current (time-domain)
|
|
|
|
% port.it.time current time vector
|
|
|
|
%
|
|
|
|
% % output signals/values in frequency domain (FD):
|
2011-09-19 08:14:27 +00:00
|
|
|
% port.f the given frequency fector
|
|
|
|
% port.uf.tot/inc/ref total, incoming and reflected voltage
|
|
|
|
% port.if.tot/inc/ref total, incoming and reflected current
|
2013-03-22 12:52:27 +00:00
|
|
|
% port.ZL_ref used refernce impedance
|
2012-11-09 14:41:18 +00:00
|
|
|
%
|
2013-12-09 13:11:49 +00:00
|
|
|
% port.P_inc incoming power
|
|
|
|
% port.P_ref reflected power
|
|
|
|
% port.P_acc accepted power (incoming minus reflected,
|
|
|
|
% may be negative for passive ports)
|
|
|
|
%
|
2012-11-09 14:41:18 +00:00
|
|
|
% if port is a transmission line port:
|
2011-09-19 08:14:27 +00:00
|
|
|
% port.beta: propagation constant
|
|
|
|
% port.ZL: characteristic line impedance
|
2010-10-04 08:16:05 +00:00
|
|
|
%
|
2011-09-19 08:14:27 +00:00
|
|
|
% example:
|
2012-11-09 14:41:18 +00:00
|
|
|
% port = calcPort(port, Sim_Path, f, 'RefImpedance', 50);
|
2010-10-04 08:16:05 +00:00
|
|
|
%
|
|
|
|
% openEMS matlab interface
|
|
|
|
% -----------------------
|
2012-11-09 14:41:18 +00:00
|
|
|
% (C) 2012 Thorsten Liebig <thorsten.liebig@gmx.de>
|
|
|
|
%
|
|
|
|
% See also AddMSLPort, AddLumpedPort, AddCurvePort, calcTLPort, calcLumpedPort
|
2011-09-19 08:14:27 +00:00
|
|
|
|
2012-11-09 14:41:18 +00:00
|
|
|
if (iscell(port))
|
|
|
|
for n=1:numel(port)
|
|
|
|
port{n}=calcPort(port{n}, SimDir, f, varargin{:});
|
2011-09-19 08:14:27 +00:00
|
|
|
end
|
2012-11-09 14:41:18 +00:00
|
|
|
return;
|
2010-05-21 09:41:33 +00:00
|
|
|
end
|
|
|
|
|
2013-07-24 15:20:25 +00:00
|
|
|
if isempty(port)
|
|
|
|
return;
|
|
|
|
end
|
|
|
|
|
2014-06-07 18:22:35 +00:00
|
|
|
if (strcmpi(port.type,'MSL') || strcmpi(port.type,'Coaxial') || strcmpi(port.type,'StripLine') || strcmpi(port.type,'CPW'))
|
2012-11-09 14:41:18 +00:00
|
|
|
port = calcTLPort( port, SimDir, f, varargin{:});
|
2013-03-22 12:54:18 +00:00
|
|
|
elseif strcmpi(port.type,'WaveGuide')
|
|
|
|
port = calcWGPort( port, SimDir, f, varargin{:});
|
2012-11-09 14:41:18 +00:00
|
|
|
elseif (strcmpi(port.type,'Lumped') || strcmpi(port.type,'Curve'))
|
|
|
|
port = calcLumpedPort( port, SimDir, f, varargin{:});
|
2013-03-22 12:52:27 +00:00
|
|
|
else
|
|
|
|
error 'unknown port type'
|
2011-09-19 08:14:27 +00:00
|
|
|
end
|
|
|
|
|
2013-12-09 13:11:49 +00:00
|
|
|
% calc some more port parameter
|
|
|
|
% incoming power
|
|
|
|
port.P_inc = 0.5*real(port.uf.inc.*conj(port.if.inc));
|
|
|
|
% reflected power
|
|
|
|
port.P_ref = 0.5*real(port.uf.ref.*conj(port.if.ref));
|
|
|
|
% accepted power (incoming - reflected)
|
|
|
|
port.P_acc = 0.5*real(port.uf.tot.*conj(port.if.tot));
|