Skip to content

Commit 5096ed8

Browse files
committed
Add broadband frequency input parameters
1 parent 5b212e3 commit 5096ed8

File tree

9 files changed

+74
-32
lines changed

9 files changed

+74
-32
lines changed

docs/documentation/case.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -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 |

examples/2D_acoustic_broadband/case.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
'p' : 0,
1818
'dt' : 5e-7,
1919
't_step_start' : 0,
20-
't_step_stop' : 50000,
21-
't_step_save' : 500,
20+
't_step_stop' : 1000,
21+
't_step_save' : 10,
2222
# ==========================================================================
2323

2424
# Simulation Algorithm Parameters ==========================================
@@ -80,11 +80,14 @@
8080
'acoustic(1)%length' : 0.1,
8181
'acoustic(1)%pulse' : 4,
8282
'acoustic(1)%npulse' : 1000000,
83-
'acoustic(1)%mag' : 10.,
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.,
8487
# ==========================================================================
8588

8689
# Fluids Physical Parameters ===============================================
87-
'fluid_pp(1)%gamma' : 1.E+00/(4.4E+00-1.E+00),
90+
'fluid_pp(1)%gamma' : 1.E+00/(1.4E+00-1.E+00),
8891
'fluid_pp(1)%pi_inf' : 0,
8992
# ==========================================================================
9093
}))

src/common/m_constants.fpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ 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-
29-
!< Broadband acoustic source constant (reference: Tam et al. JSV 2005)
30-
integer, parameter :: num_broadband_freq = 100 !< The number of sine wave frequencies in broadband acoustic source.
31-
real(kind(0d0)), parameter :: broadband_freq_lowest = 500d0 !< The lower sine wave frequency bound in broadband acoustic source.
32-
real(kind(0d0)), parameter :: broadband_bandwidth = 100d0 !< The bandwidth of the discretized sine wave frequencies.
3328
real(kind(0d0)), parameter :: broadband_spectral_level_constant = 20d0 !< The constant to scale the spectral level at the lower frequency bound
3429
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
3530

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: 33 additions & 16 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,7 @@ contains
6366
subroutine s_initialize_acoustic_src
6467
integer :: i, j !< generic loop variables
6568

66-
@:ALLOCATE_GLOBAL(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_GLOBAL(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))
6770
do i = 1, num_source
6871
do j = 1, 3
6972
loc_acoustic(j, i) = acoustic(i)%loc(j)
@@ -85,6 +88,10 @@ contains
8588
element_spacing_angle(i) = acoustic(i)%element_spacing_angle
8689
element_polygon_ratio(i) = acoustic(i)%element_polygon_ratio
8790
num_elements(i) = acoustic(i)%num_elements
91+
bb_num_freq(i) = acoustic(i)%bb_num_freq
92+
bb_bandwidth(i) = acoustic(i)%bb_bandwidth
93+
bb_lowest_freq(i) = acoustic(i)%bb_lowest_freq
94+
8895
if (acoustic(i)%element_on == dflt_int) then
8996
element_on(i) = 0
9097
else
@@ -101,7 +108,7 @@ contains
101108
delay(i) = acoustic(i)%delay
102109
end if
103110
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)
111+
!$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)
105112

106113
@:ALLOCATE_GLOBAL(mass_src(0:m, 0:n, 0:p))
107114
@:ALLOCATE_GLOBAL(mom_src(1:num_dims, 0:m, 0:n, 0:p))
@@ -136,11 +143,11 @@ contains
136143
real(kind(0d0)) :: frequency_local, gauss_sigma_time_local
137144
real(kind(0d0)) :: mass_src_diff, mom_src_diff
138145
real(kind(0d0)) :: source_temporal
139-
real(kind(0d0)), dimension(1:num_broadband_freq) :: period_BB !< period of each sine wave in broadband source
140-
real(kind(0d0)), dimension(1:num_broadband_freq) :: sl_BB !< spectral level at each frequency
141-
real(kind(0d0)), dimension(1:num_broadband_freq) :: ffre_BB !< source term corresponding to each frequency
142-
real(kind(0d0)), dimension(1:num_broadband_freq) :: phi_rn !< random phase shift for each frequency
146+
real(kind(0d0)) :: period_BB !< period of each sine wave in broadband source
147+
real(kind(0d0)) :: sl_BB !< spectral level at each frequency
148+
real(kind(0d0)) :: ffre_BB !< source term corresponding to each frequency
143149
real(kind(0d0)) :: sum_BB !< total source term for the broadband wave
150+
real(kind(0d0)), allocatable, dimension(:) :: phi_rn !< random phase shift for each frequency
144151

