Ejemplo n.º 1
0
    def testSiso(self):
        "mixsyn with SISO system"
        from control import tf, augw, hinfsyn, mixsyn
        from control import ss
        # Skogestad+Postlethwaite, Multivariable Feedback Control, 1st Ed., Example 2.11
        s = tf([1, 0], 1)
        # plant
        g = 200/(10*s+1)/(0.05*s+1)**2
        # sensitivity weighting
        M = 1.5
        wb = 10
        A = 1e-4
        w1 = (s/M+wb)/(s+wb*A)
        # KS weighting
        w2 = tf(1, 1)

        p = augw(g, w1, w2)
        kref, clref, gam, rcond = hinfsyn(p, 1, 1)
        ktest, cltest, info = mixsyn(g, w1, w2)
        # check similar to S+P's example
        np.testing.assert_allclose(gam, 1.37, atol = 1e-2)

        # mixsyn is a convenience wrapper around augw and hinfsyn, so
        # results will be exactly the same.  Given than, use the lazy
        # but fragile testing option.
        np.testing.assert_allclose(ktest.A, kref.A)
        np.testing.assert_allclose(ktest.B, kref.B)
        np.testing.assert_allclose(ktest.C, kref.C)
        np.testing.assert_allclose(ktest.D, kref.D)

        np.testing.assert_allclose(cltest.A, clref.A)
        np.testing.assert_allclose(cltest.B, clref.B)
        np.testing.assert_allclose(cltest.C, clref.C)
        np.testing.assert_allclose(cltest.D, clref.D)

        np.testing.assert_allclose(gam, info[0])

        np.testing.assert_allclose(rcond, info[1])
Ejemplo n.º 2
0
P = augw(G,wp,wu) #generalized plant P
P = minreal(P)
wps = tf(wp)
Gs= tf(G)
Is= tf(I)

# correct generalized plant
p11 = wps
p12 = wps*Gs
p21 = -Is
p22 = -Gs


K2 = h2syn(P, 2, 2)
# H INF CONTROLLER
K, CL, gam, rcond = hinfsyn(P,2,2) #generalized plant incorrect so doing mixsyn
print(gam)

#open loop plot
openloop = triv_sigma(G*K, w)
openloop2 = triv_sigma(G*K2, w)
plt.figure(1)
plt.semilogx(w, 20*np.log10(openloop[:, 0]), label=r'G*K')
plt.semilogx(w, 20*np.log10(openloop2[:, 0]), label=r'G*K2')
plt.ylim([-50, 50])
plt.ylabel('magnitude [dB]')
plt.xlim([1e-3, 1e3])
plt.xlabel('freq [rad/s]')
plt.title('open loop')
plt.grid(1)
plt.legend()
# Augmented plant
P = con.augw(G, w1, w2)  #generalized plant P
P = con.minreal(P)

# H 2 CONTROLLER
K2 = con.h2syn(P, 1, 1)

L = G * K2
Ltf = con.ss2tf(L)
So2 = 1.0 / (1.0 + Ltf)
So2 = con.minreal(So2)
To2 = G * K2 * So2
To2 = con.minreal(To2)

# H INF CONTROLLER
K, CL, gam, rcond = con.hinfsyn(P, 1, 1)
print(gam)

L = G * K
Ltf = con.ss2tf(L)
So = 1.0 / (1.0 + Ltf)
So = con.minreal(So)
To = G * K * So
To = con.minreal(To)

plt.figure(1)

sw1 = triv_sigma(1.0 / w1, w)
sigS = triv_sigma(So, w)
sigS2 = triv_sigma(So2, w)
plt.semilogx(w, 20 * np.log10(sw1[:, 0]), label=r'$\sigma_1(1/W1)$')
Ejemplo n.º 4
0
import control
import numpy as np


num = np.array([1.])
den = np.array([1, -1.])
my_tf = control.tf(num, den)
print(my_tf)

print(control.hinfsyn(my_tf, 1, 1))


def hinf(tf, tol):
    """
    Computes the H-inf norm
    :param tf: 
    :return: 
    """
    best = 0
    gammal =
    gammah =
    while (gammah - gammal) / 2 > 2*tol*gammal:
        # Form M

        # check eigenvaleus
        # update gammas
    return best
Ejemplo n.º 5
0
import numpy
import control

m = 1.
k = 0.4
zeta = 0.01
b = numpy.sqrt(k / m) * 2 * m * zeta
#G = control.tf(1,[m, 0., 0.])
G = control.tf([1.], [m, b, k])

f_bandwidth = 100.0
w_bandwidth = 2 * numpy.pi * f_bandwidth
A = 0.01
M = 2

w1 = control.tf([1 / M, w_bandwidth], [1.0, A * w_bandwidth])
w2 = control.tf([1.], [1.])
w3 = control.tf([1.0, w_bandwidth / M], [A, w_bandwidth])

control.bode((G, w1, w3))

P = control.augw(G, w1=w1, w2=None, w3=w3)
##
K, CL, gam, rcond = control.hinfsyn(P, 1, 1)
#K, CL, gam, rcond = control.h2syn(P,1,1)
C = control.ss2tf(K)
S = 1 / (1 + C * G)
T = G * C / (1 + C * G)

control.bode((S, 1 / w1))