# MTK query when dealing with vector variables

**URL:** <https://discourse.julialang.org/t/mtk-query-when-dealing-with-vector-variables/130366>\
**Category:** Modelling & Simulations\
**Created:** [July 1, 2025, 12:33pm UTC](https://discourse.julialang.org/t/mtk-query-when-dealing-with-vector-variables/130366 "2025-07-01T12:33:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sushrut\_Deshpande](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sushrut_deshpande/32/52754_2.png) [@Sushrut\_Deshpande](https://discourse.julialang.org/u/Sushrut_Deshpande)\
**Post date:** [July 1, 2025, 12:33pm UTC](https://discourse.julialang.org/t/mtk-query-when-dealing-with-vector-variables/130366/1 "2025-07-01T12:33:50Z")

</div>

Hello,

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

```julia
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)

```

```julia
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.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 1, 2025, 2:11pm UTC](https://discourse.julialang.org/t/mtk-query-when-dealing-with-vector-variables/130366/2 "2025-07-01T14:11:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sushrut\_Deshpande](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sushrut_deshpande/32/52754_2.png) [@Sushrut\_Deshpande](https://discourse.julialang.org/u/Sushrut_Deshpande)\
**Post date:** [July 1, 2025, 2:34pm UTC](https://discourse.julialang.org/t/mtk-query-when-dealing-with-vector-variables/130366/3 "2025-07-01T14:34:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 1, 2025, 5:23pm UTC](https://discourse.julialang.org/t/mtk-query-when-dealing-with-vector-variables/130366/4 "2025-07-01T17:23:06Z")

</div>

> [@Sushrut\_Deshpande](#):
>
> 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`.
