Skip to content

Os/imex mri sr - #111

Open
oscardssmith wants to merge 6 commits into
mainfrom
os/imex-mri-sr
Open

oscardssmith wants to merge 6 commits into
mainfrom
os/imex-mri-sr

Conversation

@oscardssmith

Copy link
Copy Markdown
Member

On top of #109 (review) so not ready to merge yet.

oscardssmith and others added 6 commits August 9, 2026 16:50
Implements the practical parts of Auzinger, Hofstaetter, Ketcheson & Koch,
BIT 57:55-74 (2017): coefficient-table splitting schemes and the section 3
adjoint-pair local error estimator.

Backward substeps. Every real splitting scheme of order three or above has
negative coefficients, so some substeps run against the tree's direction --
previously unsupported, because a child's direction is fixed at construction
and the stepping loop re-signs dt back before perform_step! sees it.
reverse_direction! flips a leaf's tdir, dt, dtcache, dtpropose and dtmax and
rebuilds its tdir-keyed heaps. A splitting node needs different handling: its
heap stores raw times with the direction in the heap's type, so keys cannot be
re-signed and only behind-times are dropped, and the reversal recurses into the
subtree because add_tstop! propagates to descendants eagerly.

Coefficient tables. SplittingCoefficients holds an s-by-N table as nested
NTuples, checking each operator's consistency condition at construction. Ruth3
is the first table (exactly rational, order 3). One generic _perform_step!
walks stages by operators and skips zero coefficients. LieTrotterGodunov and
StrangMarchuk keep their hand-written steps.

AdjointPair(base) averages a base scheme of odd order p with its adjoint for a
solution of order p+1, and takes half their difference as the error estimate
driving the controller. Even-order bases are rejected: their leading error
terms are equal rather than opposite, so averaging would raise no order and the
difference would not be an error estimate. The adjoint reverses the base's
whole flat sequence of flows, reusing the same table.
AdjointPair(LieTrotterGodunov(...)) is PalindromicPairLieTrotterGodunov, which
a test asserts to the bit.

Also fixes a pre-existing bug the new schemes exposed: the snap window absorbing
child clock drift was scaled by the child's own dt, which after a substep can be
arbitrarily small and collapse the window below the drift it must absorb. It now
uses the outer step size, the scale the drift accumulated against.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Yoshida's triple jump, derived in this package's stage convention rather than
transcribed: composing three Strang steps of lengths w1*h, w0*h and w1*h and
merging the adjacent operator-1 flows gives four stages and eight flow
evaluations rather than nine. The merge zeroes the last stage's second
coefficient, so this is also the first table to exercise the zero-coefficient
skip in the generic step. Measured order 4.02, 4.00, 4.00 over dt 0.2 to 0.025.

w0 is negative and large: the second operator's cumulative time reaches 1.35*h
before returning through -0.35*h, so this leans hard on backward substeps.

Being of even order, Yoshida4 cannot serve as an AdjointPair base, which is now
asserted alongside the StrangMarchuk case.

Ruth3's two-operator restriction is factored into a shared helper, since
Yoshida4's table is also AB only.

Also adds the three bibliography entries the docstrings had been citing without
defining -- Rut:1983:cim, Yos:1990:cho and AuzHofKetKoc:2017:psm -- which would
have failed the docs build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The citation key AuzHofKetKoc:2017:psm splits into Auz/Hof/Ket/Koc, and typos
reads "Ket" as a misspelling of "Kept" or "Key". Added alongside the existing
"Tro" exception for the Trotter key.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment on lines +116 to +137
@article{FisReyRob:2023:iem,
title={Implicit-explicit multirate infinitesimal stage-restart methods},
author={Fish, Alex C. and Reynolds, Daniel R. and Roberts, Steven B.},
journal={arXiv preprint arXiv:2301.00865},
year={2023},
doi={10.48550/arXiv.2301.00865}
}

