Skip to content

Commit 4807ff8

Browse files
mgeierhagenw
authored andcommitted
Move sfs.util.displacement() to sfs.fd.displacement()
Closes #30.
1 parent 263cb93 commit 4807ff8

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

doc/examples/animations-pulsating-sphere.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"\n",
3434
"while the last one can be obtained by using\n",
3535
"\n",
36-
"- [sfs.util.displacement()](../sfs.util.rst#sfs.util.displacement)\n",
36+
"- [sfs.fd.displacement()](../sfs.fd.rst#sfs.fd.displacement)\n",
3737
"\n",
3838
"which converts the particle velocity into displacement.\n",
3939
"\n",

doc/examples/animations_pulsating_sphere.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def particle_displacement(omega, center, radius, amplitude, grid, frames,
1010
"""Generate sound particle animation."""
1111
velocity = sfs.fd.source.pulsating_sphere_velocity(
1212
omega, center, radius, amplitude, grid)
13-
displacement = sfs.util.displacement(velocity, omega)
13+
displacement = sfs.fd.displacement(velocity, omega)
1414
phasor = np.exp(1j * 2 * np.pi / frames)
1515

1616
fig, ax = plt.subplots(figsize=figsize)

doc/examples/plot_particle_density.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
def plot_particle_displacement(title):
2121
# compute displacement
22-
X = grid + amplitude * sfs.util.displacement(v, omega)
22+
X = grid + amplitude * sfs.fd.displacement(v, omega)
2323
# plot displacement
2424
plt.figure(figsize=(15, 15))
2525
plt.cla()

sfs/fd/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414
from . import source
1515
from .. import array as _array
16+
from .. import util as _util
1617
import numpy as _np
1718

1819

@@ -22,6 +23,17 @@ def shiftphase(p, phase):
2223
return p * _np.exp(1j * phase)
2324

2425

26+
def displacement(v, omega):
27+
r"""Particle displacement.
28+
29+
.. math::
30+
31+
d(x, t) = \int_{-\infty}^t v(x, \tau) d\tau
32+
33+
"""
34+
return _util.as_xyz_components(v) / (1j * omega)
35+
36+
2537
def synthesize(d, weights, ssd, secondary_source_function, **kwargs):
2638
"""Compute sound field for a generic driving function.
2739

sfs/util.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,6 @@ def normalize_vector(x):
339339
return x / np.linalg.norm(x)
340340

341341

342-
def displacement(v, omega):
343-
r"""Particle displacement.
344-
345-
.. math::
346-
347-
d(x, t) = \int_{-\infty}^t v(x, \tau) d\tau
348-
349-
"""
350-
return as_xyz_components(v) / (1j * omega)
351-
352-
353342
def db(x, *, power=False):
354343
"""Convert *x* to decibel.
355344

0 commit comments

Comments
 (0)