Event finding for scalar differential equation

I am trying to define a callback to modify the scalar state of an ODE but I get an error. Here is a simple code that reproduces this:

(v0.7) pkg> st
    Status `~/.julia/environments/v0.7/Project.toml`
  [0c46a032] DifferentialEquations v5.2.0
  [4076af6c] JuMP v0.18.2+ #master (https://github.com/JuliaOpt/JuMP.jl.git)
  [76087f3c] NLopt v0.5.0
  [91a5bcdd] Plots v0.19.2
  [89212889] ReverseDiffSparse v0.8.1+ #master (https://github.com/mlubin/ReverseDiffSparse.jl.git)

julia> using DifferentialEquations

julia> f(u,p,t)=1.0
f (generic function with 1 method)

julia> u0=0.0
0.0

julia> tspan=(0.0,10.0)
(0.0, 10.0)

julia> prob = ODEProblem(f,u0,tspan)
ODEProblem with uType Float64 and tType Float64. In-place: false
timespan: (0.0, 10.0)
u0: 0.0

julia> solve(prob,callback=ContinuousCallback((u,t,integrator)->t-1.0,integrator-> integrator.u+=1.0 ))

I can run the examples in the doc but they are for event detection using vector ODE. What can I change to make it work with scalar ODE (without switching to size-1 vectors )?

Thank you

Thanks for the report. This is fixed on master branches.

1 Like

Thank you for your reply. But I still have the same problem after doing:

(v0.7) pkg> add DifferentialEquations#master

and restarting julia.

Do I need to also update some dependencies? As I understand it with the new package manager, the user does not have control over the versioning of the dependencies of an installed package.

I said it’s on master. I still have to release it, but there’s still more I have to do for that an unfortunately I had to take an international flight without WiFi (what is this? The Iron Age?) so it’s delayed.

I didn’t understand because I had updated to master shortly after your first post. But now I have reinstalled the master branch from scratch after deleting everything and it is now working (maybe you had not pushed your changes to the github repo at the time).

Thank you.

It was OrdinaryDiffEq.jl master that needed the tag.