Skip to content

Commit d311109

Browse files
committed
updated examples and small tweaks to docs
1 parent e54b4b7 commit d311109

File tree

6 files changed

+47
-32
lines changed

6 files changed

+47
-32
lines changed

control/freqplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
742742
else:
743743
contour = 1j * omega_sys
744744

745-
# Bend the contour around any poles on/near the imaginary access
745+
# Bend the contour around any poles on/near the imaginary axis
746746
if isinstance(sys, (StateSpace, TransferFunction)) and \
747747
sys.isctime() and indent_direction != 'none':
748748
poles = sys.pole()

control/tests/nyquist_test.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _P(sys, indent='right'):
2222
if indent == 'right':
2323
return (sys.pole().real > 0).sum()
2424
elif indent == 'left':
25-
return (sys.pole().real < 0).sum()
25+
return (sys.pole().real >= 0).sum()
2626
elif indent == 'none':
2727
if any(sys.pole().real == 0):
2828
raise ValueError("indent must be left or right for imaginary pole")
@@ -209,16 +209,33 @@ def test_nyquist_indent():
209209
assert _Z(sys) == count + _P(sys)
210210

211211
plt.figure();
212-
count = ct.nyquist_plot(sys, indent_direction='right')
212+
count = ct.nyquist_plot(sys, indent_direction='left')
213213
plt.title(
214-
"Pole at origin; indent_direction='right'; encirclements = %d" % count)
214+
"Pole at origin; indent_direction='left'; encirclements = %d" % count)
215+
assert _Z(sys) == count + _P(sys, indent='left')
216+
217+
# System with poles on the imaginary axis
218+
sys = ct.tf([1, 1], [1, 0, 1])
219+
220+
# Imaginary poles with standard indentation
221+
plt.figure();
222+
count = ct.nyquist_plot(sys)
223+
plt.title("Imaginary poles; encirclements = %d" % count)
215224
assert _Z(sys) == count + _P(sys)
216225

226+
# Imaginary poles with indentation to the left
227+
plt.figure();
228+
count = ct.nyquist_plot(sys, indent_direction='left', label_freq=300)
229+
plt.title(
230+
"Imaginary poles; indent_direction='left'; encirclements = %d" % count)
231+
assert _Z(sys) == count + _P(sys, indent='left')
232+
233+
# Imaginary poles with no indentation
217234
plt.figure();
218235
count = ct.nyquist_plot(
219-
sys, omega_limits=[1e-2, 1e-3], indent_direction='none')
236+
sys, np.linspace(0, 1e3, 1000), indent_direction='none')
220237
plt.title(
221-
"Pole at origin; indent_direction='none'; encirclements = %d" % count)
238+
"Imaginary poles; indent_direction='none'; encirclements = %d" % count)
222239
assert _Z(sys) == count + _P(sys)
223240

224241

@@ -269,8 +286,7 @@ def test_nyquist_exceptions():
269286

270287
print("Unusual Nyquist plot")
271288
sys = ct.tf([1], [1, 3, 2]) * ct.tf([1], [1, 0, 1])
272-
print(sys)
273-
print("Poles:", sys.pole())
274289
plt.figure()
290+
plt.title("Poles: %s" % np.array2string(sys.pole(), precision=2, separator=','))
275291
count = ct.nyquist_plot(sys)
276292
assert _Z(sys) == count + _P(sys)

0 commit comments

Comments
 (0)