diff --git a/matlab/calcLumpedPort.m b/matlab/calcLumpedPort.m index 0a33c32..45f5af0 100644 --- a/matlab/calcLumpedPort.m +++ b/matlab/calcLumpedPort.m @@ -14,6 +14,7 @@ function [port] = calcLumpedPort( port, SimDir, f, varargin) % 'RefImpedance': - use a given reference impedance to calculate inc and % ref voltages and currents % - default is given port or calculated line impedance +% 'SwitchDirection': 0/1, switch assumed direction of propagation % % output: % port.f the given frequency fector @@ -45,12 +46,17 @@ end %set defaults ref_ZL = port.Feed_R; +switch_dir = 1; UI_args = {}; for n=1:2:numel(varargin) if (strcmp(varargin{n},'RefImpedance')==1); ref_ZL = varargin{n+1}; + elseif (strcmpi(varargin{n},'SwitchDirection')==1); + if (varargin{n+1}) + switch_dir = -1; + end else UI_args(end+1) = varargin(n); UI_args(end+1) = varargin(n+1); @@ -65,7 +71,7 @@ I = ReadUI( port.I_filename, SimDir, f, UI_args{:} ); % store the original frequency domain waveforms u_f = U.FD{1}.val; -i_f = I.FD{1}.val; % shift to same position as v +i_f = switch_dir*I.FD{1}.val; port.Zin = u_f./i_f; diff --git a/matlab/calcPort.m b/matlab/calcPort.m index 418e095..2033f69 100644 --- a/matlab/calcPort.m +++ b/matlab/calcPort.m @@ -18,6 +18,7 @@ function [port] = calcPort( port, SimDir, f, varargin) % - default is given port or calculated line impedance % 'RefPlaneShift': for transmission lines only, See also calcTLPort for % more details +% 'SwitchDirection': 0/1, switch assumed direction of propagation % % output: % port.f the given frequency fector diff --git a/matlab/calcTLPort.m b/matlab/calcTLPort.m index f9c75e1..6df2d1c 100644 --- a/matlab/calcTLPort.m +++ b/matlab/calcTLPort.m @@ -19,6 +19,7 @@ function [port] = calcTLPort( port, SimDir, f, varargin) % for a desired phase correction % - default is the measurement plane % - the plane shift has to be given in drawing units! +% 'SwitchDirection': 0/1, switch assumed direction of propagation % % output: % port.f the given frequency fector @@ -62,6 +63,7 @@ end %set defaults ref_ZL = -1; ref_shift = nan; +switch_dir = 1; UI_args = {}; @@ -70,6 +72,10 @@ for n=1:2:numel(varargin) ref_shift = varargin{n+1}; elseif (strcmp(varargin{n},'RefImpedance')==1); ref_ZL = varargin{n+1}; + elseif (strcmpi(varargin{n},'SwitchDirection')==1); + if (varargin{n+1}) + switch_dir = -1; + end else UI_args(end+1) = varargin(n); UI_args(end+1) = varargin(n+1); @@ -82,7 +88,7 @@ I = ReadUI( port.I_filename, SimDir, f, UI_args{:} ); % store the original frequency domain waveforms u_f = U.FD{2}.val; -i_f = (I.FD{1}.val + I.FD{2}.val) / 2; % shift to same position as v +i_f = switch_dir*(I.FD{1}.val + I.FD{2}.val) / 2; % shift to same position as v f = U.FD{2}.f; Et = U.FD{2}.val; diff --git a/matlab/calcWGPort.m b/matlab/calcWGPort.m index 05fca16..031068e 100644 --- a/matlab/calcWGPort.m +++ b/matlab/calcWGPort.m @@ -1,5 +1,5 @@ function [port] = calcWGPort( port, SimDir, f, varargin) -% [port] = calcTLPort( port, SimDir, f, varargin) +% [port] = calcWGPort( port, SimDir, f, varargin) % % Calculate voltages and currents, the propagation constant beta % and the characteristic impedance ZL of the given waveguide port. @@ -20,6 +20,8 @@ function [port] = calcWGPort( port, SimDir, f, varargin) % - default is the measurement plane at the end of the % port % - the plane shift has to be given in drawing units! +% 'RefractiveIndex': set a material refractive index +% 'SwitchDirection': 0/1, switch assumed direction of propagation % % output: % port.f the given frequency fector @@ -52,6 +54,8 @@ end %set defaults ref_ZL = -1; ref_shift = nan; +ref_index = 1; +switch_dir = 1; UI_args = {}; @@ -60,6 +64,12 @@ for n=1:2:numel(varargin) ref_shift = varargin{n+1}; elseif (strcmp(varargin{n},'RefImpedance')==1); ref_ZL = varargin{n+1}; + elseif (strcmp(varargin{n},'RefractiveIndex')==1); + ref_index = varargin{n+1}; + elseif (strcmpi(varargin{n},'SwitchDirection')==1); + if (varargin{n+1}) + switch_dir = -1; + end else UI_args(end+1) = varargin(n); UI_args(end+1) = varargin(n+1); @@ -72,11 +82,11 @@ I = ReadUI( port.I_filename, SimDir, f, UI_args{:} ); % store the original frequency domain waveforms u_f = U.FD{1}.val; -i_f = I.FD{1}.val; +i_f = I.FD{1}.val * switch_dir; physical_constants -k = 2*pi*f/C0; -fc = C0*port.kc/2/pi; +k = 2*pi*f/C0*ref_index; +fc = C0*port.kc/2/pi/ref_index; port.beta = sqrt(k.^2 - port.kc^2); port.ZL = k * Z0 ./ port.beta; %analytic waveguide impedance