-
Notifications
You must be signed in to change notification settings - Fork 445
Fix interconnect type conversion bug for StateSpace systems #788
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
Fix interconnect type conversion bug for StateSpace systems #788
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except for the one comment.
control/iosys.py
Outdated
| type(self)) | ||
|
|
||
| def dynamics(self, t, x, u): | ||
| def dynamics(self, t, x, u, params={}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to use the params=None, if params is None: params={} pattern here? Using mutable objects for default parameters is usually not a good idea.
Also, why not **kwargs?
control/iosys.py
Outdated
| returns the time derivative | ||
| dx/dt = f(t, x, u) | ||
| dx/dt = f(t, x, u, params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| dx/dt = f(t, x, u, params) | |
| dx/dt = f(t, x, u[, params]) |
control/iosys.py
Outdated
| If the system is discrete-time, returns the next value of `x`: | ||
| x[t+dt] = f(t, x[t], u[t]) | ||
| x[t+dt] = f(t, x[t], u[t], params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| x[t+dt] = f(t, x[t], u[t], params) | |
| x[t+dt] = f(t, x[t], u[t][, params]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other thought: currently, StateSpace.dynamics does not have params as a kwarg, but it probably should (maybe with a warning that it will be ignored).
|
Like the |
This PR fixes a problem that was identified in PR #785, where interconnecting a
LinearIOSystemwith aStateSpacesystem via theinterconnectfunction did not work correctly. In particular, if you created a mixed system of this type you would get back anInterconnectedSystemthat would generate an error is you tried to simulate it or evaluate the dynamics. This was fixed by adding a few lines of code tointerconnect()that convertStateSpaceandTransferFunctionobjects toLinearIOSystems, mimicking what is done with operator overloading.In addition, there was a bug where the
paramkeyword was not allowed in thedynamicsandoutputfunctions. This is now fixed and tested with a unit test.