Skip to content

Commit c2fd4b4

Browse files
committed
Slightly increase the epsilon value for margin computation frequency,
many type 2 systems (on Windows, 32 bit pythonxy, but not on 64 bit Linux which I tested on) got cross over margins calculated at frequencies around 1e-11
1 parent 08e70a1 commit c2fd4b4

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/margins.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ def _polysqr(pol):
8080
# idea for the frequency data solution copied/adapted from
8181
# https://github.com/alchemyst/Skogestad-Python/blob/master/BODE.py
8282
# Rene van Paassen <rene.vanpaassen@gmail.com>
83-
def stability_margins(sysdata, deg=True, returnall=False, epsw=1e-12):
83+
def stability_margins(sysdata, deg=True, returnall=False, epsw=1e-10):
8484
"""Calculate gain, phase and stability margins and associated
8585
crossover frequencies.
8686
8787
Usage
8888
-----
89-
gm, pm, sm, wg, wp, ws = stability_margins(sysdata, deg=True)
89+
gm, pm, sm, wg, wp, ws = stability_margins(sysdata, deg=True,
90+
returnall=False, epsw=1e-10)
9091
9192
Parameters
9293
----------
@@ -101,7 +102,7 @@ def stability_margins(sysdata, deg=True, returnall=False, epsw=1e-12):
101102
returnall=False: boolean
102103
If true, return all margins found. Note that for frequency data or
103104
FRD systems, only one margin is found and returned.
104-
epsw=1e-12: float
105+
epsw=1e-10: float
105106
frequencies below this value are considered static gain, and not
106107
returned as margin.
107108
@@ -114,7 +115,7 @@ def stability_margins(sysdata, deg=True, returnall=False, epsw=1e-12):
114115
one crossover frequency is detected, returns the lowest corresponding
115116
margin.
116117
When requesting all margins, the return values are array_like,
117-
and all margins are returns for linear systems not equal to FRD
118+
and all margins are returned for linear systems not equal to FRD
118119
"""
119120

120121
try:

0 commit comments

Comments
 (0)