Skip to content

Commit

Permalink
Move sfs.util.displacement() to sfs.fd.displacement()
Browse files Browse the repository at this point in the history
Closes #30.
  • Loading branch information
mgeier authored and hagenw committed Mar 18, 2019
1 parent 263cb93 commit 4807ff8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion doc/examples/animations-pulsating-sphere.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"\n",
"while the last one can be obtained by using\n",
"\n",
"- [sfs.util.displacement()](../sfs.util.rst#sfs.util.displacement)\n",
"- [sfs.fd.displacement()](../sfs.fd.rst#sfs.fd.displacement)\n",
"\n",
"which converts the particle velocity into displacement.\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/animations_pulsating_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def particle_displacement(omega, center, radius, amplitude, grid, frames,
"""Generate sound particle animation."""
velocity = sfs.fd.source.pulsating_sphere_velocity(
omega, center, radius, amplitude, grid)
displacement = sfs.util.displacement(velocity, omega)
displacement = sfs.fd.displacement(velocity, omega)
phasor = np.exp(1j * 2 * np.pi / frames)

fig, ax = plt.subplots(figsize=figsize)
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/plot_particle_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def plot_particle_displacement(title):
# compute displacement
X = grid + amplitude * sfs.util.displacement(v, omega)
X = grid + amplitude * sfs.fd.displacement(v, omega)
# plot displacement
plt.figure(figsize=(15, 15))
plt.cla()
Expand Down
12 changes: 12 additions & 0 deletions sfs/fd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""
from . import source
from .. import array as _array
from .. import util as _util
import numpy as _np


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


def displacement(v, omega):
r"""Particle displacement.
.. math::
d(x, t) = \int_{-\infty}^t v(x, \tau) d\tau
"""
return _util.as_xyz_components(v) / (1j * omega)


def synthesize(d, weights, ssd, secondary_source_function, **kwargs):
"""Compute sound field for a generic driving function.
Expand Down
11 changes: 0 additions & 11 deletions sfs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,6 @@ def normalize_vector(x):
return x / np.linalg.norm(x)


def displacement(v, omega):
r"""Particle displacement.
.. math::
d(x, t) = \int_{-\infty}^t v(x, \tau) d\tau
"""
return as_xyz_components(v) / (1j * omega)


def db(x, *, power=False):
"""Convert *x* to decibel.
Expand Down

0 comments on commit 4807ff8

Please sign in to comment.