skrf.vectorFitting.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, passivity evaluation and enforcement, and export of SPICE equivalent circuits.

Parameters:

network (skrf.network.Network) – Network instance of the \(N\)-port holding the frequency responses to be fitted, for example a scattering, impedance or admittance matrix.

Examples

Load the Network, create a VectorFitting instance, perform the fit with a given number of real and complex-conjugate starting poles:

>>> nw_3port = skrf.Network('my3port.s3p')
>>> vf = skrf.VectorFitting(nw_3port)
>>> vf.vector_fit(n_poles_real=1, n_poles_cmplx=4)

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

Attributes

network

Instance variable holding the Network to be fitted.

poles

Instance variable holding the list of fitted poles.

residues

Instance variable holding the list of fitted residues.

proportional_coeff

Instance variable holding the list of fitted proportional coefficients.

constant_coeff

Instance variable holding the list of fitted constants.

max_iterations

Instance variable specifying the maximum number of iterations for the fitting process and for the passivity enforcement.

max_tol

Instance variable specifying the convergence criterion in terms of relative tolerance.

wall_clock_time

Instance variable holding the wall-clock time (in seconds) consumed by the most recent fitting process with vector_fit().

Methods

__init__

auto_fit

Automatic fitting routine implementing the "vector fitting with adding and skimming" algorithm as proposed in [#Grivet-Talocia]_.

get_model_order

Returns the model order calculated with \(N_{real} + 2 N_{complex}\) for a given set of poles.

get_model_response

Returns one of the frequency responses \(H_{i+1,j+1}\) of the fitted model \(H\).

get_rms_error

Returns the root-mean-square (rms) error magnitude of the fit, i.e. \(\sqrt{ \mathrm{mean}(|S - S_\mathrm{fit} |^2) }\), either for an individual response \(S_{i+1,j+1}\) or for larger slices of the network.

get_spurious

Classifies fitted pole-residue pairs as spurious or not spurious.

is_passive

Returns the passivity status of the model as a boolean value.

passivity_enforce

Enforces the passivity of the vector fitted model, if required.

passivity_test

Evaluates the passivity of reciprocal vector fitted models by means of a half-size test matrix [#]_.

plot

Plots the specified component of the parameter \(H_{i+1,j+1}\) in the fit, where \(H\) is either the scattering (\(S\)), the impedance (\(Z\)), or the admittance (\(H\)) response specified in parameter.

plot_convergence

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.

plot_passivation

Plots the history of the greatest singular value during the iterative passivity enforcement process, which should eventually converge to a value slightly lower than 1.0 or stop after reaching the maximum number of iterations specified in the class variable max_iterations.

plot_s_db

Plots the magnitude in dB of the scattering parameter response(s) in the fit.

plot_s_deg

Plots the phase in degrees of the scattering parameter response(s) in the fit.

plot_s_deg_unwrap

Plots the unwrapped phase in degrees of the scattering parameter response(s) in the fit.

plot_s_im

Plots the imaginary part of the scattering parameter response(s) in the fit.

plot_s_mag

Plots the magnitude in linear scale of the scattering parameter response(s) in the fit.

plot_s_re

Plots the real part of the scattering parameter response(s) in the fit.

plot_s_singular

Plots the singular values of the vector fitted S-matrix in linear scale.

read_npz

Reads all model parameters poles, residues, proportional_coeff and constant_coeff from a labeled NumPy .npz file.

vector_fit

Main work routine performing the vector fit.

write_npz

Writes the model parameters in poles, residues, proportional_coeff and constant_coeff to a labeled NumPy .npz file.

write_spice_subcircuit_s

Creates an equivalent N-port SPICE subcircuit based on its vector fitted S parameter responses.