SciML / SciMLBase.jl

The Base interface of the SciML ecosystem
https://docs.sciml.ai/SciMLBase/stable
MIT License
118 stars 91 forks source link

Inconsistent behaviour when changing integrator variable value #653

Closed TorkelE closed 3 months ago

TorkelE commented 3 months ago

In one case, using oint[X] works while setu(oint, X)(oint, 10.0) throws an error. Presumably, the first one should throw an error as well?

using  ModelingToolkit, OrdinaryDiffEq
using ModelingToolkit: t_nounits as t, D_nounits as D

@parameters p
@variables X(t)

eq = D(X) ~ p - X
@mtkbuild osys = ODESystem([eq], t)
oprob = ODEProblem(osys, [X => 0.1], (0.0, 1.0), [p => 1.0])

oint = init(oprob, Tsit5())
oint[X] = 1.0 # Works.
setu(oint, X)(oint, 10.0) # ERROR: Integrator state cannot be reset unless it is initialized with save_everystep=false

oint = init(oprob, Tsit5(); save_everystep=false)
oint[X] = 1.0 # Works.
setu(oint, X)(oint, 10.0) # Works.