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

add sensitivity solution constructor #1152

Merged
merged 1 commit into from
May 30, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
[compat]
ArrayInterface = "2.7"
DataStructures = "0.17"
DiffEqBase = "6.33"
DiffEqBase = "6.36"
ExponentialUtilities = "1.2"
FiniteDiff = "2"
ForwardDiff = "0.10.3"
Expand Down
26 changes: 23 additions & 3 deletions src/composite_solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,32 @@ function DiffEqBase.solution_new_retcode(sol::ODECompositeSolution{T,N,uType,uTy
sol.u,sol.u_analytic,sol.errors,sol.t,sol.k,sol.prob,
sol.alg,sol.interp,sol.alg_choice,sol.dense,sol.tslocation,
sol.destats,retcode)
end
end

function DiffEqBase.solution_new_tslocation(sol::ODECompositeSolution{
function DiffEqBase.solution_new_tslocation(sol::ODECompositeSolution{
T,N,uType,uType2,EType,tType,rateType,P,A,IType,DE},tslocation) where {T,N,uType,uType2,EType,tType,rateType,P,A,IType,DE}
ODECompositeSolution{T,N,uType,uType2,EType,tType,rateType,P,A,IType,DE}(
sol.u,sol.u_analytic,sol.errors,sol.t,sol.k,sol.prob,
sol.alg,sol.interp,sol.alg_choice,sol.dense,tslocation,
sol.destats,sol.retcode)
end
end

function DiffEqBase.sensitivity_solution(sol::ODECompositeSolution,u,t)
T = eltype(eltype(u))
N = length((size(sol.prob.u0)..., length(u)))
interp = if typeof(sol.interp) <: LinearInterpolation
LinearInterpolation(t,u)
elseif typeof(sol.interp) <: ConstantInterpolation
ConstantInterpolation(t,u)
else
SensitivityInterpolation(t,u)
end

ODECompositeSolution{T,N,typeof(u),typeof(sol.u_analytic),typeof(sol.errors),
typeof(t),Nothing,typeof(sol.prob),typeof(sol.alg),
typeof(interp),typeof(sol.destats)}(
u,sol.u_analytic,sol.errors,t,nothing,sol.prob,
sol.alg,interp,sol.alg_choice,
sol.dense,sol.tslocation,
sol.destats,sol.retcode)
end