@article{ChiRey:2021:iem,
title={Implicit-explicit multirate infinitesimal GARK methods},
author={Chinomona, Rujeko and Reynolds, Daniel R.},
journal={SIAM Journal on Scientific Computing},
volume={43},
number={5},
pages={A3082--A3113},
year={2021},
doi={10.1137/20M1354349}
}

@article{SanGun:2015:gsa,
title={A generalized-structure approach to additive Runge--Kutta methods},
author={Sandu, Adrian and G{\"u}nther, Michael},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You've seen the OrdinaryDiffEqMultirate(Implicit) things?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, but they are still constrained to a subset of multi-rate solvers, right? In OrdinaryDIffEq we cannot sync the subintegrators using different algorithms (and related the easier to fix one is that I also didn't see a canonical way to use a split function with more than two components).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Merging this into OrdinaryDiffEq is still an open todo, don't understand me wrong, and we can still move algorithms between subpackages. I just want the internals and interfaces to stability a bit before merging into the monorepo. I just do not want to cause any major trouble if I messed something up.

@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated review from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris. It is posted so that you can act on it. Chris or a maintainer may disagree.

Verdict: changes needed before merge (reviewed at 27c49fc).

Adds the IMEX-MRI-SR2(1)/SR3(2) multirate methods of Fish–Reynolds–Roberts (IMEXMRISR2, IMEXMRISR3), plus two tree hooks (init_cache_with_parameters, child_node_count), and takes a hard dependency on NonlinearSolveFirstOrder. The PR is stacked on the still-open #109, and its body says "not ready to merge yet". It also fails typos and QA, and both failures come from its own diff.

Risk assessment

  • Risk: medium
  • Blast radius: Every user of the package. NonlinearSolveFirstOrder becomes a hard dependency, and with it ForwardDiff, LinearSolve, FiniteDiff and Sobol, which adds load and precompile time for users who never touch IMEX-MRI-SR. The change to __init/build_subintegrators (the cache is now built before the children, and cache is a new positional argument) runs for every algorithm. Core tests still pass on it.
  • Evidence:
    • CI on head 27c49fc: Core (1, lts, pre), Downgrade, Documentation and Runic all pass. The Core (julia 1) log shows Core/imex_mri_sr.jl | 29 29 18.2s, so the new convergence-order assertions (atol 0.2 on the order for SR2 and SR3 on KPR) passed in CI.
    • Failing on the head: Spell Check with Typos and tests / QA (julia 1, ubuntu-latest). Both pass on main at 619b927 (Tests, Format Check, Documentation, Downgrade all green on 2026-09-24). Both also pass on the PR's base, 3rd and 4th order methods #109, so this PR introduces both failures.
    • QA details: Aqua reports 4 ambiguities, and ExplicitImports fails all_qualified_accesses_via_owners and all_qualified_accesses_are_public.
    • I read the full diff and diffed the multirate-only part (git diff aa18c94 27c49fc: 11 files, +1246/−14).
    • From the General registry, NonlinearSolveFirstOrder's Deps.toml lists ForwardDiff as a hard dependency.
    • I did not run the tests locally. The only numerical claim is the convergence order, and the passing CI assertion covers it.
  • Merge: needs changes. 3rd and 4th order methods #109 has to land first, then rebase. After that: fix typos and QA, and decide whether the nonlinear-solver dependency should be hard or optional.

Findings

  1. PR body — The author says the PR is stacked on 3rd and 4th order methods #109 and not ready to merge. 3rd and 4th order methods #109 is still open, and its head has moved to 8e837e1 ("address review") since this branch was cut from aa18c94. This branch also predates main's version bump (it has version = "0.4.1", main has 0.4.3), so it will conflict in Project.toml. Fix: land 3rd and 4th order methods #109, then rebase onto main.
  2. src/solvers/mri_tables.jl:115 — typos CI flags mis-stepping (mis → miss). Fix: reword it (e.g. "silently stepping wrongly") rather than adding another allowlist entry.
  3. src/solvers/imex_mri_sr.jl:294 — _fast_mass_matrix(_) = SciMLBase.I reaches LinearAlgebra.I through SciMLBase, where it is not public. This is the cause of both ExplicitImports QA errors. Fix: add LinearAlgebra as a dependency and use LinearAlgebra.I.
  4. src/solvers/imex_mri_sr.jl:315 — The _build_child(::OperatorSplittingProblem, ::AbstractIMEXMRISR, ::GenericSplitFunction, ::Any, …) guard method is ambiguous with the generic _build_child(…, p::Tuple, …) at src/integrator.jl:~1725. This is Aqua ambiguity Bump codecov/codecov-action from 4 to 5 #1. Fix: type the fourth argument as ::Tuple, or dispatch the guard on something narrower.
  5. Project.toml / src/OrdinaryDiffEqOperatorSplitting.jl:17 — The hard NonlinearSolveFirstOrder dependency loads ForwardDiff. That triggers DiffEqBase's ForwardDiff extension, which exposes 3 ambiguities between DiffEqBaseForwardDiffExt.promote_tspan and this package's existing SciMLBase.promote_tspan(u0, p, tspan, prob::OperatorSplittingProblem, kwargs) at src/integrator.jl:239 (Aqua ambiguities Integrate interface with OrdinaryDiffEq #2–Fix sync of OrdinaryDiffEq algos and add test coverage #4). The method itself is pre-existing, but this PR is what makes the failure appear. I inferred the chain from the Aqua output and the registry Deps.toml; I did not reproduce it locally. Fix: add the disambiguating promote_tspan methods that Aqua suggests. Separately, consider whether the default NewtonRaphson() belongs behind a package extension or weak dependency, with nlsolve required when it isn't loaded, so that users of the classic splittings don't pay for NonlinearSolve, LinearSolve, ForwardDiff and FiniteDiff at load time. The dependency is MIT-licensed, so this is not a license problem.
  6. test/imex_mri_sr.jl:153-156 — The comment says that "at H ≈ 0.2 the stage solves stop converging altogether" on KPR, and the order test only uses H = π/2^9 … π/2^11 (≈0.006–0.0015). KPR with λS = −1 and γH ≈ 0.1 is a mild implicit stage, so Newton failing at H = 0.2 is worth explaining before merge: it could be a sign that the stage residual or the initial guess is off. Ask the author to confirm that the H = 0.2 failure is intrinsic to the problem (e.g. u → 0 in the 1/u terms) and not a bug. Not a blocker if explained.
  7. src/integrator.jl (build_subintegrators) — A positional cache::AbstractOperatorSplittingCache argument is added to build_subintegrators, and __init now calls init_cache_with_parameters before building children. Neither build_subintegrators nor _build_child appears in the devdocs, so this is not a documented-API break. The two new hooks are documented in docs/src/devdocs/index.md and have docstrings. No SemVer issue. The new exports IMEXMRISR2/IMEXMRISR3 are a minor-level feature, and no version bump is included; the maintainers should bump at release.
  8. Maintainer context — termi-official (the package author) commented on the review thread started by Chris's question about OrdinaryDiffEqMultirate(Implicit). He argues that the algorithms belong here for now because the splitting interface supports different sub-integrators per operator and more than two components, with a move into the OrdinaryDiffEq monorepo later. He has not approved or requested changes. No tests are skipped, weakened or deleted: test/convergence.jl and test/saving.jl only gain cases, and those come from 3rd and 4th order methods #109.

Push a fix and the PR is reviewed again automatically at the new head.


🤖 Posted by an AI agent — harness: Claude Code · model: claude-opus-5-5[1m] (fleet master); review by Devin CLI (Mac) / fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local Claude Code session 3cd6500a-1f81-46b5-ac0b-c466e15b6a53 on Chris's Mac (session ID, no URL)

This branch has not been deployed

No deployments
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.

3 participants