Ejemplo n.º 1
0
 def test_calculate_analytical_solution_1d(self):
     for init in self.INIT_CONDITION_1D:
         for coefficient in self.COEFF_MATRIX_1D:
             ode = Ode(coeff_matrix=coefficient, init_condition=init)
             actual = ode.calculate_analytical_solution(self.STEPS)
             self.assertEqual(type(actual), numpy.ndarray)
             self.assertEqual(actual.size, self.EXPECTED_SIZE_100)
             for index, variable in enumerate(self.STEPS):
                 expected = ode.calculate_exp_solution(init, coefficient, variable)
                 self.assertIn(type(actual[index]), self.ACCEPTED_TYPES)
                 self.assertEqual(actual[index], expected)
Ejemplo n.º 2
0
 def test_calculate_analytical_solution_for_constant_diagonal_case(self):
     ode = Ode(coeff_matrix=self.COEFF_MATRIX_CONSTANT_DIAGONAL, init_condition=self.INIT_CONDITION_GENERAL)
     actual = ode.calculate_analytical_solution(self.STEPS)
     self.assertEqual(type(actual), numpy.ndarray)
     self.assertEqual(actual.size, self.EXPECTED_SIZE_200)
     for i in range(self.STEP_NUMBER):
         for j in range(self.INIT_CONDITION_GENERAL.size):
             expected = ode.calculate_exp_solution(self.INIT_CONDITION_GENERAL[j],
                                                   self.COEFF_MATRIX_CONSTANT_DIAGONAL[j, j], self.STEPS[i])
             self.assertIn(type(actual[i, j]), self.ACCEPTED_TYPES)
             self.assertAlmostEqual(actual[i, j], expected, self.DECIMALS_6)