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

Seemingly weird result with very large errors with MIRK5() #268

Open
vyudu opened this issue Jan 17, 2025 · 1 comment
Open

Seemingly weird result with very large errors with MIRK5() #268

vyudu opened this issue Jan 17, 2025 · 1 comment
Labels

Comments

@vyudu
Copy link

vyudu commented Jan 17, 2025

I have this problem that MIRK3, MIRK4, and MIRK6 seem to handle fine, but MIRK5 ends up having very large errors on:

using BoundaryValueDiffEq, BenchmarkTools 

function lotkavolterra!(du, u, p, t) 
    du[1] = p[1]*u[1] - p[2]*u[1]*u[2]
    du[2] = -p[4]*u[2] + p[3]*u[1]*u[2]
end

function bc!(du, u, p, t) 
    du[1] = u(0.6)[1] - 3.5
    du[2] = u(0.3)[1] - 7.0 
end

p = [1.5, 1., 1., 3.]
bvp = BVProblem(lotkavolterra!, bc!, [4., 2.], (0., 1.), p)

du = zeros(2)
sol = @btime solve($bvp, MIRK3(), dt = 0.05) # time: 3.134 ms
bc!(du, sol, p, 1.) # [0.00014751435360382814, -0.0001928704283686855]

sol = @btime solve($bvp, MIRK4(), dt = 0.05) # time: 411.375 μs
bc!(du, sol, p, 1.) # [0.00026448435797687964, -0.00031431123142944273]

sol = @btime solve($bvp, MIRK5(), dt = 0.05) # time: 8.272 ms
bc!(du, sol, p, 1.) # [2.0705889974019476, -0.9358530914362078]

sol = @btime solve($bvp, MIRK6(), dt = 0.05) # time: 499.292 μs
bc!(du, sol, p, 1.) # [0.0002639321800703698, -0.000315300179799749]

It also returns a successful retcode in this case. Not sure if this is something wrong or expected weirdness, but thought i'd report in case.

@vyudu vyudu added the bug label Jan 17, 2025
@ErikQQY
Copy link
Member

ErikQQY commented Jan 18, 2025

I think there is something wrong with the solutions passed to boundary conditions evaluations, but it's weird that it differs with different MIRK solvers, I need to investigate which part is going wrong

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

2 participants