145152
integer :: i, j, k, l, q !< generic loop variables
146153
integer :: ai !< acoustic source index
@@ -176,23 +183,33 @@ contains
176183

177184
num_points = source_spatials_num_points(ai) ! Use scalar to force firstprivate to prevent GPU bug
178185

179-
call random_number(phi_rn(1:num_broadband_freq))
180-
! Ensure all the ranks have the same random phase shift
181-
call s_mpi_send_random_number(phi_rn)
186+
! Calculate the broadband source
187+
period_BB = 0d0
188+
sl_BB = 0d0
189+
ffre_BB = 0d0
182190
sum_BB = 0d0
183191

192+
! Allocate buffers for random phase shift
193+
allocate (phi_rn(1:bb_num_freq(ai)))
194+
195+
call random_number(phi_rn(1:bb_num_freq(ai)))
196+
! Ensure all the ranks have the same random phase shift
197+
call s_mpi_send_random_number(phi_rn, bb_num_freq(ai))
198+
184199
!$acc loop reduction(+:sum_BB)
185-
do k = 1, num_broadband_freq
200+
do k = 1, bb_num_freq(ai)
186201
! Acoustic period of the wave at each discrete frequency
187-
period_BB(k) = 1d0/(broadband_freq_lowest + k*broadband_bandwidth)
202+
period_BB = 1d0/(bb_lowest_freq(ai) + k*bb_bandwidth(ai))
188203
! Spectral level at each frequency
189-
sl_BB(k) = broadband_spectral_level_constant*mag(ai) + k*mag(ai)/broadband_spectral_level_growth_rate
204+
sl_BB = broadband_spectral_level_constant*mag(ai) + k*mag(ai)/broadband_spectral_level_growth_rate
190205
! Source term corresponding to each frequencies
191-
ffre_BB(k) = dsqrt((2d0*sl_BB(k)*broadband_bandwidth))*cos((sim_time)*2d0*pi/period_BB(k) + 2d0*pi*phi_rn(k))
206+
ffre_BB = dsqrt((2d0*sl_BB*bb_bandwidth(ai)))*cos((sim_time)*2d0*pi/period_BB + 2d0*pi*phi_rn(k))
192207
! Sum up the source term of each frequency to obtain the total source term for broadband wave
193-
sum_BB = sum_BB + ffre_BB(k)
208+
sum_BB = sum_BB + ffre_BB
194209
end do
195210

211+
deallocate (phi_rn)
212+
196213
!$acc parallel loop gang vector default(present) private(myalpha, myalpha_rho)
197214
do i = 1, num_points
198215
j = source_spatials(ai)%coord(1, i)

