Skip to content
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

add summing junction + implicit signal interconnection #517

Merged
merged 3 commits into from Jan 26, 2021

Conversation

murrayrm
Copy link
Member

This PR addresses the enhancement describe in issue #516 where signals with the same name are automatically interconnected by the interconnect function. It also defines a new function summation_block that addresses the request in issue #493. Together, these capabilities allow the following code to work for setting up a simple feedback system:

P = ct.ss2io(
    ct.rss(2, 1, 1, strictly_proper=True),
    inputs='u', outputs='y', name='P')
kp = ct.tf(random.uniform(1, 10), [1])
ki = ct.tf(random.uniform(1, 10), [1, 0])
C = ct.tf2io(kp + ki, inputs='e', outputs='u', name='C')
sumblk = ct.summation_block(inputs=['r', '-y'], output='e', name="sum")
Tio_sum = ct.interconnect(
    (C, P, sumblk), inplist=['r'], outlist=['y'])

Other minor changes:

  • Added code to allow the iosys.feedback function to accept a float_like for the feedback system (so that feedback(P * C, 1) now works.

@murrayrm murrayrm changed the title dd summation_block and implicit signal interconnection add summation_block + implicit signal interconnection Jan 23, 2021
@coveralls
Copy link

coveralls commented Jan 23, 2021

Coverage Status

Coverage increased (+0.1%) to 87.754% when pulling 791f7a6 on murrayrm:sumblk_implicit_interconnect into 1502d38 on python-control:master.

@sawyerbfuller
Copy link
Contributor

sawyerbfuller commented Jan 23, 2021

Very cool!

I particularly like that it appears possible with this to leave out the ‘name’ keyword for the constitutive systems for simple interconnections like this. Am I correct in that? Nice to have that option because thst keyword is somewhat redundant and prone to errors when code gets modified.

If you give the sumblock more input names (eg 3 instead of 2), does it sum those three signals?

@murrayrm
Copy link
Member Author

murrayrm commented Jan 24, 2021

it appears possible with this to leave out the ‘name’ keyword for the constitutive systems for simple interconnections like this. Am I correct in that?

Correct. The following works just fine (from #516):

P = ct.tf2io(ct.tf(1, [1, 0]), inputs='u', outputs='y')
C = ct.tf2io(ct.tf(10, [1, 1]), inputs='e', outputs='u')
sumblk = ct.summation_block(inputs=['r', '-y'], output='e')
T = ct.interconnect((P, C, sumblk), inplist='r', outlist='y')

(P, C, and sumblk all have names automatically assigned, but not needed here).

If you give the sumblock more input names (eg 3 instead of 2), does it sum those three signals?

Yup. Any number of inputs can be summed together. The summation_block function does not require named signals, so you can also do ct.summation_block(7) if you want a LinearIOSystem that has 7 inputs and 1 output (sum of the inputs), for example).

Some possible tweaks:

  • I think I may use the term summing_junction (instead of summation_block) to line up with the term we use in FBS.
  • I will add a bit more documentation, both in docstrings and in the manual
  • I want to switch all examples using InterconnectedSystem to use interconnect since using the class constructor since the function provides a slightly higher level interface (eg, the class constructor still requires the explicit signal name).

@sawyerbfuller
Copy link
Contributor

Awesome.

New name for summer sounds better.

Hoping this will make creating simulink-like interconnected system simulations much easier. I will let you know how it goes once it’s been merged in.

@bnavigator
Copy link
Contributor

Very nice!

(Now we will have users demanding a graphical editor next 😁. Implemented as jupyter notebook widget or the like.)

@sawyerbfuller
Copy link
Contributor

sawyerbfuller commented Jan 24, 2021 via email

interconneciton map by connecting all signals with the same base names
(ignoring the system name). Specifically, for each input signal name
in the list of systems, if that signal name corresponds to the output
signal in any of the systems, it will be connected to that input (with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this summation effect is stated explicitly.

@murrayrm murrayrm changed the title add summation_block + implicit signal interconnection add summing junction + implicit signal interconnection Jan 26, 2021
@murrayrm murrayrm merged commit 122672a into python-control:master Jan 26, 2021
@murrayrm murrayrm deleted the sumblk_implicit_interconnect branch January 31, 2021 00:13
@murrayrm murrayrm added this to the 0.9.0 milestone Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using interconnect/interconnected system sumblk doesnt exists for connection in matlab compatibility module
4 participants