Skip to content

Commit a948186

Browse files
committed
z-to-s plane mapping results in small numerical errors so assume s-plane poles near imaginary axis are on imaginary axis
1 parent aa92e43 commit a948186

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

control/freqplot.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -718,16 +718,22 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
718718
splane_contour = 1j * omega_sys
719719

720720
# Bend the contour around any poles on/near the imaginary axis
721+
# TODO: smarter indent radius that depends on dcgain of system
722+
# and timebase of discrete system.
721723
if isinstance(sys, (StateSpace, TransferFunction)) \
722724
and indent_direction != 'none':
723725
if sys.isctime():
724726
splane_poles = sys.pole()
725727
else:
726-
# map z-plane poles to s-plane
727-
splane_poles = np.log(sys.pole())/sys.dt
728+
# map z-plane poles to s-plane, ignoring any at the origin
729+
# because we don't need to indent for them
730+
zplane_poles = sys.pole()
731+
zplane_poles = zplane_poles[~np.isclose(abs(zplane_poles), 0.)]
732+
splane_poles = np.log(zplane_poles)/sys.dt
728733

729734
if splane_contour[1].imag > indent_radius \
730-
and 0. in splane_poles and not omega_range_given:
735+
and np.any(np.isclose(abs(splane_poles), 0)) \
736+
and not omega_range_given:
731737
# add some points for quarter circle around poles at origin
732738
splane_contour = np.concatenate(
733739
(1j * np.linspace(0., indent_radius, 50),
@@ -737,13 +743,13 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
737743
p = splane_poles[(np.abs(splane_poles - s)).argmin()]
738744
# See if we need to indent around it
739745
if abs(s - p) < indent_radius:
740-
if p.real < 0 or \
741-
(p.real == 0 and indent_direction == 'right'):
746+
if p.real < 0 or (np.isclose(p.real, 0) \
747+
and indent_direction == 'right'):
742748
# Indent to the right
743749
splane_contour[i] += \
744750
np.sqrt(indent_radius ** 2 - (s-p).imag ** 2)
745-
elif p.real > 0 or \
746-
(p.real == 0 and indent_direction == 'left'):
751+
elif p.real > 0 or (np.isclose(p.real, 0) \
752+
and indent_direction == 'left'):
747753
# Indent to the left
748754
splane_contour[i] -= \
749755
np.sqrt(indent_radius ** 2 - (s-p).imag ** 2)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy