Skip to content

Commit 4eedde4

Browse files
committed
fix build problem (numerical problem)
1 parent 62ed2aa commit 4eedde4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

control/rlocus.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ def _default_gains(num, den, xlim, ylim):
206206
distance_points = np.abs(np.diff(mymat, axis=0)) > tolerance # distance between points
207207
indexes_too_far = np.where(distance_points)
208208

209-
new_gains = np.hstack((np.linspace(kvect[-1], kvect[-1]*1e10, 10)))
210-
new_points = _RLFindRoots(num, den, new_gains[1:10])
211-
kvect = np.append(kvect, new_gains[1:10])
209+
new_gains = kvect[-1] * np.hstack((np.logspace(0, 3, 4)))
210+
new_points = _RLFindRoots(num, den, new_gains[1:4])
211+
kvect = np.append(kvect, new_gains[1:4])
212212
mymat = np.concatenate((mymat, new_points), axis=0)
213213
mymat = _RLSortRoots(mymat)
214214
return kvect, mymat, xlim, ylim
@@ -265,7 +265,8 @@ def _k_max(num, den, real_break_points, k_break_points):
265265
kmax_asymp = np.abs([np.abs(den.coeffs[0]) / np.abs(num.coeffs[0]) * 3])
266266

267267
kmax = np.max(np.concatenate((np.real(kmax_asymp), np.real(k_break_points)), axis=0))
268-
kmax = np.max([kmax, np.abs(false_gain)])
268+
if np.abs(false_gain) > kmax:
269+
kmax = np.abs(false_gain)
269270
return kmax
270271

271272

@@ -410,9 +411,9 @@ def _sgrid_func(fig=None, zeta=None, wn=None):
410411
def _default_zetas(xlim, ylim):
411412
"""Return default list of dumps coefficients"""
412413
sep1 = -xlim[0]/4
413-
ang1 = [np.arctan((sep1*i)/ylim[1]) for i in np.arange(1,4,1)]
414+
ang1 = [np.arctan((sep1*i)/ylim[1]) for i in np.arange(1, 4, 1)]
414415
sep2 = ylim[1] / 3
415-
ang2 = [np.arctan(-xlim[0]/(ylim[1]-sep2*i)) for i in np.arange(1,3,1)]
416+
ang2 = [np.arctan(-xlim[0]/(ylim[1]-sep2*i)) for i in np.arange(1, 3, 1)]
416417

417418
angules = np.concatenate((ang1, ang2))
418419
angules = np.insert(angules, len(angules), np.pi/2)

0 commit comments

Comments
 (0)