Modern Fortran utility to generate optimized finite-differences schemes
FinDiff is small Fortran utility package to generate optimized (dispersion-relation-preserving) finite difference schemes for regular stencils. Along with the standard central, forward and backward finite difference schemes optimized in the sense of Taylor, it can also compute optimized central finite difference schemes for the first and second derivatives.
FinDiff can be built with the Fortran Package Manager fpm using the provided fpm.toml like so:
fpm build --releaseOnly quadrapule precision (real128) is currently supported. To use FinDiff within your fpm project, add the following line to your fpm.toml file:
[dependencies]
FinDiff = {git="https://github.com/loiseaujc/FinDiff.git"}In 1993, Tam & Webb proposed dispersion-relation-preserving (DRP) finite difference schemes. They illustrated their approach by deriving a 7 points-DRP scheme which is fourth-order accurate while also minimizing the dispersion error
where
program tam_webb
use FinDiff
implicit none (type, external)
integer, parameter :: npts = 7, order = 4, nth = 1
real(qp), parameter :: pi = 4 * atan(1.0_qp)
real(qp), parameter :: alpha_max = pi/2
real(qp), allocatable :: weights(:)
!> Tam & Webb DRP scheme.
weights = central_drp_findiff(npts=npts, order=order, nth=nth, alpha_max=alpha_max)
print *, weights
end program tam_webb- K. Kumari, R. Bhattacharya and D. A. Donzis. A unified approach for deriving optimal finite differences. Journal of Computational Physics, vol. 399, 2019. [PDF]
- C. K. W. Tam and J. C. Webb. Dispersion-Relation-Preserving Finite Difference Schemes for Computational Acoustics. Journal of Computational Physics, vol. 107, 1993. [PDF]
