Created on Wed Dec 7 11:35:44 2016
@author: Filippo Broggini (ETH Zürich) - filippo.broggini@erdw.ethz.ch
Functions
dispersion (vmin, dx, fc[, coeff]) |
Compute maximum dt for a stable simulation. |
fdtaylorcoeff (k, xbar, x) |
Compute coefficients for finite difference approximation. |
stability (vmax, dx, dt) |
Compute maximum dt for a stable simulation. |
serendipyty.seismic.utils.fd.
stability
(vmax, dx, dt)[source]¶Compute maximum dt for a stable simulation.
Parameters: | vmax: float
dx: float
dt: float
|
---|---|
Returns: | dt_stable: float
|
serendipyty.seismic.utils.fd.
dispersion
(vmin, dx, fc, coeff=2.0)[source]¶Compute maximum dt for a stable simulation.
Parameters: | vmin: float
dx: float
fc: float
coeff: float
|
---|---|
Returns: | dt_stable: float
|
serendipyty.seismic.utils.fd.
fdtaylorcoeff
(k, xbar, x)[source]¶Compute coefficients for finite difference approximation.
Compute coefficients for finite difference approximation for the derivative of order k at xbar based on grid values at points in x.
Notes
This function returns a row vector c of dimension 1 by n, where n=length(x), containing coefficients to approximate \(u^{(k)}(xbar)\), the k’th derivative of u evaluated at xbar, based on n values of u at x(1), x(2), … x(n). If U is a column vector containing u(x) at these n points, then c*U will give the approximation to \(u^{(k)}(xbar)\). Note for k=0 this can be used to evaluate the interpolating polynomial itself. Requires length(x) > k. Usually the elements x(i) are monotonically increasing and x(1) <= xbar <= x(n), but neither condition is required. The x values need not be equally spaced but must be distinct. This program should give the same results as fdcoeffV.m, but for large values of n is much more stable numerically. Based on the program “weights” in [R911].
Note: Forberg’s algorithm can be used to simultaneously compute the coefficients for derivatives of order 0, 1, …, m where m <= n-1. This gives a coefficient matrix C(1:n,1:m) whose k’th column gives the coefficients for the k’th derivative. In this version we set m=k and only compute the coefficients for derivatives of order up to order k, and then return only the k’th column of the resulting C matrix (converted to a row vector). This routine is then compatible with fdcoeffV. It can be easily modified to return the whole array if desired.
From http://www.amath.washington.edu/~rjl/fdmbook/ (2007).
References
[R911] | (1, 2) B. Fornberg, “Calculation of weights in finite difference formulas”, SIAM Review 40 (1998), pp. 685-691. |