-
Notifications
You must be signed in to change notification settings - Fork 438
Nyquist plot rescaling is confusing #1143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
think I see my error - the code 1458-1482 is doing the indent - I thought it was correcting for something else |
You can see exactly what the contour is using the
|
Hi - yes, I see that now - the artifact that I was trying to track down seems to come from L1908 I think I understand the intent of this line, but compare the 2 nyquist plots you get if that line was changed to: I might be missing something, but I am not convinced the current "resp[rescale] *= max_curve_magnitude / abs(resp[rescale])" example casefrom control import nyquist_plot, zpk, nyquist_response, tf G2 = tf([1],[1, 1]) * tf([1],[1, 0])**2 fig, ax = plt.subplots(1,figsize=(4, 4),dpi=150) |
I'll look into this further. I don't think we want to rescale the entire plot, since that could change the number of encirclements that show up on the plot. |
agreed - I was just trying to find the easiest way to show the weird bit that appears in the bottom plot above (around -20,3) |
I've been looking into what is going on in the rescaling and how to fix it. First, what is going on is that the way in which the nonlinear rescaling is done can distort the shape of the Nyquist curve. Consider the system from above, with the Nyquist indentation around the poles set to be on the left:
This is a system with two poles at the origin and a pole at -1. The default Nyquist plot for the system looks like this: From the plot, it is not that clear what is happening at
We can get a better view if we turn off the rescaling and adjust the size of the indentation around the poles of the origin:
In this view we can no longer see the -1 point, but we see that there is a clear gap between the Nyquist curve and the negative imaginary axis. This (quite large) gap is not at all event in the default plot. Note also that the inversion in the direction of the curve is now gone. The reason for the distortion is the way in which the rescaling is done. Currently any point that has magnitude greater than An easy fix is to change the indentation radius so that the magnitude of the curve near the pole does not exceed the maximum curve magnitude. For a double pole at the origin, if we want the magnitude to be less than 20 when we evaluation at the point
We see that comparing this plot to the "unscaled" plot gives a quite nice representation with no major distortions in the shape. Now that we understand the problem, the question is how to best fix it. I can see a couple of paths:
Before talking about these options, one other important point to remember is that the generation of the Nyquist response is actually separate from the plotting of that response. In the commands above, I have used
The reason this matters is indicated in the use of the parameters above: the choice of the indentation direction and radius needs to happen at the time of generating the response, while the choice of the maximum magnitude that you plot happens at the time of creating the plot. Now to the options:
My current plan is to implement a two-pronged solution: allow automatic computation of |
I also think drawing negative frequencies in Nyquist plots is unnecessary if the system is not complex valued adds no value but confuses the directions when there are axis crossings. As far as I can look into it historically (which is not much), it's just out of habit which is often more powerful than any logical argument. It also pairs better with one-sided Bode plots. |
|
I think having the negative freq part in the plot is helpful for those learning to visualize encirclements - so I would at least leave it as an option to display both parts. What I had been doing recently was the equivalent of RM solution #1 and creating 2 graphs, one just a zoomed in version (around -1) of the larger. Suboptimal to have 2 plots, but when I tried to show the zoomed in part as an inset, I noticed another behavior I didn't understand regarding axes. For example, if you do this: import control as ct G = ct.tf([1], [1, 1]) * ct.tf([1], [1, 0])**2 fig, ax = plt.subplots(1,2,figsize=(8, 4),dpi=150) resp = ct.nyquist_response(G, indent_direction='left', indent_radius=0.05) resp = ct.nyquist_response(G, indent_direction='left', indent_radius=0.05) both plots appear on ax[1] as opposed to what I want, which is 1 each on ax[0] and ax[1]. |
Hi - not sure I fully understand how the indentation around an imaginary axis pole is being done for the nyquist plot.
Looking at freqplot.py L 1449:1555 I see:
with the phase being from -pi/2:pi/2 (unless at origin) with a direction determined by the indent direction
and np.exp(...) creating the small complex valued quarter/half circle centered at pole p (on imag axis)
this change seems to break the encirclement math that follows in the code, so I cannot provide a working example
The text was updated successfully, but these errors were encountered: