def test_comp_c(self): GR = Grid(n=[5, 7], l=[ [-4., 3.], [-1., 2.], ], k='c') X = GR.comp([0, 0]) np.testing.assert_almost_equal( X, np.array([[3.], [2.]]) ) X = GR.comp([4, 6]) np.testing.assert_almost_equal( X, np.array([[-4.], [-1.]]) ) X = GR.comp([ [0, 4], [0, 6], ]) np.testing.assert_almost_equal( X, np.array([ [3., -4.], [2., -1.], ]) )
def test_1ord_elements(self): N = 5 SG = Grid(d=1, n=N + 1, l=[-1., 1.]) X = SG.comp()[0, :] D = dif1(SG) e = D[0, 0] - (2. * N**2 + 1.) / 6. self.assertTrue(np.max(np.abs(e)) < 1.E-14) e = D[0, 2] - 2. / (1. - X[2]) self.assertTrue(np.max(np.abs(e)) < 1.E-14) e = D[0, 3] + 2. / (1. - X[3]) self.assertTrue(np.max(np.abs(e)) < 1.E-14) e = D[4, 4] + X[4] / (1. - X[4]**2) / 2. self.assertTrue(np.max(np.abs(e)) < 1.E-14)