Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f34a7b

Browse files
committed
Recommended changes from the linter
1 parentc17910f commit5f34a7b

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

‎control/margins.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
importnumpyasnp
1212
importscipyassp
13-
importmatplotlib
14-
importmatplotlib.pyplotasplt
1513

1614
from .importfrdata,freqplot,xferfcn,statesp
1715
from .exceptionimportControlMIMONotImplemented
@@ -631,7 +629,7 @@ def disk_margins(L, omega, skew = 0.0, returnall = False):
631629
ifL.issiso()and (ab13md==None):
632630
# For the SISO case, the norm on (S + (skew - I)/2) is
633631
# unstructured, and can be computed as Bode magnitude
634-
DM[ii]=1.0/bode(ST_jw,omega=omega[ii],plot=False)[0]
632+
DM[ii]=1.0/ST_mag[ii]
635633
else:
636634
# For the MIMO case, the norm on (S + (skew - I)/2) assumes a
637635
# single complex uncertainty block diagonal uncertainty structure.

‎control/tests/margin_test.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,6 @@ def test_siso_disk_margin_return_all():
425425
# Frequencies of interest
426426
omega=np.logspace(-1,2,1001)
427427

428-
# Laplace variable
429-
s=tf('s')
430-
431428
# Loop transfer function
432429
L=tf(25, [1,10,10,10])
433430

@@ -445,9 +442,6 @@ def test_mimo_disk_margin_return_all():
445442
# Frequencies of interest
446443
omega=np.logspace(-1,3,1001)
447444

448-
# Laplace variable
449-
s=tf('s')
450-
451445
# Loop transfer gain
452446
P=ss([[0,10],[-10,0]],np.eye(2),\
453447
[[1,10], [-10,1]], [[0,0],[0,0]])# plant

‎examples/disk_margins.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@
22
Demonstrate disk-based stability margin calculations.
33
"""
44

5-
importos,sys,math
6-
importnumpyasnp
7-
importcontrol
8-
5+
importos
96
importmath
10-
importmatplotlibasmpl
7+
importcontrol
8+
importmatplotlib
119
importmatplotlib.pyplotasplt
12-
fromwarningsimportwarn
13-
1410
importnumpyasnp
15-
importscipyassp
1611

1712
defplot_allowable_region(alpha_max,skew,ax=None):
1813
"""Plot region of allowable gain/phase variation, given worst-case disk margin.
@@ -122,19 +117,16 @@ def test_siso1():
122117
# Frequencies of interest
123118
omega=np.logspace(-1,2,1001)
124119

125-
# Laplace variable
126-
s=control.tf('s')
127-
128120
# Loop transfer gain
129121
L=control.tf(25, [1,10,10,10])
130122

131-
print(f"------------- Python control built-in (S) -------------")
123+
print("------------- Python control built-in (S) -------------")
132124
GM_,PM_,SM_=control.stability_margins(L)[:3]# python-control default (S-based...?)
133125
print(f"SM_ ={SM_}")
134126
print(f"GM_ ={GM_} dB")
135127
print(f"PM_ ={PM_} deg\n")
136128

137-
print(f"------------- Sensitivity function (S) -------------")
129+
print("------------- Sensitivity function (S) -------------")
138130
DM,GM,PM=control.disk_margins(L,omega,skew=1.0,returnall=True)# S-based (S)
139131
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
140132
print(f"GM ={GM[np.argmin(DM)]} dB")
@@ -173,7 +165,7 @@ def test_siso1():
173165
plt.ylim([0,90])
174166
plt.xlabel('Frequency (rad/s)')
175167

176-
print(f"------------- Complementary sensitivity function (T) -------------")
168+
print("------------- Complementary sensitivity function (T) -------------")
177169
DM,GM,PM=control.disk_margins(L,omega,skew=-1.0,returnall=True)# T-based (T)
178170
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
179171
print(f"GM ={GM[np.argmin(DM)]} dB")
@@ -212,7 +204,7 @@ def test_siso1():
212204
plt.ylim([0,90])
213205
plt.xlabel('Frequency (rad/s)')
214206

