Skip to content

Commit ee6a72e

Browse files
committed
evalfr(sys,s) -> sys(s); mimo errors specified as ControlMIMONotImplemented in a few places
1 parent 151fb6c commit ee6a72e

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

control/freqplot.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from .ctrlutil import unwrap
5151
from .bdalg import feedback
5252
from .margins import stability_margins
53+
from .exception import ControlMIMONotImplemented
5354
from . import config
5455

5556
__all__ = ['bode_plot', 'nyquist_plot', 'gangof4_plot',
@@ -214,9 +215,9 @@ def bode_plot(syslist, omega=None,
214215

215216
mags, phases, omegas, nyquistfrqs = [], [], [], []
216217
for sys in syslist:
217-
if sys.ninputs > 1 or sys.noutputs > 1:
218+
if not sys.issiso():
218219
# TODO: Add MIMO bode plots.
219-
raise NotImplementedError(
220+
raise ControlMIMONotImplemented(
220221
"Bode is currently only implemented for SISO systems.")
221222
else:
222223
omega_sys = np.array(omega)
@@ -582,9 +583,9 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
582583
num=50, endpoint=True, base=10.0)
583584

584585
for sys in syslist:
585-
if sys.ninputs > 1 or sys.noutputs > 1:
586+
if not sys.issiso():
586587
# TODO: Add MIMO nyquist plots.
587-
raise NotImplementedError(
588+
raise ControlMIMONotImplemented(
588589
"Nyquist is currently only implemented for SISO systems.")
589590
else:
590591
# Get the magnitude and phase of the system
@@ -672,9 +673,9 @@ def gangof4_plot(P, C, omega=None, **kwargs):
672673
-------
673674
None
674675
"""
675-
if P.ninputs > 1 or P.noutputs > 1 or C.ninputs > 1 or C.noutputs > 1:
676+
if not P.issiso() or not C.issiso():
676677
# TODO: Add MIMO go4 plots.
677-
raise NotImplementedError(
678+
raise ControlMIMONotImplemented(
678679
"Gang of four is currently only implemented for SISO systems.")
679680

680681
# Get the default parameter values

control/margins.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def fun(wdt):
207207

208208

209209
# Took the framework for the old function by
210-
# Sawyer B. Fuller <minster@caltech.edu>, removed a lot of the innards
210+
# Sawyer B. Fuller <minster@uw.edu>, removed a lot of the innards
211211
# and replaced with analytical polynomial functions for LTI systems.
212212
#
213213
# idea for the frequency data solution copied/adapted from
@@ -294,29 +294,29 @@ def stability_margins(sysdata, returnall=False, epsw=0.0):
294294
# frequency for gain margin: phase crosses -180 degrees
295295
w_180 = _poly_iw_real_crossing(num_iw, den_iw, epsw)
296296
with np.errstate(all='ignore'): # den=0 is okay
297-
w180_resp = evalfr(sys, 1J * w_180)
297+
w180_resp = sys(1J * w_180)
298298

299299
# frequency for phase margin : gain crosses magnitude 1
300300
wc = _poly_iw_mag1_crossing(num_iw, den_iw, epsw)
301-
wc_resp = evalfr(sys, 1J * wc)
301+
wc_resp = sys(1J * wc)
302302

303303
# stability margin
304304
wstab = _poly_iw_wstab(num_iw, den_iw, epsw)
305-
ws_resp = evalfr(sys, 1J * wstab)
305+
ws_resp = sys(1J * wstab)
306306

307307
else: # Discrete Time
308308
zargs = _poly_z_invz(sys)
309309
# gain margin
310310
z, w_180 = _poly_z_real_crossing(*zargs, epsw=epsw)
311-
w180_resp = evalfr(sys, z)
311+
w180_resp = sys(z)
312312

313313
# phase margin
314314
z, wc = _poly_z_mag1_crossing(*zargs, epsw=epsw)
315-
wc_resp = evalfr(sys, z)
315+
wc_resp = sys(z)
316316

317317
# stability margin
318318
z, wstab = _poly_z_wstab(*zargs, epsw=epsw)
319-
ws_resp = evalfr(sys, z)
319+
ws_resp = sys(z)
320320

321321
# only keep frequencies where the negative real axis is crossed
322322
w_180 = w_180[w180_resp <= 0.]

0 commit comments

Comments
 (0)