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

DFBDF performs poorly when integrating sin(t) #2130

Open
topolarity opened this issue Feb 5, 2024 · 1 comment
Open

DFBDF performs poorly when integrating sin(t) #2130

topolarity opened this issue Feb 5, 2024 · 1 comment
Labels

Comments

@topolarity
Copy link

Describe the bug 🐞

DFBDF appears to solve the system dx ~ y, y ~ sin(t) very poorly.

Minimal Reproducible Example 👇

julia> using OrdinaryDiffEq, Plots
julia> dae_f(du, u, _, t) = [du[1] - u[2], u[2] - sin(t)]
julia> prob = DAEProblem(DAEFunction(dae_f), [0.0, 0.0], [0.0, 0.0], (0., 2π), nothing, differential_vars=[true,false], abstol=1e-6, reltol=1e-6)
julia> sol = solve(prob, DFBDF(); maxiters=10_000_000)
retcode: Success
Interpolation: 1st order linear
t: 1359394-element Vector{Float64}:
 0.0
 6.283185307179586e-6
 7.924885500379142e-6
 8.703751558664616e-6
 
u: 1359394-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [0.0, 0.0]
 [1.0315106532637465e-11, 6.283185307138244e-6]
 [1.6487530864616867e-11, 7.92488550029619e-6]
  

julia> t′ = 0.0:1e-3:2π
julia> plot(t′, -cos.(t′) .+ 1.0 .- [u[1] for u in sol(t′)]; label="u[1] error")
julia> plot!(t′, sin.(t′) - [u[2] for u in sol(t′)]; label="u[2] error")

The solution with abstol = 1e-3, reltol = 1e-3 is also noticeably bad:

A few things jump out to me here:

  • 1.3 million points is... a lot of time steps
  • u[2] seems to be solved very precisely but for the previous timestep (for the first few time points at least)
  • the error in u is about [2e-5, 5e-5] which is ~one and a half orders of magnitude worse than the tolerances

Environment:

  • Output of using Pkg; Pkg.status()
(tmp) pkg> status
Status `~/repos/tmp/tmp/Project.toml`
  [459566f4] DiffEqCallbacks v2.36.1
  [1dea7af3] OrdinaryDiffEq v6.70.0
  [c3572dad] Sundials v4.23.2
@topolarity topolarity added the bug label Feb 5, 2024
@topolarity
Copy link
Author

For comparison, IDA solves this in just 115 timesteps with much better results:
image

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

No branches or pull requests

1 participant