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

Skip to content

Add test for Nyquist evaluation at a pole #1104

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 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions control/freqplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,12 @@ def nyquist_response(
else:
contour = np.exp(splane_contour * sys.dt)

# Make sure we don't try to evaluate at a pole
if isinstance(sys, (StateSpace, TransferFunction)):
if any([pole in contour for pole in sys.poles()]):
raise RuntimeError(
"attempt to evaluate at a pole; indent required")

# Compute the primary curve
resp = sys(contour)

Expand Down
9 changes: 9 additions & 0 deletions control/tests/nyquist_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,15 @@ def test_nyquist_frd():
warnings.resetwarnings()


def test_no_indent_pole():
s = ct.tf('s')
sys = ((1 + 5/s)/(1 + 0.5/s))**2 # Double-Lag-Compensator

with pytest.raises(RuntimeError, match="evaluate at a pole"):
resp = ct.nyquist_response(
sys, warn_encirclements=False, indent_direction='none')


if __name__ == "__main__":
#
# Interactive mode: generate plots for manual viewing
Expand Down
Loading