Skip to content

Commit e08fd82

Browse files
committed
Helmholtz not checked
1 parent 310df00 commit e08fd82

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

test/test_recurrence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def test_helmholtz_3D():
6161

6262
def test_helmholtz_2D():
6363
w = make_identity_diff_op(2)
64-
laplace2d = laplacian(w) + w
65-
_,_, r = get_processed_and_shifted_recurrence(laplace2d)
64+
helmholtz2d = laplacian(w) + w
65+
_,_, r = get_processed_and_shifted_recurrence(helmholtz2d)
6666

6767
n = sp.symbols("n")
6868
s = sp.Function("s")

test/test_recurrenceqbx.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
import sympy as sp
3+
from sympy import hankel1
34

45
from sumpy.expansion.diff_op import (
56
laplacian,
@@ -8,14 +9,39 @@
89
from sumpy.recurrenceqbx import recurrence_qbx_lp, _make_sympy_vec
910
from sumpy.array_context import PytestPyOpenCLArrayContextFactory, _acf # noqa: F401
1011
from sumpy.expansion.local import LineTaylorLocalExpansion, VolumeTaylorLocalExpansion
11-
from sumpy.kernel import LaplaceKernel
12+
from sumpy.kernel import LaplaceKernel, HelmholtzKernel
1213
from sumpy.qbx import LayerPotential
1314

1415
actx_factory = _acf
1516
expn_class = LineTaylorLocalExpansion
1617

1718
actx = actx_factory()
1819
lknl = LaplaceKernel(2)
20+
hlknl = HelmholtzKernel(2, "k")
21+
22+
def _qbx_lp_helmholtz_general(sources,targets,centers,radius,strengths,order):
23+
lpot = LayerPotential(actx.context,
24+
expansion=expn_class(hlknl, order),
25+
target_kernels=(hlknl,),
26+
source_kernels=(hlknl,))
27+
28+
#print(lpot.get_kernel())
29+
expansion_radii = actx.from_numpy(radius * np.ones(sources.shape[1]))
30+
sources = actx.from_numpy(sources)
31+
targets = actx.from_numpy(targets)
32+
centers = actx.from_numpy(centers)
33+
34+
strengths = (strengths,)
35+
extra_kernel_kwargs={"k": 1}
36+
_evt, (result_qbx,) = lpot(
37+
actx.queue,
38+
targets, sources, centers, strengths,
39+
expansion_radii=expansion_radii,
40+
kwargs=extra_kernel_kwargs)
41+
result_qbx = actx.to_numpy(result_qbx)
42+
43+
return result_qbx
44+
1945

2046
def _qbx_lp_laplace_general(sources,targets,centers,radius,strengths,order):
2147
lpot = LayerPotential(actx.context,
@@ -78,4 +104,28 @@ def test_recurrence_laplace_2d_ellipse():
78104
err.append(np.max(np.abs(exp_res - qbx_res)))
79105
assert np.max(err) <= 1e-13
80106

81-
test_recurrence_laplace_2d_ellipse()
107+
108+
def test_recurrence_helmholtz_2d_ellipse():
109+
110+
#------------- 1. Define PDE, Green's Function
111+
w = make_identity_diff_op(2)
112+
helmholtz2d = laplacian(w) + w
113+
114+
var = _make_sympy_vec("x", 2)
115+
var_t = _make_sympy_vec("t", 2)
116+
k = 1
117+
abs_dist = sp.sqrt((var[0]-var_t[0])**2 + (var[1]-var_t[1])**2)
118+
g_x_y = (1j/4) * hankel1(0, k * abs_dist)
119+
120+
p = 4
121+
err = []
122+
for n_p in range(200, 1001, 200):
123+
sources, centers, normals, density, h, radius = _create_ellipse(n_p)
124+
strengths = h * density
125+
exp_res = recurrence_qbx_lp(sources, centers, normals, strengths, radius, helmholtz2d, g_x_y, 2, p)
126+
#qbx_res = _qbx_lp_helmholtz_general(sources, sources, centers, radius, strengths, p)
127+
#qbx_res,_ = lpot_eval_circle(sources.shape[1], p)
128+
#err.append(np.max(np.abs(exp_res - qbx_res)))
129+
#assert np.max(err) <= 1e-13
130+
131+
test_recurrence_helmholtz_2d_ellipse()

0 commit comments

Comments
 (0)