Skip to content

feat: add implicit-euler, trapezoidal, bdf2, and ros2 solver methods#40

Merged
jc-macdonald merged 2 commits intomainfrom
solver-methods
Apr 7, 2026
Merged

feat: add implicit-euler, trapezoidal, bdf2, and ros2 solver methods#40
jc-macdonald merged 2 commits intomainfrom
solver-methods

Conversation

@jc-macdonald
Copy link
Copy Markdown
Collaborator

Summary

Adds four new Jacobian-based solver methods to CoreSolver:

Method Order Type Estimator
implicit-euler 1 Linearized backward Euler Step-doubling
trapezoidal 2 Crank-Nicolson-style Embedded implicit Euler
bdf2 2 Multistep (uniform dt) Embedded implicit Euler
ros2 2 Rosenbrock-W 2(1) Embedded 1st-order

All methods use a user-supplied jacobian(t, y) callable and support adaptive step control (except BDF2 which requires uniform dt).

Changes

  • RunConfig: new jacobian field (JacobianFunction | None)
  • RunPlan/StepIO: plumbed Jacobian and previous-state support
  • New helpers: _compute_linearized_residual, _apply_operator_matmul, _identity_operator
  • Method aliases: cn, crank-nicolson, trap, rosenbrock, rosenbrock-w
  • Tests: convergence-order verification for all 4 methods + plumbing tests for Jacobian requirement and BDF2 uniform grid check

Review feedback addressed (from PR #18)

This PR extracts the solver-method portion of the now-closed #18 and addresses @TimothyWillard's inline feedback:

  • Removed _resolve_jacobian static method indirection (L754) — Jacobian now called directly
  • Fixed _compute_linearized_residual to return only the Jacobian operator; residual written to self._f_extrap buffer (L772)
  • Used NDArray[np.floating] consistently instead of np.ndarray (L672)
  • Documented op, op validation pattern in _apply_operator_matmul (L613)

The larger architectural concerns (dispatch refactor L1850/L1918, validation placement L840/L855, mutable+return state pattern L1) are tracked in separate issues under the CoreSolver Refactor milestone (#30, #31, #32).

Closes #27, closes #28, closes #29

@jc-macdonald jc-macdonald added this to the Solver Methods milestone Apr 5, 2026
@jc-macdonald jc-macdonald added the enhancement New feature or request label Apr 5, 2026
Add four new Jacobian-based solver methods to CoreSolver:
- implicit-euler: linearized backward Euler with step-doubling estimator
- trapezoidal: Crank-Nicolson-style with implicit Euler embedded estimator
- bdf2: second-order BDF with uniform dt requirement
- ros2: Rosenbrock-W 2(1) pair for stiff ODEs

Includes:
- JacobianFunction type and jacobian field on RunConfig/RunPlan
- _compute_linearized_residual helper (writes residual into buffer)
- _apply_operator_matmul for J*y products
- Previous-state cache for multistep (BDF2) method
- Method aliases (cn, crank-nicolson, trap, rosenbrock, rosenbrock-w)
- Plumbing tests for Jacobian requirement and BDF2 uniform grid check
- Accuracy/convergence order tests for all four methods

Addresses review feedback from PR #18:
- Remove _resolve_jacobian static method indirection
- Fix _compute_linearized_residual to return only Jacobian (residual in buffer)
- Use NDArray[np.floating] consistently
- Document op validation in _apply_operator_matmul

Closes #27, closes #28, closes #29
@jc-macdonald jc-macdonald requested a review from pearsonca April 7, 2026 05:29
@jc-macdonald jc-macdonald self-assigned this Apr 7, 2026
@jc-macdonald jc-macdonald merged commit 672f498 into main Apr 7, 2026
5 checks passed
@jc-macdonald jc-macdonald deleted the solver-methods branch April 7, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Promote error-order helpers to op_engine public API Add accuracy test suite for solver methods Add new solver stepping methods

1 participant