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

In-place solution evaluation does not work with ModelingToolkit #2562

Open
hersle opened this issue Dec 19, 2024 · 0 comments
Open

In-place solution evaluation does not work with ModelingToolkit #2562

hersle opened this issue Dec 19, 2024 · 0 comments
Assignees
Labels

Comments

@hersle
Copy link

hersle commented Dec 19, 2024

The documentation mentions an inplace function for evaluating a solution, but this does not work with ModelingToolkit:

using OrdinaryDiffEq, ModelingToolkit, Test
using ModelingToolkit: t_nounits as t, D_nounits as D
@variables x(t) y(t)
@named sys = ODESystem([
    D(x) ~ 0 # unknown
    y ~ 2*x # observed
], t)
sys = structural_simplify(sys)
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [])
sol = solve(prob, Tsit5())

ts = range(0.0, 1.0, length=5)
out = zeros(size(ts))
@test sol(out, ts; idxs=1) == sol(ts; idxs=1) # passes
@test sol(out, ts; idxs=sys.x) == sol(ts; idxs=sys.x) # RHS works, LHS fails
@test sol(out, ts; idxs=sys.y) == sol(ts; idxs=sys.y) # RHS works, LHS fails

The last two in-place evaluations fail with

ERROR: ArgumentError: invalid index: x(t) of type SymbolicUtils.BasicSymbolic{Real}
ERROR: ArgumentError: invalid index: y(t) of type SymbolicUtils.BasicSymbolic{Real}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants