Skip to content

Commit

Permalink
test for adaptive=true on non-adaptive alg
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith committed Oct 15, 2024
1 parent 873f440 commit 0b95c58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/OrdinaryDiffEqCore/src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function DiffEqBase.__init(
if only_diagonal_mass_matrix(alg) &&
prob.f.mass_matrix isa AbstractMatrix &&
!isdiag(prob.f.mass_matrix)
error("$(typeof(alg).name.name) only works with diagonal mass matrices. Please choose a solver suitable for your problem (e.g. Rodas5P)")
throw(ArgumentError("$(typeof(alg).name.name) only works with diagonal mass matrices. Please choose a solver suitable for your problem (e.g. Rodas5P)"))
end

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

isdae = alg isa DAEAlgorithm || (!(prob isa DiscreteProblem) &&
Expand Down
3 changes: 3 additions & 0 deletions test/integrators/check_error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ end
@test sol.stats.naccept + sol.stats.nreject <= 30
@test_broken sol.retcode = ReturnCode.Success
end

@test_throws ArgumentError solve(prob, Euler(), dt=0.1 adaptive=true)
@test_throws ArgumentError solve(prob, Euler())

0 comments on commit 0b95c58

Please sign in to comment.