Skip to content

Commit

Permalink
warn for Rosenbrock methods with no differential variables
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith committed Nov 2, 2023
1 parent 8f5474a commit 4cc617d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ function DiffEqBase.__init(prob::Union{DiffEqBase.AbstractODEProblem,
error("This solver is not able to use mass matrices.")
end

if alg isa OrdinaryDiffEqRosenbrockAdaptiveAlgorithm &&
!(prob.f.mass_matrix isa SciMLOperators.AbstractSciMLOperator) &&
all(isequal(0), prob.f.mass_matrix)
alg isa Union{Rosenbrock23, Rosenbrock32} && error("Rosenbrock23 and Rosenbrock32 require at least one differential variable to produce valid solutions")
if dense && verbose
@warn("Rosenbrock methods have questionable interpolations when applied to equations without differential states.")
end
end

if !isempty(saveat) && dense
@warn("Dense output is incompatible with saveat. Please use the SavingCallback from the Callback Library to mix the two behaviors.")
end
Expand Down
8 changes: 8 additions & 0 deletions test/integrators/check_error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ for i in 1:(integrator.opts.maxiters)
end
end
@test ok

let
function f!(out, u, _, t)
out[1] = u[1] - sin(1e8*t)
end
mprob = ODEProblem(ODEFunction(f!, mass_matrix=[0.0;;]), [0.0], (0, 2.0))
@test_throws ErrorException solve(mprob, Rosenbrock23())
end

0 comments on commit 4cc617d

Please sign in to comment.