diff --git a/docs/src/index.md b/docs/src/index.md index b9cc0933e..a50c7635f 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -84,7 +84,8 @@ The following is a list of packages from the wider Julia ecosystem that may be o - [DescriptorSystems.jl](https://github.com/andreasvarga/DescriptorSystems.jl) contains types that represent statespace systems on descriptor form, i.e., with a mass matrix. These systems can represent linear DAE systems and non-proper systems. - [LowLevelParticleFilters.jl](https://github.com/baggepinnen/LowLevelParticleFilters.jl) is a library for state estimation using particle filters and Kalman filters of different flavors. - [ModelingToolkit.jl](https://mtk.sciml.ai/stable/) is an acausal modeling tool, similar in spirit to Modelica. A video showing ControlSystems and ModelingToolkit together is [available here](https://youtu.be/favQKOyyx4o). [ControlSystemsMTK.jl](https://juliacontrol.github.io/ControlSystemsMTK.jl/dev/) exists to ease the use of these two packages together. -- [JuliaSimControl.jl](https://help.juliahub.com/juliasimcontrol/dev/) is a product that builds upon the JuliaControl ecosystem and ModelingToolkit, providing additional nonlinear and robust control methods. +- [DyadControlSystems.jl](https://help.juliahub.com/dyadcontrol/dev/) is a product that builds upon the JuliaControl ecosystem and ModelingToolkit, providing additional nonlinear and robust control methods. +- [LinearMPC.jl](https://darnstrom.github.io/LinearMPC.jl/stable/) A package for linear quadratic MPC that supports generation of embeddable C-code for real-time applications. - [FaultDetectionTools.jl](https://github.com/andreasvarga/FaultDetectionTools.jl) contains utilities and observers for online fault detection. - [ReachabilityAnalysis.jl](https://juliareach.github.io/ReachabilityAnalysis.jl/dev/generated_examples/Building/) is a package for reachability analysis. This can be used to verify stability and safety properties of linear and nonlinear systems. - [MatrixEquations.jl](https://github.com/andreasvarga/MatrixEquations.jl) contains solvers for many different matrix equations common in control. ControlSystems.jl makes use of this package for solving Riccati and Lyapunov equations. diff --git a/lib/ControlSystemsBase/src/matrix_comps.jl b/lib/ControlSystemsBase/src/matrix_comps.jl index de73d5da7..b216d8473 100644 --- a/lib/ControlSystemsBase/src/matrix_comps.jl +++ b/lib/ControlSystemsBase/src/matrix_comps.jl @@ -1019,4 +1019,13 @@ end function observer_filter(sys::AbstractStateSpace{Continuous}, K::AbstractMatrix; kwargs...) observer_predictor(sys, K; kwargs...) -end \ No newline at end of file +end + +function LinearAlgebra.det(sys::LTISystem) + sys = deepcopy(sys) + arrayofsys = getindex.(Ref(sys), 1:sys.ny, (1:sys.nu)') + if sys isa AbstractStateSpace + @. arrayofsys = sminreal(arrayofsys) + end + LinearAlgebra.det_bareiss!(arrayofsys) +end diff --git a/lib/ControlSystemsBase/src/types/StateSpace.jl b/lib/ControlSystemsBase/src/types/StateSpace.jl index 66da63d2e..5e955fc23 100644 --- a/lib/ControlSystemsBase/src/types/StateSpace.jl +++ b/lib/ControlSystemsBase/src/types/StateSpace.jl @@ -265,6 +265,10 @@ Base.zero(sys::AbstractStateSpace) = basetype(sys)(zero(sys.D), sys.timeevol) Base.zero(::Type{StateSpace{Continuous, F}}) where {F} = ss([zero(F)], Continuous()) Base.zero(::Type{StateSpace{D, F}}) where {D<:Discrete, F} = ss([zero(F)], undef_sampletime(D)) +# one is a multiplicative identity, which can be set to the one of the element type. This is different from oneunit which should be of the same type. +Base.one(::Type{StateSpace{TE, T}}) where {TE, T} = Base.one(T) + + function +(s1::ST, s2::ST) where {ST <: AbstractStateSpace} #Ensure systems have same dimensions if size(s1) != size(s2) diff --git a/lib/ControlSystemsBase/test/test_matrix_comps.jl b/lib/ControlSystemsBase/test/test_matrix_comps.jl index 9dd7ba807..585a1ab85 100644 --- a/lib/ControlSystemsBase/test/test_matrix_comps.jl +++ b/lib/ControlSystemsBase/test/test_matrix_comps.jl @@ -11,6 +11,12 @@ sysr, G = balreal(sys) @test gram(sysr, :o) ≈ diagm(G) @test sort(poles(sysr), by=real) ≈ sort(poles(sys), by=real) +@testset "det" begin + detsys = det(sys) + w = 0.1 + @test freqresp(detsys, w)[1] ≈ det(freqresp(sys, w)) +end + sysb,T = ControlSystemsBase.balance_statespace(sys) @test similarity_transform(sysb, T) ≈ sys Ab,Bb,Cb,T = ControlSystemsBase.balance_statespace(A,B,C)