Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abec61f

Browse files
committed
add test for quarter circle
1 parent 6699da0 commit abec61f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

control/tests/nyquist_test.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,30 @@ def test_nyquist_indent():
186186
# FBS Figure 10.10
187187
s = ct.tf('s')
188188
sys = 3 * (s+6)**2 / (s * (s+1)**2)
189+
# poles: [-1, -1, 0]
189190

190191
plt.figure();
191192
count = ct.nyquist_plot(sys)
192193
plt.title("Pole at origin; indent_radius=default")
193194
assert _Z(sys) == count + _P(sys)
194195

196+
# first value of default omega vector was 0.1, replaced by 0. for contour
197+
# indent_radius is larger than 0.1 -> no extra quater circle around origin
198+
count, contour = ct.nyquist_plot(sys, plot=False, indent_radius=.1007,
199+
return_contour=True)
200+
np.testing.assert_allclose(contour[0], .1007+0.j)
201+
# second value of omega_vector is larger than indent_radius: not indented
202+
assert np.all(contour.real[2:] == 0.)
203+
195204
plt.figure();
196-
count = ct.nyquist_plot(sys, indent_radius=0.01)
205+
count, contour = ct.nyquist_plot(sys, indent_radius=0.01,
206+
return_contour=True)
197207
plt.title("Pole at origin; indent_radius=0.01; encirclements = %d" % count)
198208
assert _Z(sys) == count + _P(sys)
209+
# indent radius is smaller than the start of the default omega vector
210+
# check that a quarter circle around the pole at origin has been added.
211+
np.testing.assert_allclose(contour[:50].real**2 + contour[:50].imag**2,
212+
0.01**2)
199213

200214
plt.figure();
201215
count = ct.nyquist_plot(sys, indent_direction='left')

0 commit comments

Comments
 (0)