Skip to content

Commit accc829

Browse files
committed
BB
Add BB
1 parent 4396130 commit accc829

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/simulation/m_acoustic_src.fpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ contains
173173
real(kind(0d0)) :: frequency_local, gauss_sigma_time_local
174174
real(kind(0d0)) :: mass_src_diff, mom_src_diff
175175
real(kind(0d0)) :: source_temporal
176+
real(kind(0d0)), dimension(1:100) :: f_BB, period_BB, sl_BB, bwid_BB, ffre_BB, phi_rn
177+
real(kind(0d0)) :: sum_BB
176178

177179
integer :: i, j, k, l, q !< generic loop variables
178180
integer :: ai !< acoustic source index
@@ -208,6 +210,20 @@ contains
208210

209211
num_points = source_spatials_num_points(ai) ! Use scalar to force firstprivate to prevent GPU bug
210212

213+
call random_number(phi_rn(1:100))
214+
call s_mpi_send_random_number(phi_rn)
215+
sum_BB = 0d0
216+
217+
!$acc loop
218+
do k = 1, 100
219+
f_BB(k) = 500d0 + k*100d0 ! Discrete frequency specturm center
220+
period_BB(k) = 1d0/f_BB(k)
221+
sl_BB(k) = 20d0*mag(ai) + k*mag(ai)/10 ! Spectral level at each frequency
222+
bwid_BB(k) = 100d0 ! Bandwidth
223+
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))
224+
sum_BB = sum_BB + ffre_BB(k)
225+
end do
226+
211227
!$acc parallel loop gang vector default(present) private(myalpha, myalpha_rho)
212228
do i = 1, num_points
213229
j = source_spatials(ai)%coord(1, i)
@@ -257,7 +273,7 @@ contains
257273
if (pulse(ai) == 2) gauss_sigma_time_local = f_gauss_sigma_time_local(gauss_conv_flag, ai, c)
258274

259275
! Update momentum source term
260-
call s_source_temporal(sim_time, c, ai, mom_label, frequency_local, gauss_sigma_time_local, source_temporal)
276+
call s_source_temporal(sim_time, c, ai, mom_label, frequency_local, gauss_sigma_time_local, source_temporal, sum_BB)
261277
mom_src_diff = source_temporal*source_spatials(ai)%val(i)
262278

263279
if (dipole(ai)) then ! Double amplitude & No momentum source term (only works for Planar)
@@ -294,7 +310,7 @@ contains
294310
mass_src_diff = mom_src_diff/c
295311
else ! Spherical or cylindrical support
296312
! Mass source term must be calculated differently using a correction term for spherical and cylindrical support
297-
call s_source_temporal(sim_time, c, ai, mass_label, frequency_local, gauss_sigma_time_local, source_temporal)
313+
call s_source_temporal(sim_time, c, ai, mass_label, frequency_local, gauss_sigma_time_local, source_temporal, sum_BB)
298314
mass_src_diff = source_temporal*source_spatials(ai)%val(i)
299315
end if
300316
mass_src(j, k, l) = mass_src(j, k, l) + mass_src_diff
@@ -334,10 +350,10 @@ contains
334350
!! @param frequency_local Frequency at the spatial location for sine and square waves
335351
!! @param gauss_sigma_time_local sigma in time for Gaussian pulse
336352
!! @param source Source term amplitude
337-
subroutine s_source_temporal(sim_time, c, ai, term_index, frequency_local, gauss_sigma_time_local, source)
353+
subroutine s_source_temporal(sim_time, c, ai, term_index, frequency_local, gauss_sigma_time_local, source, sum_BB)
338354
!$acc routine seq
339355
integer, intent(in) :: ai, term_index
340-
real(kind(0d0)), intent(in) :: sim_time, c
356+
real(kind(0d0)), intent(in) :: sim_time, c, sum_BB
341357
real(kind(0d0)), intent(in) :: frequency_local, gauss_sigma_time_local
342358
real(kind(0d0)), intent(out) :: source
343359

@@ -387,6 +403,10 @@ contains
387403
if (abs(sine_wave) < 1d-2) then
388404
source = mag(ai)*sine_wave*1d2
389405
end if
406+
407+
elseif (pulse(ai) == 4) then
408+
! TO DO: delay broadband acoustic source
409+
source = sum_BB
390410

391411
end if
392412
end subroutine s_source_temporal

src/simulation/m_mpi_proxy.fpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,13 @@ contains
23332333
23342334
end subroutine s_mpi_sendrecv_capilary_variables_buffers
23352335
2336+
subroutine s_mpi_send_random_number(phi_rn)
2337+
real(kind(0d0)), dimension(1:100) :: phi_rn
2338+
#ifdef MFC_MPI
2339+
call MPI_BCAST(phi_rn, size(phi_rn), MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
2340+
#endif
2341+
end subroutine s_mpi_send_random_number
2342+
23362343
!> Module deallocation and/or disassociation procedures
23372344
subroutine s_finalize_mpi_proxy_module
23382345

0 commit comments

Comments
 (0)