Skip to content

Commit 1b84d80

Browse files
authored
Merge pull request #894 from sawyerbfuller/damp-dt-freq
fix damp command natural frequency printout for discrete poles on real axis
2 parents 147d531 + 6cfd466 commit 1b84d80

File tree

1 file changed

+31
-41
lines changed

1 file changed

+31
-41
lines changed

control/lti.py

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@
22
33
The lti module contains the LTI parent class to the child classes StateSpace
44
and TransferFunction. It is designed for use in the python-control library.
5-
6-
Routines in this module:
7-
8-
LTI.__init__
9-
isdtime()
10-
isctime()
11-
timebase()
12-
common_timebase()
135
"""
146

157
import numpy as np
168

17-
from numpy import absolute, real, angle, abs
9+
from numpy import real, angle, abs
1810
from warnings import warn
1911
from . import config
20-
from .namedio import NamedIOSystem, isdtime
12+
from .namedio import NamedIOSystem
2113

2214
__all__ = ['poles', 'zeros', 'damp', 'evalfr', 'frequency_response',
2315
'freqresp', 'dcgain', 'bandwidth', 'pole', 'zero']
@@ -110,21 +102,21 @@ def damp(self):
110102
Returns
111103
-------
112104
wn : array
113-
Natural frequencies for each system pole
105+
Natural frequency for each system pole
114106
zeta : array
115107
Damping ratio for each system pole
116108
poles : array
117-
Array of system poles
109+
System pole locations
118110
'''
119111
poles = self.poles()
120112

121113
if self.isdtime(strict=True):
122114
splane_poles = np.log(poles.astype(complex))/self.dt
123115
else:
124116
splane_poles = poles
125-
wn = absolute(splane_poles)
126-
Z = -real(splane_poles)/wn
127-
return wn, Z, poles
117+
wn = abs(splane_poles)
118+
zeta = -real(splane_poles)/wn
119+
return wn, zeta, poles
128120

129121
def frequency_response(self, omega, squeeze=None):
130122
"""Evaluate the linear time-invariant system at an array of angular
@@ -346,25 +338,23 @@ def zero(sys):
346338

347339
def damp(sys, doprint=True):
348340
"""
349-
Compute natural frequency, damping ratio, and poles of a system
350-
351-
The function takes 1 or 2 parameters
341+
Compute natural frequencies, damping ratios, and poles of a system
352342
353343
Parameters
354344
----------
355-
sys: LTI (StateSpace or TransferFunction)
345+
sys : LTI (StateSpace or TransferFunction)
356346
A linear system object
357-
doprint:
358-
if true, print table with values
347+
doprint : bool (optional)
348+
if True, print table with values
359349
360350
Returns
361351
-------
362-
wn: array
363-
Natural frequencies of the poles
364-
damping: array
365-
Damping values
366-
poles: array
367-
Pole locations
352+
wn : array
353+
Natural frequency for each system pole
354+
zeta : array
355+
Damping ratio for each system pole
356+
poles : array
357+
System pole locations
368358
369359
See Also
370360
--------
@@ -374,37 +364,37 @@ def damp(sys, doprint=True):
374364
-----
375365
If the system is continuous,
376366
wn = abs(poles)
377-
Z = -real(poles)/poles.
367+
zeta = -real(poles)/poles
378368
379369
If the system is discrete, the discrete poles are mapped to their
380370
equivalent location in the s-plane via
381371
382-
s = log10(poles)/dt
372+
s = log(poles)/dt
383373
384374
and
385375
386376
wn = abs(s)
387-
Z = -real(s)/wn.
377+
zeta = -real(s)/wn.
388378
389379
Examples
390380
--------
391381
>>> G = ct.tf([1], [1, 4])
392-
>>> wn, damping, poles = ct.damp(G)
393-
_____Eigenvalue______ Damping___ Frequency_
394-
-4 1 4
382+
>>> wn, zeta, poles = ct.damp(G)
383+
Eigenvalue (pole) Damping Frequency
384+
-4 1 4
395385
396386
"""
397-
wn, damping, poles = sys.damp()
387+
wn, zeta, poles = sys.damp()
398388
if doprint:
399-
print('_____Eigenvalue______ Damping___ Frequency_')
400-
for p, d, w in zip(poles, damping, wn):
389+
print(' Eigenvalue (pole) Damping Frequency')
390+
for p, z, w in zip(poles, zeta, wn):
401391
if abs(p.imag) < 1e-12:
402-
print("%10.4g %10.4g %10.4g" %
403-
(p.real, 1.0, -p.real))
392+
print(" %10.4g %10.4g %10.4g" %
393+
(p.real, 1.0, w))
404394
else:
405-
print("%10.4g%+10.4gj %10.4g %10.4g" %
406-
(p.real, p.imag, d, w))
407-
return wn, damping, poles
395+
print("%10.4g%+10.4gj %10.4g %10.4g" %
396+
(p.real, p.imag, z, w))
397+
return wn, zeta, poles
408398

409399

410400
def evalfr(sys, x, squeeze=None):

0 commit comments

Comments
 (0)