From 2646eadcb453ce8ab146d8bf77b6fd661264fb91 Mon Sep 17 00:00:00 2001 From: Richard Murray Date: Sat, 24 Feb 2018 15:36:12 -0800 Subject: [PATCH 1/3] Fix margin() documentation to address issue #195 --- control/margins.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/control/margins.py b/control/margins.py index 392acbc9a..6821a7345 100644 --- a/control/margins.py +++ b/control/margins.py @@ -340,10 +340,10 @@ def margin(*args): Gain margin pm : float Phase margin (in degrees) - Wcg : float - Gain crossover frequency (corresponding to phase margin) - Wcp : float - Phase crossover frequency (corresponding to gain margin) (in rad/sec) + wg: float or array_like + Gain margin crossover frequency (where phase crosses -180 degrees) + wp: float or array_like + Phase margin crossover frequency (where gain crosses 0 dB) Margins are of SISO open-loop. If more than one crossover frequency is detected, returns the lowest corresponding margin. @@ -351,7 +351,7 @@ def margin(*args): Examples -------- >>> sys = tf(1, [1, 2, 1, 0]) - >>> gm, pm, Wcg, Wcp = margin(sys) + >>> gm, pm, wg, wp = margin(sys) """ if len(args) == 1: From 9fd6ae7990a001c827903f53d07aaef72fd4a4c7 Mon Sep 17 00:00:00 2001 From: Richard Murray Date: Sat, 24 Feb 2018 15:45:19 -0800 Subject: [PATCH 2/3] DOC: remove extraneous ininfo from docstring (margin always returns scalar) --- control/margins.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/control/margins.py b/control/margins.py index 6821a7345..b567a9628 100644 --- a/control/margins.py +++ b/control/margins.py @@ -340,9 +340,9 @@ def margin(*args): Gain margin pm : float Phase margin (in degrees) - wg: float or array_like + wg: float Gain margin crossover frequency (where phase crosses -180 degrees) - wp: float or array_like + wp: float Phase margin crossover frequency (where gain crosses 0 dB) Margins are of SISO open-loop. If more than one crossover frequency is From 1593391b7d17fff2fe53813eba60303bb80857cd Mon Sep 17 00:00:00 2001 From: Rene van Paassen Date: Mon, 2 Jul 2018 21:43:44 +0200 Subject: [PATCH 3/3] Clarify comments on margin and stability_margins functions --- control/margins.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/control/margins.py b/control/margins.py index b567a9628..a98ff3936 100644 --- a/control/margins.py +++ b/control/margins.py @@ -108,12 +108,12 @@ def stability_margins(sysdata, returnall=False, epsw=0.0): Linear SISO system mag, phase, omega : sequence of array_like Arrays of magnitudes (absolute values, not dB), phases (degrees), - and corresponding frequencies. Crossover frequencies returned are + and corresponding frequencies. Crossover frequencies returned are in the same units as those in `omega` (e.g., rad/sec or Hz). returnall: bool, optional - If true, return all margins found. If false (default), return only the - minimum stability margins. For frequency data or FRD systems, only one - margin is found and returned. + If true, return all margins found. If False (default), return only the + minimum stability margins. For frequency data or FRD systems, only + margins in the given frequency region can be found and returned. epsw: float, optional Frequencies below this value (default 0.0) are considered static gain, and not returned as margin. @@ -127,11 +127,11 @@ def stability_margins(sysdata, returnall=False, epsw=0.0): sm: float or array_like Stability margin, the minimum distance from the Nyquist plot to -1 wg: float or array_like - Gain margin crossover frequency (where phase crosses -180 degrees) + Frequency for gain margin (at phase crossover, phase = -180 degrees) wp: float or array_like - Phase margin crossover frequency (where gain crosses 0 dB) + Frequency for phase margin (at gain crossover, gain = 0 dB) ws: float or array_like - Stability margin frequency (where Nyquist plot is closest to -1) + Frequency for stability margin (complex gain closest to -1) """ try: @@ -341,12 +341,16 @@ def margin(*args): pm : float Phase margin (in degrees) wg: float - Gain margin crossover frequency (where phase crosses -180 degrees) + Frequency for gain margin (at phase crossover, phase = -180 degrees) wp: float - Phase margin crossover frequency (where gain crosses 0 dB) + Frequency for phase margin (at gain crossover, gain = 0 dB) - Margins are of SISO open-loop. If more than one crossover frequency is - detected, returns the lowest corresponding margin. + Margins are calculated for a SISO open-loop system. + + If there is more than one gain crossover, the one at the smallest + margin (deviation from gain=0dB), in absolute sense, is + returned. Likewise the smallest phase margin (in absolute sense) + is returned. Examples --------