コード例 #1
0
    def test_logistic(self):
        """Test the logistic ODE convenience function."""
        rv = Constant(0.1)
        lg1 = ivp_examples.logistic(self.tspan, rv)
        lg2 = ivp_examples.logistic(self.tspan, rv, params=(1.0, 1.0))

        self.assertIsInstance(lg1, ivp.IVP)
        self.assertIsInstance(lg2, ivp.IVP)
コード例 #2
0
 def test_logistic_jacobian(self):
     rv = Constant(0.1)
     lg1 = ivp_examples.logistic(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_logistic_rhs(self):
        rv = Constant(0.1)
        lg1 = ivp_examples.logistic(self.tspan, rv)

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