Skip to content

Commit 8f0c037

Browse files
committed
Put more comments in the disk margin example, add example to documentation
1 parent 077d538 commit 8f0c037

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

doc/examples/disk_margins.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Disk margin example
2+
------------------------------------------
3+
4+
This example demonstrates the use of the `disk_margins` routine
5+
to compute robust stability margins for a feedback system, i.e.,
6+
variation in gain and phase one or more loops. The SISO examples
7+
are drawn from the published paper and the MIMO example is the
8+
"spinning satellite" example from the MathWorks documentation.
9+
10+
Code
11+
....
12+
.. literalinclude:: disk_margins.py
13+
:language: python
14+
:linenos:
15+
16+
Notes
17+
.....
18+
1. The environment variable `PYCONTROL_TEST_EXAMPLES` is used for
19+
testing to turn off plotting of the outputs.

examples/disk_margins.py

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1-
"""test_margins.py
1+
"""disk_margins.py
2+
23
Demonstrate disk-based stability margin calculations.
4+
5+
References:
6+
[1] Blight, James D., R. Lane Dailey, and Dagfinn Gangsaas. “Practical
7+
Control Law Design for Aircraft Using Multivariable Techniques.”
8+
International Journal of Control 59, no. 1 (January 1994): 93-137.
9+
https://doi.org/10.1080/00207179408923071.
10+
11+
[2] Seiler, Peter, Andrew Packard, and Pascal Gahinet. “An Introduction
12+
to Disk Margins [Lecture Notes].” IEEE Control Systems Magazine 40,
13+
no. 5 (October 2020): 78-95.
14+
15+
[3] P. Benner, V. Mehrmann, V. Sima, S. Van Huffel, and A. Varga, "SLICOT
16+
- A Subroutine Library in Systems and Control Theory", Applied and
17+
Computational Control, Signals, and Circuits (Birkhauser), Vol. 1, Ch.
18+
10, pp. 505-546, 1999.
19+
20+
[4] S. Van Huffel, V. Sima, A. Varga, S. Hammarling, and F. Delebecque,
21+
"Development of High Performance Numerical Software for Control", IEEE
22+
Control Systems Magazine, Vol. 24, Nr. 1, Feb., pp. 60-76, 2004.
323
"""
424

525
import os
@@ -32,32 +52,6 @@ def plot_allowable_region(alpha_max, skew, ax = None):
3252
PM : ndarray
3353
1D array of frequency-dependent disk-based phase margins, in deg.
3454
PM is the same size as "omega" parameter.
35-
36-
Examples
37-
--------
38-
>> import control
39-
>> import numpy as np
40-
>> import matplotlib
41-
>> import matplotlib.pyplot as plt
42-
>>
43-
>> omega = np.logspace(-1, 2, 1001)
44-
>>
45-
>> s = control.tf('s') # Laplace variable
46-
>> L = 6.25*(s + 3)*(s + 5)/(s*(s + 1)**2*(s**2 + 0.18*s + 100)) # loop gain
47-
>>
48-
>> DM_plot = []
49-
>> DM_plot.append(control.disk_margins(L, omega, skew = -1.0)[0]) # T-based (T)
50-
>> DM_plot.append(control.disk_margins(L, omega, skew = 0.0)[0]) # balanced (S - T)
51-
>> DM_plot.append(control.disk_margins(L, omega, skew = 1.0)[0]) # S-based (S)
52-
>> plt.figure(1)
53-
>> control.disk_margin_plot(DM_plot, skew = [-1.0, 0.0, 1.0])
54-
>> plt.show()
55-
56-
References
57-
----------
58-
[1] Seiler, Peter, Andrew Packard, and Pascal Gahinet. “An Introduction
59-
to Disk Margins [Lecture Notes].” IEEE Control Systems Magazine 40,
60-
no. 5 (October 2020): 78-95.
6155
"""
6256

6357
# Create axis if needed

0 commit comments

Comments
 (0)