Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith committed Nov 6, 2024
1 parent cf7dcd1 commit 04b3dbb
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 372 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
OrdinaryDiffEqDefault = "50262376-6c5a-4cf5-baba-aaf4f84d72d7"
OrdinaryDiffEqDifferentiation = "4302a76b-040a-498a-8c04-15b101fed76b"
OrdinaryDiffEqNonlinearSolve = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8"
OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand All @@ -28,6 +29,7 @@ DiffEqBase = "6.122"
OrdinaryDiffEq = "6.69"
OrdinaryDiffEqCore = "1.9.0"
OrdinaryDiffEqDefault = "1.1.0"
OrdinaryDiffEqDifferentiation = "1.1.0"
OrdinaryDiffEqNonlinearSolve = "1.2.2"
OrdinaryDiffEqRosenbrock = "1.2.0"
RecursiveArrayTools = "2, 3"
Expand Down
2 changes: 1 addition & 1 deletion src/DelayDiffEq.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module DelayDiffEq

using Reexport
import OrdinaryDiffEqCore, OrdinaryDiffEqNonlinearSolve, OrdinaryDiffEqRosenbrock
import OrdinaryDiffEqCore, OrdinaryDiffEqNonlinearSolve, OrdinaryDiffEqDifferentiation, OrdinaryDiffEqRosenbrock
@reexport using OrdinaryDiffEq

using DataStructures
Expand Down
24 changes: 7 additions & 17 deletions src/integrators/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function OrdinaryDiffEqCore.perform_step!(integrator::DDEIntegrator)
# solution, i.e. returned extrapolated values, continue with a fixed-point iteration
if history.isout
# perform fixed-point iteration
OrdinaryDiffEqCore.nlsolve!(integrator.fpsolver, integrator)
OrdinaryDiffEqNonlinearSolve.nlsolve!(integrator.fpsolver, integrator)
end

# update ODE integrator to next time interval together with correct interpolation
Expand Down Expand Up @@ -190,8 +190,8 @@ function Base.resize!(integrator::DDEIntegrator, cache, i)
for c in full_cache(cache)
resize!(c, i)
end
OrdinaryDiffEqCore.resize_nlsolver!(integrator, i)
OrdinaryDiffEqCore.resize_J_W!(cache, integrator, i)
OrdinaryDiffEqNonlinearSolve.resize_nlsolver!(integrator, i)
OrdinaryDiffEqDifferentiation.resize_J_W!(cache, integrator, i)
resize_non_user_cache!(integrator, cache, i)
resize_fpsolver!(integrator, i)
nothing
Expand All @@ -203,8 +203,8 @@ function DiffEqBase.resize_non_user_cache!(integrator::DDEIntegrator,
cache::RosenbrockMutableCache, i)
cache.J = similar(cache.J, i, i)
cache.W = similar(cache.W, i, i)
OrdinaryDiffEqCore.resize_jac_config!(cache.jac_config, i)
OrdinaryDiffEqCore.resize_grad_config!(cache.grad_config, i)
OrdinaryDiffEqDifferentiation.resize_jac_config!(cache.jac_config, i)
OrdinaryDiffEqDifferentiation.resize_grad_config!(cache.grad_config, i)
nothing
end

Expand Down Expand Up @@ -493,18 +493,8 @@ end

DiffEqBase.has_stats(::DDEIntegrator) = true

# https://github.com/SciML/OrdinaryDiffEqCore.jl/pull/1753
# Backwards compatability
@static if isdefined(OrdinaryDiffEqCore, :DEPRECATED_ADDSTEPS)
const _ode_addsteps! = OrdinaryDiffEqCore._ode_addsteps!
const ode_addsteps! = OrdinaryDiffEqCore.ode_addsteps!
else
const _ode_addsteps! = DiffEqBase.addsteps!
const ode_addsteps! = OrdinaryDiffEqCore._ode_addsteps!
end

function DiffEqBase.addsteps!(integrator::DDEIntegrator, args...)
ode_addsteps!(integrator, args...)
OrdinaryDiffEqCore.ode_addsteps!(integrator, args...)
end

