I’ll look into why this isn’t giving the better error message. The issue of course is that you’re missing guesses for the nonlinear solver:
using ModelingToolkit
using DifferentialEquations: solve
@variables t
@mtkmodel LinearEq begin
@parameters begin
end
@variables begin
x(t)
y(t)
end
@equations begin
10 ~ x + y
15 ~ x - y
end
end
@mtkbuild eq = LinearEq()
prob = ODEProblem(eq,[],(0,1),[], guesses = [eq.x => 0.0, eq.y => 0.0])
sol = solve(prob)
But why it gives the less informative error is worth investigating. This is the expected error:
julia> prob = ODEProblem(eq,[],(0,1),[], guesses = [eq.x => 0.0])
ERROR: Initial condition underdefined. Some are missing from the variable map.
Please provide a default (`u0`), initialization equation, or guess
for the following variables:
SymbolicUtils.BasicSymbolic{Real}[y(t)]
Stacktrace:
[1] _varmap_to_vars(varmap::Dict{…}, varlist::Vector{…}; defaults::Dict{…}, check::Bool, toterm::typeof(ModelingToolkit.default_toterm), initialization_phase::Bool)
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/variables.jl:198
[2] varmap_to_vars(varmap::Vector{…}, varlist::Vector{…}; defaults::Dict{…}, check::Bool, toterm::Function, promotetoconcrete::Nothing, tofloat::Bool, use_union::Bool)
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/variables.jl:152
[3] get_u0(sys::NonlinearSystem, u0map::Vector{Pair{Num, Float64}}, parammap::Vector{Any}; symbolic_u0::Bool)
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:0
[4] get_u0
@ ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:815 [inlined]
[5] process_NonlinearProblem(constructor::Type, sys::NonlinearSystem, u0map::Vector{…}, parammap::Vector{…}; version::Nothing, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, tofloat::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/nonlinear/nonlinearsystem.jl:365
[6] process_NonlinearProblem
@ ~/.julia/dev/ModelingToolkit/src/systems/nonlinear/nonlinearsystem.jl:350 [inlined]
[7] (NonlinearProblem{…})(sys::NonlinearSystem, u0map::Vector{…}, parammap::Vector{…}; check_length::Bool, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/nonlinear/nonlinearsystem.jl:401
[8] (NonlinearProblem{true})(sys::NonlinearSystem, u0map::Vector{Pair{Num, Float64}}, parammap::Vector{Any})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/nonlinear/nonlinearsystem.jl:395
[9] NonlinearProblem(::NonlinearSystem, ::Vector{Pair{Num, Float64}}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/nonlinear/nonlinearsystem.jl:392
[10] NonlinearProblem(::NonlinearSystem, ::Vector{Pair{Num, Float64}}, ::Vararg{Any})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/nonlinear/nonlinearsystem.jl:391
[11] ModelingToolkit.InitializationProblem{…}(sys::ODESystem, t::Int64, u0map::Vector{…}, parammap::Vector{…}; guesses::Vector{…}, check_length::Bool, warn_initialize_determined::Bool, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1601
[12] kwcall(::NamedTuple, ::Type{…}, sys::ModelingToolkit.AbstractODESystem, args::Vararg{…})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1558 [inlined]
[13] #_#762
@ ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1536 [inlined]
[14] kwcall(::NamedTuple, ::Type{…}, sys::ModelingToolkit.AbstractODESystem, args::Vararg{…})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1535 [inlined]
[15] #InitializationProblem#760
@ ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1524 [inlined]
[16] kwcall(::NamedTuple, ::Type{…}, sys::ModelingToolkit.AbstractODESystem, args::Vararg{…})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1523 [inlined]
[17] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{…}, parammap::Vector{…}; implicit_dae::Bool, du0map::Nothing, version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, tofloat::Bool, symbolic_u0::Bool, u0_constructor::typeof(identity), guesses::Vector{…}, t::Int64, warn_initialize_determined::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:886
[18] process_DEProblem
@ ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:844 [inlined]
[19] (ODEProblem{…})(sys::ODESystem, u0map::Vector{…}, tspan::Tuple{…}, parammap::Vector{…}; callback::Nothing, check_length::Bool, warn_initialize_determined::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1046
[20] (ODEProblem{true})(::ODESystem, ::Vector{Any}, ::Vararg{Any}; kwargs::@Kwargs{guesses::Vector{Pair{Num, Float64}}})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1023
[21] ODEProblem(::ODESystem, ::Vector{Any}, ::Vararg{Any}; kwargs::@Kwargs{guesses::Vector{Pair{Num, Float64}}})
@ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/abstractodesystem.jl:1012
[22] top-level scope
@ REPL[2]:1
Some type information was truncated. Use `show(err)` to see complete types.