-
Notifications
You must be signed in to change notification settings - Fork 89
Closed
Description
lsim() fails if it is passed a state space system with only a D matrix. Below is a minimum working example:
using ControlSystems
sys = pid_ss(1.0, 0)
lsim(sys, (_, _) -> [1.0], 0:0.1:1)This produces the following error using ControlSystems v1.15.1
ERROR: LoadError: BoundsError: attempt to access 0-element Vector{Float64} at index [1]
Stacktrace:
[1] throw_boundserror(A::Vector{Float64}, I::Tuple{Int64})
@ Base ./essentials.jl:14
[2] getindex
@ ./essentials.jl:916 [inlined]
[3] first
@ ./abstractarray.jl:452 [inlined]
[4] ode_interpolant
@ ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/dense/generic_dense.jl:956 [inlined]
[5] ode_interpolant
@ ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/dense/generic_dense.jl:143 [inlined]
[6] _savevalues!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…}, force_save::Bool, reduce_size::Bool)
@ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/integrators/integrator_utils.jl:110
[7] savevalues! (repeats 2 times)
@ ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/integrators/integrator_utils.jl:95 [inlined]
[8] handle_callbacks!
@ ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/integrators/integrator_utils.jl:406 [inlined]
[9] _loopfooter!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…})
@ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/integrators/integrator_utils.jl:284
[10] loopfooter!
@ ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/integrators/integrator_utils.jl:248 [inlined]
[11] solve!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…})
@ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/solve.jl:612
[12] #__solve#62
@ ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/solve.jl:7 [inlined]
[13] __solve
@ ~/.julia/packages/OrdinaryDiffEqCore/qzTLI/src/solve.jl:1 [inlined]
[14] solve_call(_prob::SciMLBase.ODEProblem{…}, args::OrdinaryDiffEqTsit5.Tsit5{…}; merge_callbacks::Bool, kwargshandle::Nothing, kwargs::@Kwargs{…})
@ DiffEqBase ~/.julia/packages/DiffEqBase/p82Yh/src/solve.jl:127
[15] solve_up(prob::SciMLBase.ODEProblem{…}, sensealg::Nothing, u0::Vector{…}, p::Tuple{…}, args::OrdinaryDiffEqTsit5.Tsit5{…}; originator::SciMLBase.ChainRulesOriginator, kwargs::@Kwargs{…})
@ DiffEqBase ~/.julia/packages/DiffEqBase/p82Yh/src/solve.jl:563
[16] solve_up
@ ~/.julia/packages/DiffEqBase/p82Yh/src/solve.jl:540 [inlined]
[17] solve(prob::SciMLBase.ODEProblem{…}, args::OrdinaryDiffEqTsit5.Tsit5{…}; sensealg::Nothing, u0::Nothing, p::Nothing, wrap::Val{…}, kwargs::@Kwargs{…})
@ DiffEqBase ~/.julia/packages/DiffEqBase/p82Yh/src/solve.jl:530
[18] lsim(sys::StateSpace{…}, u::var"#11#12", t::StepRangeLen{…}; x0::Vector{…}, method::Symbol, dtmax::Float64, alg::OrdinaryDiffEqTsit5.Tsit5{…}, kwargs::@Kwargs{})
@ ControlSystems ~/.julia/packages/ControlSystems/gkwy6/src/timeresp.jl:45
[19] lsim(sys::StateSpace{Continuous, Float64}, u::Function, t::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64})
@ ControlSystems ~/.julia/packages/ControlSystems/gkwy6/src/timeresp.jl:24
[20] top-level scope
@ ~/gnc_tools/TestDelete/test.jl:4
[21] include(fname::String)
@ Main ./sysimg.jl:38
[22] top-level scope
@ REPL[9]:1Metadata
Metadata
Assignees
Labels
No labels