SciML / ModelingToolkitStandardLibrary.jl

A standard library of components to model the world and beyond
https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/
MIT License
112 stars 36 forks source link

Mux/Demux missing #80

Open baggepinnen opened 2 years ago

baggepinnen commented 2 years ago

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.

ValentinKaisermayer commented 2 years ago

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.

baggepinnen commented 2 years ago

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?