Skip to content

Commit d0dd8db

Browse files
committed
Fix magic number and case file checker
1 parent d664c1e commit d0dd8db

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

docs/documentation/case.md

Lines changed: 2 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) |
@@ -576,7 +576,7 @@ Details of the transducer acoustic source model can be found in [Maeda and Colon
576576

577577
- `%%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).
578578

579-
- `%%pulse` specifies the acoustic wave form. `%%pulse = 1`, `2`, and `3` correspond to sinusoidal wave, Gaussian wave, and square wave, respectively.
579+
- `%%pulse` specifies the acoustic wave form. `%%pulse = 1`, `2`, `3` and `4` correspond to sinusoidal wave, Gaussian wave, square wave and broadband wave, respectively.
580580

581581
- `%%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.
582582

src/common/m_constants.fpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ module m_constants
2323
integer, parameter :: pathlen_max = 400
2424
integer, parameter :: nnode = 4 !< Number of QBMM nodes
2525
real(kind(0d0)), parameter :: capillary_cutoff = 1e-6 !< color function gradient magnitude at which to apply the surface tension fluxes
26-
real(kind(0d0)), parameter :: acoustic_spatial_support_width = 2.5d0 !< Spatial support width of acoustic source, used in s_source_spatial
26+
real(kind(0d0)), parameter :: acoustic_spatial_support_width = 20d0 !< 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
2828

29+
!< Broadband acoustic source constant (reference: Tam et al. JSV 2004 )
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.
33+
real(kind(0d0)), parameter :: broadband_spectral_level_constant = 20d0 !< The constant to scale the spectral level at the lower frequency bound
34+
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
35+
2936
end module m_constants

src/simulation/m_acoustic_src.fpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ contains
136136
real(kind(0d0)) :: frequency_local, gauss_sigma_time_local
137137
real(kind(0d0)) :: mass_src_diff, mom_src_diff
138138
real(kind(0d0)) :: source_temporal
139-
real(kind(0d0)), dimension(1:100) :: f_BB, period_BB, sl_BB, bwid_BB, ffre_BB, phi_rn
139+
real(kind(0d0)), dimension(1:num_broadband_freq) :: period_BB, sl_BB, ffre_BB, phi_rn ! broadband source variables
140140
real(kind(0d0)) :: sum_BB
141141

142142
integer :: i, j, k, l, q !< generic loop variables
@@ -178,13 +178,11 @@ contains
178178
sum_BB = 0d0
179179

180180
!$acc loop
181-
do k = 1, 100
182-
f_BB(k) = 500d0 + k*100d0 ! Discrete frequency specturm center
183-
period_BB(k) = 1d0/f_BB(k)
184-
sl_BB(k) = 20d0*mag(ai) + k*mag(ai)/10 ! Spectral level at each frequency
185-
bwid_BB(k) = 100d0 ! Bandwidth
186-
ffre_BB(k) = dsqrt((2d0*sl_BB(k)*bwid_BB(k)))*cos((sim_time)*2.d0*pi/period_BB(k) + 2d0*pi*phi_rn(k))
187-
sum_BB = sum_BB + ffre_BB(k)
181+
do k = 1, num_broadband_freq
182+
period_BB(k) = 1d0/(broadband_freq_lowest + k*broadband_bandwidth) ! Acoustic period of the wave at each discrete frequency
183+
sl_BB(k) = broadband_spectral_level_constant*mag(ai) + k*mag(ai)/broadband_spectral_level_growth_rate ! Spectral level at each frequency
184+
ffre_BB(k) = dsqrt((2d0*sl_BB(k)*broadband_bandwidth))*cos((sim_time)*2.d0*pi/period_BB(k) + 2d0*pi*phi_rn(k)) ! Source term corresponding to each frequencies
185+
sum_BB = sum_BB + ffre_BB(k) ! Total source term for the broadband wave
188186
end do
189187

190188
!$acc parallel loop gang vector default(present) private(myalpha, myalpha_rho)
@@ -367,10 +365,8 @@ contains
367365
source = mag(ai)*sine_wave*1d2
368366
end if
369367

370-
elseif (pulse(ai) == 4) then
371-
! TO DO: delay broadband acoustic source
368+
elseif (pulse(ai) == 4) then ! Broadband wave
372369
source = sum_BB
373-
374370
end if
375371
end subroutine s_source_temporal
376372

src/simulation/m_checker.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ contains
164164
"acoustic("//trim(jStr)//")%mag must be specified")
165165
@:PROHIBIT(acoustic(j)%pulse == dflt_int, &
166166
"acoustic("//trim(jStr)//")%pulse must be specified")
167-
@:PROHIBIT(.not. any(acoustic(j)%pulse == (/1, 2, 3/)), &
168-
"Only acoustic("//trim(jStr)//")%pulse = 1, 2, or 3 is allowed")
167+
@:PROHIBIT(.not. any(acoustic(j)%pulse == (/1, 2, 3, 4/)), &
168+
"Only acoustic("//trim(jStr)//")%pulse = 1, 2, 3 or 4 is allowed")
169169
170170
@:PROHIBIT(any(acoustic(j)%pulse == (/1, 3/)) .and. &
171171
(f_is_default(acoustic(j)%frequency) .eqv. f_is_default(acoustic(j)%wavelength)), &

0 commit comments

Comments
 (0)