Skip to content

Commit df8a76d

Browse files
committed
add docstrings
1 parent 21abe09 commit df8a76d

5 files changed

Lines changed: 32 additions & 23 deletions

File tree

examples/hinf_example_tank.jl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,14 @@ D = zeros(2,2)
3636
G = ss(A,B,C,D);
3737

3838
# Sensitivity weight function
39-
WSelement = 100*tf([1,1],[1000,1])
40-
WS = [WSelement 0; 0 WSelement]
41-
iWSelement = 1/WSelement
42-
iWS = [iWSelement 0; 0 iWSelement]
39+
WS = 100*tf([1,1],[1000,1]) .* I(2)
4340

4441
# Output sensitivity weight function
45-
WUelement = 5*tf([1,1],[0.1,1])
46-
WUelement = ss(0.01)
47-
WU = [WUelement 0; 0 WUelement]
48-
iWUelement = 1/WUelement
49-
iWU = [iWUelement 0; 0 iWUelement]
42+
# WUelement = 5*tf([1,1],[0.1,1])
43+
WU = tf(0.01) .* I(2)
5044

5145
# Complementary sensitivity weight function
52-
WTelement = tf([10,0.1],[1,1])
53-
WT = [WTelement 0; 0 WTelement]
54-
iWTelement = 1/WTelement
55-
iWT = [iWTelement 0; 0 iWTelement]
46+
WT = tf([10,0.1],[1,1]) .* I(2)
5647

5748
# Form augmented P dynamics in state-space
5849
P = hinfpartition(G, WS, WU, WT)

src/RobustAndOptimalControl.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import MatrixPencils, MatrixEquations
1919
export ExtendedStateSpace, system_mapping, performance_mapping, noise_mapping, ssdata_e, partition, ss
2020
include("ExtendedStateSpace.jl")
2121

22-
export δ, δr, δc, δss, nominal, UncertainSS, uss
22+
export δ, δr, δc, δss, nominal, UncertainSS, uss, blocksort
2323
include("uncertainty_interface.jl")
2424

2525
export Weights, makeweight, neglected_delay, gain_and_delay_uncertainty, neglected_lag, fit_complex_perturbations

src/diskmargin.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ The notation follows "An Introduction to Disk Margins", Peter Seiler, Andrew Pac
88
`ω0`: The worst-case frequency
99
`f0`: The destabilizing perturbation `f0` is a complex number with simultaneous gain and phase variation. This critical perturbation causes an instability with closed-loop pole on the imaginary axis at the critical frequency ω0
1010
`δ0`: The uncertain element generating f0.
11-
`γmin`: The lower real-axis intercept of the disk (classical lower gain margin).
12-
`γmax`: The upper real-axis intercept of the disk (classical upper gain margin).
13-
`ϕm`: is the classical phase margin.
11+
`γmin`: The lower real-axis intercept of the disk (analogous to classical lower gain margin).
12+
`γmax`: The upper real-axis intercept of the disk (analogous to classical upper gain margin).
13+
`ϕm`: is analogous to the classical phase margin.
1414
`σ`: The skew parameter that was used to calculate the margin
1515
16+
Note, `γmax` and `ϕm` are in smaller than the classical gain and phase margins sicne the classical margins do not consider simultaneous perturbations in gain and phase.
17+
1618
The "disk" margin becomes a half plane for `α = 2` and an inverted circle for `α > 2`. In this case, the upper gain margin is infinite. See the paper for more details, in particular figure 6.
1719
"""
1820
struct Diskmargin

src/mimo_diskmargin.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ any0det(D::Matrix{<:Complex{<:Interval}}) = 0 ∈ det(D)
1515

1616
"""
1717
bisect_a(P, K, w; W = (:), Z = (:), au0 = 3.0, tol = 0.001, N = 32, upper = true, δ = δc, σ=-1)
18+
bisect_a(M, D, w; W = (:), Z = (:), au0 = 3.0, tol = 0.001, N = 32, upper = true, δ = δc, σ=-1)
1819
1920
EXPERIMENTAL AND SUBJECT TO BUGS, BREAKAGE AND REMOVAL
2021
@@ -38,8 +39,8 @@ If `upper = true`, a Monte-Carlo approach is used to find an upper bound of the
3839
- `upper`: Calculate upper or lower bound?
3940
- `δ = δc` for complex perturbations and `δ = δr` for real perturbations.
4041
"""
41-
function bisect_a(args...; au0 = 3.0, tol=1e-3, kwargs...)
42-
M0, D = get_M(args...; kwargs...)
42+
function bisect_a(M0::AbstractArray, D::AbstractMatrix; au0 = 3.0, tol=1e-3, kwargs...)
43+
4344
iters = ceil(Int, log2(au0/tol))
4445
@views map(axes(M0, 3)) do i
4546
au = au0
@@ -57,6 +58,11 @@ function bisect_a(args...; au0 = 3.0, tol=1e-3, kwargs...)
5758
end
5859
end
5960

61+
function bisect_a(args...; au0 = 3.0, tol=1e-3, kwargs...)
62+
M0, D = get_M(args...; kwargs...)
63+
bisect_a(M0, D; au0 = 3.0, tol=1e-3, kwargs...)
64+
end
65+
6066
"""
6167
M,D = get_M(P, K, w; W = (:), Z = (:), N = 32, upper = false, δ = δc, σ=-1)
6268

src/uncertainty_interface.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,10 @@ end
523523
block_structure(Δ)
524524
525525
Take a vector of uncertain elements and return a vector of vectors with the block
526-
structure of perturbation blocks as described expected my μ-tools, i.e.
527-
- `[-N, 0]` denots a repeated real block of size `N`
528-
- `[N, 0]` denots a repeated complex block of size `N`
529-
- `[ny, nu]` denots a full complex block of size `ny × nu`
526+
structure of perturbation blocks as described by μ-tools, i.e.
527+
- `[-N, 0]` denotes a repeated real block of size `N`
528+
- `[N, 0]` denotes a repeated complex block of size `N`
529+
- `[ny, nu]` denotes a full complex block of size `ny × nu`
530530
"""
531531
function block_structure(D)
532532
perm = sortperm(D, by=d->d.name)
@@ -561,6 +561,16 @@ function makeblock(d) # TODO: full uncertain block that is not a dynamical syste
561561
end
562562

563563

564+
"""
565+
blocks, M = blocksort(P::UncertainSS)
566+
567+
Returns the block structure of `P.Δ` as well as `P.M` permuted according to the sorted block structure.
568+
`blocks` is a vector of vectors with the block
569+
structure of perturbation blocks as described by μ-tools, i.e.
570+
- `[-N, 0]` denotes a repeated real block of size `N`
571+
- `[N, 0]` denotes a repeated complex block of size `N`
572+
- `[ny, nu]` denotes a full complex block of size `ny × nu`
573+
"""
564574
function blocksort(P::UncertainSS)
565575
blocks, perm = block_structure(P.Δ)
566576
Poutinds = []

0 commit comments

Comments
 (0)