215-
print(f"------------- Balanced sensitivity function (S - T) -------------")
207+
print("------------- Balanced sensitivity function (S - T) -------------")
216208
DM,GM,PM=control.disk_margins(L,omega,skew=0.0,returnall=True)# balanced (S - T)
217209
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
218210
print(f"GM ={GM[np.argmin(DM)]} dB")
@@ -276,13 +268,13 @@ def test_siso2():
276268
# Loop transfer gain
277269
L= (6.25*(s+3)*(s+5))/(s*(s+1)**2*(s**2+0.18*s+100))
278270

279-
print(f"------------- Python control built-in (S) -------------")
271+
print("------------- Python control built-in (S) -------------")
280272
GM_,PM_,SM_=control.stability_margins(L)[:3]# python-control default (S-based...?)
281273
print(f"SM_ ={SM_}")
282274
print(f"GM_ ={GM_} dB")
283275
print(f"PM_ ={PM_} deg\n")
284276

285-
print(f"------------- Sensitivity function (S) -------------")
277+
print("------------- Sensitivity function (S) -------------")
286278
DM,GM,PM=control.disk_margins(L,omega,skew=1.0,returnall=True)# S-based (S)
287279
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
288280
print(f"GM ={GM[np.argmin(DM)]} dB")
@@ -321,7 +313,7 @@ def test_siso2():
321313
plt.ylim([0,90])
322314
plt.xlabel('Frequency (rad/s)')
323315

324-
print(f"------------- Complementary sensitivity function (T) -------------")
316+
print("------------- Complementary sensitivity function (T) -------------")
325317
DM,GM,PM=control.disk_margins(L,omega,skew=-1.0,returnall=True)# T-based (T)
326318
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
327319
print(f"GM ={GM[np.argmin(DM)]} dB")
@@ -360,7 +352,7 @@ def test_siso2():
360352
plt.ylim([0,90])
361353
plt.xlabel('Frequency (rad/s)')
362354

363-
print(f"------------- Balanced sensitivity function (S - T) -------------")
355+
print("------------- Balanced sensitivity function (S - T) -------------")
364356
DM,GM,PM=control.disk_margins(L,omega,skew=0.0,returnall=True)# balanced (S - T)
365357
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
366358
print(f"GM ={GM[np.argmin(DM)]} dB")
@@ -419,15 +411,12 @@ def test_mimo():
419411
# Frequencies of interest
420412
omega=np.logspace(-1,3,1001)
421413

422-
# Laplace variable
423-
s=control.tf('s')
424-
425414
# Loop transfer gain
426415
P=control.ss([[0,10],[-10,0]],np.eye(2), [[1,10], [-10,1]], [[0,0],[0,0]])# plant
427416
K=control.ss([],[],[], [[1,-2], [0,1]])# controller
428417
L=P*K# loop gain
429418

430-
print(f"------------- Sensitivity function (S) -------------")
419+
print("------------- Sensitivity function (S) -------------")
431420
DM,GM,PM=control.disk_margins(L,omega,skew=1.0,returnall=True)# S-based (S)
432421
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
433422
print(f"GM ={GM[np.argmin(DM)]} dB")
@@ -466,7 +455,7 @@ def test_mimo():
466455
plt.ylim([0,90])
467456
plt.xlabel('Frequency (rad/s)')
468457

469-
print(f"------------- Complementary sensitivity function (T) -------------")
458+
print("------------- Complementary sensitivity function (T) -------------")
470459
DM,GM,PM=control.disk_margins(L,omega,skew=-1.0,returnall=True)# T-based (T)
471460
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
472461
print(f"GM ={GM[np.argmin(DM)]} dB")
@@ -505,7 +494,7 @@ def test_mimo():
505494
plt.ylim([0,90])
506495
plt.xlabel('Frequency (rad/s)')
507496

508-
print(f"------------- Balanced sensitivity function (S - T) -------------")
497+
print("------------- Balanced sensitivity function (S - T) -------------")
509498
DM,GM,PM=control.disk_margins(L,omega,skew=0.0,returnall=True)# balanced (S - T)
510499
print(f"min(DM) ={min(DM)} (omega ={omega[np.argmin(DM)]})")
511500
print(f"GM ={GM[np.argmin(DM)]} dB")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp