Exemple #1
0
    def linear_equation_fft_solver_3d_test(self, N):
        """
        -\Delta u + u = f

        u(x, y, z) = sin(x)*sin(y)*sin(z) [0, 2*\pi)^3
        """
        def u(p):
            x = p[0]
            y = p[1]
            z = p[2]
            return np.sin(x)*np.sin(y)*np.sin(z)

        def f(p):
            x = p[0]
            y = p[1]
            z = p[2]
            return 4*np.sin(x)*np.sin(y)*np.sin(z)

        box = np.array([
            [2*np.pi, 0, 0],
            [0, 2*np.pi, 0],
            [0, 0, 2*np.pi]]) 
        space = FourierSpace(box, 6)
        U = space.linear_equation_fft_solver(f)
        error = space.error(u, U)
        print(error)
Exemple #2
0
    def linear_equation_fft_solver_1d_test(self, N):
        """
        -\Delta u + u = f

        u(x) = sin(x) [0, 2*\pi)
        """
        def u(p):
            x = p[0]
            return np.sin(x) 

        def f(p):
            x = p[0]
            return 2*np.sin(x) 

        box = np.array([[2*np.pi]]) 
        space = FourierSpace(box, N)
        U = space.linear_equation_fft_solver(f)
        error = space.error(u, U)
        print(error)