Skip to content

Commit 2c41252

Browse files
Remove the warning on DynamicalODEProblems and instead raise an error if it's not a SecondOrderODEProblem (#133)
* Remove the warning and instead raise an error Previously, we warned the user when they provide a DynamicalODEFunction to inform them that we can not handle true DynamicalODEProblems, but only SecondOrderODEProblems. Now, we instead check if the problem has the SecondOrderODEProblem trait and raise an error if not. * Apply JuliaFormatter.jl * Fix the failing tests * Remove escapes in error string to fix the tests for Julia 1.6 * Apply JuliaFormatter.jl
1 parent 120acfa commit 2c41252

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/caches.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ function OrdinaryDiffEq.alg_cache(
101101
end
102102

103103
is_secondorder_ode = f isa DynamicalODEFunction
104-
if is_secondorder_ode
105-
@warn "Assuming that the given ODE is a SecondOrderODE. If this is not the case, e.g. because it is some other dynamical ODE, the solver will probably run into errors!"
106-
end
107104

108105
q = alg.order
109106
d = is_secondorder_ode ? length(u[1, :]) : length(u)

src/perform_step.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Called in the OrdinaryDiffEQ.__init; All `OrdinaryDiffEqAlgorithm`s have one
22
function OrdinaryDiffEq.initialize!(integ, cache::GaussianODEFilterCache)
3+
if integ.f isa DynamicalODEFunction &&
4+
!(integ.sol.prob.problem_type isa SecondOrderODEProblem)
5+
error(
6+
"""
7+
The given problem is a `DynamicalODEProblem`, but not a `SecondOrderODEProblem`.
8+
This can not be handled by ProbNumDiffEq.jl right now. Please check if the
9+
problem can be formulated as a second order ODE. If not, please open a new
10+
github issue!
11+
""",
12+
)
13+
end
14+
315
if integ.opts.dense && !integ.alg.smooth
416
error("To use `dense=true` you need to set `smooth=true`!")
517
elseif !integ.opts.dense && integ.alg.smooth

src/solve.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ function DiffEqBase.__init(
77
) where {uType,tType}
88
@warn "The given problem is in out-of-place form. Since the algorithms in this package are written for in-place problems, it will be automatically converted."
99
if prob.f isa DynamicalODEFunction
10+
if !(prob.problem_type isa SecondOrderODEProblem)
11+
error(
12+
"DynamicalODEProblems that are not SecondOrderODEProblems are currently not supported",
13+
)
14+
end
1015
f1!(dv, v, u, p, t) = dv .= prob.f.f1(v, u, p, t)
11-
f2!(du, v, u, p, t) = du .= prob.f.f2(v, u, p, t)
12-
_prob = DynamicalODEProblem(
16+
# f2!(du, v, u, p, t) = du .= prob.f.f2(v, u, p, t)
17+
_prob = SecondOrderODEProblem(
1318
f1!,
14-
f2!,
19+
# f2!,
1520
prob.u0.x[1],
1621
prob.u0.x[2],
1722
prob.tspan,

0 commit comments

Comments
 (0)