def test_06(self): # Second order system with a repeated root: x''(t) + 2*x(t) + x(t) = u(t) # The exact impulse response is t*exp(-t). system = ([1.0], [1.0, 2.0, 1.0]) tout, y = impulse2(system) expected_y = tout * np.exp(-tout) assert_almost_equal(y, expected_y)
def test_01(self): # First order system: x'(t) + x(t) = u(t) # Exact impulse response is x(t) = exp(-t). system = ([1.0],[1.0,1.0]) tout, y = impulse2(system) expected_y = np.exp(-tout) assert_almost_equal(y, expected_y)
def test_04(self): """Specify an initial condition as a list.""" # First order system: x'(t) + x(t) = u(t), x(0)=3.0 # Exact impulse response is x(t) = 4*exp(-t). system = ([1.0],[1.0,1.0]) tout, y = impulse2(system, X0=[3.0]) expected_y = 4.0*np.exp(-tout) assert_almost_equal(y, expected_y)
def test_02(self): """Specify the desired time values for the output.""" # First order system: x'(t) + x(t) = u(t) # Exact impulse response is x(t) = exp(-t). system = ([1.0],[1.0,1.0]) n = 21 t = np.linspace(0, 2.0, n) tout, y = impulse2(system, T=t) assert_equal(tout.shape, (n,)) assert_almost_equal(tout, t) expected_y = np.exp(-t) assert_almost_equal(y, expected_y)
def test_05(self): # Simple integrator: x'(t) = u(t) system = ([1.0],[1.0,0.0]) tout, y = impulse2(system) expected_y = np.ones_like(tout) assert_almost_equal(y, expected_y)