Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions ext/FractionalDiffEqFdeSolverExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@ using FdeSolver
# const default_values = (2^-6, 1, nothing, 1e-6, 100)
function SciMLBase.__solve(prob::FODEProblem, alg::FdeSolverPECE; dt = 0.0, abstol = 1e-3, maxiters = 1000, kwargs...)
(; f, order, tspan, u0, p) = prob

iip = isinplace(prob)

tSpan = [first(tspan), last(tspan)]
# FdeSolver only supports out-of-place computing
newf = function (t, y, par)
du = similar(y)
f(du, y, par, t)
return du
newf = if iip
function (t, y, par)
du = similar(y)
f(du, y, par, t)
return du
end
else
function (t, y, par)
return f.(y, par, t)
end
end
t, y = FDEsolver(newf, tSpan, u0, order, p, JF = prob.f.jac, h = dt, tol = abstol)
par = p isa SciMLBase.NullParameters ? nothing : p
t, y = FDEsolver(newf, tSpan, u0, order, par, JF = prob.f.jac, h = dt, tol = abstol)
u = eachrow(y)

return DiffEqBase.build_solution(prob, alg, t, u)
Expand Down