Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare DAESolution for interpolation #622

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
35 changes: 21 additions & 14 deletions src/solutions/dae_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ https://docs.sciml.ai/DiffEqDocs/stable/basics/solution/
exited due to an error. For more details, see
[the return code documentation](https://docs.sciml.ai/SciMLBase/stable/interfaces/Solutions/#retcodes).
"""
struct DAESolution{T, N, uType, duType, uType2, DType, tType, P, A, ID, S} <:
struct DAESolution{T, N, uType, duType, uType2, DType, tType, P, A, ID, S, rateType} <:
AbstractDAESolution{T, N, uType}
u::uType
du::duType
u_analytic::uType2
errors::DType
t::tType
k::rateType
prob::P
alg::A
interp::ID
Expand Down Expand Up @@ -84,17 +85,18 @@ function build_solution(prob::AbstractDAEProblem, alg, t, u, du = nothing;
end
Base.depwarn(msg, :build_solution)
end

if has_analytic(prob.f)
u_analytic = Vector{typeof(prob.u0)}()
errors = Dict{Symbol, real(eltype(prob.u0))}()

sol = DAESolution{T, N, typeof(u), typeof(du), typeof(u_analytic), typeof(errors),
typeof(t),
typeof(prob), typeof(alg), typeof(interp), typeof(stats)}(u, du,
typeof(t), typeof(prob), typeof(alg), typeof(interp), typeof(stats), typeof(k)}(
u,
du,
u_analytic,
errors,
t,
k,
prob,
alg,
interp,
Expand All @@ -110,9 +112,10 @@ function build_solution(prob::AbstractDAEProblem, alg, t, u, du = nothing;
sol
else
DAESolution{T, N, typeof(u), typeof(du), Nothing, Nothing, typeof(t),
typeof(prob), typeof(alg), typeof(interp), typeof(stats)}(u, du,
typeof(prob), typeof(alg), typeof(interp), typeof(stats), typeof(k)}(
u, du,
nothing,
nothing, t,
nothing, t, k,
prob, alg,
interp,
dense, 0,
Expand Down Expand Up @@ -161,12 +164,13 @@ end

function build_solution(sol::AbstractDAESolution{T, N}, u_analytic, errors) where {T, N}
DAESolution{T, N, typeof(sol.u), typeof(sol.du), typeof(u_analytic), typeof(errors),
typeof(sol.t),
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.stats)}(sol.u,
typeof(sol.t), typeof(sol.prob), typeof(sol.alg), typeof(sol.interp),
typeof(sol.stats), typeof(sol.k)}(sol.u,
sol.du,
u_analytic,
errors,
sol.t,
sol.k,
sol.prob,
sol.alg,
sol.interp,
Expand All @@ -178,12 +182,13 @@ end

function solution_new_retcode(sol::AbstractDAESolution{T, N}, retcode) where {T, N}
DAESolution{T, N, typeof(sol.u), typeof(sol.du), typeof(sol.u_analytic),
typeof(sol.errors), typeof(sol.t),
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.stats)}(sol.u,
typeof(sol.errors), typeof(sol.t), typeof(sol.prob), typeof(sol.alg),
typeof(sol.interp), typeof(sol.stats), typeof(sol.k)}(sol.u,
sol.du,
sol.u_analytic,
sol.errors,
sol.t,
sol.k,
sol.prob,
sol.alg,
sol.interp,
Expand All @@ -195,12 +200,13 @@ end

function solution_new_tslocation(sol::AbstractDAESolution{T, N}, tslocation) where {T, N}
DAESolution{T, N, typeof(sol.u), typeof(sol.du), typeof(sol.u_analytic),
typeof(sol.errors), typeof(sol.t),
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.stats)}(sol.u,
typeof(sol.errors), typeof(sol.t), typeof(sol.prob), typeof(sol.alg),
typeof(sol.interp), typeof(sol.stats), typeof(k)}(sol.u,
sol.du,
sol.u_analytic,
sol.errors,
sol.t,
sol.k,
sol.prob,
sol.alg,
sol.interp,
Expand All @@ -212,15 +218,16 @@ end

function solution_slice(sol::AbstractDAESolution{T, N}, I) where {T, N}
DAESolution{T, N, typeof(sol.u), typeof(sol.du), typeof(sol.u_analytic),
typeof(sol.errors), typeof(sol.t),
typeof(sol.prob), typeof(sol.alg), typeof(sol.interp), typeof(sol.stats)}(sol.u[I],
typeof(sol.errors), typeof(sol.t), typeof(sol.prob), typeof(sol.alg),
typeof(sol.interp), typeof(sol.stats), typeof(sol.k)}(sol.u[I],
sol.du[I],
sol.u_analytic ===
nothing ?
nothing :
sol.u_analytic[I],
sol.errors,
sol.t[I],
sol.k[I],
sol.prob,
sol.alg,
sol.interp,
Expand Down
Loading