Skip to content

Commit 66d9e78

Browse files
Fix wrong interpolation coefficients for Rodas3, ROS34PW3
The Rosenbrock consolidation PR (SciML#3102) added a Hermite fallback in _ode_addsteps! for methods with empty H matrices that computed: k₁ = dt*f₀ - (u - uprev) k₂ = 2*(u - uprev) - dt*(f₀ + f₁) But hermite_interpolant in generic_dense.jl expects k[1] = f₀ and k[2] = f₁ (raw derivative values at endpoints). The mismatch produced wildly wrong interpolated values at saveat points (e.g. u(0.15) = 3.97 vs correct 3.28 for the test ODE du/dt = u*p). Remove the incorrect fallback. Methods with empty H now fall through to the generic _ode_addsteps! which correctly stores f₀ and f₁ for standard Hermite interpolation. Fixes SciML/SciMLSensitivity.jl#1398 (Core2 stiff_adjoints failures). Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1fc789e commit 66d9e78

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/OrdinaryDiffEqRosenbrock/src/stiff_addsteps.jl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,10 @@ function _ode_addsteps!(
126126
end
127127
copyat_or_push!(k, j, kj)
128128
end
129-
else
130-
# No H matrix: compute Hermite-compatible coefficients
131-
# k₁ = dt*f₀ - (y₁-y₀), k₂ = 2(y₁-y₀) - dt*(f₀+f₁)
132-
f0 = f(uprev, p, t)
133-
f1 = f(u, p, t + dt)
134-
copyat_or_push!(k, 1, @.. dt * f0 - (u - uprev))
135-
copyat_or_push!(k, 2, @.. 2 * (u - uprev) - dt * (f0 + f1))
136129
end
130+
# Methods with empty H (Rodas3, ROS34PW3, etc.) have no dense output
131+
# coefficients — fall through to the generic _ode_addsteps! which
132+
# stores f₀ and f₁ for standard Hermite interpolation.
137133
end
138134
return nothing
139135
end
@@ -208,14 +204,10 @@ function _ode_addsteps!(
208204
@.. k[j] += H[j, i] * _vec(ks[i])
209205
end
210206
end
211-
else
212-
# No H matrix: compute Hermite-compatible coefficients
213-
# k₁ = dt*f₀ - (y₁-y₀), k₂ = 2(y₁-y₀) - dt*(f₀+f₁)
214-
f(du, uprev, p, t)
215-
f(du1, u, p, t + dt)
216-
copyat_or_push!(k, 1, @.. dt * du - (u - uprev))
217-
copyat_or_push!(k, 2, @.. 2 * (u - uprev) - dt * (du + du1))
218207
end
208+
# Methods with empty H (Rodas3, ROS34PW3, etc.) have no dense output
209+
# coefficients — fall through to the generic _ode_addsteps! which
210+
# stores f₀ and f₁ for standard Hermite interpolation.
219211
end
220212
return nothing
221213
end

0 commit comments

Comments
 (0)