[SciPy-User] Root Locus Analysis

Ilhan Polat ilhanpolat at gmail.com
Sat Mar 9 06:22:41 EST 2019


I am the author of the first package that Joseph linked to (thank you for
mentioning it). I don't know which version but it is now available in
python-control package 0.8.1 I don't have Slycot and seemingly it is not
needed for this functionality

import control as cnt
G = cnt.rss(5)
cnt.root_locus(Gc, Plot=True);

would give you a decent Root Locus plot (note the final semicolon). Some
clickability is introduced but I didn't use it yet.


Having said that, here is some rant; I have actually thought about this for
a while and decided that there is nothing that this analysis brings in and
is an artifact of the past only used to pester students. What root locus
analysis does is to find out when a particular gain value causes a SISO
system to go unstable under static gain feedback. Kind of a routh-hurwitz
in a for loop. There can only be a single gain as a parameter and the
system is strictly SISO. Hence the application scope is severely limited
and cripples the curiosity of the interested students. Also it really
doesn't give much of an insight. Instead consider the following home-baked
plot inside an IPython notebook. I only spent about 15 minutes for this
hence there is so much that can be polished but I hope it demonstrates the
idea

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interactive
from ipywidgets import FloatSlider
from IPython.display import display
# You don't really need harold for this, scipy.signal, python-control is
also fine
# We just need two polynomials representing num and den
# For state models it is a bit more tedious but still simple
from harold import Transfer, haroldpolyadd
G = Transfer([1, 2, -3, 1], [1, -1, 3, 5, 4])

def rlocus_demo(K=1):
    # polyadd is here only because it takes care of addition of different
lengths
    r = np.roots(haroldpolyadd(G.den[0], K*G.num[0]))
    print(r)
    # plt.scatter(roots.real, roots.imag)
    plt.xlim((r.real.min()-1,r.real.max()+1))
    plt.ylim((r.imag.min()-1,r.imag.max()+1))
    plt.scatter(r.real, r.imag)
    plt.ylabel('Imaginary')
    plt.xlabel('Real')
    plt.grid()

K_slider = FloatSlider(min=1, max=50, step=0.2, value=1)
w=interactive(rlocus_demo,K=K_slider)
display(w)

Paste it in a notebook cell and you have an interactive pzmap. Just by
interacting with the slider we see things swap around from stable to
unstable etc. and later towards the end suddenly you get a pair coinciding.
Then you start to question things about why. You can take it from here to
make other incredible things, adding more parameters with sliders, other
plants, checking the effect of delays etc. Thus it is the concept of
simultaneous pole motion and not the plot type itself that matters.
Unfortunately this message is lost some time ago and we are stuck with
plots of the 1950s (matlab has a big role in this unfortunately). Root
locus curves were a big thing when we didn't have computing power at our
disposal but hardly ever applies today. I guess it is not going away out of
the curriculum anytime soon. I'll add this to my todo list and ping when I
add that. </rant>


Best,
ilhan


On Fri, Mar 8, 2019 at 10:43 PM Slater, Joseph C. <joseph.slater at wright.edu>
wrote:

