How would you solve this DAE?

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!

So far I’ve tried:

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:

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.

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?

1 Like

I’ll give that a shot, thanks!