Skip to content

Commit bb21236

Browse files
haocheysbryngelson
andauthored
Add Broadband Acoustic Src (#706)
Co-authored-by: Spencer Bryngelson <[email protected]>
1 parent 6742230 commit bb21236

File tree

10 files changed

+191
-18
lines changed

10 files changed

+191
-18
lines changed

docs/documentation/case.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ If `file_per_process` is true, then pre_process, simulation, and post_process mu
545545
| `acoustic(i)%%support` | Integer | Geometry of spatial support for the acoustic source |
546546
| `acoustic(i)%%dipole` | Logical | Dipole source activation (optional; default = false -> monopole) |
547547
| `acoustic(i)%%loc(j)` | Real | $j$-th coordinate of the point that defines the acoustic source location |
548-
| `acoustic(i)%%pulse` | Integer | Acoustic wave form: [1] Sine [2] Gaussian [3] Square |
548+
| `acoustic(i)%%pulse` | Integer | Acoustic wave form: [1] Sine [2] Gaussian [3] Square [4] Broadband |
549549
| `acoustic(i)%%npulse` | Real | Number of pulse cycles |
550550
| `acoustic(i)%%mag` | Real | Pulse magnitude |
551551
| `acoustic(i)%%frequency` | Real | Sine/Square - Frequency of the acoustic wave (exclusive) |
@@ -563,6 +563,9 @@ If `file_per_process` is true, then pre_process, simulation, and post_process mu
563563
| `acoustic(i)%%element_spacing_angle` | Real | 2D Transducer array - Spacing angle (in rad) between adjacent transducer elements |
564564
| `acoustic(i)%%element_polygon_ratio` | Real | 3D Transducer array - Ratio of polygon side length to transducer element radius |
565565
| `acoustic(i)%%rotate_angle` | Real | 3D Transducer array - Rotation angle of the transducer array (optional; default = 0) |
566+
| `acoustic(i)%%bb_num_freq` | integer | Number of frequencies in broadband wave |
567+
| `acoustic(i)%%bb_bandwidth` | Real | The bandwidth of each frequency in the broadband wave |
568+
| `acoustic(i)%%bb_lowest_freq` | Real | The lower frequency bound of the broadband wave |
566569

567570
Details of the transducer acoustic source model can be found in [Maeda and Colonius (2017)](references.md#Maeda17).
568571

@@ -576,7 +579,7 @@ Details of the transducer acoustic source model can be found in [Maeda and Colon
576579

577580
- `%%loc(j)` specifies the location of the acoustic source in the $j$-th coordinate direction. For planer support, the location defines midpoint of the source plane. For transducer arrays, the location defines the center of the transducer or transducer array (not the focal point; for 3D it's the tip of the spherical cap, for 2D it's the tip of the arc).
578581

579-
- `%%pulse` specifies the acoustic wave form. `%%pulse = 1`, `2`, and `3` correspond to sinusoidal wave, Gaussian wave, and square wave, respectively.
582+
- `%%pulse` specifies the acoustic wave form. `%%pulse = 1`, `2`, `3` and `4` correspond to sinusoidal wave, Gaussian wave, square wave and broadband wave, respectively. The implementation of the broadband wave is based on [Tam (2005)](references.md#Tam05)
580583

581584
- `%%npulse` specifies the number of cycles of the acoustic wave generated. Only applies to `%%pulse = 1 and 3` (sine and square waves), and must be an integer for non-planar waves.
582585

@@ -608,6 +611,12 @@ Details of the transducer acoustic source model can be found in [Maeda and Colon
608611

609612
- `%%rotate_angle` specifies the rotation angle of the 3D circular transducer array along the x-axis (principal axis). It is optional and defaults to 0.
610613

614+
- `%%bb_num_freq` specifies the number discretized frequencies in the broadband acoustic wave. If `%%bb_num_freq` is 1, the acoustic wave will be a discrete tone (i.e. single frequency sine wave).
615+
616+
- `%%bb_bandwidth` specifies the bandwidth of the discretized frequencies.
617+
618+
- `%%bb_lowest_freq` specifies the lower frequency bound of the broadband acoustic wave. The upper frequency bound will be calculated as `%%bb_lowest_freq + %%bb_num_freq * %%bb_bandwidth`. The wave is no longer broadband below the lower bound and above the upper bound.
619+
611620
### 9. Ensemble-Averaged Bubble Model
612621

613622
| Parameter | Type | Description |

docs/documentation/references.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
- <a id="Suresh97">Suresh, A. and Huynh, H. (1997). Accurate monotonicity-preserving schemes with runge–kutta time stepping. Journal of Computational Physics, 136(1):83–99.</a>
4242

43+
- <a id="Tam05">Tam, C. K., Ju, H., Jones, M. G., Watson, W. R., and Parrott, T. L. (2005). A computational and experimental study of slit resonators. Journal of Sound and Vibration, 284(3-5), 947-984.</a>
44+
4345
- <a id="Thompson87">Thompson, K. W. (1987). Time dependent boundary conditions for hyperbolic systems. Journal of computational physics, 68(1):1–24.</a>
4446

4547
- <a id="Thompson90">Thompson, K. W. (1990). Time-dependent boundary conditions for hyperbolic systems, ii. Journal of computational physics, 89(2):439–461.</a>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env python3
2+
3+
import json, math
4+
5+
print(json.dumps({
6+
# Logistics ================================================================
7+
'run_time_info' : 'T',
8+
# ==========================================================================
9+
10+
# Computational Domain Parameters ==========================================
11+
'x_domain%beg' : 0,
12+
'x_domain%end' : 0.3,
13+
'y_domain%beg' : 0,
14+
'y_domain%end' : 0.1,
15+
'm' : 299,
16+
'n' : 99,
17+
'p' : 0,
18+
'dt' : 5e-7,
19+
't_step_start' : 0,
20+
't_step_stop' : 1000,
21+
't_step_save' : 10,
22+
# ==========================================================================
23+
24+
# Simulation Algorithm Parameters ==========================================
25+
'num_patches' : 1,
26+
'model_eqns' : 2,
27+
'alt_soundspeed' : 'F',
28+
'num_fluids' : 1,
29+
'mpp_lim' : 'F',
30+
'mixture_err' : 'F',
31+
'time_stepper' : 3,
32+
'weno_order' : 5,
33+
'weno_eps' : 1.E-16,
34+
'teno' : 'T',
35+
'teno_CT' : 1E-8,
36+
'null_weights' : 'F',
37+
'mp_weno' : 'F',
38+
'riemann_solver' : 2,
39+
'wave_speeds' : 1,
40+
'avg_state' : 2,
41+
'bc_x%beg' : -6,
42+
'bc_x%end' : -6,
43+
'bc_y%beg' : -6,
44+
'bc_y%end' : -6,
45+
# ==========================================================================
46+
47+
# Formatted Database Files Structure Parameters ============================
48+
'format' : 1,
49+
'precision' : 2,
50+
'prim_vars_wrt' :'T',
51+
'parallel_io' :'T',
52+
'probe_wrt' :'T',
53+
'fd_order' : 2,
54+
'num_probes' : 1,
55+
'probe(1)%x' : 0.13,
56+
'probe(1)%y' : 0.05,
57+
58+
# ==========================================================================
59+
60+
# Patch 1 Liquid ===========================================================
61+
'patch_icpp(1)%geometry' : 3,
62+
'patch_icpp(1)%x_centroid' : 0.15,
63+
'patch_icpp(1)%y_centroid' : 0.05,
64+
'patch_icpp(1)%length_x' : 0.3,
65+
'patch_icpp(1)%length_y' : 0.1,
66+
'patch_icpp(1)%vel(1)' : 0.0,
67+
'patch_icpp(1)%vel(2)' : 0.0,
68+
'patch_icpp(1)%pres' : 1E+05,
69+
'patch_icpp(1)%alpha_rho(1)' : 1.19,
70+
'patch_icpp(1)%alpha(1)' : 1.0,
71+
# ==========================================================================
72+
73+
# Acoustic source ==========================================================
74+
'acoustic_source' : 'T',
75+
'num_source' : 1,
76+
'acoustic(1)%support' : 2,
77+
'acoustic(1)%loc(1)' : 0.1,
78+
'acoustic(1)%loc(2)' : 0.05,
79+
'acoustic(1)%dir' : math.pi * 0,
80+
'acoustic(1)%length' : 0.1,
81+
'acoustic(1)%pulse' : 4,
82+
'acoustic(1)%npulse' : 1000000,
83+
'acoustic(1)%mag' : 1000.,
84+
'acoustic(1)%bb_num_freq' : 100,
85+
'acoustic(1)%bb_lowest_freq' : 500.,
86+
'acoustic(1)%bb_bandwidth' : 500.,
87+
# ==========================================================================
88+
89+
# Fluids Physical Parameters ===============================================
90+
'fluid_pp(1)%gamma' : 1.E+00/(1.4E+00-1.E+00),
91+
'fluid_pp(1)%pi_inf' : 0,
92+
# ==========================================================================
93+
}))
94+
95+
# ==============================================================================

src/common/m_constants.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ module m_constants
2525
real(kind(0d0)), parameter :: capillary_cutoff = 1e-6 !< color function gradient magnitude at which to apply the surface tension fluxes
2626
real(kind(0d0)), parameter :: acoustic_spatial_support_width = 2.5d0 !< Spatial support width of acoustic source, used in s_source_spatial
2727
real(kind(0d0)), parameter :: dflt_vcfl_dt = 100d0 !< value of vcfl_dt when viscosity is off for computing adaptive timestep size
28+
real(kind(0d0)), parameter :: broadband_spectral_level_constant = 20d0 !< The constant to scale the spectral level at the lower frequency bound
29+
real(kind(0d0)), parameter :: broadband_spectral_level_growth_rate = 10d0 !< The spectral level constant to correct the magnitude at each frqeuency to ensure the source is overall broadband
2830

2931
end module m_constants

src/common/m_derived_types.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,11 @@ module m_derived_types
298298
real(kind(0d0)) :: element_spacing_angle !< Spacing between aperture elements in 2D acoustic array
299299
real(kind(0d0)) :: element_polygon_ratio !< Ratio of aperture element diameter to side length of polygon connecting their centers, in 3D acoustic array
300300
real(kind(0d0)) :: rotate_angle !< Angle of rotation of the entire circular 3D acoustic array
301+
real(kind(0d0)) :: bb_bandwidth !< Bandwidth of each frequency in broadband wave
302+
real(kind(0d0)) :: bb_lowest_freq !< The lower frequency bound of broadband wave
301303
integer :: num_elements !< Number of elements in the acoustic array
302304
integer :: element_on !< Element in the acoustic array to turn on
305+
integer :: bb_num_freq !< Number of frequencies in the broadband wave
303306
end type acoustic_parameters
304307
305308
!> Acoustic source source_spatial pre-calculated values

src/simulation/m_acoustic_src.fpp

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ module m_acoustic_src
4141
real(kind(0d0)), allocatable, dimension(:) :: element_spacing_angle, element_polygon_ratio, rotate_angle
4242
!$acc declare create(element_spacing_angle, element_polygon_ratio, rotate_angle)
4343

44-
integer, allocatable, dimension(:) :: num_elements, element_on
45-
!$acc declare create(num_elements, element_on)
44+
real(kind(0d0)), allocatable, dimension(:) :: bb_bandwidth, bb_lowest_freq
45+
!$acc declare create(bb_bandwidth, bb_lowest_freq)
46+
47+
integer, allocatable, dimension(:) :: num_elements, element_on, bb_num_freq
48+
!$acc declare create(num_elements, element_on, bb_num_freq)
4649

4750
!> @name Acoustic source terms
4851
!> @{
@@ -63,7 +66,8 @@ contains
6366
subroutine s_initialize_acoustic_src
6467
integer :: i, j !< generic loop variables
6568

66-
@:ALLOCATE(loc_acoustic(1:3, 1:num_source), mag(1:num_source), dipole(1:num_source), support(1:num_source), length(1:num_source), height(1:num_source), wavelength(1:num_source), frequency(1:num_source), gauss_sigma_dist(1:num_source), gauss_sigma_time(1:num_source), foc_length(1:num_source), aperture(1:num_source), npulse(1:num_source), pulse(1:num_source), dir(1:num_source), delay(1:num_source), element_polygon_ratio(1:num_source), rotate_angle(1:num_source), element_spacing_angle(1:num_source), num_elements(1:num_source), element_on(1:num_source))
69+
@:ALLOCATE(loc_acoustic(1:3, 1:num_source), mag(1:num_source), dipole(1:num_source), support(1:num_source), length(1:num_source), height(1:num_source), wavelength(1:num_source), frequency(1:num_source), gauss_sigma_dist(1:num_source), gauss_sigma_time(1:num_source), foc_length(1:num_source), aperture(1:num_source), npulse(1:num_source), pulse(1:num_source), dir(1:num_source), delay(1:num_source), element_polygon_ratio(1:num_source), rotate_angle(1:num_source), element_spacing_angle(1:num_source), num_elements(1:num_source), element_on(1:num_source), bb_num_freq(1:num_source), bb_bandwidth(1:num_source), bb_lowest_freq(1:num_source))
70+
6771
do i = 1, num_source
6872
do j = 1, 3
6973
loc_acoustic(j, i) = acoustic(i)%loc(j)
@@ -85,6 +89,10 @@ contains
8589
element_spacing_angle(i) = acoustic(i)%element_spacing_angle
8690
element_polygon_ratio(i) = acoustic(i)%element_polygon_ratio
8791
num_elements(i) = acoustic(i)%num_elements
92+
bb_num_freq(i) = acoustic(i)%bb_num_freq
93+
bb_bandwidth(i) = acoustic(i)%bb_bandwidth
94+
bb_lowest_freq(i) = acoustic(i)%bb_lowest_freq
95+
8896
if (acoustic(i)%element_on == dflt_int) then
8997
element_on(i) = 0
9098
else
@@ -101,7 +109,7 @@ contains
101109
delay(i) = acoustic(i)%delay
102110
end if
103111
end do
104-
!$acc update device(loc_acoustic, mag, dipole, support, length, height, wavelength, frequency, gauss_sigma_dist, gauss_sigma_time, foc_length, aperture, npulse, pulse, dir, delay, element_polygon_ratio, rotate_angle, element_spacing_angle, num_elements, element_on)
112+
!$acc update device(loc_acoustic, mag, dipole, support, length, height, wavelength, frequency, gauss_sigma_dist, gauss_sigma_time, foc_length, aperture, npulse, pulse, dir, delay, element_polygon_ratio, rotate_angle, element_spacing_angle, num_elements, element_on, bb_num_freq, bb_bandwidth, bb_lowest_freq)
105113

106114
@:ALLOCATE(mass_src(0:m, 0:n, 0:p))
107115
@:ALLOCATE(mom_src(1:num_dims, 0:m, 0:n, 0:p))
@@ -136,6 +144,11 @@ contains
136144
real(kind(0d0)) :: frequency_local, gauss_sigma_time_local
137145
real(kind(0d0)) :: mass_src_diff, mom_src_diff
138146
real(kind(0d0)) :: source_temporal
147+
real(kind(0d0)) :: period_BB !< period of each sine wave in broadband source
148+
real(kind(0d0)) :: sl_BB !< spectral level at each frequency
149+
real(kind(0d0)) :: ffre_BB !< source term corresponding to each frequency
150+
real(kind(0d0)) :: sum_BB !< total source term for the broadband wave
151+
real(kind(0d0)), allocatable, dimension(:) :: phi_rn !< random phase shift for each frequency
139152

140153
integer :: i, j, k, l, q !< generic loop variables
141154
integer :: ai !< acoustic source index
@@ -171,6 +184,35 @@ contains
171184

172185
num_points = source_spatials_num_points(ai) ! Use scalar to force firstprivate to prevent GPU bug
173186

187+
! Calculate the broadband source
188+
period_BB = 0d0
189+
sl_BB = 0d0
190+
ffre_BB = 0d0
191+
sum_BB = 0d0
192+
193+
! Allocate buffers for random phase shift
194+
allocate (phi_rn(1:bb_num_freq(ai)))
195+
196+
if (pulse(ai) == 4) then
197+
call random_number(phi_rn(1:bb_num_freq(ai)))
198+
! Ensure all the ranks have the same random phase shift
199+
call s_mpi_send_random_number(phi_rn, bb_num_freq(ai))
200+
end if
201+
202+
!$acc loop reduction(+:sum_BB)
203+
do k = 1, bb_num_freq(ai)
204+
! Acoustic period of the wave at each discrete frequency
205+
period_BB = 1d0/(bb_lowest_freq(ai) + k*bb_bandwidth(ai))
206+
! Spectral level at each frequency
207+
sl_BB = broadband_spectral_level_constant*mag(ai) + k*mag(ai)/broadband_spectral_level_growth_rate
208+
! Source term corresponding to each frequencies
209+
ffre_BB = dsqrt((2d0*sl_BB*bb_bandwidth(ai)))*cos((sim_time)*2d0*pi/period_BB + 2d0*pi*phi_rn(k))
210+
! Sum up the source term of each frequency to obtain the total source term for broadband wave
211+
sum_BB = sum_BB + ffre_BB
212+
end do
213+
214+
deallocate (phi_rn)
215+
174216
!$acc parallel loop gang vector default(present) private(myalpha, myalpha_rho)
175217
do i = 1, num_points
176218
j = source_spatials(ai)%coord(1, i)
@@ -190,7 +232,7 @@ contains
190232

191233
if (bubbles) then
192234
if (num_fluids > 2) then
193-
!$acc loop reduction(+:myRho,B_tait,small_gamma)
235+
!$acc loop seq
194236
do q = 1, num_fluids - 1
195237
myRho = myRho + myalpha_rho(q)
196238
B_tait = B_tait + myalpha(q)*pi_infs(q)
@@ -204,7 +246,7 @@ contains
204246
end if
205247

206248
if ((.not. bubbles) .or. (mpp_lim .and. (num_fluids > 2))) then
207-
!$acc loop reduction(+:myRho,B_tait,small_gamma)
249+
!$acc loop seq
208250
do q = 1, num_fluids
209251
myRho = myRho + myalpha_rho(q)
210252
B_tait = B_tait + myalpha(q)*pi_infs(q)
@@ -220,7 +262,7 @@ contains
220262
if (pulse(ai) == 2) gauss_sigma_time_local = f_gauss_sigma_time_local(gauss_conv_flag, ai, c)
221263

222264
! Update momentum source term
223-
call s_source_temporal(sim_time, c, ai, mom_label, frequency_local, gauss_sigma_time_local, source_temporal)
265+
call s_source_temporal(sim_time, c, ai, mom_label, frequency_local, gauss_sigma_time_local, source_temporal, sum_BB)
224266
mom_src_diff = source_temporal*source_spatials(ai)%val(i)
225267

226268
if (dipole(ai)) then ! Double amplitude & No momentum source term (only works for Planar)
@@ -257,7 +299,7 @@ contains
257299
mass_src_diff = mom_src_diff/c
258300
else ! Spherical or cylindrical support
259301
! Mass source term must be calculated differently using a correction term for spherical and cylindrical support
260-
call s_source_temporal(sim_time, c, ai, mass_label, frequency_local, gauss_sigma_time_local, source_temporal)
302+
call s_source_temporal(sim_time, c, ai, mass_label, frequency_local, gauss_sigma_time_local, source_temporal, sum_BB)
261303
mass_src_diff = source_temporal*source_spatials(ai)%val(i)
262304
end if
263305
mass_src(j, k, l) = mass_src(j, k, l) + mass_src_diff
@@ -297,10 +339,10 @@ contains
297339
!! @param frequency_local Frequency at the spatial location for sine and square waves
298340
!! @param gauss_sigma_time_local sigma in time for Gaussian pulse
299341
!! @param source Source term amplitude
300-
subroutine s_source_temporal(sim_time, c, ai, term_index, frequency_local, gauss_sigma_time_local, source)
342+
subroutine s_source_temporal(sim_time, c, ai, term_index, frequency_local, gauss_sigma_time_local, source, sum_BB)
301343
!$acc routine seq
302344
integer, intent(in) :: ai, term_index
303-
real(kind(0d0)), intent(in) :: sim_time, c
345+
real(kind(0d0)), intent(in) :: sim_time, c, sum_BB
304346
real(kind(0d0)), intent(in) :: frequency_local, gauss_sigma_time_local
305347
real(kind(0d0)), intent(out) :: source
306348

@@ -351,6 +393,8 @@ contains
351393
source = mag(ai)*sine_wave*1d2
352394
end if
353395

396+
elseif (pulse(ai) == 4) then ! Broadband wave
397+
source = sum_BB
354398
end if
355399
end subroutine s_source_temporal
356400

0 commit comments

Comments
 (0)