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

Skip to content

allow root locus maps with only 1 point #1065

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
Nov 24, 2024
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
12 changes: 7 additions & 5 deletions control/pzmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,16 @@ def _compute_root_locus_limits(response):
# Find the local maxima of root locus curve
xpeaks = np.where(
np.diff(np.abs(locus.real)) < 0, locus.real[0:-1], 0)
xlim = [
min(xlim[0], np.min(xpeaks) * rho),
max(xlim[1], np.max(xpeaks) * rho)
]
if xpeaks.size > 0:
xlim = [
min(xlim[0], np.min(xpeaks) * rho),
max(xlim[1], np.max(xpeaks) * rho)
]

ypeaks = np.where(
np.diff(np.abs(locus.imag)) < 0, locus.imag[0:-1], 0)
ylim = max(ylim, np.max(ypeaks) * rho)
if ypeaks.size > 0:
ylim = max(ylim, np.max(ypeaks) * rho)

if isctime(dt=response.dt):
# Adjust the limits to include some space around features
Expand Down
7 changes: 3 additions & 4 deletions control/rlocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ def root_locus_map(sysdata, gains=None):
Returns
-------
rldata : PoleZeroData or list of PoleZeroData
Root locus data object(s) corresponding to the . The loci of
the root locus diagram are available in the array
`rldata.loci`, indexed by the gain index and the locus index,
and the gains are in the array `rldata.gains`.
Root locus data object(s). The loci of the root locus diagram are
available in the array `rldata.loci`, indexed by the gain index and
the locus index, and the gains are in the array `rldata.gains`.

Notes
-----
Expand Down
15 changes: 15 additions & 0 deletions control/tests/rlocus_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,18 @@ def test_root_locus_documentation(savefigs=False):

# Run tests that generate plots for the documentation
test_root_locus_documentation(savefigs=True)


# https://github.com/python-control/python-control/issues/1063
def test_rlocus_singleton():
# Generate a root locus map for a singleton
L = ct.tf([1, 1], [1, 2, 3])
rldata = ct.root_locus_map(L, 1)
np.testing.assert_equal(rldata.gains, np.array([1]))
assert rldata.loci.shape == (1, 2)

# Generate the root locus plot (no loci)
cplt = rldata.plot()
assert len(cplt.lines[0, 0]) == 1 # poles (one set of markers)
assert len(cplt.lines[0, 1]) == 1 # zeros
assert len(cplt.lines[0, 2]) == 2 # loci (two 0-length lines)
Loading