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

Plotting output/input values #71

Open
kakila opened this issue Jun 9, 2022 · 1 comment
Open

Plotting output/input values #71

kakila opened this issue Jun 9, 2022 · 1 comment

Comments

@kakila
Copy link

kakila commented Jun 9, 2022

How one does plot the values of the input/output pins?
For example, from the RC circuit example (not working on v1.4.0 , see #70) one plots the current and voltage in the components with

plot(sol, vars = [capacitor.v,resistor.i])

but (as I was expecting being used to work with MTK) this doesn't work

plot(sol, vars = [capacitor.v, resistor.i, source.V])

or in the modified version (#70)

plot(sol, vars = [C.v, R.i, V.V])

or

plot(sol, vars = [C.v,R.i, source.output])

Is this because we are not composing the systems but directly assemble the ODESystem? or is it an effect of the connect function?

@baggepinnen
Copy link
Contributor

baggepinnen commented Jun 9, 2022

You currently need to use source.output.u since source.output is a connector. I find this quite annoying and would be happy to figure out a solution such that simply typing source.output would work.

For this connector, there is only a single variable that could be plotted, but in general there may be any number of plottable variables in a connector. Maybe SciMLBase.solution_interface could introduce an access function plot_representation etc. that is called on each symbol that is passed in. The default implementation would simply be the identity

plot_representation(x) = x

but ODESystem could overload this to something like the following

plot_representation(sys::ODESystem) = length(states(sys)) == 1 ? states(sys)[] : error()

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