Skip to content

Commit

Permalink
Add test for Laplace2D
Browse files Browse the repository at this point in the history
  • Loading branch information
hirish99 committed Jun 17, 2024
1 parent 98d64ab commit e39e0f5
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions sumpy/recurrence.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

import sympy as sp
from pytools.obj_array import make_obj_array

from sumpy.expansion.diff_op import make_identity_diff_op, laplacian
import math

#A similar function exists in sumpy.symbolic
def make_sympy_vec(name, n):
Expand Down Expand Up @@ -272,10 +273,31 @@ def hc_diff(i, n):
return r.simplify()


def test_recurrence_finder():
from sumpy.expansion.diff_op import make_identity_diff_op, laplacian
def test_recurrence_finder_laplace():
"""
test_recurrence_finder_laplace
Description: Checks that the recurrence finder works correctly for the Laplace
2D point potential.
"""
w = make_identity_diff_op(2)
laplace2d = laplacian(w)
print(get_pde_in_recurrence_form(laplace2d))

assert 1 == 1
ode_in_r, var, n_derivs = get_pde_in_recurrence_form(laplace2d)
ode_in_x = ode_in_r_to_x(ode_in_r, var, n_derivs).simplify()
poly = compute_poly_in_deriv(ode_in_x, n_derivs, var)
coeffs = compute_coefficients_of_poly(poly, n_derivs)
i = sp.symbols("i")
s = sp.Function("s")
r = compute_recurrence_relation(coeffs, n_derivs, var)

def coeff_laplace(i):
x, y = sp.symbols("x,y")
c_vec = make_sympy_vec("c", 2)
true_f = sp.log(sp.sqrt(x**2 + y**2))
return sp.diff(true_f, x, i).subs(x, c_vec[0]).subs(
y, c_vec[1])/math.factorial(i)
d = 6
# pylint: disable=not-callable
val = r.subs(i, d).subs(s(d+1),coeff_laplace(d+1)).subs(
s(d), coeff_laplace(d)).subs(s(d-1), coeff_laplace(d-1)).subs(
s(d-2), coeff_laplace(d-2)).simplify()
assert val == 0

0 comments on commit e39e0f5

Please sign in to comment.