22
33.. include:: math-definitions.rst
44
5+ .. plot::
6+ :context: reset
7+
8+ import matplotlib.pyplot as plt
9+ import numpy as np
10+ import sfs
11+
12+ plt.rcParams['figure.figsize'] = 6, 6
13+
14+ xs = -1.5, 1.5, 0
15+ xs_focused = -0.5, 0.5, 0
16+ # normal vector for plane wave:
17+ npw = sfs.util.direction_vector(np.radians(-45))
18+ # normal vector for focused source:
19+ ns = sfs.util.direction_vector(np.radians(-45))
20+ f = 300 # Hz
21+ omega = 2 * np.pi * f
22+ R = 1.5 # Radius of circular loudspeaker array
23+
24+ grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.02)
25+
26+ x0, n0, a0 = sfs.array.circular(N=32, R=R)
27+
28+ def plot(d, selected):
29+ p = sfs.mono.synthesized.generic(omega, x0, n0, d * selected * a0 , grid)
30+ sfs.plot.soundfield(p, grid)
31+ sfs.plot.loudspeaker_2d(x0, n0, selected * a0, size=0.15)
32+
533"""
634
735import numpy as np
@@ -18,6 +46,15 @@ def wfs_2d_line(omega, x0, n0, xs, c=None):
1846
1947 D(x0,k) = j/2 k (x0-xs) n0 / |x0-xs| * H1(k |x0-xs|)
2048
49+ Examples
50+ --------
51+ .. plot::
52+ :context: close-figs
53+
54+ d = sfs.mono.drivingfunction.wfs_2d_line(omega, x0, n0, xs)
55+ a = sfs.mono.drivingfunction.source_selection_line(n0, x0, xs)
56+ plot(d, a)
57+
2158 """
2259 x0 = util .asarray_of_rows (x0 )
2360 n0 = util .asarray_of_rows (n0 )
@@ -37,6 +74,15 @@ def _wfs_point(omega, x0, n0, xs, c=None):
3774 D(x0,k) = j k ------------- e^(-j k |x0-xs|)
3875 |x0-xs|^(3/2)
3976
77+ Examples
78+ --------
79+ .. plot::
80+ :context: close-figs
81+
82+ d = sfs.mono.drivingfunction.wfs_3d_point(omega, x0, n0, xs)
83+ a = sfs.mono.drivingfunction.source_selection_point(n0, x0, xs)
84+ plot(d, a)
85+
4086 """
4187 x0 = util .asarray_of_rows (x0 )
4288 n0 = util .asarray_of_rows (n0 )
@@ -59,6 +105,15 @@ def wfs_25d_point(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
59105 D(x0,k) = \|j k |xref-x0| ------------- e^(-j k |x0-xs|)
60106 |x0-xs|^(3/2)
61107
108+ Examples
109+ --------
110+ .. plot::
111+ :context: close-figs
112+
113+ d = sfs.mono.drivingfunction.wfs_25d_point(omega, x0, n0, xs)
114+ a = sfs.mono.drivingfunction.source_selection_point(n0, x0, xs)
115+ plot(d, a)
116+
62117 """
63118 x0 = util .asarray_of_rows (x0 )
64119 n0 = util .asarray_of_rows (n0 )
@@ -83,6 +138,15 @@ def _wfs_plane(omega, x0, n0, n=[0, 1, 0], c=None):
83138
84139 D(x0,k) = j k n n0 e^(-j k n x0)
85140
141+ Examples
142+ --------
143+ .. plot::
144+ :context: close-figs
145+
146+ d = sfs.mono.drivingfunction.wfs_3d_plane(omega, x0, n0, npw)
147+ a = sfs.mono.drivingfunction.source_selection_plane(n0, npw)
148+ plot(d, a)
149+
86150 """
87151 x0 = util .asarray_of_rows (x0 )
88152 n0 = util .asarray_of_rows (n0 )
@@ -103,6 +167,15 @@ def wfs_25d_plane(omega, x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None,
103167 ____________
104168 D_2.5D(x0,w) = \|j k |xref-x0| n n0 e^(-j k n x0)
105169
170+ Examples
171+ --------
172+ .. plot::
173+ :context: close-figs
174+
175+ d = sfs.mono.drivingfunction.wfs_25d_plane(omega, x0, n0, npw)
176+ a = sfs.mono.drivingfunction.source_selection_plane(n0, npw)
177+ plot(d, a)
178+
106179 """
107180 x0 = util .asarray_of_rows (x0 )
108181 n0 = util .asarray_of_rows (n0 )
@@ -126,6 +199,15 @@ def _wfs_focused(omega, x0, n0, xs, c=None):
126199 D(x0,k) = j k ------------- e^(j k |x0-xs|)
127200 |x0-xs|^(3/2)
128201
202+ Examples
203+ --------
204+ .. plot::
205+ :context: close-figs
206+
207+ d = sfs.mono.drivingfunction.wfs_3d_focused(omega, x0, n0, xs_focused)
208+ a = sfs.mono.drivingfunction.source_selection_focused(ns, x0, xs_focused)
209+ plot(d, a)
210+
129211 """
130212 x0 = util .asarray_of_rows (x0 )
131213 n0 = util .asarray_of_rows (n0 )
@@ -148,6 +230,15 @@ def wfs_25d_focused(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
148230 D(x0,w) = \|j k |xref-x0| ------------- e^(j k |x0-xs|)
149231 |x0-xs|^(3/2)
150232
233+ Examples
234+ --------
235+ .. plot::
236+ :context: close-figs
237+
238+ d = sfs.mono.drivingfunction.wfs_25d_focused(omega, x0, n0, xs_focused)
239+ a = sfs.mono.drivingfunction.source_selection_focused(ns, x0, xs_focused)
240+ plot(d, a)
241+
151242 """
152243 x0 = util .asarray_of_rows (x0 )
153244 n0 = util .asarray_of_rows (n0 )
@@ -248,6 +339,14 @@ def nfchoa_2d_plane(omega, x0, r0, n=[0, 1, 0], max_order=None, c=None):
248339
249340 See http://sfstoolbox.org/#equation-D.nfchoa.pw.2D.
250341
342+ Examples
343+ --------
344+ .. plot::
345+ :context: close-figs
346+
347+ d = sfs.mono.drivingfunction.nfchoa_2d_plane(omega, x0, R, npw)
348+ plot(d, 1)
349+
251350 """
252351 x0 = util .asarray_of_rows (x0 )
253352 k = util .wavenumber (omega , c )
@@ -274,6 +373,14 @@ def nfchoa_25d_point(omega, x0, r0, xs, max_order=None, c=None):
274373
275374 See http://sfstoolbox.org/#equation-D.nfchoa.ps.2.5D.
276375
376+ Examples
377+ --------
378+ .. plot::
379+ :context: close-figs
380+
381+ d = sfs.mono.drivingfunction.nfchoa_25d_point(omega, x0, R, xs)
382+ plot(d, 1)
383+
277384 """
278385 x0 = util .asarray_of_rows (x0 )
279386 k = util .wavenumber (omega , c )
@@ -302,6 +409,14 @@ def nfchoa_25d_plane(omega, x0, r0, n=[0, 1, 0], max_order=None, c=None):
302409
303410 See http://sfstoolbox.org/#equation-D.nfchoa.pw.2.5D.
304411
412+ Examples
413+ --------
414+ .. plot::
415+ :context: close-figs
416+
417+ d = sfs.mono.drivingfunction.nfchoa_25d_plane(omega, x0, R, npw)
418+ plot(d, 1)
419+
305420 """
306421 x0 = util .asarray_of_rows (x0 )
307422 k = util .wavenumber (omega , c )
0 commit comments