VectorFitting (skrf.vectorFitting
)¶

class
skrf.vectorFitting.
VectorFitting
(network)[source]¶ This class provides a Python implementation of the Vector Fitting algorithm and various functions for the fit analysis and export of SPICE equivalent circuits.
Notes
The fitting code is based on the original algorithm [1] and on two improvements for relaxed pole relocation [2] and efficient (fast) solving [3]. See also the Vector Fitting website [4] for further information and download of the papers listed below. A Matlab implementation is also available there for reference.
References
[1] B. Gustavsen, A. Semlyen, “Rational Approximation of Frequency Domain Responses by Vector Fitting”, IEEE Transactions on Power Delivery, vol. 14, no. 3, pp. 10521061, July 1999, DOI: https://doi.org/10.1109/61.772353 [2] B. Gustavsen, “Improving the Pole Relocating Properties of Vector Fitting”, IEEE Transactions on Power Delivery, vol. 21, no. 3, pp. 15871592, July 2006, DOI: https://doi.org/10.1109/TPWRD.2005.860281 [3] D. Deschrijver, M. Mrozowski, T. Dhaene, D. De Zutter, “Marcomodeling of Multiport Systems Using a Fast Implementation of the Vector Fitting Method”, IEEE Microwave and Wireless Components Letters, vol. 18, no. 6, pp. 383385, June 2008, DOI: https://doi.org/10.1109/LMWC.2008.922585 [4] Vector Fitting website: https://www.sintef.no/projectweb/vectorfitting/ 
get_model_response
(i, j, freqs=None)[source]¶ Returns the frequency response of the fitted model.
Parameters:  i (int) – Row index of the response.
 j (int) – Column index of the response.
 freqs (list of float or ndarray or None, optional) – List of frequencies for the response plot. If None, the sample frequencies of the fitted network in
network
are used.
Returns: Model response at the frequencies specified in freqs (complexvalued ndarray).
Return type: ndarray

plot_convergence
()[source]¶ Plots the history of the model residue parameter d_res during the iterative pole relocation process of the vector fitting, which should eventually converge to a fixed value. Additionally, the relative change of the maximum singular value of the coefficient matrix A are plotted, which serve as a convergence indicator.
Returns: Return type: None

plot_pz
(i, j)[source]¶ Plots a polezero diagram of the fit of the response S_(i+1,j+1).
Parameters:  i (int) – Row index of the response.
 j (int) – Column index of the response.
Returns: Return type: None

plot_s_db
(i, j, freqs=None)[source]¶ Plots the magnitude in dB of the response S_(i+1,j+1) in the fit.
Parameters:  i (int) – Row index of the response.
 j (int) – Column index of the response.
 freqs (list of float or ndarray or None, optional) – List of frequencies for the response plot. If None, the sample frequencies of the fitted network in
network
are used.
Returns: Return type: None

plot_s_mag
(i, j, freqs=None)[source]¶ Plots the magnitude in linear scale of the response S_(i+1,j+1) in the fit.
Parameters:  i (int) – Row index of the response.
 j (int) – Column index of the response.
 freqs (list of float or ndarray or None, optional) – List of frequencies for the response plot. If None, the sample frequencies of the fitted network in
network
are used.
Returns: Return type: None

read_npz
(file)[source]¶ Reads all model parameters
poles
,zeros
,proportional_coeff
andconstant_coeff
from a labeled NumPy .npz file.Parameters: file (str) – NumPy .npz file containing the parameters. See notes. Returns: Return type: None Notes
The .npz file needs to include the model parameters as individual ndarray`s labeled *poles*, *zeros*, *proportionals* and *constants*. The shapes of those `ndarray`s need to match the network properties in :attr:`network (correct number of ports). Preferably, the .npz file was created by
write_npz()
.See also
write_npz()
 Writes all model parameters to a .npz file

vector_fit
(n_poles_real=2, n_poles_cmplx=2, init_pole_spacing='lin', parameter_type='S', fit_constant=True, fit_proportional=True)[source]¶ Main work routine performing the vector fit. The results will be stored in the class variables
poles
,zeros
,proportional_coeff
andconstant_coeff
.Parameters:  n_poles_real (int, optional) – Number of initial real poles. See notes.
 n_poles_cmplx (int, optional) – Number of initial complex conjugate poles. See notes.
 init_pole_spacing (str, optional) – Type of initial pole spacing across the frequency interval of the Smatrix. Either linear (lin) or logarithmic (log).
 parameter_type (str, optional) – Representation type of the frequency responses to be fitted. Either scattering (
s
orS
), impedance (z
orZ
) or admittance (y
orY
). As scikitrf can currently only read S parameters from a Touchstone file, the fit should also be performed on the original S parameters. Otherwise, scikitrf will convert the responses from S to Z or Y, which might work for the fit but can cause other issues.  fit_constant (bool, optional) – Include a constant term d in the fit.
 fit_proportional (bool, optional) – Include a proportional term e in the fit.
Returns: Return type: None
Notes
The required number of real or complex conjugate starting poles depends on the behaviour of the frequency responses. To fit a smooth response such as a lowpass characteristic, 13 real poles and no complex conjugate poles is usually sufficient. If resonances or other types of peaks are present in some or all of the responses, a similar number of complex conjugate poles is required. Be careful not to use too many poles, as excessive poles will not only increase the computation workload during the fitting and the subsequent use of the model, but they can also introduce unwanted resonances at frequencies well outside the fit interval.

write_npz
(path)[source]¶ Writes the model parameters in
poles
,zeros
,proportional_coeff
andconstant_coeff
to a labeled NumPy .npz file.Parameters: path (str) – Target path without filename for the export. The filename will be added automatically based on the network name in network
Returns: Return type: None See also
read_npz()
 Reads all model parameters from a .npz file

write_spice_subcircuit_s
(file)[source]¶ Creates an equivalent Nport SPICE subcircuit based on its vector fitted S parameter responses.
Parameters: file (str) – Path and filename including file extension (usually .sp) for the SPICE subcircuit file. Returns: Return type: None Notes
In the SPICE subcircuit, all ports will share a common reference node (global SPICE ground on node 0). The equivalent circuit uses linear dependent current sources on all ports, which are controlled by the currents through equivalent admittances modelling the parameters from a vector fit. This approach is based on [5].
References
[5] G. Antonini, “SPICE Equivalent Circuits of FrequencyDomain Responses”, IEEE Transactions on Electromagnetic Compatibility, vol. 45, no. 3, pp. 502512, August 2003, DOI: https://doi.org/10.1109/TEMC.2003.815528
