Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix find_eqpt when y0 is None#798

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
murrayrm merged 1 commit intopython-control:mainfromadswid:fix-find_eqpt
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
11 changes: 8 additions & 3 deletionscontrol/iosys.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2138,10 +2138,15 @@ def rootfun(z):
dx = sys._rhs(t, x, u) - dx0
if dtime:
dx -= x # TODO: check
dy = sys._out(t, x, u) - y0

# Map the results into the constrained variables
return np.concatenate((dx[deriv_vars], dy[output_vars]), axis=0)
# If no y0 is given, don't evaluate the output function
if y0 is None:
return dx[deriv_vars]
else:
dy = sys._out(t, x, u) - y0

# Map the results into the constrained variables
return np.concatenate((dx[deriv_vars], dy[output_vars]), axis=0)

# Set the initial condition for the root finding algorithm
z0 = np.concatenate((x[state_vars], u[input_vars]), axis=0)
Expand Down
11 changes: 11 additions & 0 deletionscontrol/tests/iosys_test.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -822,6 +822,17 @@ def test_find_eqpts(self, tsys):
np.testing.assert_array_almost_equal(
nlsys_full._rhs(0, xeq, ueq)[-4:], np.zeros((4,)), decimal=5)

# The same test as previous, but now all constraints are in the state vector
nlsys_full = ios.NonlinearIOSystem(pvtol_full, None)
xeq, ueq, result = ios.find_eqpt(
nlsys_full, [0, 0, 0.1, 0.1, 0, 0], [0.01, 4*9.8],
idx=[2, 3, 4, 5], ix=[0, 1, 2, 3], return_result=True)
assert result.success
np.testing.assert_array_almost_equal(
nlsys_full._out(0, xeq, ueq)[[2, 3]], [0.1, 0.1], decimal=5)
np.testing.assert_array_almost_equal(
nlsys_full._rhs(0, xeq, ueq)[-4:], np.zeros((4,)), decimal=5)

# Fix one input and vary the other
nlsys_full = ios.NonlinearIOSystem(pvtol_full, None)
xeq, ueq, result = ios.find_eqpt(
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp