Skip to content

pedrohnv/RationalVectorFitting.jl

Repository files navigation

RationalVectorFitting

Fast Relaxed Vector Fitting implementation in Julia.

Given a transfer function $f(s) = y$, the Vector Fitting algorithm tries to find a rational approximation

$$f(s) \approx \sum_{n=1}^N \frac{r_n}{s - a_n} + d + s h$$

where $s$ is the complex frequency, $r_n$ are the complex residues, $a_n$ are the complex poles, $d$ and $h$ are real constants.

The transfer function can be a vector $f(s) = [y_1, \dots, y_m]$ and the Vector Fitting algorithm will fit the response using the same set of poles $a_n$ for all $y_m$.

A rational representation of a transfer function makes it easier to find a state space canonical realization of a system and to perform convolutions.

Example

Read the docs for more examples.

using RationalVectorFitting
using Plots

Ns = 101
freq = exp10.(range(0, 4, length = Ns))
s = 2im * pi * freq
poles0 = [-5.0, -100 - 500im, -100 + 500im]
residues0 = [2.0, 30 - 40im, 30 + 40im]
d0 = 0.5
h0 = 0.0
f = rational(s, poles0, residues0, d0, h0)
init_poles = -2pi * exp10.(range(0, 4, length = 3))
poles, residues, d, h, fitted, error_norm = vector_fitting(s, f, init_poles)
begin
    p1 = plot(freq, abs.(f), label="f(s)", linecolor=:blue, xlabel="Frequency [Hz]", xaxis=:log, yaxis=:log, legend=:right)
    plot!(freq, abs.(fitted), label="fitted(s)", linecolor=:darkorange)
    plot!(freq, abs.(f - fitted), label="deviation", linecolor=:green)
    display(p1)
end

Stable Documentation In development documentation Build Status Test workflow status Lint workflow Status Docs workflow Status

Coverage DOI Contributor Covenant All Contributors BestieTemplate

How to Cite

If you use RationalVectorFitting.jl in your work, please cite using the reference given in CITATION.cff.

Contributing

If you want to make contributions of any kind, please first that a look into our contributing guide directly on GitHub or the contributing page on the website.


Contributors

Bibliography

[1] B. Gustavsen and A. Semlyen, "Rational approximation of frequency domain responses by vector fitting," in IEEE Transactions on Power Delivery, vol. 14, no. 3, pp. 1052-1061, July 1999, doi: 10.1109/61.772353.

[2] B. Gustavsen, "Improving the pole relocating properties of vector fitting," in IEEE Transactions on Power Delivery, vol. 21, no. 3, pp. 1587-1592, July 2006, doi: 10.1109/TPWRD.2005.860281.

[3] D. Deschrijver, M. Mrozowski, T. Dhaene and D. De Zutter, "Macromodeling of Multiport Systems Using a Fast Implementation of the Vector Fitting Method," in IEEE Microwave and Wireless Components Letters, vol. 18, no. 6, pp. 383-385, June 2008, doi: 10.1109/LMWC.2008.922585.

[4] A. M. Smith, S. D'Arco, J. A. Suul and B. Gustavsen, "Improved Pole Placement and Compaction of MIMO Vector Fitting Applied to System Identification," in IEEE Transactions on Power Delivery, vol. 39, no. 2, pp. 1259-1270, April 2024, doi: 10.1109/TPWRD.2024.3364836.

About

Fast Relaxed Vector-Fitting algorithm in Julia

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages