I believe this is the same error as from Missing from the variable map error
Specifically, I have created a ModelingToolkit ODESystem, saved it into a variable, and passed that variable to a function. The below is an MWE version of the function.
function MTK_MWE(model::ODESystem)
t = ModelingToolkit.get_iv(model)
model_eq = ModelingToolkit.equations(model)
model_states = ModelingToolkit.states(model)
model_ps = ModelingToolkit.parameters(model)
time_interval = (0.0, 1.0)
initial_conditions = [s => (1.0) for s in ModelingToolkit.states(model)]
parameter_values = [p => (1.0) for p in ModelingToolkit.parameters(model)]
u0 = [parameter_values; initial_conditions]
prob = ODEProblem(model, initial_conditions, time_interval)
rprob = remake(prob, u = u0)
end
I will paste the error below. The discourse link above suggests a solution (@nonamespace) which I can’t get to work, and as of 2021 was suggested to soon be breaking. A link is also given to Accessing and referring to `ODESystem` states · Issue #1049 · SciML/ModelingToolkit.jl · GitHub . I am using Julia 1.10 and all the latest versions of packages as of 10Feb24.
Full error below
ERROR: LoadError: ArgumentError: SymbolicUtils.BasicSymbolic{Real}[a, b, c, d] are missing from the variable map.
Stacktrace:
[1] throw_missingvars(vars::Vector{SymbolicUtils.BasicSymbolic{Real}})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/variables.jl:122
[2] _varmap_to_vars(varmap::Dict{Any, Any}, varlist::Vector{SymbolicUtils.BasicSymbolic{Real}}; defaults::Dict{Any, Any}, check::Bool, toterm::typeof(ModelingToolkit.default_toterm))
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/variables.jl:116
[3] varmap_to_vars(varmap::SciMLBase.NullParameters, varlist::Vector{SymbolicUtils.BasicSymbolic{Real}}; defaults::Dict{Any, Any}, check::Bool, toterm::Function, promotetoconcrete::Nothing, tofloat::Bool, use_union::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/variables.jl:85
[4] get_u0_p(sys::ODESystem, u0map::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}}, parammap::SciMLBase.NullParameters; use_union::Bool, tofloat::Bool, symbolic_u0::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:788
[5] get_u0_p
@ ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:768 [inlined]
[6] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{…}, parammap::SciMLBase.NullParameters; 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), kwargs::@Kwargs{…})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:811
[7] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}}, tspan::Tuple{Float64, Float64}, parammap::SciMLBase.NullParameters; callback::Nothing, check_length::Bool, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:936
[8] ODEProblem
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:929 [inlined]
[9] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}}, tspan::Tuple{Float64, Float64})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:929
[10] (ODEProblem{true})(::ODESystem, ::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:916
[11] (ODEProblem{true})(::ODESystem, ::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}}, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:915
[12] ODEProblem(::ODESystem, ::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:912
[13] ODEProblem(::ODESystem, ::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}}, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:911
[14] MTK_MWE(model::ODESystem)
@ Main ~/learning/ODETests/SPE.jl:30
[15] main()
@ Main ~/learning/ODETests/supersimple.jl:58
[16] top-level scope
@ ~/learning/ODETests/supersimple.jl:64
[17] include(fname::String)
@ Base.MainInclude ./client.jl:489
[18] top-level scope
@ REPL[3]:1
in expression starting at /home/orebas/learning/ODETests/supersimple.jl:64
Some type information was truncated. Use `show(err)` to see complete types.