Skip to content

saveat causes incorrect evaluation of the history function #52

@Jamesafross

Description

@Jamesafross

using the saveat feature seems to cause incorrect evaluation of history function.

The code:

using StochasticDelayDiffEq
 
function f(du,u,h,p,t) 
     du[1] = -u[1]
     println(h(p, t-0.001))
 end
 
 function g(du,u,h,p,t)
     du[1] = 0.1
 end
 
 tspan = (0.0,0.1)
 h(p, t) = 0.0
 u0 = [0.0]
 prob = SDDEProblem(f,g, u0,h,tspan, 0.0,constant_lags=[0.001])
 alg = EM()
 
 sol = solve(prob,alg,dt=0.01);
 
 sol = solve(prob,alg,dt=0.01,saveat=0.1);

println output of evaluation of history function for a realisation without saveat

0
[0.0]
[0.0014037592652750368]
[0.0009688081360439431]
[0.00614797237584531]
[0.0035864500205580593]
[0.001500811510678003]

println output of evaluation of history function for a realisation with saveat

 0
[0.0]
[0.0]
[0.0]
[0.0]
[0.0]
[0.0]

Tried other SDE algorithms and the same problem occurs.

Julia Version 1.7.2

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