WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Dopri5 solver doesn't work for DDEs #260

@thibmonsel

Description

@thibmonsel

Hello I was playing around with the DDE solver on some equations and consistently Dopri5 doesn't integrate properly.

MWE :

using DifferentialEquations
using DelimitedFiles
using PyPlot
using Metrics


# Basic check 1 =========================================
function basic_check_1(du, u, h, p, t)
    tau = p
    hist1 = h(p, t - tau)[1]
    du[1] = u[1] * (1 - hist1)
end

h(p, t) = 1.2 * ones(1)
u0 = [1.2]
tau = 1.0
lags = [tau]
p = (tau)
tspan = (0.0, 20.0)


prob = DDEProblem(basic_check_1, u0, h, tspan, p; constant_lags=lags)
alg = MethodOfSteps(Tsit5()) # doesn't work with DP5 DP8 but works with Tsit5 and Bosh3
sol = solve(prob, alg, saveat=0.1)
usol = transpose(hcat(sol.u...))
time = sol.t

alg2 = MethodOfSteps(DP5()) # doesn't work with DP5 DP8 but works with Tsit5 and Bosh3
sol2 = solve(prob, alg2, saveat=0.1)
usol2 = transpose(hcat(sol2.u...))

alg3 = MethodOfSteps(BS3()) # doesn't work with DP5 DP8 but works with Tsit5 and Bosh3
sol3 = solve(prob, alg3, saveat=0.1)
usol3 = transpose(hcat(sol3.u...))

plot(sol.t, usol, linestyle="dashed", label="Tsit5")
plot(sol.t, usol2, linestyle="dashdot", label="Dopri5")
plot(sol.t, usol3, linestyle="dotted", label="Bosh3")
plt.title("x' = x * (1 - x(t-1))")
plt.legend()
plt.xlabel("Time")
# plt.savefig("exp1.png")
plt.show()
plt.close()

I haven't checked the source code but I would guess that it comes from the Butcher tableau if an ODE example with Dopri5 doesn't work (I didn't check)

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