Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dopri5 solver doesn't work for DDEs #260

Open
thibmonsel opened this issue Mar 9, 2023 · 0 comments
Open

Dopri5 solver doesn't work for DDEs #260

thibmonsel opened this issue Mar 9, 2023 · 0 comments

Comments

@thibmonsel
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant