Skip to content

Commit 3e71f3a

Browse files
Merge pull request #909 from SciML/init
Handle init with algorithm defaults
2 parents a11df53 + fb37868 commit 3e71f3a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DifferentialEquations"
22
uuid = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "7.5.0"
4+
version = "7.6.0"
55

66
[deps]
77
BoundaryValueDiffEq = "764a87c0-6b3e-53db-9096-fe964310641d"

src/default_solve.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ function DiffEqBase.__solve(prob::DiffEqBase.DEProblem,
99
DiffEqBase.__solve(prob, alg, args...; default_set = true, kwargs..., extra_kwargs...)
1010
end
1111

12+
function DiffEqBase.__init(prob::DiffEqBase.DEProblem,
13+
alg::Union{Nothing, DiffEqBase.DEAlgorithm},
14+
args...; default_set = false, kwargs...)
15+
if default_set == true
16+
error("The chosen algorithm, $alg, does not exist. Please verify that the appropriate solver package has been installed.")
17+
end
18+
alg, extra_kwargs = default_algorithm(prob; kwargs...)
19+
alg = DiffEqBase.prepare_alg(alg, prob.u0, prob.p, prob)
20+
DiffEqBase.__init(prob, alg, args...; default_set = true, kwargs..., extra_kwargs...)
21+
end
22+
1223
#=
1324
function DiffEqBase.__solve(prob::JumpProcesses.JumpProblem,alg::Nothing,
1425
args...;default_set=false,kwargs...)

test/default_ode_alg_test.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ prob_ode_2Dlinear = ODEProblem(ODEFunction(f_2dlinear, analytic = f_2dlinear_ana
66
rand(4, 2), (0.0, 1.0), 1.01)
77

88
alg, kwargs = default_algorithm(prob_ode_2Dlinear; dt = 1 // 2^(4))
9+
integ = init(prob_ode_2Dlinear; dt = 1 // 2^(4))
910
sol = solve(prob_ode_2Dlinear; dt = 1 // 2^(4))
1011

1112
@test typeof(sol.alg.algs[1]) <: Tsit5

0 commit comments

Comments
 (0)