tem_eval_acoustic_pulse Function

public function tem_eval_acoustic_pulse(me, coord, time, n) result(res)

Evaluate the acoustic pulse at given points in space for one point in time.

Exact solution for an acoustic wave from a Gaussian pulse in pressure. See Tam: Computational Acoustics, a wave number approach. Appendix G.3. Any point may be probed, the solution at the center is properly defined with a finite value.

Arguments

Type IntentOptional Attributes Name
type(tem_acoustic_pulse_type), intent(in) :: me

Definition of the acoustic pulse to evaluate

real(kind=rk), intent(in) :: coord(n,3)

3D Coordinates of all points.

real(kind=rk), intent(in) :: time

Point in time to evaluate the points at.

integer, intent(in) :: n

Number of different points to evaluate the acoustic pulse at.

Return Value real(kind=rk), (n)

Analytical solution in all n points.


Source Code

  function tem_eval_acoustic_pulse(me, coord, time, n) result(res)
    !> Definition of the acoustic pulse to evaluate
    type(tem_acoustic_pulse_type), intent(in) :: me

    !> Number of different points to evaluate the acoustic pulse at.
    integer, intent(in) :: n

    !> 3D Coordinates of all points.
    real(kind=rk), intent(in) :: coord(n,3)

    !> Point in time to evaluate the points at.
    real(kind=rk), intent(in) :: time

    !> Analytical solution in all n points.
    real(kind=rk) :: res(n)
    ! -------------------------------------------------------------------- !
    real(kind=rk) :: radius(n)
    real(kind=rk), parameter :: zero_rad = 16.0_rk * tiny(time)
    real(kind=rk) :: wavepos
    real(kind=rk) :: ampfact
    real(kind=rk) :: expfact
    ! -------------------------------------------------------------------- !

    radius = sqrt( (coord(:,1)-me%center(1))**2  &
      &           + (coord(:,2)-me%center(2))**2 &
      &           + (coord(:,3)-me%center(3))**2 )

    wavepos = me%speed_of_sound * time
    ampfact = 0.5_rk * me%amplitude
    expfact = -log(2.0_rk) / me%halfwidth**2

    where (radius > zero_rad)
      res = me%background &
        & + (ampfact/radius) * ( (radius-wavepos)                   &
        &                        * exp(expfact*(radius-wavepos)**2) &
        &                      + (radius+wavepos)                   &
        &                        * exp(expfact*(radius+wavepos)**2) )
    elsewhere
      res = me%background + me%amplitude * exp(expfact*wavepos**2)       &
        &                                * (1.0_rk + 2*expfact*wavepos**2)
    end where

  end function tem_eval_acoustic_pulse