Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqCore/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OrdinaryDiffEqCore"
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
authors = ["ParamThakkar123 <paramthakkar864@gmail.com>"]
version = "4.12.0"
version = "4.12.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
13 changes: 13 additions & 0 deletions lib/OrdinaryDiffEqCore/src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ Return whether `alg` provides a special interpolant for its stiff branch
"""
has_stiff_interpolation(alg) = false

"""
get_current_has_stiff_interpolation(alg, cache) -> Bool

`has_stiff_interpolation` for the algorithm that is currently active, which for a
`CompositeAlgorithm` is the sub-algorithm selected by `cache.current` rather than
the wrapper itself.
"""
get_current_has_stiff_interpolation(alg, cache) = has_stiff_interpolation(alg)

"""
OrdinaryDiffEqCore.has_stage_limiter(alg)

Expand Down Expand Up @@ -160,6 +169,10 @@ function get_current_isfsal(alg::CompositeAlgorithm, cache)
return _eval_index(isfsal, alg.algs, cache.current)::Bool
end

function get_current_has_stiff_interpolation(alg::CompositeAlgorithm, cache)
return _eval_index(has_stiff_interpolation, alg.algs, cache.current)::Bool
end

all_fsal(alg, cache) = isfsal(alg)
all_fsal(alg::CompositeAlgorithm, cache) = _all_fsal(alg.algs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ end
@inline function SciMLBase.get_du(integrator::ODEIntegrator)
isdiscretecache(integrator.cache) &&
error("Derivatives are not defined for this stepper.")
return if isfsal(integrator.alg) &&
!has_stiff_interpolation(integrator.alg)
return if get_current_isfsal(integrator.alg, integrator.cache) &&
!get_current_has_stiff_interpolation(integrator.alg, integrator.cache)
# Special stiff interpolations do not store the
# right value in fsallast
integrator.fsallast
Expand Down Expand Up @@ -116,8 +116,8 @@ end
if isdiscretecache(integrator.cache)
out .= integrator.cache.tmp
else
return if isfsal(integrator.alg) &&
!has_stiff_interpolation(integrator.alg)
return if get_current_isfsal(integrator.alg, integrator.cache) &&
!get_current_has_stiff_interpolation(integrator.alg, integrator.cache)
# Special stiff interpolations do not store the
# right value in fsallast
out .= integrator.fsallast
Expand Down
4 changes: 4 additions & 0 deletions test/InterfaceII/get_du.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ res = copy(cache)
for alg in [
Vern6(), Vern7(), Vern8(), Vern9(), Rodas4(), Rodas4P(),
Rodas5(), Rodas5P(), TRBDF2(), KenCarp4(), FBDF(), QNDF(),
# A CompositeAlgorithm must report the derivative of whichever
# sub-algorithm is currently active, not of the wrapper.
AutoTsit5(Rosenbrock23()), AutoTsit5(Rodas5P()),
AutoVern7(Rodas4()), AutoVern9(Rodas4()), AutoVern9(Rodas5P()),
]
sol = solve(
prob, alg, tstops = [0.2], callback = dusave, abstol = 1.0e-12, reltol = 1.0e-12
Expand Down
Loading