|
1 | 1 | """Compute driving functions for various systems.""" |
2 | 2 |
|
3 | 3 | import numpy as np |
4 | | -from numpy.core.umath_tests import inner1d # element-wise inner product |
| 4 | +from numpy.core.umath_tests import inner1d # element-wise inner product |
5 | 5 | from scipy.special import sph_jn, sph_yn, jn, hankel2 |
6 | 6 | from .. import util |
7 | 7 | from .. import defs |
@@ -357,7 +357,7 @@ def esa_edge_2d_plane(omega, x0, n=[0, 1, 0], alpha=3/2*np.pi, Nc=None, c=None): |
357 | 357 | d = d + 1/epsilon[m] * np.exp(1j*nu*np.pi/2) * np.sin(nu*phi_s) \ |
358 | 358 | * np.cos(nu*phi) * nu/r * jn(nu, k*r) |
359 | 359 |
|
360 | | - d[phi>0] = -d[phi>0] |
| 360 | + d[phi > 0] = -d[phi > 0] |
361 | 361 |
|
362 | 362 | return 4*np.pi/alpha * d |
363 | 363 |
|
@@ -474,7 +474,7 @@ def esa_edge_2d_line(omega, x0, xs, alpha=3/2*np.pi, Nc=None, c=None): |
474 | 474 | d[idx] = d[idx] + f[idx] * jn(nu, k*r[idx]) * hankel2(nu, k*r_s) |
475 | 475 | d[~idx] = d[~idx] + f[~idx] * jn(nu, k*r_s) * hankel2(nu, k*r[~idx]) |
476 | 476 |
|
477 | | - d[phi>0] = -d[phi>0] |
| 477 | + d[phi > 0] = -d[phi > 0] |
478 | 478 |
|
479 | 479 | return -1j*np.pi/alpha * d |
480 | 480 |
|
@@ -512,14 +512,14 @@ def esa_edge_25d_point(omega, x0, xs, xref=[2, -2, 0], alpha=3/2*np.pi, Nc=None, |
512 | 512 | Complex weights of secondary sources. |
513 | 513 |
|
514 | 514 | """ |
515 | | - x0 = np.asarray(x0) |
| 515 | + x0 = np.asarray(x0) |
516 | 516 | xs = np.asarray(xs) |
517 | 517 | xref = np.asarray(xref) |
518 | | - |
519 | | - if np.ndim==1: |
520 | | - a = np.linalg.norm(xref-x0, axis=1)/np.linalg.norm(xref-xs) |
521 | | - else: |
| 518 | + |
| 519 | + if np.isscalar(xref): |
522 | 520 | a = np.linalg.norm(xref)/np.linalg.norm(xref-xs) |
| 521 | + else: |
| 522 | + a = np.linalg.norm(xref-x0, axis=1)/np.linalg.norm(xref-xs) |
523 | 523 |
|
524 | 524 | return 1j*np.sqrt(a) * esa_edge_2d_line(omega, x0, xs, alpha=alpha, Nc=Nc, c=c) |
525 | 525 |
|
|
0 commit comments