# Animations of a Pulsating Sphere¶

[1]:

import sfs
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import HTML

/home/docs/checkouts/readthedocs.org/user_builds/sfs-python/conda/0.6.2/lib/python3.9/site-packages/traitlets/traitlets.py:3030: FutureWarning: --rc={'figure.dpi': 96} for dict-traits is deprecated in traitlets 5.0. You can pass --rc <key=value> ... multiple times to add items to a dict.
warn(


In this example, the sound field of a pulsating sphere is visualized. Different acoustic variables, such as sound pressure, particle velocity, and particle displacement, are simulated. The first two quantities are computed with

while the last one can be obtained by using

which converts the particle velocity into displacement.

A couple of additional functions are implemented in

in order to help creating animating pictures, which is fun!

[2]:

import animations_pulsating_sphere as animation

[3]:

# Pulsating sphere
center = [0, 0, 0]
amplitude = 0.05
f = 1000  # frequency
omega = 2 * np.pi * f  # angular frequency

# Axis limits
figsize = (6, 6)
xmin, xmax = -1, 1
ymin, ymax = -1, 1

# Animations
frames = 20  # frames per period


## Particle Displacement¶

[4]:

grid = sfs.util.xyz_grid([xmin, xmax], [ymin, ymax], 0, spacing=0.025)
ani = animation.particle_displacement(
omega, center, radius, amplitude, grid, frames, figsize, c='Gray')
plt.close()
HTML(ani.to_jshtml())

[4]: