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

WIP: implement fifth order Radau IIA #612

Merged
merged 19 commits into from Jan 21, 2019
Merged

WIP: implement fifth order Radau IIA #612

merged 19 commits into from Jan 21, 2019

Conversation

YingboMa
Copy link
Member

julia> using OrdinaryDiffEq

julia> function lorenz(u,p,t)
        du = similar(u)
        du[1] = 10.0(u[2]-u[1])
        du[2] = u[1]*(28.0-u[3]) - u[2]
        du[3] = u[1]*u[2] - (8/3)*u[3]
        du
       end
lorenz (generic function with 1 method)

julia> solve(prob, Vern9(), dt=0.01, adaptive=false)[end]
3-element Array{Float64,1}:
 -5.857685382424004
 -5.831082486429051
 23.932132987022584

julia> solve(prob, RadauIIA5(), dt=0.01, adaptive=false)[end]
3-element Array{Float64,1}:
 -5.857676300291801
 -5.831062113159235
 23.932140720000515

@coveralls
Copy link

coveralls commented Jan 20, 2019

Coverage Status

Coverage decreased (-9.1%) to 53.271% when pulling 8947511 on myb/radau into ef6b965 on master.

@codecov
Copy link

codecov bot commented Jan 20, 2019

Codecov Report

Merging #612 into master will increase coverage by 0.17%.
The diff coverage is 82.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #612      +/-   ##
==========================================
+ Coverage   68.45%   68.62%   +0.17%     
==========================================
  Files          83       86       +3     
  Lines       24721    24883     +162     
==========================================
+ Hits        16923    17077     +154     
- Misses       7798     7806       +8
Impacted Files Coverage Δ
src/OrdinaryDiffEq.jl 100% <ø> (ø) ⬆️
src/alg_utils.jl 30.63% <0%> (-0.21%) ⬇️
src/algorithms.jl 98.05% <100%> (+0.01%) ⬆️
src/caches/firk_caches.jl 100% <100%> (ø)
src/integrators/integrator_utils.jl 78.07% <54.54%> (+6.59%) ⬆️
src/perform_step/firk_perform_step.jl 81.73% <81.73%> (ø)
src/tableaus/firk_tableaus.jl 96.87% <96.87%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef6b965...8947511. Read the comment docs.

@YingboMa
Copy link
Member Author

The adaptivity of the current implementation is very weird.

julia> using OrdinaryDiffEq, DiffEqDevTools, Test, LinearAlgebra

julia> using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems()

julia> import DiffEqProblemLibrary.ODEProblemLibrary: van

julia> solve(remake(vanstiff, p=1e7), RadauIIA5(), abstol=1e-5, reltol=1e-7) |> length
668

julia> solve(remake(vanstiff, p=1e7), RadauIIA5()) |> length
┌ Warning: Interrupted. Larger maxiters is needed.
└ @ DiffEqBase ~/.julia/packages/DiffEqBase/8usQ9/src/integrator_interface.jl:150
95

julia> solve(remake(vanstiff, p=1e7), Kvaerno5()) |> length
110

julia> solve(remake(vanstiff, p=1e7), Kvaerno5(), abstol=1e-5, reltol=1e-7) |> length
401


if adaptive
e1dt, e2dt, e3dt = e1/dt, e2/dt, e3/dt
tmp = @. e1dt*z1 + e2dt*z2 + e3dt*z3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not the err tilde term?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The err tilde term is integrator.fsalfirst + tmp.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e1dt, e2dt, e3dt = e1/dt, e2/dt, e3/dt
tmp = @. e1dt*z1 + e2dt*z2 + e3dt*z3
mass_matrix != I && (tmp = mass_matrix*tmp)
err = @. integrator.fsalfirst + tmp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this not be err tilde?

γdt, αdt, βdt = γ/dt, α/dt, β/dt
J = calc_J(integrator, cache, is_compos)
if u isa Number
LU1 = γdt*mass_matrix - J
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this term should be mass_matrix/(gamma*dt), but it's not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, yes it is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capture

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all cases you should have gamma*dt. The transformation is to divide both sides by gdt = gamma*dt. The reason is because J is O(n^2) but I is O(n) (without mass matrices of course), so this decreases the overall calculations. This is exactly the same as the invW_t transformation on the Rosenbrock and SDIRK methods.

qtmp = (integrator.EEst^expo)/fac
@fastmath q = max(inv(integrator.opts.qmax),min(inv(integrator.opts.qmin),qtmp))
integrator.qold = q
if q <= integrator.opts.qsteady_max && q >= integrator.opts.qsteady_min
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be handling

capture

But it looks slightly incorrect. It's really only used with a few recent algorithms:

https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/blob/master/src/alg_utils.jl#L312-L321

This might be the main difference between us and CVODE. Check with LSODE stuff and see if they are using qold here like Hairer.

u = @. uprev + z3

if adaptive
e1dt, e2dt, e3dt = e1/dt, e2/dt, e3/dt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should all be divided by γdt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e1, e2, and e3 are already divided by γ0 in the tableau
image

@ChrisRackauckas ChrisRackauckas merged commit 09f48d9 into master Jan 21, 2019
@ChrisRackauckas ChrisRackauckas deleted the myb/radau branch January 21, 2019 12:04
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

Successfully merging this pull request may close these issues.

None yet

3 participants