ModelingToolkit, initial data for second order ODE with state vector

I don’t get why this doesn’t work:

@variables t z[1:2,1:2](t)
z = collect(z)
Dt = Differential(t)

eqs = Dt.(Dt.(z[:])) .~ 1

u0 = vcat(z[:] .=> 0., Dt.(z[:]) .=> 1.0)
tspan = (0.0, 10.0)

@named sys = ODESystem(eqs)
prob = ODEProblem(sys, u0, tspan)

The error message is

ERROR: ArgumentError: A differentiated state's operation must be a `Sym`, so states like `D(u + u)` are disallowed. Got `z[1, 1]`.
  [1] diff2term(O::Term{Real, Nothing})
    @ Symbolics C:\Users\steff\.julia\packages\Symbolics\mFWWM\src\utils.jl:114
  [2] (::ModelingToolkit.var"#10#11"{typeof(Symbolics.diff2term)})(k::Num)
    @ ModelingToolkit .\none:0
  [3] iterate
    @ .\generator.jl:47 [inlined]
  [4] _all(f::Base.var"#282#284", itr::Base.Generator{Base.KeySet{Any, Dict{Any, Any}}, ModelingToolkit.var"#10#11"{typeof(Symbolics.diff2term)}}, #unused#::Colon)
    @ Base .\reduce.jl:930
  [5] all
    @ .\reduce.jl:918 [inlined]
  [6] Dict(kv::Base.Generator{Base.KeySet{Any, Dict{Any, Any}}, ModelingToolkit.var"#10#11"{typeof(Symbolics.diff2term)}})
    @ Base .\dict.jl:131
  [7] _varmap_to_vars(varmap::Dict{Num, Float64}, varlist::Vector{Term{Real, Base.ImmutableDict{DataType, Any}}}; defaults::Dict{Any, Any}, check::Bool, toterm::typeof(Symbolics.diff2term))
    @ ModelingToolkit C:\Users\steff\.julia\packages\ModelingToolkit\eSpDL\src\variables.jl:69
  [8] varmap_to_vars(varmap::Vector{Pair{Num, Float64}}, varlist::Vector{Term{Real, Base.ImmutableDict{DataType, Any}}}; defaults::Dict{Any, Any}, check::Bool, toterm::Function)
    @ ModelingToolkit C:\Users\steff\.julia\packages\ModelingToolkit\eSpDL\src\variables.jl:52
  [9] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{Pair{Num, Float64}}, 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, kwargs::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:has_difference,), Tuple{Bool}}})
    @ ModelingToolkit C:\Users\steff\.julia\packages\ModelingToolkit\eSpDL\src\systems\diffeqs\abstractodesystem.jl:467
 [10] (ODEProblem{true, tType, isinplace, P, F, K, PT} where {tType, isinplace, P, F, K, PT})(sys::ODESystem, u0map::Vector{Pair{Num, Float64}}, tspan::Tuple{Float64, Float64}, parammap::SciMLBase.NullParameters; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ModelingToolkit C:\Users\steff\.julia\packages\ModelingToolkit\eSpDL\src\systems\diffeqs\abstractodesystem.jl:557

If I do the same where z is just a scalar, then it works.

@variables t z(t)
Dt = Differential(t)
eqs = [Dt(Dt(z)) ~ 1]
u0 = [z => 0., Dt(z) => 1.0]
@named sys = ODESystem(eqs)
prob = ODEProblem(sys, u0, tspan)

(I’m posting this here, since the last time I though something is an issue, it was just me being stupid :smiley: )

It looks like a missing heuristic on array variables. Worth an issue.

Thanks. I will open an issue!