Skip to content

Better error message for using old Problem creation notatio #3680

Closed
@TorkelE

Description

@TorkelE

With v10 coming out there will probably be tons of people using the old notation to create ODEProblems by mistake (i.e. I did for a while until I looked at the NEws file). It might make sense to add a specific warning mentioning the v10 release. It will likely save people tons of time.

Currently

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

@parameters p d1 d2
@variables X(t) Y(t)

ode_eqs = [
    D(X) ~ p - d1*X,
    D(Y) ~ p - d2*Y
]
@mtkcompile osys = System(ode_eqs, t)

u0 = [X => 0.2, Y => 2.0]
tspan = (0.0, 10.0)
ps = [p => 1.0, d1 => 0.5, d2 => 1.0]
oprob = ODEProblem(osys, u0, tspan, ps)

yields a

ERROR: No methods were found for the model function passed to the equation solver.
The function `f` needs to have dispatches, for example, for an ODEProblem
`f` must define either `f(u,p,t)` or `f(du,u,p,t)`. For more information
on how the model function `f` should be defined, consult the docstring for
the appropriate `AbstractSciMLFunction`.

Offending function: f
Stacktrace:
 [1] 
   @ SciMLBase ~/.julia/packages/SciMLBase/Ha7rZ/src/utils.jl:254
 [2] isinplace (repeats 2 times)
   @ ~/.julia/packages/SciMLBase/Ha7rZ/src/utils.jl:246 [inlined]
 [3] ODEProblem(f::System, u0::Vector{Pair{…}}, tspan::Tuple{Float64, Float64}, p::Vector{Pair{…}}; kwargs::@Kwargs{})
   @ SciMLBase ~/.julia/packages/SciMLBase/Ha7rZ/src/problems/ode_problems.jl:198
 [4] ODEProblem(f::System, u0::Vector{Pair{Num, Float64}}, tspan::Tuple{Float64, Float64}, p::Vector{Pair{Num, Float64}})
   @ SciMLBase ~/.julia/packages/SciMLBase/Ha7rZ/src/problems/ode_problems.jl:197
 [5] top-level scope
   @ ~/Desktop/Julia Playground/Environment - Temporary/temporary_playground.jl:23
Some type information was truncated. Use `show(err)` to see complete types.

error, which is not very helpful.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions