MTK query when dealing with vector variables

Hello,

When I run the following toy case I get the following problem:

using ModelingToolkit, SteadyStateDiffEq

@independent_variables t
function my_fun(;name,N=100)
    vars = @variables begin
        x(t)[1:N+1],
        y(t)[1:N+1]
        σ(t)
    end

    para = @parameters begin
        Δ
    end

    eqs = [
        [x[i+1] ~ i^2/N + 5 for i = 0:N]
        [y[i+1] ~ σ for i = 0:N]
        Δ ~ minimum(y .- x)
    ]

    System(eqs, t, vars, para; name)

end

@named test = my_fun()
sys = mtkcompile(test)

para = [
    sys.Δ => 2
]
u0 = [
    sys.σ => 2
]
prob = SteadyStateProblem(sys, merge(if isempty(u0)  Dict() else Dict(unknowns(sys) .=> u0) end, Dict(para)))
sol = solve(prob)
ERROR: LoadError: MethodError: Cannot `convert` an object of type Pair{Num, Int64} to an object of type Real
The function `convert` exists, but no method is defined for this combination of argument types.

I am not sure what is the mistake here.

on v10? There should just be one Dict not two. Merge them

1 Like

A side question regarding NonlinearSolve

Is it possible to not use ForwardDiff internally for a NL solve problem? I use a internal library which is based over C++ code. Hence it cannot propagate through it.

Just pass autodiff=AutoFiniteDiff(), like TrustRegion(autodiff=AutoFiniteDiff()). Requires using ADTypes.

1 Like