Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test for adaptive=true on non-adaptive alg #2497

Merged
merged 3 commits into from
Oct 16, 2024
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
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
Loading