@@ -23,6 +23,68 @@ def point(omega, x0, n0, grid, c=None):
23
23
return np .squeeze (1 / (4 * np .pi ) * np .exp (- 1j * k * r ) / r )
24
24
25
25
26
+ def point_modal (omega , x0 , grid , L , N = None , deltan = 0 , c = None ):
27
+ """Point source in a rectangular room using a modal room model.
28
+
29
+ Parameters
30
+ ----------
31
+ omega : float
32
+ Frequency of source.
33
+ x0 : triple of floats
34
+ Position of source.
35
+ grid : list of numpy.ndarrays
36
+ The grid that is used for the sound field calculations.
37
+ L : triple of floats
38
+ Dimensionons of the rectangular room.
39
+ N : triple of integers
40
+ Combination of modal orders in the three-spatial dimensions to
41
+ calculate the sound field for. If not given, the maximum modal order
42
+ is determined and the sound field is computed up to this max.
43
+ deltan : float
44
+ Absorption coefficient of the walls.
45
+ c : float
46
+ Speed of sound.
47
+
48
+ Returns
49
+ -------
50
+
51
+ """
52
+ k = util .wavenumber (omega , c )
53
+ x0 = util .asarray_1d (x0 )
54
+ x , y , z = util .asarray_of_arrays (grid )
55
+
56
+ if N is None :
57
+ # determine maximum modal order per dimension
58
+ Nx = int (np .ceil (L [0 ]/ np .pi * k ))
59
+ Ny = int (np .ceil (L [1 ]/ np .pi * k ))
60
+ Nz = int (np .ceil (L [2 ]/ np .pi * k ))
61
+ mm = range (Nx )
62
+ nn = range (Ny )
63
+ ll = range (Nz )
64
+ else :
65
+ # compute field for one order combination only
66
+ mm = [N [0 ]]
67
+ nn = [N [1 ]]
68
+ ll = [N [2 ]]
69
+
70
+ p = 0
71
+ for m in mm :
72
+ for n in nn :
73
+ for l in ll :
74
+ kx = m * np .pi / L [0 ]
75
+ ky = n * np .pi / L [1 ]
76
+ kz = l * np .pi / L [2 ]
77
+
78
+ km = (kx + 1j * deltan )** 2 + (ky + 1j * deltan )** 2 + \
79
+ (kz + 1j * deltan )** 2
80
+
81
+ p = p + 1 / (k ** 2 - km ) * \
82
+ np .cos (kx * x ) * np .cos (ky * y ) * np .cos (kz * z ) * \
83
+ np .cos (kx * x0 [0 ]) * np .cos (ky * x0 [1 ]) * np .cos (kz * x0 [2 ])
84
+
85
+ return np .squeeze (p )
86
+
87
+
26
88
def line (omega , x0 , n0 , grid , c = None ):
27
89
"""Line source parallel to the z-axis.
28
90
0 commit comments