Skip to content

Commit a1f528e

Browse files
committed
Odd derivative expression incorrect
1 parent 7bd2c7e commit a1f528e

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test/test_recurrence.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ def test_laplace_2d_off_axis():
221221
derivs = [sp.diff(g_x_y,
222222
var_t[0], i).subs(var_t[0], 0).subs(var_t[1], 0)
223223
for i in range(15)]
224-
x_coord = 0.5234#np.random.rand() # noqa: NPY002
225-
y_coord = 1.1#np.random.rand() # noqa: NPY002
224+
x_coord = 1e-2 * np.random.rand() # noqa: NPY002
225+
y_coord = np.random.rand() # noqa: NPY002
226226
coord_dict = {var[0]: x_coord, var[1]: y_coord}
227227

228228
w = make_identity_diff_op(2)
@@ -250,29 +250,27 @@ def test_laplace_2d_off_axis():
250250
#print(np.max(np.abs(ic[::2]-true_ic[::2])/np.abs(true_ic[::2])))
251251

252252
# CHECK ACCURACY OF EXPRESSION FOR deriv_order
253-
deriv_order = 6
254-
exp_order = 6
253+
deriv_order = 7
254+
exp_order = 5
255255

256256
exp, exp_range = get_off_axis_expression(laplace2d, exp_order)
257257
approx_deriv = exp.subs(n, deriv_order)
258258
for i in range(exp_range):
259259
approx_deriv = approx_deriv.subs(s(deriv_order-i), ic[deriv_order-i])
260260

261261
rat = coord_dict[var[0]]/coord_dict[var[1]]
262-
prederror = abs(ic[deriv_order+exp_order+2] * coord_dict[var[0]]**(exp_order+2)/math.factorial(exp_order+2))
262+
if deriv_order + exp_order % 2 == 0:
263+
prederror = abs(ic[deriv_order+exp_order+2] * coord_dict[var[0]]**(exp_order+2)/math.factorial(exp_order+2))
264+
else:
265+
prederror = abs(ic[deriv_order+exp_order+1] * coord_dict[var[0]]**(exp_order+1)/math.factorial(exp_order+1))
263266
print("PREDICTED ERROR: ", prederror)
264267
relerr = abs((approx_deriv - derivs[deriv_order])/derivs[deriv_order]).subs(var[0], coord_dict[var[0]]).subs(var[1], coord_dict[var[1]])
265268
print("RELATIVE ERROR: ", relerr)
266269
print("RATIO: ", rat)
267270
assert relerr <= prederror
268271

269-
270-
271-
272-
273272
test_laplace_2d_off_axis()
274273

275-
276274
import matplotlib.pyplot as plt
277275
def _plot_laplace_2d(max_order_check, max_abs):
278276
w = make_identity_diff_op(2)

0 commit comments

Comments
 (0)