sfs.fd.nfchoa¶
Compute NFC-HOA driving functions.
\[\gdef\dirac#1{\mathop{{}\delta}\left(#1\right)}
\gdef\e#1{\operatorname{e}^{#1}}
\gdef\Hankel#1#2#3{\mathop{{}H_{#2}^{(#1)}}\!\left(#3\right)}
\gdef\hankel#1#2#3{\mathop{{}h_{#2}^{(#1)}}\!\left(#3\right)}
\gdef\i{\mathrm{i}}
\gdef\scalarprod#1#2{\left\langle#1,#2\right\rangle}
\gdef\vec#1{\mathbf{#1}}
\gdef\wc{\frac{\omega}{c}}
\gdef\w{\omega}
\gdef\x{\vec{x}}
\gdef\n{\vec{n}}\]
import matplotlib.pyplot as plt
import numpy as np
import sfs
plt.rcParams['figure.figsize'] = 6, 6
xs = -1.5, 1.5, 0
# normal vector for plane wave:
npw = sfs.util.direction_vector(np.radians(-45))
f = 300 # Hz
omega = 2 * np.pi * f
R = 1.5 # Radius of circular loudspeaker array
grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.02)
array = sfs.array.circular(N=32, R=R)
def plot(d, selection, secondary_source):
p = sfs.fd.synthesize(d, selection, array, secondary_source, grid=grid)
sfs.plot2d.amplitude(p, grid)
sfs.plot2d.loudspeakers(array.x, array.n, selection * array.a, size=0.15)
Functions
plane_25d (omega, x0, r0[, n, max_order, c]) |
Driving function for 2.5-dimensional NFC-HOA for a virtual plane wave. |
plane_2d (omega, x0, r0[, n, max_order, c]) |
Driving function for 2-dimensional NFC-HOA for a virtual plane wave. |
point_25d (omega, x0, r0, xs, *[, max_order, c]) |
Driving function for 2.5-dimensional NFC-HOA for a virtual point source. |
-
sfs.fd.nfchoa.
plane_2d
(omega, x0, r0, n=[0, 1, 0], *, max_order=None, c=None)[source]¶ Driving function for 2-dimensional NFC-HOA for a virtual plane wave.
Parameters: - omega (float) – Angular frequency of plane wave.
- x0 ((N, 3) array_like) – Sequence of secondary source positions.
- r0 (float) – Radius of circular secondary source distribution.
- n ((3,) array_like, optional) – Normal vector (traveling direction) of plane wave.
- max_order (float, optional) – Maximum order of circular harmonics used for the calculation.
- c (float, optional) – Speed of sound.
Returns: - d ((N,) numpy.ndarray) – Complex weights of secondary sources.
- selection ((N,) numpy.ndarray) – Boolean array containing only
True
indicating that all secondary source are “active” for NFC-HOA. - secondary_source_function (callable) – A function that can be used to create the sound field of a
single secondary source. See
sfs.fd.synthesize()
.
Notes
\[D(\phi_0, \omega) = -\frac{2\i}{\pi r_0} \sum_{m=-M}^M \frac{\i^{-m}}{\Hankel{2}{m}{\wc r_0}} \e{\i m (\phi_0 - \phi_\text{pw})}\]See https://sfs.rtfd.io/d_nfchoa/#equation-fd-nfchoa-plane-2d
Examples
d, selection, secondary_source = sfs.fd.nfchoa.plane_2d( omega, array.x, R, npw) plot(d, selection, secondary_source)
-
sfs.fd.nfchoa.
point_25d
(omega, x0, r0, xs, *, max_order=None, c=None)[source]¶ Driving function for 2.5-dimensional NFC-HOA for a virtual point source.
Parameters: - omega (float) – Angular frequency of point source.
- x0 ((N, 3) array_like) – Sequence of secondary source positions.
- r0 (float) – Radius of circular secondary source distribution.
- xs ((3,) array_like) – Position of point source.
- max_order (float, optional) – Maximum order of circular harmonics used for the calculation.
- c (float, optional) – Speed of sound.
Returns: - d ((N,) numpy.ndarray) – Complex weights of secondary sources.
- selection ((N,) numpy.ndarray) – Boolean array containing only
True
indicating that all secondary source are “active” for NFC-HOA. - secondary_source_function (callable) – A function that can be used to create the sound field of a
single secondary source. See
sfs.fd.synthesize()
.
Notes
\[D(\phi_0, \omega) = \frac{1}{2 \pi r_0} \sum_{m=-M}^M \frac{\hankel{2}{|m|}{\wc r}}{\hankel{2}{|m|}{\wc r_0}} \e{\i m (\phi_0 - \phi)}\]See https://sfs.rtfd.io/d_nfchoa/#equation-fd-nfchoa-point-25d
Examples
d, selection, secondary_source = sfs.fd.nfchoa.point_25d( omega, array.x, R, xs) plot(d, selection, secondary_source)
-
sfs.fd.nfchoa.
plane_25d
(omega, x0, r0, n=[0, 1, 0], *, max_order=None, c=None)[source]¶ Driving function for 2.5-dimensional NFC-HOA for a virtual plane wave.
Parameters: - omega (float) – Angular frequency of point source.
- x0 ((N, 3) array_like) – Sequence of secondary source positions.
- r0 (float) – Radius of circular secondary source distribution.
- n ((3,) array_like, optional) – Normal vector (traveling direction) of plane wave.
- max_order (float, optional) – Maximum order of circular harmonics used for the calculation.
- c (float, optional) – Speed of sound.
Returns: - d ((N,) numpy.ndarray) – Complex weights of secondary sources.
- selection ((N,) numpy.ndarray) – Boolean array containing only
True
indicating that all secondary source are “active” for NFC-HOA. - secondary_source_function (callable) – A function that can be used to create the sound field of a
single secondary source. See
sfs.fd.synthesize()
.
Notes
\[D(\phi_0, \omega) = \frac{2\i}{r_0} \sum_{m=-M}^M \frac{\i^{-|m|}}{\wc \hankel{2}{|m|}{\wc r_0}} \e{\i m (\phi_0 - \phi_\text{pw})}\]See https://sfs.rtfd.io/d_nfchoa/#equation-fd-nfchoa-plane-25d
Examples
d, selection, secondary_source = sfs.fd.nfchoa.plane_25d( omega, array.x, R, npw) plot(d, selection, secondary_source)