Skip to content

Commit 719debc

Browse files
Merge pull request #62 from ChrisRackauckas-Claude/sciml-v3-compat
Bump SciMLBase to v3, DiffEqBase to v7, OrdinaryDiffEq to v7
2 parents 89e45c1 + fca13bd commit 719debc

3 files changed

Lines changed: 60 additions & 21 deletions

File tree

Project.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
name = "GeometricIntegratorsDiffEq"
22
uuid = "5a33fad7-5ce4-5983-9f5d-5f26ceab5c96"
3-
version = "1.1.0"
3+
version = "1.2.0"
44
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
55

66
[deps]
77
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
88
GeometricIntegrators = "dcce2d33-59f6-5b8d-9047-0defad88ae06"
99
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1010
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
11+
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
1112

1213
[compat]
13-
DiffEqBase = "6.62"
14+
DiffEqBase = "6.62, 7"
1415
ExplicitImports = "1.14.0"
1516
GeometricIntegrators = "0.15, 0.16"
1617
Reexport = "0.2, 1"
17-
SciMLBase = "2"
18+
SciMLBase = "2, 3"
19+
SciMLLogging = "1"
1820
julia = "1.10"
1921

2022
[extras]

src/GeometricIntegratorsDiffEq.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module GeometricIntegratorsDiffEq
22

33
using Reexport: Reexport, @reexport
44
@reexport using DiffEqBase: DiffEqBase
5-
using SciMLBase: SciMLBase, ReturnCode, check_keywords, warn_compat
5+
using SciMLBase: SciMLBase, ReturnCode
6+
using SciMLLogging: @SciMLMessage
67

78
using GeometricIntegrators: GeometricIntegrators, CrankNicolson, Crouzeix,
89
ExplicitEuler, ExplicitMidpoint, Gauss, Heun2, Heun3, ImplicitEuler,

src/solve.jl

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,46 @@ function DiffEqBase.__solve(
2222
}
2323
)
2424

25-
if verbose
26-
warned = !isempty(kwargs) && check_keywords(alg, kwargs, warnlist)
27-
if !(prob.f isa DiffEqBase.AbstractParameterizedFunction) && isstiff
28-
if DiffEqBase.has_tgrad(prob.f)
29-
@warn "Explicit t-gradient given to this stiff solver is ignored."
30-
warned = true
31-
end
32-
if DiffEqBase.has_jac(prob.f)
33-
@warn "Explicit Jacobian given to this stiff solver is ignored."
34-
warned = true
35-
end
25+
# `verbose` may be a `Bool` (DiffEqBase v6) or a `DEVerbosity` / other
26+
# `AbstractVerbositySpecifier` (DiffEqBase v7+). Route each warning through
27+
# `@SciMLMessage` so a silent spec (e.g. `DEVerbosity(None())`) actually
28+
# suppresses it — a `verbose !== false` guard can't, since a silent
29+
# `DEVerbosity` is not `false`. The `:mismatched_input_output_type` toggle
30+
# is the right DEVerbosity bucket for these: every message here reports an
31+
# input the GeometricIntegrators solver cannot honor. For `Bool` verbose,
32+
# `@SciMLMessage` ignores the toggle name and just maps true→WarnLevel,
33+
# false→Silent.
34+
warned = false
35+
for (kw, val) in kwargs
36+
if kw in warnlist && val !== nothing
37+
@SciMLMessage(
38+
string("The ", kw, " argument is ignored by ", alg, "."),
39+
verbose, :mismatched_input_output_type
40+
)
41+
warned = true
3642
end
37-
warned && warn_compat()
43+
end
44+
if !(prob.f isa DiffEqBase.AbstractParameterizedFunction) && isstiff
45+
if DiffEqBase.has_tgrad(prob.f)
46+
@SciMLMessage(
47+
"Explicit t-gradient given to this stiff solver is ignored.",
48+
verbose, :mismatched_input_output_type
49+
)
50+
warned = true
51+
end
52+
if DiffEqBase.has_jac(prob.f)
53+
@SciMLMessage(
54+
"Explicit Jacobian given to this stiff solver is ignored.",
55+
verbose, :mismatched_input_output_type
56+
)
57+
warned = true
58+
end
59+
end
60+
if warned
61+
@SciMLMessage(
62+
"https://docs.sciml.ai/DiffEqDocs/stable/basics/compatibility_chart/",
63+
verbose, :mismatched_input_output_type
64+
)
3865
end
3966

4067
if callback !== nothing
@@ -68,15 +95,20 @@ function DiffEqBase.__solve(
6895
# Create function wrapper for GeometricIntegrators API
6996
# GeometricIntegrators expects: v(v, t, q, params)
7097
# DiffEqBase provides: f(du, u, p, t) for inplace or f(u, p, t) for out-of-place
98+
# SciMLBase v3's default AutoSpecialize wraps f in a FunctionWrappersWrapper that
99+
# only accepts the exact argument types captured at problem construction (e.g.
100+
# `Matrix{Float64}`), so passing a `Base.ReshapedArray` to it errors. Unwrap the
101+
# underlying user-defined function before invoking it.
102+
raw_f = SciMLBase.unwrapped_f(prob.f.f)
71103
if !isinplace && u isa AbstractArray
72-
v! = (v, t, q, params) -> (v .= vec(prob.f(reshape(q, sizeu), p, t)); nothing)
104+
v! = (v, t, q, params) -> (v .= vec(raw_f(reshape(q, sizeu), p, t)); nothing)
73105
elseif !(u isa Vector{Float64})
74106
v! = (
75107
v, t, q,
76108
params,
77-
) -> (prob.f(reshape(v, sizeu), reshape(q, sizeu), p, t); nothing)
109+
) -> (raw_f(reshape(v, sizeu), reshape(q, sizeu), p, t); nothing)
78110
else
79-
v! = (v, t, q, params) -> prob.f(v, q, p, t)
111+
v! = (v, t, q, params) -> raw_f(v, q, p, t)
80112
end
81113

82114
ode = GeometricIntegrators.ODEProblem(v!, prob.tspan, dt, vec(prob.u0))
@@ -111,17 +143,21 @@ function DiffEqBase.__solve(
111143

112144
v! = (v, t, q, p_state, params) -> (v .= p_state) # dq/dt = p
113145

146+
# Unwrap past SciMLBase v3 AutoSpecialize FunctionWrappers for the acceleration
147+
# function so it accepts argument types other than those captured at construction.
148+
raw_f1 = SciMLBase.unwrapped_f(prob.f.f1.f)
149+
114150
# Handle both inplace and out-of-place problems
115151
if isinplace
116152
f! = (
117153
f_out, t, q, p_state,
118154
params,
119-
) -> (prob.f.f1.f(f_out, p_state, q, p, t); nothing) # dp/dt = f1(p, q)
155+
) -> (raw_f1(f_out, p_state, q, p, t); nothing) # dp/dt = f1(p, q)
120156
else
121157
f! = (
122158
f_out, t, q, p_state,
123159
params,
124-
) -> (f_out .= prob.f.f1.f(p_state, q, p, t); nothing)
160+
) -> (f_out .= raw_f1(p_state, q, p, t); nothing)
125161
end
126162

127163
pode = GeometricIntegrators.PODEProblem(

0 commit comments

Comments
 (0)