(UNDER CONSTRUCTION)
This library provides a set of functions for computation derivatives using spectral methods. The lib depends on FFTW library. The library is compatible with W-SLDA Toolkit however, it can be used as standalone lib. It is written in C99 standard.
Name convention
Generic name of a function is wderiv_operation_Nd_t, where:
-
wderiv: fixed, function belongs to wderiv lib, -
operation:-
dfdx:\frac{\partial f}{\partial x} -
dfdy:\frac{\partial f}{\partial y} -
dfdz:\frac{\partial f}{\partial z} -
d2fdx2:\frac{\partial^2 f}{\partial x^2} -
d2fdy2:\frac{\partial^2 f}{\partial y^2} -
d2fdz2:\frac{\partial^2 f}{\partial z^2} -
dnfdxn:\frac{\partial^n f}{\partial x^n} -
dnfdyn:\frac{\partial^n f}{\partial y^n} -
dnfdzn:\frac{\partial^n f}{\partial z^n} -
gradient:(\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z}) -
gradient2:|\nabla f|^2, see here for computation details -
laplace:\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2} + \frac{\partial^2 f}{\partial z^2} -
divergence:\frac{\partial f}{\partial x} + \frac{\partial f}{\partial y} + \frac{\partial f}{\partial z} -
curl:(\frac{\partial f_y}{\partial z} - \frac{\partial f_z}{\partial y},\frac{\partial f_z}{\partial x} - \frac{\partial f_x}{\partial z},\frac{\partial f_x}{\partial y} - \frac{\partial f_y}{\partial x})
-
-
N:-
1for 1D problems -
2for 2D problems -
3for 3D problems
-
-
t:-
rfor real problems -
cfor complex problems
-
Function Documentation
3D derivatives:
Basic 3D derivative function:
int wderiv_derivative_3d_r(int direction, int n, double *f, double *deriv)
Function computes n-th derivative with respect to direction of 3D real function f(x,y,z): \frac{\partial^n f}{\partial t^n}.
-
direction- predefined integer corresponding to direction of derivative:WDERIV_DXorWDERIV_DYorWDERIV_DZ -
f- pointer to input function which is array of size [nx*ny*nz] -
deriv- pointer to output derivative function which is array of size [nx*ny*nz] -
return- error code
deriv can be the same pointer as f, then result overwrites input.
First 3D derivative functions:
int wderiv_dfdx_3d_r(double *f, double *dfdx)
Function computes first derivative with respect to x of 3D real function f(x,y,z): \frac{\partial f}{\partial x}.
-
f- pointer to input function which is array of size [nx*ny*nz] -
dfdx- pointer to output derivative function which is array of size [nx*ny*nz] -
return- error code
dfdx can be the same pointer as f, then result overwrites input.
int wderiv_dfdy_3d_r(double *f, double *dfdy)
Function computes first derivative with respect to y of 3D real function f(x,y,z): \frac{\partial f}{\partial y}.
-
f- pointer to input function which is array of size [nxnynz] -
dfdy- pointer to output derivative function which is array of size [nxnynz] -
return- error code
dfdy can be the same pointer as f, then result overwrites input.
int wderiv_dfdz_3d_r(double *f, double *dfdz)
Function computes first derivative with respect to z of 3D real function f(x,y,z): \frac{\partial f}{\partial x}.
-
f- pointer to input function which is array of size [nxnynz] -
dfdz- pointer to output derivative function which is array of size [nxnynz] -
return- error code
dfdz can be the same pointer as f, then result overwrites input.
Second 3D derivative functions:
int wderiv_d2fdx2_3d_r(double *f, double *d2fdx2)
Function computes second derivative with respect to x of 3D real function f(x,y,z): \frac{\partial^2 f}{\partial x^2}.
-
f- pointer to input function which is array of size [nx*ny*nz] -
d2fdx2- pointer to output derivative function which is array of size [nx*ny*nz] -
return- error code
d2fdx2 can be the same pointer as f, then result overwrites input.
int wderiv_d2fdy2_3d_r(double *f, double *d2fdy2)
Function computes second derivative with respect to y of 3D real function f(x,y,z): \frac{\partial^2 f}{\partial y^2}.
-
f- pointer to input function which is array of size [nx*ny*nz] -
d2fdy2- pointer to output derivative function which is array of size [nx*ny*nz] -
return- error code
d2fdy2 can be the same pointer as f, then result overwrites input.
int wderiv_d2fdz2_3d_r(double *f, double *d2fdz2)
Function computes second derivative with respect to z of 3D real function f(x,y,z): (\frac{d^2f}{dz^2}).
-
f- pointer to input function which is array of size [nxnynz] -
d2fdz2- pointer to output derivative function which is array of size [nxnynz] -
return- error code
d2fdz2 can be the same pointer as f, then result overwrites input.
/**
- Function computes gradient
- of 3D real function f(x,y,z)
- @param f pointer to function, array of size [nxnynz] (INPUT)
- @param dfdx pointer to function, array of size [nxnynz] (OUTPUT)
- @param dfdy pointer to function, array of size [nxnynz] (OUTPUT)
- @param dfdz pointer to function, array of size [nxnynz] (OUTPUT)
- @return error code
- */ int wderiv_gradient_3d_r(double *f, double *dfdx, double *dfdy, double *dfdz);
/**
- Function computes second derivative with respect to z (d^2f/dz^2)
- of 3D complex function f(x,y,z)
- @param f pointer to function, array of size [nxnynz] (INPUT)
- @param d2fdz2 pointer to function, array of size [nxnynz] (OUTPUT)
-
NOTE: d2fdz2 can be the same pointer as f, then result overwrites input - @return error code
- */ int wderiv_d2fdz2_3d_c(double complex *f, double complex *d2fdz2);
/**
- Function computes n-th derivative with respect to x (d^nf/dx^n)
- of 1D complex function f(x)
- @param n order of derivative
- @param f pointer to function, array of size [nx] (INPUT)
- @param dnfdxn pointer to function, array of size [nx] (OUTPUT)
-
NOTE: dnfdxn can be the same pointer as f, then result overwrites input - @return error code
- */ int wderiv_dnfdxn_1d_c(int n, double complex *f, double complex *dnfdxn);