Title: Can you split an input to an interconnected system? · python-control/python-control · Discussion #1047 · GitHub
Open Graph Title: Can you split an input to an interconnected system? · python-control/python-control · Discussion #1047
X Title: Can you split an input to an interconnected system? · python-control/python-control · Discussion #1047
Description: Can you split an input to an interconnected system?
Open Graph Description: If I have an input that is external to an interconnected system, and I want this external input to connect into multiple systems contained within, the only way I can think to do this is by using se...
X Description: If I have an input that is external to an interconnected system, and I want this external input to connect into multiple systems contained within, the only way I can think to do this is by using se...
Opengraph URL: https://github.com/python-control/python-control/discussions/1047
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Can you split an input to an interconnected system?","text":"If I have an input that is external to an interconnected system, and I want this external input to connect into multiple systems contained within, the only way I can think to do this is by using set_input_map. Is there a more elegant way? Even when I use set_input_map, I still get the \"unused input\" warning.
\nPart of the motivation for this question is that it is difficult to understand how an external input is being used if you can only specify it in terms of the subsystem that it connects to. It might be intended for the input to connect to multiple subsystems.
\nHere is an example of how I have implemented:
\nimport numpy as np\nimport control as ct\n\ndef dynamics(t, x, u, p):\n A = np.array([[0, 1], [-p['spring_constant'], -p['damping_coefficient']]])\n B = np.array([[0], [1]])\n return A @ x + B @ u\n\ndef outputs(t, x, u, p):\n C = np.array([[1, 0]])\n D = np.array([[0]])\n return C @ x + D @ u\n\nsys1 = ct.nlsys(updfcn=dynamics, outfcn=outputs, states=['pos', 'vel'], inputs=['u1'], outputs=['pos'], name='sys1')\nsys1.params = {'spring_constant': 10, 'damping_coefficient': 0.5}\n\nsys2 = ct.nlsys(updfcn=dynamics, outfcn=outputs, states=['pos', 'vel'], inputs=['u2'], outputs=['pos'], name='sys2')\nsys2.params = {'spring_constant': 1, 'damping_coefficient': 1}\n\nsys = ct.interconnect(\n (sys1, sys2),\n # inplist=['u'], # only works if both subsystem inputs are named u\n outlist=['sys1.pos', 'sys2.pos'],\n outputs=['pos1', 'pos2']\n)\n\n# /venv/lib/python3.12/site-packages/control/nlsys.py:1192: UserWarning: Unused input(s) in InterconnectedSystem: (1, 0)=sys2.u2; (0, 0)=sys1.u1\n\nsys.set_input_map(np.array([[1],[1]]))\nsys.set_inputs('external_input')\n\nt = np.linspace(0, 10, 1000)\n\nu0 = lambda t: 1\nU = np.array([\n [u0(ti) for ti in t]\n])\n\nresults = ct.input_output_response(sys, T=t, U=U)\n\np = results.plot()\np.figure.show()
","upvoteCount":1,"answerCount":3,"acceptedAnswer":{"@type":"Answer","text":"You can accomplish this interconnection using the following:
\n sys = ct.interconnect(\n [sys1, sys2],\n connections=None,\n inplist=[\n ['sys1.u1', 'sys2.u2'] # Input connects to multiple signals\n ],\n inputs='external_input',\n outlist=['sys1.pos', 'sys2.pos'],\n outputs=['pos1', 'pos2'],\n ) \n
\nThe reason this works is that if you specify a list as an entry for inplist, it will connect that input (external_input) here to all of the signals in that list.
\nI also like the alternative syntax you have proposed above, so I've added issue #1049 to track its implementation.
","upvoteCount":1,"url":"https://github.com/python-control/python-control/discussions/1047#discussioncomment-10923719"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:943da936-9ad1-7760-bc48-11b3c4298ca3 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | 8282:39A312:60C125:88BEEC:6979ED8D |
| html-safe-nonce | a4860e63aee2894542f594a5d2a80b66e3edbd1e1326544ccc41bde11d757757 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjgyOjM5QTMxMjo2MEMxMjU6ODhCRUVDOjY5NzlFRDhEIiwidmlzaXRvcl9pZCI6IjE0OTU3MTcxMzg2Njc4ODIzNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 28a8bf0ae087f1aaff34f9f0e4865d9174fd6fa8dace08ddcf14c7201940f150 |
| hovercard-subject-tag | discussion:7296059 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-control/python-control/1047/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/a9255e148fd44e828024cc78e10ebc743c917f155710f039527c5eac829acd24/python-control/python-control/discussions/1047 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a9255e148fd44e828024cc78e10ebc743c917f155710f039527c5eac829acd24/python-control/python-control/discussions/1047 |
| og:image:alt | If I have an input that is external to an interconnected system, and I want this external input to connect into multiple systems contained within, the only way I can think to do this is by using se... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d518616844426fb176f4177c4776349f6e70ef1ce75f459c8c53bf9293bb6982 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-control/python-control git https://github.com/python-control/python-control.git |
| octolytics-dimension-user_id | 2285872 |
| octolytics-dimension-user_login | python-control |
| octolytics-dimension-repository_id | 22791752 |
| octolytics-dimension-repository_nwo | python-control/python-control |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 22791752 |
| octolytics-dimension-repository_network_root_nwo | python-control/python-control |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 22c6ce7724007ae85d7487fce3308a1c7cea8be6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width