Skip to content

Commit 60ab391

Browse files
Merge pull request #19 from Shreyas-Ekanathan/upstream
Upstream
2 parents b6b86de + 14e6cb6 commit 60ab391

File tree

22 files changed

+279
-495
lines changed

22 files changed

+279
-495
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
- OrdinaryDiffEqExponentialRK
3535
- OrdinaryDiffEqExtrapolation
3636
- OrdinaryDiffEqFIRK
37-
- OrdinaryDiffEqFIRKGenerator
3837
- OrdinaryDiffEqFeagin
3938
- OrdinaryDiffEqFunctionMap
4039
- OrdinaryDiffEqHighOrderRK
@@ -91,8 +90,8 @@ jobs:
9190
env:
9291
GROUP: ${{ matrix.group }}
9392
- uses: julia-actions/julia-processcoverage@v1
94-
- uses: codecov/codecov-action@v4
93+
- uses: codecov/codecov-action@v5
9594
with:
9695
token: ${{ secrets.CODECOV_TOKEN }}
9796
file: lcov.info
98-
fail_ci_if_error: true
97+
fail_ci_if_error: false

.github/workflows/Documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
3333
run: julia --project=docs/ --code-coverage=user docs/make.jl
3434
- uses: julia-actions/julia-processcoverage@v1
35-
- uses: codecov/codecov-action@v4
35+
- uses: codecov/codecov-action@v5
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838
file: lcov.info

.github/workflows/Downstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
exit(0) # Exit immediately, as a success
7474
end
7575
- uses: julia-actions/julia-processcoverage@v1
76-
- uses: codecov/codecov-action@v4
76+
- uses: codecov/codecov-action@v5
7777
with:
7878
token: ${{ secrets.CODECOV_TOKEN }}
7979
file: lcov.info

lib/OrdinaryDiffEqCore/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OrdinaryDiffEqCore"
22
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
33
authors = ["ParamThakkar123 <paramthakkar864@gmail.com>"]
4-
version = "1.11.0"
4+
version = "1.12.1"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -70,7 +70,7 @@ Random = "<0.0.1, 1"
7070
RecursiveArrayTools = "2.36, 3"
7171
Reexport = "1.0"
7272
SafeTestsets = "0.1.0"
73-
SciMLBase = "2.60"
73+
SciMLBase = "2.62"
7474
SciMLOperators = "0.3"
7575
SciMLStructures = "1"
7676
SimpleUnPack = "1"

lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ using DiffEqBase: check_error!, @def, _vec, _reshape
6060

6161
using FastBroadcast: @.., True, False
6262

63-
using SciMLBase: NoInit, CheckInit, _unwrap_val
63+
using SciMLBase: NoInit, CheckInit, OverrideInit, AbstractDEProblem, _unwrap_val
6464

6565
import SciMLBase: alg_order
6666

