@@ -32,7 +32,6 @@ def plot(d, selection, secondary_source):
32
32
33
33
"""
34
34
import numpy as _np
35
- from numpy .core .umath_tests import inner1d as _inner1d
36
35
from scipy .special import hankel2 as _hankel2
37
36
38
37
from . import secondary_source_line as _secondary_source_line
@@ -91,7 +90,7 @@ def line_2d(omega, x0, n0, xs, *, c=None):
91
90
k = _util .wavenumber (omega , c )
92
91
ds = x0 - xs
93
92
r = _np .linalg .norm (ds , axis = 1 )
94
- d = - 1j / 2 * k * _inner1d ( ds , n0 ) / r * _hankel2 (1 , k * r )
93
+ d = - 1j / 2 * k * _np . einsum ( 'ij,ij->i' , ds , n0 ) / r * _hankel2 (1 , k * r )
95
94
selection = _util .source_selection_line (n0 , x0 , xs )
96
95
return d , selection , _secondary_source_line (omega , c )
97
96
@@ -147,7 +146,8 @@ def _point(omega, x0, n0, xs, *, c=None):
147
146
k = _util .wavenumber (omega , c )
148
147
ds = x0 - xs
149
148
r = _np .linalg .norm (ds , axis = 1 )
150
- d = 1j * k * _inner1d (ds , n0 ) / r ** (3 / 2 ) * _np .exp (- 1j * k * r )
149
+ d = 1j * k * _np .einsum ('ij,ij->i' , ds , n0 ) / r ** (3 / 2 ) * _np .exp (
150
+ - 1j * k * r )
151
151
selection = _util .source_selection_point (n0 , x0 , xs )
152
152
return d , selection , _secondary_source_point (omega , c )
153
153
@@ -235,7 +235,7 @@ def point_25d(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
235
235
preeq_25d (omega , omalias , c ) *
236
236
_np .sqrt (8 * _np .pi ) *
237
237
_np .sqrt ((r * s ) / (r + s )) *
238
- _inner1d ( n0 , ds ) / s *
238
+ _np . einsum ( 'ij,ij->i' , ds , n0 ) / s *
239
239
_np .exp (- 1j * k * s ) / (4 * _np .pi * s ))
240
240
selection = _util .source_selection_point (n0 , x0 , xs )
241
241
return d , selection , _secondary_source_point (omega , c )
@@ -317,7 +317,7 @@ def point_25d_legacy(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
317
317
r = _np .linalg .norm (ds , axis = 1 )
318
318
d = (
319
319
preeq_25d (omega , omalias , c ) *
320
- _np .sqrt (_np .linalg .norm (xref - x0 )) * _inner1d ( ds , n0 ) /
320
+ _np .sqrt (_np .linalg .norm (xref - x0 )) * _np . einsum ( 'ij,ij->i' , ds , n0 ) /
321
321
r ** (3 / 2 ) * _np .exp (- 1j * k * r ))
322
322
selection = _util .source_selection_point (n0 , x0 , xs )
323
323
return d , selection , _secondary_source_point (omega , c )
@@ -500,7 +500,8 @@ def _focused(omega, x0, n0, xs, ns, *, c=None):
500
500
k = _util .wavenumber (omega , c )
501
501
ds = x0 - xs
502
502
r = _np .linalg .norm (ds , axis = 1 )
503
- d = 1j * k * _inner1d (ds , n0 ) / r ** (3 / 2 ) * _np .exp (1j * k * r )
503
+ d = 1j * k * _np .einsum ('ij,ij->i' , ds , n0 ) / r ** (3 / 2 ) * _np .exp (
504
+ 1j * k * r )
504
505
selection = _util .source_selection_focused (ns , x0 , xs )
505
506
return d , selection , _secondary_source_point (omega , c )
506
507
@@ -570,7 +571,7 @@ def focused_25d(omega, x0, n0, xs, ns, *, xref=[0, 0, 0], c=None,
570
571
r = _np .linalg .norm (ds , axis = 1 )
571
572
d = (
572
573
preeq_25d (omega , omalias , c ) *
573
- _np .sqrt (_np .linalg .norm (xref - x0 )) * _inner1d ( ds , n0 ) /
574
+ _np .sqrt (_np .linalg .norm (xref - x0 )) * _np . einsum ( 'ij,ij->i' , ds , n0 ) /
574
575
r ** (3 / 2 ) * _np .exp (1j * k * r ))
575
576
selection = _util .source_selection_focused (ns , x0 , xs )
576
577
return d , selection , _secondary_source_point (omega , c )
@@ -683,22 +684,22 @@ def soundfigure_3d(omega, x0, n0, figure, npw=[0, 0, 1], *, c=None):
683
684
figure = _np .fft .fftshift (figure , axes = (0 , 1 )) # sign of spatial DFT
684
685
figure = _np .fft .fft2 (figure )
685
686
# wavenumbers
686
- kx = _np .fft .fftfreq (nx , 1. / nx )
687
- ky = _np .fft .fftfreq (ny , 1. / ny )
687
+ kx = _np .fft .fftfreq (nx , 1. / nx )
688
+ ky = _np .fft .fftfreq (ny , 1. / ny )
688
689
# shift spectrum due to desired plane wave
689
- figure = _np .roll (figure , int (k * npw [0 ]), axis = 0 )
690
- figure = _np .roll (figure , int (k * npw [1 ]), axis = 1 )
690
+ figure = _np .roll (figure , int (k * npw [0 ]), axis = 0 )
691
+ figure = _np .roll (figure , int (k * npw [1 ]), axis = 1 )
691
692
# search and iterate over propagating plane wave components
692
693
kxx , kyy = _np .meshgrid (kx , ky , sparse = True )
693
694
rho = _np .sqrt ((kxx ) ** 2 + (kyy ) ** 2 )
694
695
d = 0
695
696
for n in range (nx ):
696
697
for m in range (ny ):
697
- if (rho [n , m ] < k ):
698
+ if (rho [n , m ] < k ):
698
699
# dispertion relation
699
- kz = _np .sqrt (k ** 2 - rho [n , m ]** 2 )
700
+ kz = _np .sqrt (k ** 2 - rho [n , m ] ** 2 )
700
701
# normal vector of plane wave
701
- npw = 1 / k * _np .asarray ([kx [n ], ky [m ], kz ])
702
+ npw = 1 / k * _np .asarray ([kx [n ], ky [m ], kz ])
702
703
npw = npw / _np .linalg .norm (npw )
703
704
# driving function of plane wave with positive kz
704
705
d_component , selection , secondary_source = plane_3d (
0 commit comments