Skip to content

DABDF2 fails with discrete callbacks #589

Closed
SciML/OrdinaryDiffEq.jl
#1586
@rodrigomha

Description

@rodrigomha

The following example fails with DABDF2:

f = function (out,du,u,p,t)
  out[1] = - p[1]*u[1]              + p[3]*u[2]*u[3] - du[1]
  out[2] = + p[1]*u[1] - p[2]*u[2]^2 - p[3]*u[2]*u[3] - du[2]
  out[3] = u[1] + u[2] + u[3] - p[4]
end
u₀ = [1.0, 0, 0]
du₀ = [0.0, 0.0, 0.0]
p = [0.04, 3.0e7, 1.0e4, 1.0]
tspan = (0.0,100.0)
differential_vars = [true,true,false]
prob = DAEProblem(f,du₀,u₀,tspan,p,differential_vars=differential_vars)
condition(u,t,integrator) = t in [50.0]
affect!(integrator) = integrator.p[4] += 1.0
cb = DiscreteCallback(condition,affect!)
sol = solve(prob, DABDF2(), callback=cb, tstops=[50.0])

That gives the following error:

MethodError: no method matching (::var"#35#36")(::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Float64)
Closest candidates are:
  #35(::Any, ::Any, ::Any, ::Any, !Matched::Any) at In[59]:2

Note that this does not fail with DImplicitEuler. I have not tried yet the case with Continuous callbacks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions