Skip to content

Commit cf5ac10

Browse files
committed
Bug fixed
1 parent eee3d55 commit cf5ac10

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

sumpy/recurrence.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def reindex_recurrence_relation(r: sp.Expr) -> tuple[int, sp.Expr]:
307307

308308
# Re-arrange the recurrence relation so we get s(n) = ____
309309
# in terms of s(n-1), ...
310-
true_recurrence = sum(sp.cancel(coeffs[i]/coeffs[-1]) * terms[i]
310+
true_recurrence = sum(sp.cancel(-coeffs[i]/coeffs[-1]) * terms[i]
311311
for i in range(0, len(terms)-1))
312312
true_recurrence1 = true_recurrence.subs(n, n-shift_idx)
313313

@@ -400,7 +400,7 @@ def move_center_origin_source_arbitrary(r: sp.Expr) -> sp.Expr:
400400
for i in range(len(idx_l)):
401401
r_ret = r_ret.subs(terms[i], (-1)**(n+idx_l[i])*terms[i])
402402

403-
return r_ret*((-1)**(n+1))
403+
return r_ret*((-1)**(n))
404404

405405

406406
def get_reindexed_and_center_origin_on_axis_recurrence(pde) -> tuple[int, int,
@@ -446,6 +446,7 @@ def move_center_origin_source_arbitrary_expression(pde: LinearPDESystemOperator)
446446

447447
return r_ret
448448

449+
449450
def get_reindexed_and_center_origin_off_axis_recurrence(pde: LinearPDESystemOperator) -> sp.Expr:
450451
r"""
451452
A function that takes in as input a pde and outputs a off-axis recurrence
@@ -454,6 +455,15 @@ def get_reindexed_and_center_origin_off_axis_recurrence(pde: LinearPDESystemOper
454455
"""
455456
var = _make_sympy_vec("x", 1)
456457
r_exp = move_center_origin_source_arbitrary_expression(pde).subs(var[0], 0)
458+
459+
var = _make_sympy_vec("x", 2)
460+
var_t = _make_sympy_vec("t", 2)
461+
g_x_y = sp.log(sp.sqrt((var[0]-var_t[0])**2 + (var[1]-var_t[1])**2))
462+
derivs = [sp.diff(g_x_y,
463+
var_t[0], i).subs(var_t[0], 0).subs(var_t[1], 0)
464+
for i in range(8)]
465+
466+
457467
recur_order, recur = reindex_recurrence_relation(r_exp)
458468
start_order = _get_initial_order_off_axis(recur)
459469
return start_order, recur_order, recur
@@ -486,7 +496,7 @@ def get_off_axis_expression(pde, taylor_order=4):
486496
for ind in idx_l:
487497
if ind > 0:
488498
exp = exp.subs(s(n+ind), t_recurrence.subs(n, n+ind))
489-
499+
490500
idx_l, _ = _extract_idx_terms_from_recurrence(exp)
491501
max_idx = max(idx_l)
492502
exp_range = max(idx_l) - min(idx_l)

test/test_recurrence.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,6 @@ def test_laplace_2d_off_axis():
254254
test_laplace_2d_off_axis()
255255

256256

257-
258-
259-
260-
261-
262-
263-
264257
import matplotlib.pyplot as plt
265258
def _plot_laplace_2d(max_order_check, max_abs):
266259
w = make_identity_diff_op(2)

0 commit comments

Comments
 (0)