Animations of a Pulsating Sphere¶
import sfs import numpy as np import matplotlib.pyplot as plt from IPython.display import HTML
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!
import animations_pulsating_sphere as animation
# Pulsating sphere center = [0, 0, 0] radius = 0.25 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
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())