DifferentialEquations.jl icon indicating copy to clipboard operation
DifferentialEquations.jl copied to clipboard

Only Int64 and Signed index possible for sol[N]

Open stephans3 opened this issue 2 years ago • 4 comments

Hi all :) After calculating an ODE solution

sol = solve(...)

I try to get my data with

sol[N]

This does only work if N is type of Int64or Signed but not if N is Unsigned (or a subtype of it) nor if N is Int8, Int16, Int32 or Int128. In these cases I get a stackoverflow in getindex(A::SciMLBase.ODESolution .....) see below.

Is this a bug or a feature? ;)

A workaround is to use sol.u[N] because here I ask for the solution vector explicitly.

Error message:

ERROR: StackOverflowError:
Stacktrace:
 [1] getindex(A::SciMLBase.ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, SciMLBase.NullParameters, SciMLBase.ODEFunction{true, typeof(heat_conduction!), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, OrdinaryDiffEq.KenCarp5{12, true, LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}, DiffEqBase.NLNewton{Rational{Int64}, Rational{Int64}, Rational{Int64}}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{true, typeof(heat_conduction!), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.KenCarp5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.NLSolver{DiffEqBase.NLNewton{Rational{Int64}, Rational{Int64}, Rational{Int64}}, true, Vector{Float64}, Float64, Nothing, Float64, OrdinaryDiffEq.NLNewtonCache{Vector{Float64}, Float64, Float64, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, SciMLBase.UJacobianWrapper{SciMLBase.ODEFunction{true, typeof(heat_conduction!), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, SciMLBase.NullParameters}, SparseDiffTools.ForwardColorJacCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{OrdinaryDiffEq.OrdinaryDiffEqTag, Float64}, Float64, 12}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{OrdinaryDiffEq.OrdinaryDiffEqTag, Float64}, Float64, 12}}, Vector{Float64}, Vector{Vector{NTuple{12, Float64}}}, UnitRange{Int64}, Nothing}, LinearSolve.LinearCache{Matrix{Float64}, Vector{Float64}, Vector{Float64}, SciMLBase.NullParameters, LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}, LinearAlgebra.LU{Float64, Matrix{Float64}}, LinearSolve.InvPreconditioner{LinearAlgebra.Diagonal{Float64, Vector{Float64}}}, LinearAlgebra.Diagonal{Float64, Vector{Float64}}, Float64}}}, OrdinaryDiffEq.KenCarp5Tableau{Float64, Float64}, Nothing}}, DiffEqBase.DEStats}, sym::Int128, args::Int64) (repeats 79984 times)
   @ SciMLBase ~/.julia/packages/SciMLBase/BoNUy/src/solutions/solution_interface.jl:84

stephans3 avatar May 11 '22 13:05 stephans3

You'd need to expand this: https://github.com/SciML/SciMLBase.jl/blob/master/src/solutions/solution_interface.jl#L32

@shashi @YingboMa is Num defined in a lightweight package now? We might want to dispatch on it directly.

ChrisRackauckas avatar May 11 '22 14:05 ChrisRackauckas

Num isn't in a lightweight package now, but we can move it.

YingboMa avatar May 11 '22 18:05 YingboMa

What about the Symbolic abstract type?

ChrisRackauckas avatar May 12 '22 08:05 ChrisRackauckas

Oh I guess it's <:Number, that makes it hard.

ChrisRackauckas avatar May 12 '22 08:05 ChrisRackauckas