lib/OrdinaryDiffEqCore/src/caches/basic_caches.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ function alg_cache(alg::CompositeAlgorithm{CS, Tuple{A1, A2, A3, A4, A5, A6}}, u
7373
args = (u, rate_prototype, uEltypeNoUnits,
7474
uBottomEltypeNoUnits, tTypeNoUnits, uprev, uprev2, f, t, dt,
7575
reltol, p, calck, Val(V))
76-
argT = map(typeof, args)
76+
# Core.Typeof to turn uEltypeNoUnits into Type{uEltypeNoUnits} rather than DataType
77+
argT = map(Core.Typeof, args)
7778
T1 = Base.promote_op(alg_cache, A1, argT...)
7879
T2 = Base.promote_op(alg_cache, A2, argT...)
7980
T3 = Base.promote_op(alg_cache, A3, argT...)

lib/OrdinaryDiffEqCore/src/dense/generic_dense.jl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ function default_ode_interpolant(
168168
return ode_interpolant(Θ, integrator.dt, integrator.uprev,
169169
integrator.u, integrator.k, cache.cache5, idxs,
170170
deriv, integrator.differential_vars)
171-
else # alg_choice == 6
171+
elseif alg_choice == 6
172172
return ode_interpolant(Θ, integrator.dt, integrator.uprev,
173173
integrator.u, integrator.k, cache.cache6, idxs,
174174
deriv, integrator.differential_vars)
175+
else
176+
error("DefaultCache invalid alg_choice. File an issue.")
175177
end
176178
end
177179

@@ -227,6 +229,8 @@ end
227229
ode_interpolant!(val, Θ, integrator.dt, integrator.uprev, integrator.u,
228230
integrator.k, integrator.cache.cache6,
229231
idxs, deriv, integrator.differential_vars)
232+
else
233+
error("DefaultCache invalid alg_choice. File an issue.")
230234
end
231235
else
232236
ode_interpolant!(val, Θ, integrator.dt, integrator.uprev, integrator.u,
@@ -256,10 +260,12 @@ function default_ode_interpolant!(
256260
return ode_interpolant!(val, Θ, integrator.dt, integrator.uprev,
257261
integrator.u, integrator.k, cache.cache5, idxs,
258262
deriv, integrator.differential_vars)
259-
else # alg_choice == 6
263+
elseif alg_choice == 6
260264
return ode_interpolant!(val, Θ, integrator.dt, integrator.uprev,
261265
integrator.u, integrator.k, cache.cache6, idxs,
262266
deriv, integrator.differential_vars)
267+
else
268+
error("DefaultCache invalid alg_choice. File an issue.")
263269
end
264270
end
265271

@@ -380,6 +386,8 @@ function default_ode_extrapolant!(
380386
ode_interpolant!(val, Θ, integrator.t - integrator.tprev,
381387
integrator.uprev2, integrator.uprev,
382388
integrator.k, cache.cache6, idxs, deriv, integrator.differential_vars)
389+
else
390+
error("DefaultCache invalid alg_choice. File an issue.")
383391
end
384392
end
385393

@@ -444,6 +452,8 @@ function default_ode_extrapolant(
444452
ode_interpolant(Θ, integrator.t - integrator.tprev,
445453
integrator.uprev2, integrator.uprev,
446454
integrator.k, cache.cache6, idxs, deriv, integrator.differential_vars)
455+
else
456+
error("DefaultCache invalid alg_choice. File an issue.")
447457
end
448458
end
449459

@@ -810,6 +820,8 @@ function ode_interpolation(tval::Number, id::I, idxs, deriv::D, p,
810820
cache.cache6) # update the kcurrent
811821
val = ode_interpolant(Θ, dt, timeseries[i₋], timeseries[i₊], ks[i₊],
812822
cache.cache6, idxs, deriv, differential_vars)
823+
else
824+
error("DefaultCache invalid alg_choice. File an issue.")
813825
end
814826
else
815827
_ode_addsteps!(ks[i₊], ts[i₋], timeseries[i₋], timeseries[i₊], dt, f, p,
@@ -892,6 +904,8 @@ function ode_interpolation!(out, tval::Number, id::I, idxs, deriv::D, p,
892904
cache.cache6) # update the kcurrent
893905
ode_interpolant!(out, Θ, dt, timeseries[i₋], timeseries[i₊], ks[i₊],
894906
cache.cache6, idxs, deriv, differential_vars)
907+
else
908+
error("DefaultCache invalid alg_choice. File an issue.")
895909
end
896910
else
897911
_ode_addsteps!(ks[i₊], ts[i₋], timeseries[i₋], timeseries[i₊], dt, f, p,

lib/OrdinaryDiffEqCore/src/initialize_dae.jl

Lines changed: 17 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ function BrownFullBasicInit(; abstol = 1e-10, nlsolve = nothing)
2020
end
2121
BrownFullBasicInit(abstol) = BrownFullBasicInit(; abstol = abstol, nlsolve = nothing)
2222

23-
struct OverrideInit{T, F} <: DiffEqBase.DAEInitializationAlgorithm
24-
abstol::T
25-
nlsolve::F
26-
end
27-
28-
function OverrideInit(; abstol = 1e-10, nlsolve = nothing)
29-
OverrideInit(abstol, nlsolve)
30-
end
31-
OverrideInit(abstol) = OverrideInit(; abstol = abstol, nlsolve = nothing)
32-
3323
## Notes
3424

3525
#=
@@ -143,19 +133,15 @@ end
143133

144134
## NoInit
145135

146-
function _initialize_dae!(integrator, prob::Union{ODEProblem, DAEProblem},
136+
function _initialize_dae!(integrator, prob::AbstractDEProblem,
147137
alg::NoInit, x::Union{Val{true}, Val{false}})
148138
end
149139

150140
## OverrideInit
151141

152-
function _initialize_dae!(integrator, prob::Union{ODEProblem, DAEProblem},
142+
function _initialize_dae!(integrator, prob::AbstractDEProblem,
153143
alg::OverrideInit, isinplace::Union{Val{true}, Val{false}})
154-
initializeprob = prob.f.initializeprob
155-
156-
if SciMLBase.has_update_initializeprob!(prob.f)
157-
prob.f.update_initializeprob!(initializeprob, prob)
158-
end
144+
initializeprob = prob.f.initialization_data.initializeprob
159145

160146
# If it doesn't have autodiff, assume it comes from symbolic system like ModelingToolkit
161147
# Since then it's the case of not a DAE but has initializeprob
@@ -168,105 +154,30 @@ function _initialize_dae!(integrator, prob::Union{ODEProblem, DAEProblem},
168154
true
169155
end
170156

171-
alg = default_nlsolve(alg.nlsolve, isinplace, initializeprob.u0, initializeprob, isAD)
172-
nlsol = solve(initializeprob, alg, abstol = integrator.opts.abstol, reltol = integrator.opts.reltol)
157+
nlsolve_alg = default_nlsolve(alg.nlsolve, isinplace, initializeprob.u0, initializeprob, isAD)
158+
159+
u0, p, success = SciMLBase.get_initial_values(prob, integrator, prob.f, alg, isinplace; nlsolve_alg, abstol = integrator.opts.abstol, reltol = integrator.opts.reltol)
160+
173161
if isinplace === Val{true}()
174-
integrator.u .= prob.f.initializeprobmap(nlsol)
162+
integrator.u .= u0
175163
elseif isinplace === Val{false}()
176-
integrator.u = prob.f.initializeprobmap(nlsol)
164+
integrator.u = u0
177165
else
178166
error("Unreachable reached. Report this error.")
179167
end
180-
if SciMLBase.has_initializeprobpmap(prob.f)
181-
integrator.p = prob.f.initializeprobpmap(prob, nlsol)
182-
sol = integrator.sol
183-
@reset sol.prob.p = integrator.p
184-
integrator.sol = sol
185-
end
168+
integrator.p = p
169+
sol = integrator.sol
170+
@reset sol.prob.p = integrator.p
171+
integrator.sol = sol
186172

187-
if nlsol.retcode != ReturnCode.Success
173+
if !success
188174
integrator.sol = SciMLBase.solution_new_retcode(integrator.sol,
189175
ReturnCode.InitialFailure)
190176
end
191177
end
192178

193179
## CheckInit
194-
struct CheckInitFailureError <: Exception
195-
normresid::Any
196-
abstol::Any
197-
end
198-
199-
function Base.showerror(io::IO, e::CheckInitFailureError)
200-
print(io,
201-
"CheckInit specified but initialization not satisifed. normresid = $(e.normresid) > abstol = $(e.abstol)")
202-
end
203-
204-
function _initialize_dae!(integrator, prob::ODEProblem, alg::CheckInit,
205-
isinplace::Val{true})
206-
@unpack p, t, f = integrator
207-
M = integrator.f.mass_matrix
208-
tmp = first(get_tmp_cache(integrator))
209-
u0 = integrator.u
210-
211-
algebraic_vars = [all(iszero, x) for x in eachcol(M)]
212-
algebraic_eqs = [all(iszero, x) for x in eachrow(M)]
213-
(iszero(algebraic_vars) || iszero(algebraic_eqs)) && return
214-
update_coefficients!(M, u0, p, t)
215-
f(tmp, u0, p, t)
216-
tmp .= ArrayInterface.restructure(tmp, algebraic_eqs .* _vec(tmp))
217-
218-
normresid = integrator.opts.internalnorm(tmp, t)
219-
if normresid > integrator.opts.abstol
220-
throw(CheckInitFailureError(normresid, integrator.opts.abstol))
221-
end
222-
end
223-
224-
function _initialize_dae!(integrator, prob::ODEProblem, alg::CheckInit,
225-
isinplace::Val{false})
226-
@unpack p, t, f = integrator
227-
u0 = integrator.u
228-
M = integrator.f.mass_matrix
229-
230-
algebraic_vars = [all(iszero, x) for x in eachcol(M)]
231-
algebraic_eqs = [all(iszero, x) for x in eachrow(M)]
232-
(iszero(algebraic_vars) || iszero(algebraic_eqs)) && return
233-
update_coefficients!(M, u0, p, t)
234-
du = f(u0, p, t)
235-
resid = _vec(du)[algebraic_eqs]
236-
237-
normresid = integrator.opts.internalnorm(resid, t)
238-
if normresid > integrator.opts.abstol
239-
throw(CheckInitFailureError(normresid, integrator.opts.abstol))
240-
end
241-
end
242-
243-
function _initialize_dae!(integrator, prob::DAEProblem,
244-
alg::CheckInit, isinplace::Val{true})
245-
@unpack p, t, f = integrator
246-
u0 = integrator.u
247-
resid = get_tmp_cache(integrator)[2]
248-
249-
f(resid, integrator.du, u0, p, t)
250-
normresid = integrator.opts.internalnorm(resid, t)
251-
if normresid > integrator.opts.abstol
252-
throw(CheckInitFailureError(normresid, integrator.opts.abstol))
253-
end
254-
end
255-
256-
function _initialize_dae!(integrator, prob::DAEProblem,
257-
alg::CheckInit, isinplace::Val{false})
258-
@unpack p, t, f = integrator
259-
u0 = integrator.u
260-
261-
nlequation_oop = u -> begin
262-
f((u - u0) / dt, u, p, t)
263-
end
264-
265-
nlequation = (u, _) -> nlequation_oop(u)
266-
267-
resid = f(integrator.du, u0, p, t)
268-
normresid = integrator.opts.internalnorm(resid, t)
269-
if normresid > integrator.opts.abstol
270-
throw(CheckInitFailureError(normresid, integrator.opts.abstol))
271-
end
180+
function _initialize_dae!(integrator, prob::AbstractDEProblem, alg::CheckInit,
181+
isinplace::Union{Val{true}, Val{false}})
182+
SciMLBase.get_initial_values(prob, integrator, prob.f, alg, isinplace; abstol = integrator.opts.abstol)
272183
end

lib/OrdinaryDiffEqDefault/test/default_solver_tests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ end
4040
prob_rober = ODEProblem(rober, [1.0, 0.0, 0.0], (0.0, 1e3), (0.04, 3e7, 1e4))
4141
sol = solve(prob_rober)
4242
rosensol = solve(prob_rober, AutoTsit5(Rosenbrock23(autodiff = false)))
43+
#test that cache is type stable
44+
@test typeof(sol.interp.cache.cache3) == typeof(rosensol.interp.cache.caches[2])
4345
# test that default has the same performance as AutoTsit5(Rosenbrock23()) (which we expect it to use for this).
4446
@test sol.stats.naccept == rosensol.stats.naccept
4547
@test sol.stats.nf == rosensol.stats.nf
@@ -50,6 +52,8 @@ rosensol = solve(prob_rober, AutoTsit5(Rosenbrock23(autodiff = false)))
5052
sol = solve(prob_rober, reltol = 1e-7, abstol = 1e-7)
5153
rosensol = solve(
5254
prob_rober, AutoVern7(Rodas5P(autodiff = false)), reltol = 1e-7, abstol = 1e-7)
55+
#test that cache is type stable
56+
@test typeof(sol.interp.cache.cache4) == typeof(rosensol.interp.cache.caches[2])
5357
# test that default has the same performance as AutoTsit5(Rosenbrock23()) (which we expect it to use for this).
5458
@test sol.stats.naccept == rosensol.stats.naccept
5559
@test sol.stats.nf == rosensol.stats.nf

lib/OrdinaryDiffEqFIRK/Project.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name = "OrdinaryDiffEqFIRK"
22
uuid = "5960d6e9-dd7a-4743-88e7-cf307b64f125"
33
authors = ["ParamThakkar123 <paramthakkar864@gmail.com>"]
4-
version = "1.4.0"
4+
version = "1.5.0"
55

66
[deps]
77
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
88
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
9+
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
910
FastPower = "a4df4552-cc26-4903-aec0-212e50a0e84b"
1011
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1112
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
@@ -15,12 +16,14 @@ OrdinaryDiffEqDifferentiation = "4302a76b-040a-498a-8c04-15b101fed76b"
1516
OrdinaryDiffEqNonlinearSolve = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8"
1617
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
1718
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
19+
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1820
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
1921

2022
[compat]
2123
DiffEqBase = "6.152.2"
2224
DiffEqDevTools = "2.44.4"
2325
FastBroadcast = "0.3.5"
26+
FastGaussQuadrature = "1.0.2"
2427
FastPower = "1"
2528
LinearAlgebra = "<0.0.1, 1"
2629
LinearSolve = "2.32.0"
@@ -33,16 +36,18 @@ Random = "<0.0.1, 1"
3336
RecursiveArrayTools = "3.27.0"
3437
Reexport = "1.2.2"
3538
SafeTestsets = "0.1.0"
39+
SciMLBase = "2.60.0"
3640
SciMLOperators = "0.3.9"
3741
Test = "<0.0.1, 1"
3842
julia = "1.10"
3943

4044
[extras]
4145
DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
46+
GenericSchur = "c145ed77-6b09-5dd9-b285-bf645a82121e"
4247
ODEProblemLibrary = "fdc4e326-1af4-4b90-96e7-779fcce2daa5"
4348
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
4449
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
4550
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4651

4752
[targets]
48-
test = ["DiffEqDevTools", "Random", "SafeTestsets", "Test", "ODEProblemLibrary"]
53+
test = ["DiffEqDevTools", "GenericSchur", "Random", "SafeTestsets", "Test", "ODEProblemLibrary"]

0 commit comments

Comments
 (0)