Skip to content

Commit e42c360

Browse files
committed
margin() docstring updates
1 parent b9a21e4 commit e42c360

1 file changed

Lines changed: 30 additions & 18 deletions

File tree

control/margins.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,36 +211,41 @@ def fun(wdt):
211211
# Sawyer B. Fuller <minster@uw.edu>, removed a lot of the innards
212212
# and replaced with analytical polynomial functions for LTI systems.
213213
#
214-
# idea for the frequency data solution copied/adapted from
214+
# The idea for the frequency data solution copied/adapted from
215215
# https://github.com/alchemyst/Skogestad-Python/blob/master/BODE.py
216216
# Rene van Paassen <rene.vanpaassen@gmail.com>
217217
#
218218
# RvP, July 8, 2014, corrected to exclude phase=0 crossing for the gain
219219
# margin polynomial
220+
#
220221
# RvP, July 8, 2015, augmented to calculate all phase/gain crossings with
221222
# frd data. Correct to return smallest phase
222223
# margin, smallest gain margin and their frequencies
224+
#
223225
# RvP, Jun 10, 2017, modified the inclusion of roots found for phase
224-
# crossing to include all >= 0, made subsequent calc
225-
# insensitive to div by 0
226-
# also changed the selection of which crossings to
227-
# return on basis of "A note on the Gain and Phase
228-
# Margin Concepts" Journal of Control and Systems
229-
# Engineering, Yazdan Bavafi-Toosi, Dec 2015, vol 3
230-
# issue 1, pp 51-59, closer to Matlab behavior, but
231-
# not completely identical in edge cases, which don't
232-
# cross but touch gain=1
226+
# crossing to include all >= 0, made subsequent
227+
# calc insensitive to div by 0. Also changed the
228+
# selection of which crossings to return on basis
229+
# of "A note on the Gain and Phase Margin Concepts"
230+
# Journal of Control and Systems Engineering,
231+
# Yazdan Bavafi-Toosi, Dec 2015, vol 3 issue 1, pp
232+
# 51-59, closer to Matlab behavior, but not
233+
# completely identical in edge cases, which don't
234+
# cross but touch gain=1.
235+
#
233236
# BG, Nov 9, 2020, removed duplicate implementations of the same code
234237
# for crossover frequencies and enhanced to handle discrete
235238
# systems
239+
240+
>>>>>>> Stashed changes
236241
def stability_margins(sysdata, returnall=False, epsw=0.0):
237242
"""Calculate stability margins and associated crossover frequencies.
238243
239244
Parameters
240245
----------
241246
sysdata: LTI system or (mag, phase, omega) sequence
242247
sys : LTI system
243-
Linear SISO system
248+
Linear SISO system representing the loop transfer function
244249
mag, phase, omega : sequence of array_like
245250
Arrays of magnitudes (absolute values, not dB), phases (degrees),
246251
and corresponding frequencies. Crossover frequencies returned are
@@ -261,12 +266,19 @@ def stability_margins(sysdata, returnall=False, epsw=0.0):
261266
Phase margin
262267
sm: float or array_like
263268
Stability margin, the minimum distance from the Nyquist plot to -1
264-
wg: float or array_like
265-
Frequency for gain margin (at phase crossover, phase = -180 degrees)
266-
wp: float or array_like
267-
Frequency for phase margin (at gain crossover, gain = 1)
268-
ws: float or array_like
269-
Frequency for stability margin (complex gain closest to -1)
269+
wpc: float or array_like
270+
Phase crossover frequency (where phase crosses -180 degrees)
271+
wgc: float or array_like
272+
Gain crossover frequency (where gain crosses 1)
273+
wms: float or array_like
274+
Stability margin frequency (where Nyquist plot is closest to -1)
275+
276+
Note that the gain margin is determined by the gain of the loop
277+
transfer function at the phase crossover frequency(s), the phase
278+
margin is determined by the phase of the loop transfer function at
279+
the gain crossover frequency(s), and the stability margin is
280+
determined by the frequency of maximum sensitivity (given by the
281+
magnitude of 1/(1+L)).
270282
"""
271283
try:
272284
if isinstance(sysdata, frdata.FRD):
@@ -456,7 +468,7 @@ def margin(*args):
456468
----------
457469
sysdata : LTI system or (mag, phase, omega) sequence
458470
sys : StateSpace or TransferFunction
459-
Linear SISO system
471+
Linear SISO system representing the loop transfer function
460472
mag, phase, omega : sequence of array_like
461473
Input magnitude, phase (in deg.), and frequencies (rad/sec) from
462474
bode frequency response data

0 commit comments

Comments
 (0)