def test_case3_fem(self): result = fem(f_x=case3_f_x, f_u_v=case3_f_u_v, f_v=case3_f_v, robin_left=True) self.assertIs(isclose(result[0], -5 / 6, abs_tol=EPSILON), True) self.assertIs(isclose(result[1], -41 / 81, abs_tol=EPSILON), True) self.assertIs(isclose(result[2], -35 / 162, abs_tol=EPSILON), True)
def test_case4_fem(self): result = fem(f_x=case4_f_x, f_u_v=case4_f_u_v, f_v=case4_f_v, c_u_v=case4_c_u_v, u_shift=case4_u_shift, robin_right=True) self.assertIs(isclose(result[0], 21601 / 49706, abs_tol=EPSILON), True) self.assertIs(isclose(result[1], -26572 / 24853, abs_tol=EPSILON), True) self.assertIs(isclose(result[2], -116669 / 49706, abs_tol=EPSILON), True)
from fem_util import fem a = 0 b = 1 f_x = lambda x: 1 n = 3 h = (b - a) / n print(fem(f_x, debug=True))
def test_case1_fem(self): result = fem(case1_f_x, case1_f_u_v) self.assertIs(isclose(result[0], -6 / 59, abs_tol=EPSILON), True) self.assertIs(isclose(result[1], -6 / 59, abs_tol=EPSILON), True)
def test_case2_fem(self): result = fem(case2_f_x, case2_f_u_v, u_shift=e3) self.assertIs(isclose(result[0], 0.396534, abs_tol=EPSILON), True) self.assertIs(isclose(result[1], 0.711519, abs_tol=EPSILON), True)