Skip to content

Commit c39299f

Browse files
Merge pull request #2497 from oscardssmith/os/adaptive-warn
test for adaptive=true on non-adaptive alg
2 parents 873f440 + 03961e7 commit c39299f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/OrdinaryDiffEqCore/src/solve.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function DiffEqBase.__init(
112112
if only_diagonal_mass_matrix(alg) &&
113113
prob.f.mass_matrix isa AbstractMatrix &&
114114
!isdiag(prob.f.mass_matrix)
115-
error("$(typeof(alg).name.name) only works with diagonal mass matrices. Please choose a solver suitable for your problem (e.g. Rodas5P)")
115+
throw(ArgumentError("$(typeof(alg).name.name) only works with diagonal mass matrices. Please choose a solver suitable for your problem (e.g. Rodas5P)"))
116116
end
117117

118118
if !isempty(saveat) && dense
@@ -131,7 +131,10 @@ function DiffEqBase.__init(
131131
!(alg isa OrdinaryDiffEqCompositeAlgorithm) &&
132132
!(alg isa DAEAlgorithm)) || !adaptive || !isadaptive(alg)) &&
133133
dt == tType(0) && isempty(tstops)) && dt_required(alg)
134-
error("Fixed timestep methods require a choice of dt or choosing the tstops")
134+
throw(ArgumentError("Fixed timestep methods require a choice of dt or choosing the tstops"))
135+
end
136+
if !isadaptive(alg) && adaptive
137+
throw(ArgumentError("Fixed timestep methods can not be run with adaptive=true"))
135138
end
136139

137140
isdae = alg isa DAEAlgorithm || (!(prob isa DiscreteProblem) &&

test/integrators/check_error.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ end
5656
@test sol.stats.naccept + sol.stats.nreject <= 30
5757
@test_broken sol.retcode = ReturnCode.Success
5858
end
59+
60+
@test_throws ArgumentError solve(prob, Euler(), dt=0.1, adaptive=true)
61+
@test_throws ArgumentError solve(prob, Euler())

test/interface/ode_initdt_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sol = solve(prob, ExplicitRK(tableau = constructBogakiShampine3()))
1010
dt₀ = sol.t[2]
1111

1212
@test 1e-7 < dt₀ < 0.1
13-
@test_throws ErrorException local sol = solve(prob, Euler())
13+
@test_throws ArgumentError local sol = solve(prob, Euler())
1414
#dt₀ = sol.t[2]
1515

1616
sol3 = solve(prob, ExplicitRK(tableau = constructDormandPrince8_64bit()))

0 commit comments

Comments
 (0)