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 typo in ICSystem updfcn, outfcn: update_params -> _update_params#990

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
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
4 changes: 2 additions & 2 deletionscontrol/nlsys.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -706,10 +706,10 @@ def __init__(self, syslist, connections=None, inplist=None, outlist=None,

# Create updfcn and outfcn
def updfcn(t, x, u, params):
self.update_params(params)
self._update_params(params)
return self._rhs(t, x, u)
def outfcn(t, x, u, params):
self.update_params(params)
self._update_params(params)
return self._out(t, x, u)

# Initialize NonlinearIOSystem object
Expand Down
30 changes: 30 additions & 0 deletionscontrol/tests/interconnect_test.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@

import numpy as np
import scipy as sp
import math

import control as ct

Expand DownExpand Up@@ -659,3 +660,32 @@ def test_interconnect_rewrite():
outputs=['y', 'z'])

assert icsys.input_labels == ['u[0]', 'u[1]', 'w[0]', 'w[1]']


def test_interconnect_params():
# Create a nominally unstable system
sys1 = ct.nlsys(
lambda t, x, u, params: params['a'] * x[0] + u[0],
states=1, inputs='u', outputs='y', params={'a': 1})

# Simple system for serial interconnection
sys2 = ct.nlsys(
None, lambda t, x, u, params: u[0],
inputs='r', outputs='u')

# Create a series interconnection
sys = ct.interconnect([sys1, sys2], inputs='r', outputs='y')

# Make sure we can call the update function
sys.updfcn(0, [0], [0], {})

# Make sure the serial interconnection is unstable to start
assert sys.linearize([0], [0]).poles()[0].real == 1

# Change the parameter and make sure it takes
assert sys.linearize([0], [0], params={'a': -1}).poles()[0].real == -1

# Now try running a simulation
timepts = np.linspace(0, 10)
resp = ct.input_output_response(sys, timepts, 0, params={'a': -1})
assert resp.states[0, -1].item() < 2 * math.exp(-10)

[8]ページ先頭

©2009-2025 Movatter.jp