# JuliaSimCompiler + symbolic arrays?

**URL:** <https://discourse.julialang.org/t/juliasimcompiler-symbolic-arrays/116161>\
**Category:** General Usage\
**Tags:** modelingtoolkit, juliasim\
**Created:** [June 24, 2024, 8:32pm UTC](https://discourse.julialang.org/t/juliasimcompiler-symbolic-arrays/116161 "2024-06-24T20:32:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctessum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctessum/32/19444_2.png) [@ctessum](https://discourse.julialang.org/u/ctessum)\
**Post date:** [June 24, 2024, 8:32pm UTC](https://discourse.julialang.org/t/juliasimcompiler-symbolic-arrays/116161/1 "2024-06-24T20:32:28Z")

</div>

Hello!

Is JuliaSimCompiler currently meant to work with arrays? I would like to create a symbolic model that does the same thing a bunch of different times (eventually with different data inputs). I am aware of `EnsembleProblems` etc., but let’s assume those options won’t work in this case. Here the the problem:

```julia
using ModelingToolkit, OrdinaryDiffEq, DomainSets
using BenchmarkTools
using JuliaSimCompiler
using Plots

N = 5
@parameters x[1:N] = ones(N)
@parameters t
@variables C(t)[1:N] = ones(N)
Dt = Differential(t)

eq = Dt(C[1]) ~ C[1]

eqs = [substitute(eq, Dict(x[1] => x[i], C[1] => C[i])) for i in 1:N]

@named sys = ODESystem(eqs, t, [C], collect(x), tspan=(0.0, 1.0))

# Try the normal way to show that it works:
prob = ODEProblem(structural_simplify(sys), [], (0, 1.0))
sol = solve(prob)
plot(sol)

```

The code above works fine, however the compile time will presumably scale quadraticly with the number of equations, which my understanding is a problem JuliaSimCompiler is meant to fix:

```julia
# Try with JuliaSimCompiler
isys = IRSystem(sys)

iisys = structural_simplify(isys)

ODEProblem(iisys, [], (0, 1.0))

```

The above code, however, gives the error ` ArgumentError: Collection has multiple elements, must contain exactly 1 element`.

So my question is, is this something that should work but I’m maybe doing it wrong, or this type of workflow not supported yet? Thanks for any help!

---

<div class="post-metadata">

**Author:** ![YingboMa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yingboma/32/2181_2.png) [@YingboMa](https://discourse.julialang.org/u/YingboMa)\
**Post date:** [June 25, 2024, 8:59pm UTC](https://discourse.julialang.org/t/juliasimcompiler-symbolic-arrays/116161/2 "2024-06-25T20:59:01Z")

</div>

Array variable support is still somewhat experimental. I have just fixed `JuliaSimCompiler` on this example. Hopefully, you can get the new release in a couple hours.

---

<div class="post-metadata">

**Author:** ![ctessum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctessum/32/19444_2.png) [@ctessum](https://discourse.julialang.org/u/ctessum)\
**Post date:** [June 27, 2024, 12:53am UTC](https://discourse.julialang.org/t/juliasimcompiler-symbolic-arrays/116161/3 "2024-06-27T00:53:27Z")

</div>

That works, thanks!
