Skip to content

Commit

Permalink
Merge pull request #101 from JuliaControl/freqseparation
Browse files Browse the repository at this point in the history
add frequency-separation decomposition
  • Loading branch information
baggepinnen authored Dec 20, 2023
2 parents 0e0aff0 + 7f88318 commit d069a96
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RobustAndOptimalControl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ include("descriptor.jl")
export ExtendedStateSpace, system_mapping, performance_mapping, noise_mapping, ssdata_e, partition, ss
include("ExtendedStateSpace.jl")

export modal_form, schur_form, hess_form
export modal_form, schur_form, hess_form, frequency_separation
include("canonical.jl")

export δ, δr, δc, δss, nominal, UncertainSS, uss, blocksort, sys_from_particles, ss2particles
Expand Down
28 changes: 28 additions & 0 deletions src/canonical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,32 @@ function hess_form(sys)
C = sys.C*Q
D = sys.D
ss(A,B,C,D, sys.timeevol), Q, F
end

"""
stateinds(sys, inds; zeroD = false)
Extract a subsystem of the statevariables indicated in `inds`.
If `zeroD = true`, the `D` matrix is set to zero.
"""
function stateinds(sys, inds; zeroD=false)
A = sys.A[inds, inds]
B = sys.B[inds, :]
C = sys.C[:, inds]
D = zeroD ? zero(sys.D) : sys.D
ss(A,B,C,D, sys.timeevol)
end

"""
frequency_separation(sys, ω)
Decomponse `sys` into `sys = sys_slow + sys_fast`, where `sys_slow` contain all modes with eigenvalues with absolute value less than `ω` and `sys_fast` contain all modes with eigenvalues with absolute value greater than or equal to `ω`.
"""
function frequency_separation(sys, ω)
sysm, T, E = modal_form(sys)
slow_inds = findall(e->abs(e) < ω, E.values)
fast_inds = findall(e->abs(e) ω, E.values)
slow_sys = stateinds(sysm, slow_inds, zeroD=true)
fast_sys = stateinds(sysm, fast_inds, zeroD=false)
(; slow_sys, fast_sys, T, E, sysm)
end
9 changes: 9 additions & 0 deletions test/test_canonical_forms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,12 @@ end
end


@testset "frequency_separation" begin
@info "Testing frequency_separation"

sys = ssrand(2,2,5)
res = frequency_separation(sys, 1)
slow_sys, fast_sys = res
# bodeplot([sys, slow_sys, fast_sys, slow_sys+fast_sys], legend=false, plotphase=false)
@test hinfnorm(fast_sys+slow_sys - sys)[1] < 1e-7
end

0 comments on commit d069a96

Please sign in to comment.