Skip to content

Commit

Permalink
- added Brune and Smoothed Brune source time functions
Browse files Browse the repository at this point in the history
  • Loading branch information
homnath committed Nov 17, 2023
1 parent fb8310f commit ebd0820
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/USER_MANUAL/05_running_the_solver.tex
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ \chapter{Running the Solver \texttt{xspecfem3D}}\label{cha:Running-the-Solver}
\item \texttt{latorUTM:} Set the latitude or UTM $x$ coordinate.
\item \texttt{longorUTM:} Set the longitude or UTM $y$ coordinate.
\item \texttt{depth:} Set the depth of the source (in km).
\item \texttt{source time function:} Set the type of source-time function: 0 = Gaussian function, 1 = Ricker function, 2 = Heaviside (step) function, 3 = monochromatic function, 4 = Gaussian function as defined in \citet{Meschede2011}.
\item \texttt{source time function:} Set the type of source-time function: 0 = Gaussian function, 1 = Ricker function, 2 = Heaviside (step) function, 3 = monochromatic function, 4 = Gaussian function as defined in \citet{Meschede2011}, 5 = Brune function, and 6 = Smoothed Brune function. Please note that we have implemented time derivatives of the Brune and smoothed Brune functions as the moment rate functions. For these source time functions, \texttt{hdurorf0} is the source duration or the rise time. The Brune and Smoothed Brune functions are currently implemented only for the viscoelastic simulations.
When {\texttt{USE\_RICKER\_TIME\_FUNCTION}} is turned on in the main parameter file \texttt{DATA/Par\_file},
it will override this source time function type selection and always use a Ricker wavelet.
Note that we use the standard definition of a Ricker, for a dominant frequency $f_0$:
Expand Down
79 changes: 79 additions & 0 deletions src/specfem3D/comp_source_time_function.f90
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,85 @@ end function comp_source_time_function_d2rck
!-------------------------------------------------------------------------------------------------
!

double precision function comp_source_time_function_brune(t,f0)

Check warning on line 266 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L266

Added line #L266 was not covered by tests

use constants, only: PI

implicit none

double precision, intent(in) :: t,f0

! local variables
double precision :: omega,omegat

! Brune source-time function
! Moment function
!if(t .lt. 0.d0)then
! comp_source_time_function_brune = 0.d0
!else
! omegat = 2.d0*PI*f0*t
! comp_source_time_function_brune = 1.d0 - exp( -omegat ) * (1.0d0+omegat)
!endif
! Moment rate function
if(t .lt. 0.d0)then
comp_source_time_function_brune = 0.d0

Check warning on line 287 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L286-L287

Added lines #L286 - L287 were not covered by tests
else
omega = 2.d0*PI*f0
omegat = omega*t
comp_source_time_function_brune = omega*omegat*exp( -omegat )

Check warning on line 291 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L289-L291

Added lines #L289 - L291 were not covered by tests
endif

end function comp_source_time_function_brune

Check warning on line 294 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L294

Added line #L294 was not covered by tests

!
!-------------------------------------------------------------------------------------------------
!

double precision function comp_source_time_function_smooth_brune(t,f0)

Check warning on line 300 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L300

Added line #L300 was not covered by tests

use constants, only: PI

implicit none

double precision, intent(in) :: t,f0

! local variables
double precision,parameter :: tau0=2.31d0
double precision :: omega,omegat

! Brune source-time function
! Moment function
!omegat = 2.d0*PI*f0*t
!if (t .lt. 0.d0) then
! comp_source_time_function_smooth_brune = 0.d0
!elseif (omegat .ge. 0.d0 .and. omegat .lt. tau0)then
! comp_source_time_function_smooth_brune = 1.d0 - exp(-omegat)*( 1.0d0 + omegat + &
! 0.5d0*omegat**2 - (1.5d0*omegat**3)/tau0 + (1.5d0*omegat**4)/(tau0**2) - &
! (0.5d0*omegat**5)/(tau0**3) )
!else ! (omegat .gt. tau0)then
! comp_source_time_function_smooth_brune = 1.d0 - exp( -omegat ) *
! (1.0d0+omegat)
!endif
! Moment rate function
omega = 2.d0*PI*f0
omegat = omega*t
if (t .lt. 0.d0) then
comp_source_time_function_smooth_brune = 0.d0
elseif (omegat .ge. 0.d0 .and. omegat .lt. tau0)then

Check warning on line 330 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L326-L330

Added lines #L326 - L330 were not covered by tests
comp_source_time_function_smooth_brune = ( 0.5d0*omega*(omegat**2)* &
exp(-omegat)/tau0**3 ) * ( tau0**3 - 3.d0*(tau0**2)*(omegat-3.d0) + &
3.d0*tau0*omegat*(omegat-4.d0) - (omegat**2)*(omegat-5.d0) )

Check warning on line 333 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L333

Added line #L333 was not covered by tests
else ! (omegat .gt. tau0)then
comp_source_time_function_smooth_brune = omega*omegat*exp( -omegat )

Check warning on line 335 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L335

Added line #L335 was not covered by tests
endif

end function comp_source_time_function_smooth_brune

Check warning on line 338 in src/specfem3D/comp_source_time_function.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/comp_source_time_function.f90#L338

Added line #L338 was not covered by tests

!
!-------------------------------------------------------------------------------------------------
!



double precision function comp_source_time_function_mono(t,f0)