> Also of note for control design:
>
> https://github.com/ilayn/harold (Trying to do without slycot)
> and https://github.com/alchemyst/Skogestad-Python (Robust control)
>
> Neither solves the problem at hand, but broader awareness can only help.
>
> Best Regards- Joe
>
>
> On Mar 8, 2019, at 3:53 PM, Jason Moore <moorepants at gmail.com> wrote:
>
> slycot now builds on Windows using scikit-build, so not as painful
> anymore. Binaries will eventually be on conda-forge too.
>
> Jason
> moorepants.info
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__moorepants.info&d=DwMFaQ&c=3buyMx9JlH1z22L_G5pM28wz_Ru6WjhVHwo-vpeS0Gk&r=rEyLMZFJ7eh_1iNO7KnqQcXbAnZbNOjKNJqN1v2jbrM&m=TSDmw5C_pMHHU9XEr6WBjtatVCGV9jkt9tsMicXuEpo&s=qlV2Rc63YZ-fY3-YeMClEP5mAMHMnp9lEpmDbxWpGb0&e=>
> +01 530-601-9791
>
>
> On Fri, Mar 8, 2019 at 12:15 PM Ralf Gommers <ralf.gommers at gmail.com>
> wrote:
>
>>
>>
>> On Sun, Mar 3, 2019 at 11:00 PM Fábio Molinar <fabiomolinar at gmail.com>
>> wrote:
>>
>>> Hi everyone,
>>>
>>> I am a Controls Engineer who used to use Matlab quite frequently at the
>>> University to analyze, among other things, system's stability. I am now
>>> reading again some theoretical books on control theory to refresh my mind
>>> again with some of the theories and concepts I haven't used for a while.
>>>
>>> But since I became a python programmer and enthusiast, I am doing this
>>> review while using SciPy to program some tests and examples. And I am
>>> really enjoying using SciPy to code some of my scripts. Although I just
>>> started using it, I can't stress enough how much fun and how useful the
>>> scipy.signal package is.
>>>
>>> But, during my theory review I came upon the Root Locus Analysis and, to
>>> my disappointment, I didn't find support for it on the scipy.signal
>>> package. *Is anyone aware if there is someone working on implementing
>>> Root Locus analysis into the scipy.signal package*?
>>>
>>
>> Not that I am aware of.
>>
>>
>>> I know that there is another python package called "control" which has
>>> support for many control analysis tools, including Root Locus analysis, but
>>> I would like to avoid installing yet another package into my python
>>> environment. Especially because installing the "control" python package
>>> isn't that straight-forward and requires a bunch of other
>>> packages/libraries.
>>>
>>
>> python-control may be your best bet. If you're on Windows yes, the Slycot
>> dependency will be very hard to install. On other platforms it should be
>> easy, especially if you use conda (conda-forge packages for macOS and Linux
>> are available).
>>
>> Cheers,
>> Ralf
>>
>>
>>
>>
>>> Yours sincerely,
>>>
>>> *Fábio Thomaz Molinar*
>>> _______________________________________________
>>> SciPy-User mailing list
>>> SciPy-User at python.org
>>> https://mail.python.org/mailman/listinfo/scipy-user
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.python.org_mailman_listinfo_scipy-2Duser&d=DwMFaQ&c=3buyMx9JlH1z22L_G5pM28wz_Ru6WjhVHwo-vpeS0Gk&r=rEyLMZFJ7eh_1iNO7KnqQcXbAnZbNOjKNJqN1v2jbrM&m=TSDmw5C_pMHHU9XEr6WBjtatVCGV9jkt9tsMicXuEpo&s=33DJzkrwfG-zpaW0uDpzZXxBUuaZG-PrW8YtSyVdWZM&e=>
>>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at python.org
>> https://mail.python.org/mailman/listinfo/scipy-user
>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.python.org_mailman_listinfo_scipy-2Duser&d=DwMFaQ&c=3buyMx9JlH1z22L_G5pM28wz_Ru6WjhVHwo-vpeS0Gk&r=rEyLMZFJ7eh_1iNO7KnqQcXbAnZbNOjKNJqN1v2jbrM&m=TSDmw5C_pMHHU9XEr6WBjtatVCGV9jkt9tsMicXuEpo&s=33DJzkrwfG-zpaW0uDpzZXxBUuaZG-PrW8YtSyVdWZM&e=>
>>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at python.org
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.python.org_mailman_listinfo_scipy-2Duser&d=DwICAg&c=3buyMx9JlH1z22L_G5pM28wz_Ru6WjhVHwo-vpeS0Gk&r=rEyLMZFJ7eh_1iNO7KnqQcXbAnZbNOjKNJqN1v2jbrM&m=TSDmw5C_pMHHU9XEr6WBjtatVCGV9jkt9tsMicXuEpo&s=33DJzkrwfG-zpaW0uDpzZXxBUuaZG-PrW8YtSyVdWZM&e=
>
>
> Professor & Chair
> ~~~~~~~~~~~~~~~~~~~~~~~~
> (+1) 937-775-5040
> https://people.wright.edu/joseph.slater
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at python.org
> https://mail.python.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20190309/3fd41f61/attachment-0001.html>


More information about the SciPy-User mailing list