fd_partial_derivative
fd_partial_derivative(gs, h, direction)
Finite difference partial derivative on a grid
Given a regular finite-difference grid described by the number of nodes on each side, the grid spacing and a desired direction, construct a sparse matrix to compute first partial derivatives in the given direction onto the staggered grid in that direction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gs |
numpy int array
|
Grid size [nx,ny(,nz)] |
required |
h |
numpy double array
|
Spacing between grid points [hx,hy(,hz)] |
required |
direction |
int
|
Direction with respect to which the derivative is computed (x: 0, y: 1, z: 2) |
required |
Returns:
Name | Type | Description |
---|---|---|
W |
scipy sparse.csr_matrix
|
Sparse matrix of partial derivative |
See Also
fd_grad, fd_interpolate.
Notes
For any function f defined on a gs by gs grid, then W @ f contains the directional derivative on a staggered grid
Examples:
TO-DO
Source code in src/gpytoolbox/fd_partial_derivative.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|