Skip to content

Commit

Permalink
Merge pull request #793 from JuliaControl/analysisdocs
Browse files Browse the repository at this point in the history
add analysis examples to the docs
  • Loading branch information
baggepinnen committed Jan 11, 2023
2 parents 98435be + a28d942 commit 5ebb53b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ makedocs(modules=[ControlSystems, ControlSystemsBase],
],
"Examples" => Any[
"Design" => "examples/example.md",
"Analysis" => "examples/analysis.md",
"Smith predictor" => "examples/smith_predictor.md",
"Iterative Learning Control (ILC)" => "examples/ilc.md",
"Properties of delay systems" => "examples/delay_systems.md",
Expand Down
67 changes: 67 additions & 0 deletions docs/src/examples/analysis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Analysis of linear control systems
From classical control, we get robustness measures such as gain and phase margins. These provide a quick and intuitive way to assess robustness of single-input, single-output systems, but also have a number of downsides, such as optimism in the presence of simultaneous gain and phase variations as well as limited applicability for MIMO systems.

Gain and phase margins can be computed using the functions [`margin`](@ref) and [`marginplot`](@ref)

## Example: Gain and phase margins
```@example
using ControlSystemsBase, Plots
P = tf(1, [1, 0.2, 1])
C = pid(0.2, 1)
loopgain = P*C
marginplot(loopgain)
```

## Sensitivity analysis
More generally applicable measures of robustness include analysis of sensitivity functions, notably the peaks of the sensitivity function
```math
S(s) = (I + P(s)C(s))^{-1}
```
and the complementary sensitivity function
```math
T(s) = I - S(s) = (I + P(s)C(s))^{-1}P(s)C(s)
```

### Examples
We can plot all four sensitivity functions referred to as the "gang of four" using [`gangoffourplot`](@ref).
```@example SENS
using ControlSystemsBase, Plots
P = tf(1, [1, 0.2, 1])
C = pid(0.2, 1)
gangoffourplot(P, C)
```

The peak value of the sensitivity function, ``M_S``, can be computed using [`hinfnorm`](@ref)
```@example SENS
S = sensitivity(P, C)
Ms, ωMs = hinfnorm(S)
```

And we can plot a circle in the Nyquist plot corresponding to the inverse distance between the loop-transfer function and the critical point:
```@example SENS
w = exp10.(-1:0.001:2)
nyquistplot(P*C, w, Ms_circles=[Ms], xlims=(-1.2, 0.5), ylims=(-2, 0.3))
```

``M_S`` is always ``≥ 1``, but we typically want to keep it below 1.3-2 for robustness reasons. For SISO systems, ``M_S`` is linked to the classical gain and phase margins through the following inequalities:
```math
\begin{aligned}
\phi_m &≥ 2 \sin^{-1}\left(\dfrac{1}{2M_S}\right) \text{rad}\\
g_m &≥ \dfrac{M_S}{M_S-1}
\end{aligned}
```

We can also obtain individual sensitivity function using the low-level function [`feedback`](@ref) directly, or using one of the higher-level functions
- [`sensitivity`](@ref)
- [`comp_sensitivity`](@ref)
- [`G_PS`](@ref)
- [`G_CS`](@ref)
- [`gangoffour`](@ref)
- [`extended_gangoffour`](@ref)
- [`feedback_control`](@ref)


## Further reading
A modern robustness measure is the [`diskmargin`](https://juliacontrol.github.io/RobustAndOptimalControl.jl/dev/#Diskmargin-example), that analyses the robustness of a SISO or MIMO system to simultaneous gain and phase variations.

In the presence of structured uncertainty, such as parameter uncertainty or other explicitly modeled uncertainty, the structured singular value (often referred to as $\mu$), provides a way to analyze robustness with respect to the modeled uncertainty. See the [RobustAndOptimalControl.jl](https://juliacontrol.github.io/RobustAndOptimalControl.jl/dev/) package for more details.

2 comments on commit 5ebb53b

@baggepinnen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/75508

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.6.0 -m "<description of version>" 5ebb53b78548cfd15f53fc59ebbd01f5c12fe584
git push origin v1.6.0

Please sign in to comment.