Skip to content

In DDEs constant_lags break PresetTimeCallback #205

@laserschwelle

Description

@laserschwelle

I wanted to modulate a DDE system at equidistant points in time. But if the constant_lags=[τ] parameter is set some combinations of delay times and distance between modulations don't work. Not every point in tstops triggers the affect.

Here is a minimal example:

using DifferentialEquations

f(u,h,p,t) = 0
h(p, t) = 0.0

p = 0.3       # delay time
step = 0.04   # intervall for callbacks
num = 1000    # number of callbacks

end_time = step*num
tstops = step:step:end_time  # callback preset times

counter = 0
function affect!(integrator)
    integrator.u = rand()
    global counter += 1
end
cb = PresetTimeCallback(tstops,affect!)

st_length = length(tstops)
println("step_times length: $st_length")

prob_const_lag = DDEProblem(f,h,(0,end_time),p,constant_lags=[p])
solve(prob_const_lag,callback=cb);
println("#callbacks: $counter")

counter = 0
prob_without = DDEProblem(f,h,(0,end_time),p)
solve(prob_without,callback=cb);
println("#callbacks: $counter")

Note: For step = 0.123 the code runs as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions