Пример #1
0
    def test_fitzhughnagumo(self):
        """Test the FHN IVP convenience function."""
        rv = Constant(np.ones(2))
        lg1 = ivp_examples.fitzhughnagumo(self.tspan, rv)
        lg2 = ivp_examples.fitzhughnagumo(self.tspan, rv, params=(1.0, 1.0, 1.0, 1.0))

        self.assertIsInstance(lg1, ivp.IVP)
        self.assertIsInstance(lg2, ivp.IVP)
Пример #2
0
 def test_fitzhughnagumo_jacobian(self):
     rv = Constant(np.ones(2))
     lg1 = ivp_examples.fitzhughnagumo(self.tspan, rv)
     random_direction = 1 + 0.1 * np.random.rand(lg1.dimension)
     random_point = 1 + np.random.rand(lg1.dimension)
     fd_approx = (0.5 * 1.0 / self.dt *
                  (lg1(0.1, random_point + self.dt * random_direction) -
                   lg1(0.1, random_point - self.dt * random_direction)))
     self.assertAllClose(
         lg1.jacobian(0.1, random_point) @ random_direction,
         fd_approx,
         rtol=self.rtol,
     )
Пример #3
0
    def test_fitzhughnagumo_rhs(self):
        rv = Constant(np.ones(2))
        lg1 = ivp_examples.fitzhughnagumo(self.tspan, rv)

        self.assertEqual(lg1.rhs(0.1, rv).shape, rv.shape)