ModelingToolkitStandardLibrary.jl icon indicating copy to clipboard operation
ModelingToolkitStandardLibrary.jl copied to clipboard

Mux/Demux missing

Open baggepinnen opened this issue 2 years ago • 2 comments

A component that has a connector RealInput(2) can not be interfaced with two separate signals like

connect(input1, signal1)
connect(input2, signal2)

since the input connector is vector valued. For this, a Mux block would be required

connect(signal1, mux.input1)
connect(signal2, mux.input2)
connect(input, mux.output)

Having said that, I find Mux/Demux very awkward and wouldn't mind a more elegant solution to this problem.

baggepinnen avatar Jun 17 '22 06:06 baggepinnen

If connect would be overloaded for Num it could work.

connect(sys1.output.u, sys2.input.u[1])

If this would be possible, also the need for RealInput and RealOutput beeing an OdeSystem would vanish.

ValentinKaisermayer avatar Jun 17 '22 14:06 ValentinKaisermayer

the need for RealInput and RealOutput beeing an OdeSystem would vanish

That would be great! It's so awkward to have to refer to input.u and output.u when plotting and doing low-level connections using equations.

How would we check that they are indeed connectors then? By a metadata check in the connect(::Num, ::Num) method? We still need to verify that the connection connects things from the same domain I guess?

baggepinnen avatar Jun 17 '22 14:06 baggepinnen