Skip to content

Bug fix and improvements to Nyquist plots #722

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

Merged
merged 11 commits into from
Apr 25, 2022
9 changes: 9 additions & 0 deletions control/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ def use_legacy_defaults(version):
#
reset_defaults() # start from a clean slate

# Version 0.9.2:
if major == 0 and minor < 9 or (minor == 9 and patch < 2):
from math import inf

# Reset Nyquist defaults
set_defaults('nyquist', indent_radius=0.1, max_curve_magnitude=inf,
max_curve_offset=0, primary_style=['-', '-'],
mirror_style=['--', '--'], start_marker_size=0)

# Version 0.9.0:
if major == 0 and minor < 9:
# switched to 'array' as default for state space objects
Expand Down
15 changes: 13 additions & 2 deletions control/descfcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def describing_function(


def describing_function_plot(
H, F, A, omega=None, refine=True, label="%5.2g @ %-5.2g", **kwargs):
H, F, A, omega=None, refine=True, label="%5.2g @ %-5.2g",
warn=None, **kwargs):
"""Plot a Nyquist plot with a describing function for a nonlinear system.

This function generates a Nyquist plot for a closed loop system consisting
Expand All @@ -220,6 +221,10 @@ def describing_function_plot(
label : str, optional
Formatting string used to label intersection points on the Nyquist
plot. Defaults to "%5.2g @ %-5.2g". Set to `None` to omit labels.
warn : bool, optional
Set to True to turn on warnings generated by `nyquist_plot` or False
to turn off warnings. If not set (or set to None), warnings are
turned off if omega is specified, otherwise they are turned on.

Returns
-------
Expand All @@ -240,9 +245,15 @@ def describing_function_plot(
[(3.344008947853124, 1.414213099755523)]

"""
# Decide whether to turn on warnings or not
if warn is None:
# Turn warnings on unless omega was specified
warn = omega is None

# Start by drawing a Nyquist curve
count, contour = nyquist_plot(
H, omega, plot=True, return_contour=True, **kwargs)
H, omega, plot=True, return_contour=True,
warn_encirclements=warn, warn_nyquist=warn, **kwargs)
H_omega, H_vals = contour.imag, H(contour)

# Compute the describing function
Expand Down
Loading