# Overdetermined system when using modelingtoolkitize

**URL:** https://discourse.julialang.org/t/overdetermined-system-when-using-modelingtoolkitize/132917
**Category:** Modelling & Simulations
**Tags:** question, modelingtoolkit
**Created:** [October 6, 2025, 3:14pm UTC](https://discourse.julialang.org/t/overdetermined-system-when-using-modelingtoolkitize/132917 "2025-10-06T15:14:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jessehummel](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jessehummel](https://discourse.julialang.org/u/jessehummel)
#### Post date: [October 6, 2025, 3:14pm UTC](https://discourse.julialang.org/t/overdetermined-system-when-using-modelingtoolkitize/132917/1 "2025-10-06T15:14:07Z")

</div>

Hi, I would like to convert a numeric differential-algebraic equation to a symbolic model using `modelingtoolkitize`. However, when then trying to convert it back to an ODEProblem, I get an overdetermined warning and when trying to solve it an `InitialFailue`. The overdetermined warning is expected since I have 2 initial conditions + 1 algebraic equation but only 2 unknowns. I would like to get rid of the initial condition on `u[2]` but am not sure how to do this.

Here’s and MWE with some comments explaining where it goes wrong.

```julia-auto
# Minimum working example of an overdetermined DAE when using modelingtoolkitize.
using ModelingToolkit
using DifferentialEquations
using Plots
using LinearAlgebra

# Making the ODEFunction representing a DAE.
function dae!(du, u, p, t)
    du[1] = u[2]
    du[2] = u[1] + u[2]
end
mass_matrix = Diagonal([1, 0])
fun! = ODEFunction(dae!; mass_matrix)

# Making the ODEProblem where we start with in inconsistent initial condition. (We specify 2
# initial conditions and have 1 algebraic equation but only 2 unknowns.)
u0 = [1.0, 0.0]
tspan = (0.0, 10.0)
prob1 = ODEProblem(fun!, u0, tspan)

# When solving, DifferentialEquations finds a suitable initial condition by changing u0[2].
sol1 = solve(prob1)
display(plot(sol1))
println(sol1[1]) # [1.0, -1.0], different from our initial condition as expected.

# Converting it to a ModelingToolkit model.
u_names = [:u1, :u2]
@mtkcompile sys = modelingtoolkitize(prob1; u_names)
prob2 = ODEProblem(sys, [], tspan) # Gives a warning that the system is overdetermined.
sol2 = solve(prob2) # InitialFailure.

```

I would like to remove the initial condition for `u[2]` to make the system fully determined but I’m not sure how to do this.  
Thanks in advance.

---

<div class="post-metadata">

### Author: ![bspanoghe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bspanoghe/32/209460_2.png) [@bspanoghe](https://discourse.julialang.org/u/bspanoghe)
#### Post date: [October 15, 2025, 2:32pm UTC](https://discourse.julialang.org/t/overdetermined-system-when-using-modelingtoolkitize/132917/2 "2025-10-15T14:32:26Z")

</div>

You can do this by setting the initial condition to `nothing`:

```julia-auto
prob2 = ODEProblem(sys, [:u2 => nothing], tspan)

```

After which the problem solves without problems:

```julia-auto
sol2 = solve(prob2) # yay!
plot(sol2, idxs = [:u1, :u2])

```

For reference, there is [a page on the ModelingToolkit docs about system initialization](https://docs.sciml.ai/ModelingToolkit/stable/tutorials/initialization/) that contains this specific problem.

---

<div class="post-metadata">

### Author: ![jessehummel](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jessehummel](https://discourse.julialang.org/u/jessehummel)
#### Post date: [October 15, 2025, 4:00pm UTC](https://discourse.julialang.org/t/overdetermined-system-when-using-modelingtoolkitize/132917/3 "2025-10-15T16:00:00Z")

</div>

That works and thank you for the link!
