feat: add implicit-euler, trapezoidal, bdf2, and ros2 solver methods#40
Merged
jc-macdonald merged 2 commits intomainfrom Apr 7, 2026
Merged
feat: add implicit-euler, trapezoidal, bdf2, and ros2 solver methods#40jc-macdonald merged 2 commits intomainfrom
jc-macdonald merged 2 commits intomainfrom
Conversation
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
44b9a46 to
fffbb84
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds four new Jacobian-based solver methods to
CoreSolver:implicit-eulertrapezoidalbdf2ros2All methods use a user-supplied
jacobian(t, y)callable and support adaptive step control (except BDF2 which requires uniform dt).Changes
RunConfig: newjacobianfield (JacobianFunction | None)RunPlan/StepIO: plumbed Jacobian and previous-state support_compute_linearized_residual,_apply_operator_matmul,_identity_operatorcn,crank-nicolson,trap,rosenbrock,rosenbrock-wReview feedback addressed (from PR #18)
This PR extracts the solver-method portion of the now-closed #18 and addresses @TimothyWillard's inline feedback:
_resolve_jacobianstatic method indirection (L754) — Jacobian now called directly_compute_linearized_residualto return only the Jacobian operator; residual written toself._f_extrapbuffer (L772)NDArray[np.floating]consistently instead ofnp.ndarray(L672)op, opvalidation 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