Expand Down
13 changes: 13 additions & 0 deletions src/specfem3D/compute_add_sources_viscoelastic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ double precision function get_stf_viscoelastic(time_source_dble,isource,it_tmp_e

double precision, external :: comp_source_time_function,comp_source_time_function_rickr, &
comp_source_time_function_gauss,comp_source_time_function_gauss_2, &
comp_source_time_function_brune,comp_source_time_function_smooth_brune, &
comp_source_time_function_mono,comp_source_time_function_ext

! external source time function
Expand Down Expand Up @@ -890,6 +891,18 @@ double precision function get_stf_viscoelastic(time_source_dble,isource,it_tmp_e
case (4)
! Gaussian source time function by Meschede et al. (2011)
stf = comp_source_time_function_gauss_2(time_source_dble,hdur(isource))
case (5)
! Brune source time function
! hdur is the source duration or the rise time
! Frequency parameter:
f0=1.d0/hdur(isource)
stf = comp_source_time_function_brune(time_source_dble,f0)

Check warning on line 899 in src/specfem3D/compute_add_sources_viscoelastic.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/compute_add_sources_viscoelastic.F90#L898-L899

Added lines #L898 - L899 were not covered by tests
case (6)
! Smoothed Brune source time function
! hdur is the source duration or the rise time
! Frequency parameter:
f0=1.d0/hdur(isource)
stf = comp_source_time_function_smooth_brune(time_source_dble,f0)

Check warning on line 905 in src/specfem3D/compute_add_sources_viscoelastic.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/compute_add_sources_viscoelastic.F90#L904-L905

Added lines #L904 - L905 were not covered by tests
case default
stop 'unsupported force_stf value!'
end select
Expand Down
14 changes: 14 additions & 0 deletions src/specfem3D/get_force.f90
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ subroutine get_force(FORCESOLUTION,tshift_src,hdur,lat,long,depth,NSOURCES, &
! null half-duration indicates a Dirac
! replace with very short Gaussian function
if (hdur(isource) < 5. * DT ) hdur(isource) = 5. * DT
case (5)
! Brune source time function
! half-duration is the rise time
! (see constants.h: TINYVAL = 1.d-9 )
if (hdur(isource) < TINYVAL ) then
stop 'Error set force period, make sure all forces have a non-zero rise time'

Check warning on line 258 in src/specfem3D/get_force.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/get_force.f90#L257-L258

Added lines #L257 - L258 were not covered by tests
endif
case (6)
! Smoothed Brune source time function
! half-duration is the rise time
! (see constants.h: TINYVAL = 1.d-9 )
if (hdur(isource) < TINYVAL ) then
stop 'Error set force period, make sure all forces have a non-zero rise time'

Check warning on line 265 in src/specfem3D/get_force.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/get_force.f90#L264-L265

Added lines #L264 - L265 were not covered by tests
endif
case default
stop 'unsupported source time function type (force_stf) value!'
end select
Expand Down
12 changes: 12 additions & 0 deletions src/specfem3D/locate_source.F90
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,18 @@ subroutine locate_source()
! Gaussian by Meschede et al. (2011)
write(IMAIN,*) ' using Gaussian source time function by Meschede et al. (2011), eq.(2)'
write(IMAIN,*) ' tau: ',hdur(isource),' seconds'
case (5)
! Brune
write(IMAIN,*) ' using Brune source time function'

Check warning on line 510 in src/specfem3D/locate_source.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/locate_source.F90#L510

Added line #L510 was not covered by tests
! prints rise time for point forces
write(IMAIN,*)
write(IMAIN,*) ' rise time: ',hdur(isource),' seconds'

Check warning on line 513 in src/specfem3D/locate_source.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/locate_source.F90#L512-L513

Added lines #L512 - L513 were not covered by tests
case (6)
! Smoothed Brune
write(IMAIN,*) ' using Smoothed Brune source time function'

Check warning on line 516 in src/specfem3D/locate_source.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/locate_source.F90#L516

Added line #L516 was not covered by tests
! prints rise time for point forces
write(IMAIN,*)
write(IMAIN,*) ' rise time: ',hdur(isource),' seconds'

Check warning on line 519 in src/specfem3D/locate_source.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/locate_source.F90#L518-L519

Added lines #L518 - L519 were not covered by tests
case default
stop 'unsupported force_stf value!'
end select
Expand Down
8 changes: 8 additions & 0 deletions src/specfem3D/setup_sources_receivers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ subroutine setup_stf_constants()
case (4)
! Gaussian source time function by Meschede et al. (2011)
t0 = min(t0,1.5d0 * (tshift_src(isource) - hdur(isource)))
case (5)
! Brune
! This needs to be CHECKED!!!
t0 = min(t0,1.5d0 * (tshift_src(isource) - hdur(isource)))

Check warning on line 467 in src/specfem3D/setup_sources_receivers.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/setup_sources_receivers.f90#L467

Added line #L467 was not covered by tests
case (6)
! Smotthed Brune
! This needs to be CHECKED!!!
t0 = min(t0,1.5d0 * (tshift_src(isource) - hdur(isource)))

Check warning on line 471 in src/specfem3D/setup_sources_receivers.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/setup_sources_receivers.f90#L471

Added line #L471 was not covered by tests
case default
stop 'unsupported force_stf value!'
end select
Expand Down

0 comments on commit ebd0820

Please sign in to comment.