src/simulation/m_checker.fpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ contains
175175
(f_is_default(acoustic(j)%gauss_sigma_time) .eqv. f_is_default(acoustic(j)%gauss_sigma_dist)), &
176176
"One and only one of acoustic("//trim(jStr)//")%gauss_sigma_time "// &
177177
"or acoustic("//trim(jStr)//")%gauss_sigma_dist must be specified for pulse = 2")
178+
@:PROHIBIT(acoustic(j)%pulse == 4 .and. acoustic(j)%bb_num_freq == dflt_int, &
179+
"The number of broadband frequencies acoustic("//trim(jStr)//")%bb_num_freq must be specified for pulse = 4")
180+
@:PROHIBIT(acoustic(j)%pulse == 4 .and. f_is_default(acoustic(j)%bb_bandwidth), &
181+
"The broadband wave band width acoustic("//trim(jStr)//")%bb_bandwidth must be specified for pulse = 4")
182+
@:PROHIBIT(acoustic(j)%pulse == 4 .and. f_is_default(acoustic(j)%bb_lowest_freq), &
183+
"The broadband wave lower frequency bound acoustic("//trim(jStr)//")%bb_lowest_freq must be specified for pulse = 4")
178184
179185
@:PROHIBIT(f_is_default(acoustic(j)%npulse), &
180186
"acoustic("//trim(jStr)//")%npulse must be specified")

src/simulation/m_global_parameters.fpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,12 @@ contains
644644
acoustic(j)%rotate_angle = dflt_real
645645
acoustic(j)%num_elements = dflt_int
646646
acoustic(j)%element_on = dflt_int
647+
acoustic(j)%rotate_angle = dflt_real
648+
acoustic(j)%num_elements = dflt_int
649+
acoustic(j)%element_on = dflt_int
650+
acoustic(j)%bb_num_freq = dflt_int
651+
acoustic(j)%bb_lowest_freq = dflt_real
652+
acoustic(j)%bb_bandwidth = dflt_real
647653
end do
648654

649655
fd_order = dflt_int

src/simulation/m_mpi_proxy.fpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,15 @@ contains
252252
253253
call MPI_BCAST(acoustic(j)%dipole, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
254254
255-
#:for VAR in [ 'pulse', 'support', 'num_elements', 'element_on' ]
255+
#:for VAR in [ 'pulse', 'support', 'num_elements', 'element_on', 'bb_num_freq' ]
256256
call MPI_BCAST(acoustic(j)%${VAR}$, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
257257
#:endfor
258258
259259
#:for VAR in [ 'mag', 'length', 'height', &
260260
'wavelength', 'frequency', 'gauss_sigma_dist', 'gauss_sigma_time', &
261261
'npulse', 'dir', 'delay', 'foc_length', 'aperture', &
262-
'element_spacing_angle', 'element_polygon_ratio', 'rotate_angle' ]
262+
'element_spacing_angle', 'element_polygon_ratio', 'rotate_angle', &
263+
'bb_bandwidth', 'bb_lowest_freq' ]
263264
call MPI_BCAST(acoustic(j)%${VAR}$, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
264265
#:endfor
265266
@@ -2332,10 +2333,11 @@ contains
23322333
23332334
end subroutine s_mpi_sendrecv_capilary_variables_buffers
23342335
2335-
subroutine s_mpi_send_random_number(phi_rn)
2336-
real(kind(0d0)), intent(inout), dimension(1:num_broadband_freq) :: phi_rn
2336+
subroutine s_mpi_send_random_number(phi_rn, num_freq)
2337+
integer, intent(in) :: num_freq
2338+
real(kind(0d0)), intent(inout), dimension(1:num_freq) :: phi_rn
23372339
#ifdef MFC_MPI
2338-
call MPI_BCAST(phi_rn, size(phi_rn), MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
2340+
call MPI_BCAST(phi_rn, num_freq, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
23392341
#endif
23402342
end subroutine s_mpi_send_random_number
23412343

toolchain/mfc/run/case_dicts.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ def analytic(self):
279279
SIMULATION[f"fluid_pp({f_id})%Re({re_id})"] = ParamType.REAL
280280

281281
for mono_id in range(1,4+1):
282-
for int_attr in ["pulse", "support", "num_elements", "element_on"]:
282+
for int_attr in ["pulse", "support", "num_elements", "element_on",
283+
"bb_num_freq"]:
283284
SIMULATION[f"acoustic({mono_id})%{int_attr}"] = ParamType.INT
284285

285286
SIMULATION[f"acoustic({mono_id})%dipole"] = ParamType.LOG
@@ -288,7 +289,7 @@ def analytic(self):
288289
"gauss_sigma_dist", "gauss_sigma_time", "npulse",
289290
"dir", "delay", "foc_length", "aperture",
290291
"element_spacing_angle", "element_polygon_ratio",
291-
"rotate_angle"]:
292+
"rotate_angle", "bb_bandwidth", "bb_lowest_freq"]:
292293
SIMULATION[f"acoustic({mono_id})%{real_attr}"] = ParamType.REAL
293294

294295
for cmp_id in range(1,3+1):

0 commit comments

Comments
 (0)