Skip to content

Commit b1d7885

Browse files
ramlakhanmadheshiyaChrisRackauckasDevin
authored
Define default_linear_interpolation with the problem first (#4834)
* Define default_linear_interpolation with the problem first * Bump OrdinaryDiffEqCore to 4.19.0 and OrdinaryDiffEqSymplecticRK to 2.3.0 The problem-first default_linear_interpolation changes the default `dense` for DAE algorithms without a stiff interpolant, DiscreteProblems, VerletLeapfrog and LeapfrogDriftKickDrift, so both get a minor bump. SymplecticRK's problem-first methods require the new Core: against an older Core they are ambiguous with the AbstractRODEProblem method and the generic method still reads its arguments in the old order. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium Agent-Session: local job ode-4834 (transcript kept on the agent host) * Keep DAE algorithms on dense output by default --------- Co-authored-by: ChrisRackauckas <[email protected]> Co-authored-by: Devin <[email protected]>
1 parent eaf3d5a commit b1d7885

7 files changed

Lines changed: 32 additions & 17 deletions

File tree

‎lib/OrdinaryDiffEqCore/Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OrdinaryDiffEqCore"
22
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
33
authors = ["ParamThakkar123 <[email protected]>"]
4-
version = "4.18.1"
4+
version = "4.19.0"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

‎lib/OrdinaryDiffEqCore/src/alg_utils.jl‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,14 +1028,13 @@ function Base.show(io::IO, ::MIME"text/plain", alg::OrdinaryDiffEqAlgorithm)
10281028
return print(io, ")")
10291029
end
10301030

1031-
# Defaults in the current system: currently opt out DAEAlgorithms until complete
10321031
"""
1033-
default_linear_interpolation(alg, prob) -> Bool
1032+
default_linear_interpolation(prob, alg) -> Bool
10341033
10351034
Return whether the solver should default to (cheaper) linear interpolation instead
1036-
of the algorithm's Hermite/dense interpolant for `alg` on `prob`. `true` for DAEs,
1037-
discrete problems, and RODE/SDE problems.
1035+
of the algorithm's Hermite/dense interpolant for `alg` on `prob`. `true` for discrete
1036+
problems and RODE/SDE problems.
10381037
"""
1039-
default_linear_interpolation(alg, prob) = alg isa DAEAlgorithm || prob isa DiscreteProblem
1040-
# RODE/SDE always uses linear interpolation (no dense output)
1041-
default_linear_interpolation(prob::SciMLBase.AbstractRODEProblem, alg) = true
1038+
function default_linear_interpolation(prob, alg)
1039+
return prob isa DiscreteProblem || prob isa SciMLBase.AbstractRODEProblem
1040+
end

‎lib/OrdinaryDiffEqSymplecticRK/Project.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OrdinaryDiffEqSymplecticRK"
22
uuid = "fa646aed-7ef9-47eb-84c4-9443fc8cbfa8"
33
authors = ["ParamThakkar123 <[email protected]>"]
4-
version = "2.2.3"
4+
version = "2.3.0"
55

66
[deps]
77
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
@@ -42,7 +42,7 @@ MuladdMacro = "0.2.4"
4242
LinearAlgebra = "1.10"
4343
OrdinaryDiffEqRKN = "2"
4444
SciMLBase = "3.39"
45-
OrdinaryDiffEqCore = "4.15.1"
45+
OrdinaryDiffEqCore = "4.19"
4646
Unitful = "1.25.1"
4747
julia = "1.10"
4848
RecursiveArrayTools = "4.2.0"

‎lib/OrdinaryDiffEqSymplecticRK/src/algorithms.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ monaghan2005 = """
4848
)
4949
struct VerletLeapfrog <: OrdinaryDiffEqPartitionedAlgorithm end
5050

51-
default_linear_interpolation(alg::VerletLeapfrog, prob) = true
51+
default_linear_interpolation(prob, alg::VerletLeapfrog) = true
5252

5353
@doc generic_solver_docstring(
5454
"2nd order explicit symplectic integrator. Drift-kick-drift form of `VerletLeapfrog`
@@ -59,7 +59,7 @@ designed to work when `f1` depends on `v`. Requires two evaluation of `f1` per s
5959
)
6060
struct LeapfrogDriftKickDrift <: OrdinaryDiffEqPartitionedAlgorithm end
6161

62-
default_linear_interpolation(alg::LeapfrogDriftKickDrift, prob) = true
62+
default_linear_interpolation(prob, alg::LeapfrogDriftKickDrift) = true
6363

6464
@doc generic_solver_docstring(
6565
"2nd order explicit symplectic integrator.",

‎lib/OrdinaryDiffEqSymplecticRK/test/symplectic_convergence.jl‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ position_error = :final => [
6161
@test first(DiffEqDevTools.calc𝒪estimates(position_error).second) ≈ 4.0 rtol = 1.0e-1
6262

6363
# 2nd Order Tableaus
64-
sim = test_convergence(dts, prob, VerletLeapfrog(), dense_errors = true)
64+
sim = test_convergence(dts, prob, VerletLeapfrog(), dense_errors = true, dense = true)
6565
@test sim.𝒪est[:l2] ≈ 2 rtol = 1.0e-1
6666
@test sim.𝒪est[:L2] ≈ 2 rtol = 1.0e-1
67-
sim = test_convergence(dts, prob, LeapfrogDriftKickDrift(), dense_errors = true)
67+
sim = test_convergence(dts, prob, LeapfrogDriftKickDrift(), dense_errors = true, dense = true)
6868
@test sim.𝒪est[:l2] ≈ 2 rtol = 1.0e-1
6969
@test sim.𝒪est[:L2] ≈ 2 rtol = 1.0e-1
7070
sim = test_convergence(dts, prob, PseudoVerletLeapfrog(), dense_errors = true)
@@ -157,10 +157,10 @@ position_error = :final => [
157157
@test first(DiffEqDevTools.calc𝒪estimates(position_error).second) ≈ 4.0 rtol = 1.0e-1
158158

159159
# 2nd Order Tableaus
160-
sim = test_convergence(dts, prob, VerletLeapfrog(), dense_errors = true)
160+
sim = test_convergence(dts, prob, VerletLeapfrog(), dense_errors = true, dense = true)
161161
@test sim.𝒪est[:l2] ≈ 2 rtol = 1.0e-1
162162
@test sim.𝒪est[:L2] ≈ 2 rtol = 1.0e-1
163-
sim = test_convergence(dts, prob, LeapfrogDriftKickDrift(), dense_errors = true)
163+
sim = test_convergence(dts, prob, LeapfrogDriftKickDrift(), dense_errors = true, dense = true)
164164
@test sim.𝒪est[:l2] ≈ 2 rtol = 1.0e-1
165165
@test sim.𝒪est[:L2] ≈ 2 rtol = 1.0e-1
166166
sim = test_convergence(dts, prob, PseudoVerletLeapfrog(), dense_errors = true)
@@ -236,6 +236,6 @@ prob = DynamicalODEProblem(ff_v, v0, u0, (0.0, 5.0))
236236

237237
dts = 1 .// 2 .^ (6:-1:3)
238238
# LeapfrogDriftKickDrift
239-
sim = test_convergence(dts, prob, LeapfrogDriftKickDrift(), dense_errors = true)
239+
sim = test_convergence(dts, prob, LeapfrogDriftKickDrift(), dense_errors = true, dense = true)
240240
@test sim.𝒪est[:l2] ≈ 2 rtol = 1.0e-1
241241
@test sim.𝒪est[:L2] ≈ 2 rtol = 1.0e-1
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using OrdinaryDiffEqBDF, OrdinaryDiffEqSymplecticRK, OrdinaryDiffEqFunctionMap, Test
2+
3+
@testset "Default dense output" begin
4+
res(du, u, p, t) = [du[1] + u[1], u[1] + u[2] - 1]
5+
dprob = DAEProblem(res, [-1.0, 0.0], [1.0, 0.0], (0.0, 1.0); differential_vars = [true, false])
6+
@test solve(dprob, DImplicitEuler()).dense
7+
@test solve(dprob, DABDF2()).dense
8+
9+
sprob = SecondOrderODEProblem((v, u, p, t) -> -u, [0.0], [1.0], (0.0, 1.0))
10+
@test !solve(sprob, VerletLeapfrog(); dt = 0.1).dense
11+
@test !solve(sprob, LeapfrogDriftKickDrift(); dt = 0.1).dense
12+
@test solve(sprob, PseudoVerletLeapfrog(); dt = 0.1).dense
13+
14+
@test !solve(DiscreteProblem((u, p, t) -> 1.1u, [1.0], (0.0, 10.0)), FunctionMap()).dense
15+
end

‎test/runtests.jl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function interface_i()
4545
@time @safetestset "Verbose Migration Tests" include("InterfaceI/verbose_migration_tests.jl")
4646
@time @safetestset "Threading Option Public Tests" include("InterfaceI/threading_option_public_tests.jl")
4747
@time @safetestset "Generic SciML Interface Tests" include("InterfaceI/generic_interface_tests.jl")
48+
@time @safetestset "Default Linear Interpolation Tests" include("InterfaceI/default_linear_interpolation_tests.jl")
4849
@time @safetestset "Type Handling Tests" include("InterfaceI/type_handling.jl")
4950
@time @safetestset "Controller Tests" include("InterfaceI/controllers.jl")
5051
@time @safetestset "Inplace Interpolation Tests" include("InterfaceI/inplace_interpolation.jl")

0 commit comments

Comments
 (0)