alchemyst / Skogestad-Python

Python code for "Multivariable Feedback Control"
111 stars 88 forks source link

Replace numpy.poly1d with numpy.polynomial.Polynomial #350

Open DeBruinJohan opened 5 years ago

DeBruinJohan commented 5 years ago

Johan de Bruin has attempted to solve this in 2019. His code did not pass the test. It was found that it is possible to rewrite the tf function to work with Polynomial, however numerous other functions in the repo are dependant on the coefficients of numerator and denominator of the fransferfunction. These numerators and denominators are both of type Polynomial and therefore their coefficients are given in the reverse order of that what is expected from the user, namely in increasing order of powers instead of decreasing order, as poly1d gives it. The transfer function can be made to display in decreasing order and takes inputs in decreasing order, however is no obvious way to ensure that the call tf.numerator.coef() would return the values in decreasing order. A possible solution to this would be to replace all instances of tf.numerator.coef with tf.numerator.coef[::-1], however this will cause confusion to anyone who wants code further on it.

His code can be found on the "Polynomial" branch of https://github.com/DeBruinJohan/Skogestad-Python/tree/Polynomial