Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add point source with line piston far-field directivity #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions sfs/fd/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,67 @@ def point_dipole(omega, x0, n0, grid, *, c=None):
_np.power(r, 2) * _np.exp(-1j * k * r)


def point_line_piston(omega, x0, u0, grid, L, *, c=None):
r"""Point source with dipole characteristics.

Parameters
----------
omega : float
Frequency of source.
x0 : (3,) array_like
Position of source.
u0 : (3,) array_like
Unit vector pointing along the line piston
grid : triple of array_like
The grid that is used for the sound field calculations.
See `sfs.util.xyz_grid()`.
L : float
Length of line piston.
c : float, optional
Speed of sound.

Returns
-------
numpy.ndarray
Sound pressure at positions given by *grid*.

Notes
-----
.. math::
G(\x-\x_0,\w) = \frac{1}{4\pi}
\frac{\sin(\wc \frac{L}{2} \cos(\Theta))}{\wc \frac{L}{2} \cos(\Theta)}
\frac{\e{-\i\wc|\x-\x_0|}}{|\x-\x_0|}
with

.. math::
\cos(\Theta) =
\frac{\langle \mathbf{x} - \mathbf{x}_0 | \mathbf{u}_0 \rangle}
{|\mathbf{x} - \mathbf{x}_0|}
Examples
--------
.. plot::
:context: close-figs

u0 = 1, 0, 0
L = 2.0
p = sfs.fd.source.point_line_piston(omega, x0, u0, grid, L)
sfs.plot2d.amplitude(p * normalization_point, grid)
plt.title("Line Piston at {} m".format(x0))

"""
k = _util.wavenumber(omega, c)
x0 = _util.asarray_1d(x0)
u0 = _util.asarray_1d(u0)
grid = _util.as_xyz_components(grid)

offset = grid - x0
r = _np.linalg.norm(offset)
cosphi = _np.inner(offset, u0) / r

return 1 / (4 * _np.pi) * _np.exp(-1j * k * r) / r * \
_special.sinc(k * cosphi * L / ( 2 * _np.pi ) )


def point_modal(omega, x0, grid, L, *, N=None, deltan=0, c=None):
"""Point source in a rectangular room using a modal room model.

Expand Down