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

Parallel system interconnection using control.interconnect() #991

Closed
sdahdah opened this issue Apr 10, 2024 · 4 comments
Closed

Parallel system interconnection using control.interconnect() #991

sdahdah opened this issue Apr 10, 2024 · 4 comments

Comments

@sdahdah
Copy link

sdahdah commented Apr 10, 2024

I'm trying to use control.interconnect() to connect one system input to two subsystem inputs, but I can't figure out a clean way to do it. The best way I've found so far is to create a dummy summing junction for this purpose, as shown below:

import control

# Systems to connect in parallel
a = control.TransferFunction([1], [1], name='a')
b = control.TransferFunction([1], [2], name='b')
sum = control.summing_junction(2, name='sum')
split = control.summing_junction(1, name='split')

# Interconnection using ``control.interconnect``
P_interconnect = control.interconnect(
    syslist=[a, b, sum, split],
    connections=[
        ['sum.u[0]', 'a'],
        ['sum.u[1]', 'b'],
        ['a', 'split'],
        ['b', 'split'],
    ],
    inplist=['split'],
    outlist=['sum'],
)
print(P_interconnect)

# Interconnection using ``control.parallel``
P_parallel = control.parallel(a, b)
print(control.tf2ss(P_parallel))

Am I missing something, or is this the recommended way to feed two subsystem blocks the same system-level input?

@slivingston
Copy link
Member

Did you try to use the inputs and outputs parameters? These are shown in the "auto-splitting" section of examples/interconnect_tutorial.ipynb.

@sdahdah
Copy link
Author

sdahdah commented Apr 11, 2024

That makes sense, thanks! Does that only work when connecting signals by name (i.e. when connections is left unspecified)?

@slivingston
Copy link
Member

connections specifies internal connections (i.e., between subsystems), whereas auto-splitting behavior only affects how system inputs map to subsystem inputs. Therefore, connections can be given when doing this.

Note that automatically (also known as "implicitly") making internal connections will not work with an explicit connections argument. For reference, the relevant part of the code is

# If connections was not specified, assume implicit interconnection.
# set up default connection list
if connections is None:
connection_type = 'implicit'
# For each system input, look for outputs with the same name
connections = []
for input_sys in syslist:
for input_name in input_sys.input_labels:
connect = [input_sys.name + "." + input_name]
for output_sys in syslist:
if input_name in output_sys.output_labels:
connect.append(output_sys.name + "." + input_name)
if len(connect) > 1:
connections.append(connect)

@sdahdah
Copy link
Author

sdahdah commented Apr 12, 2024

Got it. Thanks for the help!

@sdahdah sdahdah closed this as completed Apr 12, 2024
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

No branches or pull requests

2 participants