Ejemplo n.º 1
0
 def testMIMO(self):
     sys = StateSpace([[-0.5, 0.0], [0.0, -1.0]], [[1.0, 0.0], [0.0, 1.0]],
                      [[1.0, 0.0], [0.0, 1.0]], [[0.0, 0.0], [0.0, 0.0]])
     omega = np.logspace(-1, 2, 10)
     f1 = FRD(sys, omega)
     np.testing.assert_array_almost_equal(
         sys.frequency_response([0.1, 1.0, 10])[0],
         f1.frequency_response([0.1, 1.0, 10])[0])
     np.testing.assert_array_almost_equal(
         sys.frequency_response([0.1, 1.0, 10])[1],
         f1.frequency_response([0.1, 1.0, 10])[1])
Ejemplo n.º 2
0
 def testAgainstOctave(self):
     # with data from octave:
     # sys = ss([-2 0 0; 0 -1 1; 0 0 -3],
     #  [1 0; 0 0; 0 1], eye(3), zeros(3,2))
     # bfr = frd(bsys, [1])
     sys = StateSpace(np.array([[-2.0, 0, 0], [0, -1, 1], [0, 0, -3]]),
                      np.array([[1.0, 0], [0, 0], [0, 1]]), np.eye(3),
                      np.zeros((3, 2)))
     omega = np.logspace(-1, 2, 10)
     f1 = FRD(sys, omega)
     np.testing.assert_array_almost_equal(
         (f1.frequency_response([1.0])[0] *
          np.exp(1j * f1.frequency_response([1.0])[1])).reshape(3, 2),
         np.array([[0.4 - 0.2j, 0], [0, 0.1 - 0.2j], [0, 0.3 - 0.1j]]))
Ejemplo n.º 3
0
 def testMIMOfb2(self):
     sys = StateSpace(np.array([[-2.0, 0, 0], [0, -1, 1], [0, 0, -3]]),
                      np.array([[1.0, 0], [0, 0], [0, 1]]), np.eye(3),
                      np.zeros((3, 2)))
     omega = np.logspace(-1, 2, 10)
     K = np.array([[1, 0.3, 0], [0.1, 0, 0]])
     f1 = FRD(sys, omega).feedback(K)
     f2 = FRD(sys.feedback(K), omega)
     np.testing.assert_array_almost_equal(
         f1.frequency_response([0.1, 1.0, 10])[0],
         f2.frequency_response([0.1, 1.0, 10])[0])
     np.testing.assert_array_almost_equal(
         f1.frequency_response([0.1, 1.0, 10])[1],
         f2.frequency_response([0.1, 1.0, 10])[1])
Ejemplo n.º 4
0
    def testSISOtf(self):
        # get a SISO transfer function
        h = TransferFunction([1], [1, 2, 2])
        omega = np.logspace(-1, 2, 10)
        frd = FRD(h, omega)
        assert isinstance(frd, FRD)

        mag1, phase1, omega1 = frd.frequency_response([1.0])
        mag2, phase2, omega2 = h.frequency_response([1.0])
        np.testing.assert_array_almost_equal(mag1, mag2)
        np.testing.assert_array_almost_equal(phase1, phase2)
        np.testing.assert_array_almost_equal(omega1, omega2)