Skip to content

Explicit Jacobians for DAEs #1109

@ChrisRackauckas

Description

@ChrisRackauckas

MWE:

using OrdinaryDiffEq
tspan = (0.0,1.0)
u0 = zeros(1)
u0[1] = 1/2

function residual(res,du,u,p,t)
  res[1] = - 1.01u[1] + du[1]
end

function jacobian(jac,du,u,p,gamma,t)
  jac[1,1] = gamma - 1.01
  nothing
end

f_iip = DAEFunction{true}(residual;jac=jacobian)
prob_iip = DAEProblem{true}(f_iip,u0,u0,tspan)
sol_iip = solve(prob_iip, DImplicitEuler(), reltol=1e-8, abstol=1e-8)
sol_iip = solve(prob_iip, DABDF2(), reltol=1e-8, abstol=1e-8)

The issue is threefold.

  1. The Jacobian references duprev which doesn't exist. This should be fsalfirst
  2. fsalfirst isn't defined in the first step, so that will be undefined until the first Jacobian is calculated, which gives a causality issue...
  3. jac for a DAE is actually the W-matrix, so that needs to move to the calc_W! section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DAEDifferential-Algebraic Equations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions