Skip to content

Commit

Permalink
Merge pull request #2497 from oscardssmith/os/adaptive-warn
Browse files Browse the repository at this point in the history
test for adaptive=true on non-adaptive alg
  • Loading branch information
ChrisRackauckas authored Oct 16, 2024
2 parents 873f440 + 03961e7 commit c39299f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 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())
2 changes: 1 addition & 1 deletion test/interface/ode_initdt_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sol = solve(prob, ExplicitRK(tableau = constructBogakiShampine3()))
dt₀ = sol.t[2]

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

sol3 = solve(prob, ExplicitRK(tableau = constructDormandPrince8_64bit()))
Expand Down

0 comments on commit c39299f

Please sign in to comment.