In [ ]:
import numpy as np
import matplotlib.pyplot as plt
import sfs
In [ ]:
# Simulation parameters
number_of_secondary_sources = 56
frequency = 680 # in Hz
pw_angle = 30 # traveling direction of plane wave in degree
xs = [-2, -1, 0] # position of virtual point source in m
grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.02)
omega = 2 * np.pi * frequency # angular frequency
npw = sfs.util.direction_vector(np.radians(pw_angle)) # normal vector of plane wave
Define a helper function for synthesize and plot the sound field from the given driving signals.
In [ ]:
def sound_field(d, selection, secondary_source, array, grid, tapering=True):
if tapering:
tapering_window = sfs.tapering.tukey(selection, alpha=0.3)
else:
tapering_window = sfs.tapering.none(selection)
p = sfs.fd.synthesize(d, tapering_window, array, secondary_source, grid=grid)
sfs.plot2d.amplitude(p, grid, xnorm=[0, 0, 0])
sfs.plot2d.loudspeakers(array.x, array.n, tapering_window)
In [ ]:
radius = 1.5 # in m
array = sfs.array.circular(number_of_secondary_sources, radius)
In [ ]:
d, selection, secondary_source = sfs.fd.wfs.plane_25d(omega, array.x, array.n, n=npw)
sound_field(d, selection, secondary_source, array, grid)
In [ ]:
d, selection, secondary_source = sfs.fd.wfs.point_25d(omega, array.x, array.n, xs)
sound_field(d, selection, secondary_source, array, grid)
In [ ]:
d, selection, secondary_source = sfs.fd.nfchoa.plane_25d(omega, array.x, radius, n=npw)
sound_field(d, selection, secondary_source, array, grid, tapering=False)
In [ ]:
d, selection, secondary_source = sfs.fd.nfchoa.point_25d(omega, array.x, radius, xs)
sound_field(d, selection, secondary_source, array, grid, tapering=False)
In [ ]:
spacing = 0.07 # in m
array = sfs.array.linear(number_of_secondary_sources, spacing,
center=[0, -0.5, 0], orientation=[0, 1, 0])
In [ ]:
d, selection, secondary_source = sfs.fd.wfs.plane_25d(omega, array.x, array.n, npw)
sound_field(d, selection, secondary_source, array, grid)
In [ ]:
d, selection, secondary_source = sfs.fd.wfs.point_25d(omega, array.x, array.n, xs)
sound_field(d, selection, secondary_source, array, grid)