@@ -87,7 +87,7 @@ def point(omega, x0, n0, grid, c=None):
8787 return 1 / (4 * np .pi ) * np .exp (- 1j * k * r ) / r
8888
8989
90- def point_velocity (omega , x0 , n0 , grid , c = None ):
90+ def point_velocity (omega , x0 , n0 , grid , c = None , rho0 = None ):
9191 """Particle velocity of a point source.
9292
9393 Parameters
@@ -103,6 +103,8 @@ def point_velocity(omega, x0, n0, grid, c=None):
103103 See `sfs.util.xyz_grid()`.
104104 c : float, optional
105105 Speed of sound.
106+ rho0 : float, optional
107+ Static density of air.
106108
107109 Returns
108110 -------
@@ -124,17 +126,19 @@ def point_velocity(omega, x0, n0, grid, c=None):
124126 """
125127 if c is None :
126128 c = default .c
129+ if rho0 is None :
130+ rho0 = default .rho0
127131 k = util .wavenumber (omega , c )
128132 x0 = util .asarray_1d (x0 )
129133 grid = util .as_xyz_components (grid )
130134 offset = grid - x0
131135 r = np .linalg .norm (offset )
132136 v = point (omega , x0 , n0 , grid , c = c )
133- v *= (1 + 1j * k * r ) / (default . rho0 * c * 1j * k * r )
137+ v *= (1 + 1j * k * r ) / (rho0 * c * 1j * k * r )
134138 return util .XyzComponents ([v * o / r for o in offset ])
135139
136140
137- def point_averaged_intensity (omega , x0 , n0 , grid , c = None ):
141+ def point_averaged_intensity (omega , x0 , n0 , grid , c = None , rho0 = None ):
138142 """Velocity of a point source.
139143
140144 Parameters
@@ -150,17 +154,23 @@ def point_averaged_intensity(omega, x0, n0, grid, c=None):
150154 See `sfs.util.xyz_grid()`.
151155 c : float, optional
152156 Speed of sound.
157+ rho0 : float, optional
158+ Static density of air.
153159
154160 Returns
155161 -------
156162 `XyzComponents`
157163 Averaged intensity at positions given by *grid*.
158164 """
165+ if c is None :
166+ c = default .c
167+ if rho0 is None :
168+ rho0 = default .rho0
159169 x0 = util .asarray_1d (x0 )
160170 grid = util .as_xyz_components (grid )
161171 offset = grid - x0
162172 r = np .linalg .norm (offset )
163- i = 1 / (2 * default . rho0 * default . c )
173+ i = 1 / (2 * rho0 * c )
164174 return util .XyzComponents ([i * o / r ** 2 for o in offset ])
165175
166176
@@ -444,7 +454,7 @@ def line(omega, x0, n0, grid, c=None):
444454 return _duplicate_zdirection (p , grid )
445455
446456
447- def line_velocity (omega , x0 , n0 , grid , c = None ):
457+ def line_velocity (omega , x0 , n0 , grid , c = None , rho0 = None ):
448458 """Velocity of line source parallel to the z-axis.
449459
450460 Returns
@@ -467,13 +477,15 @@ def line_velocity(omega, x0, n0, grid, c=None):
467477 """
468478 if c is None :
469479 c = default .c
480+ if rho0 is None :
481+ rho0 = default .rho0
470482 k = util .wavenumber (omega , c )
471483 x0 = util .asarray_1d (x0 )[:2 ] # ignore z-component
472484 grid = util .as_xyz_components (grid )
473485
474486 offset = grid [:2 ] - x0
475487 r = np .linalg .norm (offset )
476- v = - 1 / (4 * c * default . rho0 ) * special .hankel2 (1 , k * r )
488+ v = - 1 / (4 * c * rho0 ) * special .hankel2 (1 , k * r )
477489 v = [v * o / r for o in offset ]
478490
479491 assert v [0 ].shape == v [1 ].shape
@@ -620,7 +632,7 @@ def plane(omega, x0, n0, grid, c=None):
620632 return np .exp (- 1j * k * np .inner (grid - x0 , n0 ))
621633
622634
623- def plane_velocity (omega , x0 , n0 , grid , c = None ):
635+ def plane_velocity (omega , x0 , n0 , grid , c = None , rho0 = None ):
624636 r"""Velocity of a plane wave.
625637
626638 Parameters
@@ -636,6 +648,8 @@ def plane_velocity(omega, x0, n0, grid, c=None):
636648 See `sfs.util.xyz_grid()`.
637649 c : float, optional
638650 Speed of sound.
651+ rho0 : float, optional
652+ Static density of air.
639653
640654 Returns
641655 -------
@@ -663,11 +677,13 @@ def plane_velocity(omega, x0, n0, grid, c=None):
663677 """
664678 if c is None :
665679 c = default .c
666- v = plane (omega , x0 , n0 , grid , c = c ) / (default .rho0 * c )
680+ if rho0 is None :
681+ rho0 = default .rho0
682+ v = plane (omega , x0 , n0 , grid , c = c ) / (rho0 * c )
667683 return util .XyzComponents ([v * n for n in n0 ])
668684
669685
670- def plane_averaged_intensity (omega , x0 , n0 , grid , c = None ):
686+ def plane_averaged_intensity (omega , x0 , n0 , grid , c = None , rho0 = None ):
671687 r"""Averaged intensity of a plane wave.
672688
673689 Parameters
@@ -683,6 +699,8 @@ def plane_averaged_intensity(omega, x0, n0, grid, c=None):
683699 See `sfs.util.xyz_grid()`.
684700 c : float, optional
685701 Speed of sound.
702+ rho0 : float, optional
703+ Static density of air.
686704
687705 Returns
688706 -------
@@ -698,7 +716,9 @@ def plane_averaged_intensity(omega, x0, n0, grid, c=None):
698716 """
699717 if c is None :
700718 c = default .c
701- i = 1 / (2 * default .rho0 * c )
719+ if rho0 is None :
720+ rho0 = default .rho0
721+ i = 1 / (2 * rho0 * c )
702722 return util .XyzComponents ([i * n for n in n0 ])
703723
704724
0 commit comments