function DiffEqBase.change_t_via_interpolation!(integrator::DDEIntegrator,
Expand Down Expand Up @@ -540,7 +530,7 @@ function DiffEqBase.reeval_internals_due_to_modification!(integrator::DDEIntegra
# update interpolation data of the integrator using the old dense history
# of the ODE integrator
resize!(integrator.k, integrator.kshortsize)
ode_addsteps!(integrator, integrator.f, true, true, true)
OrdinaryDiffEqCore.ode_addsteps!(integrator, integrator.f, true, true, true)

# copy interpolation data to the ODE integrator
recursivecopy!(ode_integrator.k, integrator.k)
Expand Down
282 changes: 69 additions & 213 deletions src/integrators/type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,226 +19,82 @@ mutable struct HistoryODEIntegrator{
end

function (integrator::HistoryODEIntegrator)(t, deriv::Type = Val{0}; idxs = nothing)
OrdinaryDiffEq.current_interpolant(t, integrator, idxs, deriv)
OrdinaryDiffEqCore.current_interpolant(t, integrator, idxs, deriv)
end

function (integrator::HistoryODEIntegrator)(val::AbstractArray,
t::Union{Number, AbstractArray},
deriv::Type = Val{0}; idxs = nothing)
OrdinaryDiffEq.current_interpolant!(val, t, integrator, idxs, deriv)
OrdinaryDiffEqCore.current_interpolant!(val, t, integrator, idxs, deriv)
end

@static if isdefined(OrdinaryDiffEq, :get_fsalfirstlast)
mutable struct DDEIntegrator{algType, IIP, uType, tType, P, eigenType, tTypeNoUnits,
tdirType,
ksEltype, SolType, F, CacheType, IType, FP, O, dAbsType,
dRelType, H,
tstopsType, discType, FSALType, EventErrorType,
CallbackCacheType, DV} <:
AbstractDDEIntegrator{algType, IIP, uType, tType}
sol::SolType
u::uType
k::ksEltype
t::tType
dt::tType
f::F
p::P
uprev::uType
uprev2::uType
tprev::tType
prev_idx::Int
prev2_idx::Int
fpsolver::FP
order_discontinuity_t0::Int
"Discontinuities tracked by callback."
tracked_discontinuities::Vector{Discontinuity{tType, Int}}
discontinuity_interp_points::Int
discontinuity_abstol::dAbsType
discontinuity_reltol::dRelType
"Future time stops for propagated discontinuities."
tstops_propagated::tstopsType
"Future propagated discontinuities."
d_discontinuities_propagated::discType
alg::algType
dtcache::tType
dtchangeable::Bool
dtpropose::tType
tdir::tdirType
eigen_est::eigenType
EEst::tTypeNoUnits
qold::tTypeNoUnits
q11::tTypeNoUnits
erracc::tTypeNoUnits
dtacc::tType
success_iter::Int
iter::Int
saveiter::Int
saveiter_dense::Int
cache::CacheType
callback_cache::CallbackCacheType
kshortsize::Int
force_stepfail::Bool
last_stepfail::Bool
just_hit_tstop::Bool
do_error_check::Bool
event_last_time::Int
vector_event_last_time::Int
last_event_error::EventErrorType
accept_step::Bool
isout::Bool
reeval_fsal::Bool
u_modified::Bool
isdae::Bool
opts::O
stats::SciMLBase.DEStats
history::H
differential_vars::DV
integrator::IType
fsalfirst::FSALType
fsallast::FSALType
end

else
mutable struct DDEIntegrator{algType, IIP, uType, tType, P, eigenType, tTypeNoUnits,
tdirType,
ksEltype, SolType, F, CacheType, IType, FP, O, dAbsType,
dRelType, H,
tstopsType, discType, FSALType, EventErrorType,
CallbackCacheType, DV} <:
AbstractDDEIntegrator{algType, IIP, uType, tType}
sol::SolType
u::uType
k::ksEltype
t::tType
dt::tType
f::F
p::P
uprev::uType
uprev2::uType
tprev::tType
prev_idx::Int
prev2_idx::Int
fpsolver::FP
order_discontinuity_t0::Int
"Discontinuities tracked by callback."
tracked_discontinuities::Vector{Discontinuity{tType, Int}}
discontinuity_interp_points::Int
discontinuity_abstol::dAbsType
discontinuity_reltol::dRelType
"Future time stops for propagated discontinuities."
tstops_propagated::tstopsType
"Future propagated discontinuities."
d_discontinuities_propagated::discType
alg::algType
dtcache::tType
dtchangeable::Bool
dtpropose::tType
tdir::tdirType
eigen_est::eigenType
EEst::tTypeNoUnits
qold::tTypeNoUnits
q11::tTypeNoUnits
erracc::tTypeNoUnits
dtacc::tType
success_iter::Int
iter::Int
saveiter::Int
saveiter_dense::Int
cache::CacheType
callback_cache::CallbackCacheType
kshortsize::Int
force_stepfail::Bool
last_stepfail::Bool
just_hit_tstop::Bool
do_error_check::Bool
event_last_time::Int
vector_event_last_time::Int
last_event_error::EventErrorType
accept_step::Bool
isout::Bool
reeval_fsal::Bool
u_modified::Bool
isdae::Bool
opts::O
stats::SciMLBase.DEStats
history::H
differential_vars::DV
integrator::IType
fsalfirst::FSALType
fsallast::FSALType

# incomplete initialization without fsalfirst and fsallast
function DDEIntegrator{algType, IIP, uType, tType, P, eigenType, tTypeNoUnits,
tdirType, ksEltype, SolType, F, CacheType, IType, FP,
O, dAbsType, dRelType, H, tstopsType, discType,
FSALType, EventErrorType, CallbackCacheType, DV}(sol, u, k, t, dt, f,
p, uprev, uprev2,
tprev, prev_idx,
prev2_idx,
fpsolver,
order_discontinuity_t0,
tracked_discontinuities,
discontinuity_interp_points,
discontinuity_abstol,
discontinuity_reltol,
tstops_propagated,
d_discontinuities_propagated,
alg, dtcache,
dtchangeable,
dtpropose, tdir,
eigen_est, EEst,
qold,
q11, erracc, dtacc,
success_iter, iter,
saveiter,
saveiter_dense,
cache,
callback_cache,
kshortsize,
force_stepfail,
last_stepfail,
just_hit_tstop,
do_error_check,
event_last_time,
vector_event_last_time,
last_event_error,
accept_step, isout,
reeval_fsal,
u_modified, isdae,
opts, stats,
history,
differential_vars,
integrator) where
{
algType, IIP, uType, tType, P, eigenType, tTypeNoUnits, tdirType, ksEltype,
SolType, F,
CacheType, IType, FP, O, dAbsType, dRelType, H, tstopsType, discType,
FSALType, EventErrorType, CallbackCacheType, DV}
new{algType, IIP, uType, tType, P, eigenType, tTypeNoUnits, tdirType, ksEltype,
SolType, F,
CacheType, IType, FP, O, dAbsType, dRelType, H, tstopsType, discType, FSALType,
EventErrorType, CallbackCacheType, DV}(
sol, u, k, t, dt, f, p, uprev, uprev2, tprev,
prev_idx, prev2_idx, fpsolver,
order_discontinuity_t0,
tracked_discontinuities,
discontinuity_interp_points,
discontinuity_abstol, discontinuity_reltol,
tstops_propagated,
d_discontinuities_propagated, alg, dtcache,
dtchangeable, dtpropose, tdir,
eigen_est, EEst, qold, q11, erracc, dtacc,
success_iter, iter, saveiter, saveiter_dense,
cache, callback_cache, kshortsize,
force_stepfail, last_stepfail,
just_hit_tstop,
do_error_check, event_last_time,
vector_event_last_time,
last_event_error, accept_step, isout,
reeval_fsal, u_modified, isdae, opts,
stats, history, differential_vars, integrator)
end
end
mutable struct DDEIntegrator{algType, IIP, uType, tType, P, eigenType, tTypeNoUnits,
tdirType,
ksEltype, SolType, F, CacheType, IType, FP, O, dAbsType,
dRelType, H,
tstopsType, discType, FSALType, EventErrorType,
CallbackCacheType, DV} <:
AbstractDDEIntegrator{algType, IIP, uType, tType}
sol::SolType
u::uType
k::ksEltype
t::tType
dt::tType
f::F
p::P
uprev::uType
uprev2::uType
tprev::tType
prev_idx::Int
prev2_idx::Int
fpsolver::FP
order_discontinuity_t0::Int
"Discontinuities tracked by callback."
tracked_discontinuities::Vector{Discontinuity{tType, Int}}
discontinuity_interp_points::Int
discontinuity_abstol::dAbsType
discontinuity_reltol::dRelType
"Future time stops for propagated discontinuities."
tstops_propagated::tstopsType
"Future propagated discontinuities."
d_discontinuities_propagated::discType
alg::algType
dtcache::tType
dtchangeable::Bool
dtpropose::tType
tdir::tdirType
eigen_est::eigenType
EEst::tTypeNoUnits
qold::tTypeNoUnits
q11::tTypeNoUnits
erracc::tTypeNoUnits
dtacc::tType
success_iter::Int
iter::Int
saveiter::Int
saveiter_dense::Int
cache::CacheType
callback_cache::CallbackCacheType
kshortsize::Int
force_stepfail::Bool
last_stepfail::Bool
just_hit_tstop::Bool
do_error_check::Bool
event_last_time::Int
vector_event_last_time::Int
last_event_error::EventErrorType
accept_step::Bool
isout::Bool
reeval_fsal::Bool
u_modified::Bool
isdae::Bool
opts::O
stats::SciMLBase.DEStats
history::H
differential_vars::DV
integrator::IType
fsalfirst::FSALType
fsallast::FSALType
end

function (integrator::DDEIntegrator)(t, deriv::Type = Val{0}; idxs = nothing)
Expand Down
Loading

0 comments on commit 04b3dbb

Please sign in to comment.