# How would you solve this DAE?

**URL:** <https://discourse.julialang.org/t/how-would-you-solve-this-dae/119303>\
**Category:** General Usage\
**Tags:** nonlinear, differentialequation\
**Created:** [September 11, 2024, 11:18pm UTC](https://discourse.julialang.org/t/how-would-you-solve-this-dae/119303 "2024-09-11T23:18:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![martru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martru/32/213400_2.png) [@martru](https://discourse.julialang.org/u/martru)\
**Post date:** [September 11, 2024, 11:18pm UTC](https://discourse.julialang.org/t/how-would-you-solve-this-dae/119303/1 "2024-09-11T23:18:41Z")

</div>

Hi everyone,

I’m a new user and I’m struggling to solve this (pictured below) DAE system. I know next to nothing about solvers so I’d appreciate all the help I can get!

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/8/487602286121c5f4db0daa3680c99e5136d1a8aa.jpeg)

So far I’ve tried:

```julia
function f(out, dx, x, p, t)
    X1 = x[1:6]
    X2 = x[7:9]
    out[1:6] = Diagonal(X1)*[A11 A12]*x-U
    out[7:9] = -dx[7:9] + 1/c*(Diagonal(X2)*[A21 A22]*x - b*X2)
end

tspan = (0.0, 3.0);
dx0 = [0,0,0,0,0,0,0,0,0];
x0 = [0,0,0,0,0,0,0,0,0];
differential_vars = [false,false,false,false,false,false,true,true,true]
prob = DAEProblem(f, dx0, x0, tspan, differential_vars = differential_vars)

sol = solve(prob, IDA())

```

The error is " Newton/Linesearch algorithm failed to converge." I also tried:

```julia
function f!(dx,x,p,t)
    X1 = x[1:6]
    X2 = x[7:9]
    U = Diagonal(X1)*[A11 A12]*x
    dx[7:9] = 1/c*(Diagonal(X2)*[A21 A22]*x - b*X2)
end

prob = ODEProblem(f!, x0, tspan) 
sol = solve(prob, Rodas4())

```

But the states were zero for all time.

---

<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:** [September 12, 2024, 1:06am UTC](https://discourse.julialang.org/t/how-would-you-solve-this-dae/119303/2 "2024-09-12T01:06:44Z")

</div>

Did you try this in ModelingToolkit? It does look like it might be index 1, but it’s a bit hard to eyeball. Does structural simplification change the formulation?

---

<div class="post-metadata">

**Author:** ![martru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martru/32/213400_2.png) [@martru](https://discourse.julialang.org/u/martru)\
**Post date:** [September 12, 2024, 4:00pm UTC](https://discourse.julialang.org/t/how-would-you-solve-this-dae/119303/3 "2024-09-12T16:00:08Z")

</div>

I’ll give that a shot, thanks!
