Add support for Two-Derivative RK Methods#299
Add support for Two-Derivative RK Methods#299JohnDriscollAcademic wants to merge 25 commits intoranocha:mainfrom
Conversation
Implement TwoDerivativeRungeKuttaMethod and TwoDerivativeAdditiveRungeKuttaMethod structures with associated functions for B-series computations.
Removed unnecessary blank lines and comments in BSeries.jl.
Added tests for the TwoDerivativeRungeKuttaMethod including constructor validation and accuracy checks.
Placed all new functionality in one section. This adds support for multi-derivative RK methods and defines these methods explicitly from two tableau
ranocha
left a comment
There was a problem hiding this comment.
Thanks! It looks like your approach will already allocate some temporary arrays. Could you please compare the performance and results with an approach creating the B-series using compose as in https://ranocha.de/BSeries.jl/stable/tutorials/bseries_creation/#tutorial-bseries-creation-RK-compose?
This should work directly for an explicit method. For an implicit method, it should work when used as a fixed point map with enough iterations so that the result does not change anymore up to the desired order. This approach is used for Runge-Kutta methods in Section 313 of Butcher's book "Numerical Methods for Ordinary Differential Equations" to derive the order conditions of RK methods.
add comments Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Refactor order condition calculation to use the more straightforward recursive method introduced in the paper by Chan and Tsai (2010) following closely the implementation by Lisann Radmacher in her undergraduate thesis. This approach improves complexity compared to computing and storing all subtrees before calculating weights.
Add a test for multi-derivative Runge-Kutta methods, specifically a 5s7p method from Chan and Tsai (2010).
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Substitute function got deleted, not sure how all tests ran.
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
simplify code by excluding the c2 which is implicitly being computed as A_2 * e. See comment thread, for my thoughts about this.
src/BSeries.jl
Outdated
|
|
||
| ```math | ||
| \\begin{aligned} | ||
| y^i &= u^n + \\Delta t \\sum_j a^{1}_{i,j} f(t^n + c_i \\Delta t, y^i) + \\Delta t^2 \\sum_j a^{2}_{i,j} g(t^n + c_i \\Delta t, y^i), \\\ |
There was a problem hiding this comment.
Did you build the docs locally? Three backslashes look suspicious to me.
There was a problem hiding this comment.
Sorry, I hadn’t rebuilt the docs after adding the extra backslash, which I do think should be removed. I’m also having some trouble understanding how LaTeX works in Julia docstrings.
One odd issue I’ve noticed is in the docstring:
Given an ODE ``u'(t) = f(t, u(t))`` with ``u''(t) = g(t, u(t))``,
one step from ``u^{n}`` to ``u^{n+1}`` is given by
The double quotes after u for the second derivative behave fine in a code editor, yet on GitHub they appear as escape characters, which seems to terminate the docstring and makes the rest of the code hard to read.
More importantly, when I just tried to build the docs, I got the following error from the doctest of continuous-stage methods:
│ ERROR: MethodError: no method matching elementary_weight(::RootedTree{Int64, Vector{Int64}}, ::ContinuousStageRungeKuttaMethod{Matrix{Rational{Int64}}})
│ The function `elementary_weight` exists, but no method is defined for this combination of argument types.
│ Closest candidates are:
│ elementary_weight(::RootedTree, !Matched::TwoDerivativeRungeKuttaMethod)
│ @ BSeries ~/BSeries/src/BSeries.jl:1362
Does the fact that for continuous methods it is defining the function as rootedtree.elementary_weight versus for TDRK it is elementary_weight directly affect type dispatch? All the tests ran fine for continuous stage Runge-Kutta methods with this new code so I was surprised to see it here.
src/BSeries.jl
Outdated
|
|
||
| This follows the recursive formula for the Butcher type order conditions exhibited in, | ||
| Chan, R.P.K., Tsai, A.Y.J. On explicit two-derivative Runge-Kutta methods. | ||
| - Numer. Algor 53, 171–194 (2010). https://doi.org/10.1007/s11075-009-9349-1 | ||
|
|
||
| #see formula 16 in the paper | ||
| # alpha(t) = b1*eta(subtrees(t)) +b2*eta(collapse_trees(nu)) | ||
|
|
||
| # Arguments | ||
| - `t`: A `RootedTree` representing the current term. | ||
| - `tdrk`: The `TwoDerivativeRungeKuttaMethod` whose coefficients define the | ||
| weights. | ||
|
|
There was a problem hiding this comment.
Please clean up code/docstring formatting
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Updated mathematical notation and descriptions for clarity.
This seems to work
Adds support for two-derivative and additive two-derivative Runge-Kutta methods, including the necessary structures and functions to work with B-series. Note I defined the structures directly where the existing methods seem to import them from RootedTrees.jl.