Skip to content

Commit 5f57f8f

Browse files
committed
On vs On+Off
1 parent eacdd92 commit 5f57f8f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

sumpy/recurrence_qbx.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,17 @@ def generate_true(i):
233233
###############
234234

235235
#slope of line y = mx
236-
m = 1e5
236+
m = 15000 * 1e3
237237
mask_on_axis = m*np.abs(coord[0]) >= np.abs(coord[1])
238238
mask_off_axis = m*np.abs(coord[0]) < np.abs(coord[1])
239239

240240
print("-------------------------")
241241

242+
percent_on = np.sum(mask_on_axis)/(mask_on_axis.shape[0]*mask_on_axis.shape[1])
243+
percent_off = 1-percent_on
244+
242245
relerr_on = np.abs(interactions_on_axis[mask_on_axis]-interactions_true[mask_on_axis])/np.abs(interactions_on_axis[mask_on_axis])
243-
print("MAX ON AXIS ERROR:", np.max(relerr_on))
246+
print("MAX ON AXIS ERROR(", percent_on, "):", np.max(relerr_on))
244247
print(np.mean(relerr_on))
245248
print("X:", coord[0].reshape(-1)[np.argmax(relerr_on)])
246249
print("Y:", coord[1].reshape(-1)[np.argmax(relerr_on)])
@@ -249,7 +252,7 @@ def generate_true(i):
249252

250253
if np.any(mask_off_axis):
251254
relerr_off = np.abs(interactions_off_axis[mask_off_axis]-interactions_true[mask_off_axis])/np.abs(interactions_off_axis[mask_off_axis])
252-
print("MAX OFF AXIS ERROR:", np.max(relerr_off))
255+
print("MAX OFF AXIS ERROR(", percent_off, "):", np.max(relerr_off))
253256
print(np.mean(relerr_off))
254257
print("X:", coord[0].reshape(-1)[np.argmax(relerr_off)])
255258
print("Y:", coord[1].reshape(-1)[np.argmax(relerr_off)])
@@ -259,5 +262,9 @@ def generate_true(i):
259262
interactions_total[mask_off_axis] = interactions_off_axis[mask_off_axis]
260263

261264
exp_res = (interactions_total * strengths[None, :]).sum(axis=1)
265+
exp_res_true = (interactions_true * strengths[None, :]).sum(axis=1)
266+
267+
relerr_total = np.max(np.abs(exp_res-exp_res_true)/np.abs(exp_res_true))
268+
print("OVERALL ERROR:", relerr_total)
262269

263270
return exp_res

test/test_recurrence_qbx.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,13 @@ def _construct_laplace_axis_2d(orders, resolutions):
296296
import matplotlib.pyplot as plt
297297
orders = [10]
298298
#resolutions = range(200, 800, 200)
299-
resolutions = [800]
299+
resolutions = [800, 1000]
300300
err_mat = _construct_laplace_axis_2d(orders, resolutions)
301-
"""
301+
302302
for i in range(len(orders)):
303303
plt.plot(resolutions, err_mat[i], label="order ="+str(orders[i]))
304304
plt.xlabel("Number of Nodes")
305305
plt.ylabel("Error")
306306
plt.title("2D Ellipse LP Eval Error")
307307
plt.legend()
308308
plt.show()
309-
"""

0 commit comments

Comments
 (0)