Skip to content

feat(sciml): expose operators as (Split)ODEFunction and search integrators per model #73

Open

Description

@kylebeggs

From Dennis Ogiermann, 2026-08-14: "Is there any chance we can funnel this into an ODEFunction or SplitODEFunction and make a search over which solver works best for our individual models?"

Status (2026-09-30): still gated on #65. #89 and #90 closed three of the gaps below; the two that sit on the jac_prototype/precs path moved to #65, and the Field-as-ODE-state gap from #81's addendum is added.

Relationship to #65

#65 is the prerequisite and covers the implicit hook that DESIGN.md §7 (:678-686) already scopes: a thin FunctionOperator-style adapter so LinearizedOp can be handed to ODEFunction as jac_prototype. This issue is the layer above it, and it is the part Dennis actually asked for: presenting the operator itself as the linear half of a split problem, and then searching the integrator space per model. Do #65 first.

What exists today

An RHS idiom and nothing else. Since #90 the documented explicit-stepping idiom is field-level apply!(du, P, u) on a prepared operator (src/linalg.jl:111-117, :688-695), a hand-rolled stepper rather than an ODEProblem; test/ode_rhs.jl exercises it and loads no ODE package. There is no SciML anywhere in [deps], [weakdeps], [extensions], or ext/.

Meanwhile every time-stepping example rolls its own integrator: explicit Euler in examples/heat_equation.jl:27-31, a hand-written Godunov split in examples/niederer_benchmark.jl:180-213, and examples/monodomain_amr.jl:60-72. None of them can reach an IMEX or exponential integrator, which for a stiff-diffusion / stiff-reaction monodomain problem is where the actual timestep savings live.

The false "OrdinaryDiffEq.jl interop" claim that README.md used to advertise was retracted in #90: README.md:150 and docs/index.qmd:23 now say there is no OrdinaryDiffEq integration yet.

The shape

A  = prepare(diffusion(g, κ), u)              # linear, constant, matrix-free
f2 = (du, u, p, t) -> reaction!(du, u, p, t)  # pointwise
prob = ODEProblem(SplitODEFunction(sciml(A), f2), u0, tspan, p)

SplitODEFunction is the right target rather than a plain ODEFunction because it is what unlocks the integrator families that suit this problem class: IMEX (KenCarp*, ARKODE), exponential integrators (ETDRK*, EPIRK*), and the split/LinearExponential methods. The reason the examples all hand-roll Godunov splitting is that there is no way to hand the linear half to a solver as an operator.

Then the search: a work-precision sweep across integrators, per model, comparing wall time at fixed accuracy against a reference solution. That belongs in benchmark/ or examples/, never in the package — same rule that keeps DifferentiationInterface out of [deps] per CLAUDE.md. The output is a work-precision diagram per model plus a recommended default, which is directly what Dennis asked for.

Gaps that block the wrapper

  • PreparedOperator has no supertype (src/linalg.jl:35), so islinear(P), isconstant(P), and adjoint(P) are MethodErrors. A SciML operator needs at least the first two. Done in fix(linalg): prepared operators declare their traits #89: it stays outside AbstractOperator by design and declares all four traits explicitly (src/linalg.jl:75-82); adjoint(P) remains deliberately unsupported — compose first, then prepare.
  • PreparedComposed and PreparedAdjoint are <: AbstractOperator (src/linalg.jl:298,326) but declare no trait methods, so islinear on a prepared composed tree silently falls through to the false default at src/operators/abstract.jl:31. Any wrapper that forwards traits from P.op gets a wrong answer that degrades safely by accident rather than by design. This is an invariant hazard — "traits default to the weaker claim" only protects you if the weaker claim is also the declared one — and it should be fixed regardless of whether this issue proceeds. Done in fix(linalg): prepared operators declare their traits #89 (src/linalg.jl:308-311, :337-340).
  • The update_coefficients! hook (via linearize!) and ldiv! on MultigridPreconditioner moved to feat(sciml): build the planned SciMLOperators jac_prototype adapter (DESIGN §7) #65 — both sit on the jac_prototype/precs path.
  • isconstant is declared on every leaf and propagated through the algebra, and consumed nowhere in src/. It is the obvious contract for a SciML isconstant / caching decision and is currently inert.
  • The affine term needs a home. Inhomogeneous BCs live outside the linear map by design and come back through boundary_rhs. In a SplitODEFunction that is a constant additive term, and the wrapper has to either carry an affine slot or document that f2 must include it. Nothing supplies it today. (It also re-allocates on every call — src/linalg.jl:493-512.)
  • Field cannot be an OrdinaryDiffEq state. It defines only eltype/similar/copy (src/Fields.jl:263-266) — no copyto!, broadcast, norm, length, or indexing — so a SplitODEFunction over Fields is impossible today, and a flat-state adapter pays back exactly the staging copies DESIGN.md:675-677 warns about. Needs the minimal array interface OrdinaryDiffEq actually requires of u (and which parts only adaptive stepping or particular integrator families need), with interior-only broadcast/norm consistent with the interior-only-DOF invariant. Scoped in meta(sciml): expose prepared operators to the SciML integrator stack #81's addendum, question 1.
  • Don't route around the guard. src/linalg.jl:704-711 deliberately makes mul!(y, ::AbstractOperator, x::AbstractVector) throw with "wrap the operator once with prepare(L, x)". A convenience constructor must not bypass it.
  • Fix the README.md:147 claim, or make it true. Retracted in docs: retract the OrdinaryDiffEq interop claim and document field-level apply! as the explicit-stepping idiom #90.

Scope note

Extension only — ext/MatrixFreeOperatorsSciMLExt.jl, weak dep, nothing added to [deps], per CLAUDE.md and DESIGN.md:50 ("Drop SciMLOperators as the core … a thin optional adapter"). The solver search is a benchmark artifact, not a package feature.

—
🤖 Claude checked off what #89/#90 already did and handed two chores to #65.
claude-opus-5-5[1m] (high) · claude-code 2.1.285 · unreviewed

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions