# Modelingtoolkit odeproblem solution vector length 1

**URL:** <https://discourse.julialang.org/t/modelingtoolkit-odeproblem-solution-vector-length-1/118194>\
**Category:** Modelling & Simulations\
**Tags:** diffeq, modelingtoolkit\
**Created:** [August 14, 2024, 5:38pm UTC](https://discourse.julialang.org/t/modelingtoolkit-odeproblem-solution-vector-length-1/118194 "2024-08-14T17:38:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aavogt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aavogt/32/211333_2.png) [@aavogt](https://discourse.julialang.org/u/aavogt)\
**Post date:** [August 14, 2024, 5:38pm UTC](https://discourse.julialang.org/t/modelingtoolkit-odeproblem-solution-vector-length-1/118194/1 "2024-08-14T17:38:12Z")

</div>

I try to solve a Modelingtoolkit ODEProblem. Apparently it runs, but I can only access the initial condition.

```julia
@mtkbuild m = Setup()
prob = ODEProblem(m, [], (0.,100.), [])
sol = solve(prob)
print(sol[m.c.w])
# get: [0.01165680598011326]
# expected: [0.01, 0.005, ...]

```

Full code [single output time · GitHub](https://gist.github.com/aavogt/32e502543e752a9ac07735531930c15c)  
I started with [ModelingToolkit.jl/docs/src/tutorials/acausal\_components.md at master · SciML/ModelingToolkit.jl · GitHub](https://github.com/SciML/ModelingToolkit.jl/blob/master/docs/src/tutorials/acausal_components.md)

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [August 14, 2024, 6:09pm UTC](https://discourse.julialang.org/t/modelingtoolkit-odeproblem-solution-vector-length-1/118194/2 "2024-08-14T18:09:20Z")

</div>

If you print the full solution object:

```julia
julia> sol
retcode: InitialFailure
Interpolation: 3rd order Hermite
t: 1-element Vector{Float64}:
 0.0
u: 1-element Vector{Vector{Float64}}:
 [760.0, 0.01165680598011326, 0.01165680598011326, 0.01165680598011326, 0.01165680598011326, 0.01165680598011326, 0.01165680598011326, 760.0, 0.01165680598011326, 760.0]

```

The [`retcode`](https://docs.sciml.ai/DiffEqDocs/stable/basics/solution/#retcodes) field indicates that consistent initial conditions could not be found so the solver never started. Check your model carefully and maybe try modeling smaller pieces of it and building up to the full system.

---

<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:** [August 15, 2024, 5:29am UTC](https://discourse.julialang.org/t/modelingtoolkit-odeproblem-solution-vector-length-1/118194/3 "2024-08-15T05:29:41Z")

</div>

Are you sure all of your initial values are consistent? It doesn’t look to be the case. Did you mean for some of them to be guesses?

---

<div class="post-metadata">

**Author:** ![aavogt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aavogt/32/211333_2.png) [@aavogt](https://discourse.julialang.org/u/aavogt)\
**Post date:** [August 15, 2024, 2:32pm UTC](https://discourse.julialang.org/t/modelingtoolkit-odeproblem-solution-vector-length-1/118194/4 "2024-08-15T14:32:03Z")

</div>

I’ve updated the gist. Now I get `Success` and a vector of values, but the system is at steady state no matter where I start it.

```julia
D(w)*P ~ ifelse(a.F <= 0, 0, 760 * (a.F * a.w) / V)

```

Seems to be the problem. It looks like `a.F` is a single value (net standard cm3/s flow into the tank). I need to refer to the vector of flows connected to the chamber flange `c.a`. This [ModelingToolkit.jl/src/systems/connectors.jl at master · SciML/ModelingToolkit.jl · GitHub](https://github.com/SciML/ModelingToolkit.jl/blob/master/src/systems/connectors.jl#L713) seems to do something like that, but I have no idea how to use it. The alternative seems to be making PressureTank with 4 flanges so that connect() only joins two flanges.

---

<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:** [August 17, 2024, 12:07pm UTC](https://discourse.julialang.org/t/modelingtoolkit-odeproblem-solution-vector-length-1/118194/5 "2024-08-17T12:07:51Z")

</div>

> [@aavogt](#):
>
> but the system is at steady state no matter where I start it.

check the equations of your initialization system: are there any initial equations you have that are accidentally forcing you to be instead state? Some stray `velocity = 0` condition you have around showing up in that equation list?
