8000 testing suggested method by Kreijstal · python-control/python-control@409d0c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 409d0c6

Browse files
committed
testing suggested method by Kreijstal
1 parent bc2ddff commit 409d0c6

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

control/lti.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,23 +210,32 @@ def bandwidth(self, dbdrop=-3):
210210
def _bandwidth(self, dbdrop=-3):
211211
# check if system is SISO and dbdrop is a negative scalar
212212
if (not self.issiso()) and (dbdrop >= 0):
213-
raise ValueError("NOT sure what to raise #TODO ")
214-
213+
raise ValueError("#TODO ")
214+
215+
# # # this will probabily fail if there is a resonant frequency larger than the bandwidth, the initial guess can be around that peak
216+
# G1 = ct.tf(0.1, [1, 0.1])
217+
# wn2 = 0.9
218+
# zeta2 = 0.001
219+
# G2 = ct.tf(wn2**2, [1, 2*zeta2*wn2, wn2**2])
220+
# ct.bandwidth(G1*G2)
221+
# import scipy
215222
# result = scipy.optimize.root(lambda w: np.abs(self(w*1j)) - np.abs(self.dcgain())*10**(dbdrop/20), x0=1)
216-
# # this will probabily fail if there is a resonant frequency larger than the bandwidth, the initial guess can be around that peak
223+
224+
# if result.success:
225+
# return np.abs(result.x)[0]
217226

218227
# use bodeplot to identify the 0-crossing bracket
219228
from control.freqplot import _default_frequency_range
220229
omega = _default_frequency_range(self)
221230
mag, phase, omega = self.frequency_response(omega)
222231

223232
dcgain = self.dcgain()
224-
idx_out = np.nonzero(mag - dcgain*10**(dbdrop/20) < 0)[0][0]
233+
idx_dropped = np.nonzero(mag - dcgain*10**(dbdrop/20) < 0)[0][0]
225234

226235
# solve for the bandwidth, use scipy.optimize.root_scalar() to solve using bisection
227236
import scipy
228237
result = scipy.optimize.root_scalar(lambda w: np.abs(self(w*1j)) - np.abs(dcgain)*10**(dbdrop/20),
229-
bracket=[omega[idx_out-1], omega[idx_out]],
238+
bracket=[omega[idx_dropped-1], omega[idx_dropped]],
230239
method='bisect')
231240

232241
# check solution
@@ -555,6 +564,13 @@ def bandwidth(sys, dbdrop=-3):
555564
>>> ct.bandwidth(G)
556565
0.9976
557566
567+
>>> G1 = ct.tf(0.1, [1, 0.1])
568+
>>> wn2 = 1
569+
>>> zeta2 = 0.001
570+
>>> G2 = ct.tf(wn2**2, [1, 2*zeta2*wn2, wn2**2])
571+
>>> ct.bandwidth(G1*G2)
572+
0.1018
573+
558574
"""
559575
return sys.bandwidth(dbdrop)
560576

control/matlab/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
190190
== ========================== ============================================
191191
\* :func:`dcgain` steady-state (D.C.) gain
192-
\ lti/bandwidth system bandwidth
192+
\* :func:`bandwidth` system bandwidth
193193
\ lti/norm h2 and Hinfinity norms of LTI models
194194
\* :func:`pole` system poles
195195
\* :func:`zero` system (transmission) zeros

0 commit comments

Comments
 (0)
0