Refactor Rosenbrock23/32 to use RodasTableau#3273
Refactor Rosenbrock23/32 to use RodasTableau#3273singhharsh1708 wants to merge 5 commits intoSciML:masterfrom
Conversation
|
refactor(Rosenbrock): migrate Rosenbrock23/32 to RodasTableau and remove per-method implementations |
| # Original Shampine formulation uses scaled stages k̃ᵢ with J*k coupling. | ||
| # Converted to Rodas form (C/dt coupling, no explicit J*k) via the identity | ||
| # J = W + M/(γdt) | ||
| # which absorbs the Jacobian coupling into the LHS operator. | ||
| # | ||
| # Stage variable relationship: k̃ᵢ_old = Σⱼ L[i,j]*ks[j]/(dt*γ) | ||
| # where L = [1 0 0; 1 1 0; 2 c₃₂ 1]. |
There was a problem hiding this comment.
what's the performance impact? Show some stiff work precision diagrams
There was a problem hiding this comment.
i ran work-precision comparisons on several stiff and non-stiff problems to check for any performance impact.
- Rosenbrock23: results are bit-identical to
masteracross all tested problems - Rosenbrock32: shows improved accuracy (≈7–12× lower error)
- Timing:
- Slight overhead on trivial scalar problems (a few μs, dominated by dispatch)
- Comparable performance on larger problems
- No measurable difference on stiff problems (e.g., ROBER)
Overall, there is no performance regression on realistic workloads, and behavior is preserved (or improved for Rosenbrock32).
|
What's the before and after, ROBER and Pollu |
|
okay looking good performance wise, but test failures and look into if the interpolant is done correctly |
| # No H matrix: set k[1]=f(uprev), k[2]=f(u_new) for Hermite interpolation | ||
| integrator.k[1] = fsalfirst_cache | ||
| integrator.k[2] = f(u, p, t + dt) | ||
| # No H matrix: compute Hermite interpolation coefficients |
There was a problem hiding this comment.
this is unrelated to the PR
aea607a to
9eb0a25
Compare
|
@ChrisRackauckas Local validation:
|
| Rosenbrock32Cache, | ||
| }, | ||
| } | ||
| return dense ? "specialized 2nd order \"free\" stiffness-aware interpolation" : |
There was a problem hiding this comment.
those cache types (Rosenbrock23Cache, Rosenbrock32Cache, Rosenbrock23ConstantCache, Rosenbrock32ConstantCache) no longer exist — they've been replaced by the generic RosenbrockCache and RosenbrockConstantCache. So this method would never dispatch. The generic Rosenbrock interp_summary already covers RosenbrockCache/RosenbrockConstantCache.
9eb0a25 to
5d41711
Compare
|
test failures |
7635d01 to
87ea627
Compare
|
Rebase this: rosenbrock tests are passing and your test changes shouldn't be in the same PR. |
test/integrators/resize_tests.jl
Outdated
| @test length(i.cache.k₁) == 5 | ||
| @test length(i.cache.k₂) == 5 | ||
| @test length(i.cache.k₃) == 5 | ||
| if hasfield(typeof(i.cache), :ks) |
test/regression/special_interps.jl
Outdated
| ) | ||
| @test maximum(norm(soloop(t) - sol(t)) for t in 0:0.001:10) < 1.0e-10 | ||
| @test maximum(norm(soloop(y1, t) - sol(y2, t)) for t in 0:0.001:10) < 1.0e-10 | ||
| @test maximum(norm(soloop(t) - sol(t)) for t in 0:0.001:10) < 5.0e-10 |
754fa35 to
0f954bc
Compare
|
@ChrisRackauckas can you check once i reverted changes |
|
Rebase for the Hermite interpolation fixes |
5d41711 to
e7881f7
Compare
|
Addressed review feedback and cleaned up the PR:
|
cc57441 to
0d149da
Compare
|
@ChrisRackauckas can you take a look at it once. |
d696b75 to
066ef50
Compare
a0bcf29 to
efe9c10
Compare
✅ Test Comparison:
|
|
Lots of those test failures look real, and the convergence test fix is on master, so rebase and this still needs fixes |
|
yes working on it |
7bf1d28 to
4a88bc2
Compare
|
Rebase this onto #3075 . It would be good to see if this could be the last thing in before v7 |
673faf1 to
74637dc
Compare
… framework Unify Rosenbrock23 and Rosenbrock32 with the existing generic Rosenbrock/Rodas infrastructure by expressing their coefficients as RodasTableau entries. This removes ~900 lines of duplicated cache structs, perform_step!, interpolation, and addsteps code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… → ks, f₁ → dense)
…terpolant
- Add OrdinaryDiffEqCore.strip_cache(::RosenbrockCache) to fix InterfaceI
failures: generic version passes all-Nothing args but concrete-typed fields
(dense, dtC, dtd, ks, interp_order) reject Nothing
- Add interp_order==-1 branch to all 4 Val{1} interpolant methods to fix
Regression_I BoundsError: empty-H Hermite uses k[1]=f₀,k[2]=f₁ but old
else-branch accessed k[3]
acea03f to
d491269
Compare
|
Rebased onto master (includes #3075); fixed strip_cache to include the new jac_reuse field. |

Summary
This PR migrates
Rosenbrock23andRosenbrock32to the existingRodasTableau-based generic Rosenbrock implementation and removes their per-method implementations.Migration (net -849 LOC)
Added
Rosenbrock23RodasTableauandRosenbrock32RodasTableau, converting Shampine coefficients to Rodas form via the identityJ = W + M/(γdt)Routed both methods through the generic
perform_step!Removed:
alg_cachemethodsperform_step!implementationsinitialize!methodsRemoved Shampine-specific interpolation code (
_ode_addsteps!,interp_summary, etc.)Impact
Checklist
[contributor guidelines](https://github.com/SciML/.github/blob/master/CONTRIBUTING.md), in particular the [SciML Style Guide](https://github.com/SciML/SciMLStyle) and
[COLPRAC](https://github.com/SciML/COLPRAC).
Additional context
This PR focuses on consolidating
Rosenbrock23andRosenbrock32into the existing tableau-based infrastructure. Any improvements to interpolation or dense output behavior can be addressed separately.