# Modelingtoolkitize does not work when parameter is passed

**URL:** https://discourse.julialang.org/t/modelingtoolkitize-does-not-work-when-parameter-is-passed/75235
**Category:** New to Julia
**Tags:** question, diffeq, modelingtoolkit
**Created:** [January 26, 2022, 4:03pm UTC](https://discourse.julialang.org/t/modelingtoolkitize-does-not-work-when-parameter-is-passed/75235 "2022-01-26T16:03:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Shashank](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shashank/32/12323_2.png) [@Shashank](https://discourse.julialang.org/u/Shashank)
#### Post date: [January 26, 2022, 4:03pm UTC](https://discourse.julialang.org/t/modelingtoolkitize-does-not-work-when-parameter-is-passed/75235/1 "2022-01-26T16:03:10Z")

</div>

I am trying to solve 5 odes in the code below. I see a peculiar problem when I try to use modelingtoolkitize. The code below works if I use size=5 but not if I use the parameter to define size (size=p[1]). Why is this happening when p[1] is equal to 5. The problem does not arise if I just solve the system without using modelingtoolkitize.

```julia
using ModelingToolkit
using DifferentialEquations

function eoms!(du,u,p,t)
    size=p[1] ### does not work.
    ## size=5 ### works
    for i in 1:size
        du[i]=-1.0*u[i]
    end
end

size=5
u0=ones(Float64,size)
tspan=(0.0,10.0)
p=[size]
prob=ODEProblem(eoms!,u0,tspan,p)

prob_=modelingtoolkitize(prob)
fastprob = ODEProblem(prob_,u0,tspan,jac=true)
#fastprob=prob

tol=1e-6
reltolp=tol
abstolp=tol

@time sol=solve(prob,Rosenbrock23(),abstol=abstolp,reltol=reltolp)
@time sol1=solve(fastprob,Rosenbrock23(),abstol=abstolp,reltol=reltolp)

println(sol.destats)
println("-------")
println(sol1.destats)

using Plots
plot(sol, vars=(1),yaxis=:log10)
plot!(sol, vars=(2),yaxis=:log10)
plot!(sol, vars=(3),yaxis=:log10)
plot!(sol, vars=(4),yaxis=:log10)
plot!(sol1, vars=(1),yaxis=:log10)
plot!(sol1, vars=(2),yaxis=:log10)
plot!(sol1, vars=(3),yaxis=:log10)
plot!(sol1, vars=(4),yaxis=:log10)

```

---

<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: [January 26, 2022, 4:19pm UTC](https://discourse.julialang.org/t/modelingtoolkitize-does-not-work-when-parameter-is-passed/75235/2 "2022-01-26T16:19:45Z")

</div>

`modelingtoolkitize` requires a code is quasi-static, so the computation is not dependent on values.
