Derivative
Derivative()
An unevaluated Derivative, which carries metadata (Dimensions, derivative order, etc) describing how the derivative will be expanded upon evaluation.
Parameters
Name | Type | Description | Default |
---|---|---|---|
expr |
expr - like | Expression for which the Derivative is produced. | required |
dims |
Dimension or tuple of Dimension | Dimensions w.r.t. which to differentiate. | required |
fd_order |
int or tuple of int | Coefficient discretization order. Note: this impacts the width of the resulting stencil. | 1 |
deriv_order |
Derivative order. | required | |
side |
Side or tuple of Side | Side of the finite difference location, centered (at x), left (at x - 1) or right (at x +1). | centered |
transpose |
Transpose | Forward (matvec=direct) or transpose (matvec=transpose) mode of the finite difference. | direct |
subs |
dict | Substitutions to apply to the finite-difference expression after evaluation. | required |
x0 |
dict | Origin (where the finite-difference is evaluated at) for the finite-difference scheme, e.g. {x: x, y: y + h_y/2}. | required |
Examples
Creation
>>> from devito import Function, Derivative, Grid
>>> grid = Grid((10, 10))
>>> x, y = grid.dimensions
>>> u = Function(name="u", grid=grid, space_order=2)
>>> Derivative(u, x)
Derivative(u(x, y), x)
This can also be obtained via the differential shortcut
>>> u.dx
Derivative(u(x, y), x)
You can also specify the order as a keyword argument
>>> Derivative(u, x, deriv_order=2)
2)) Derivative(u(x, y), (x,
Or as a tuple
>>> Derivative(u, (x, 2))
2)) Derivative(u(x, y), (x,
Once again, this can be obtained via shortcut notation
>>> u.dx2
2)) Derivative(u(x, y), (x,
Derivative object are also callable to change default setup:
>>> u.dx2(x0=x + x.spacing)
2)) Derivative(u(x, y), (x,
will create the second derivative at x=x + x.spacing. Accepted arguments for dynamic evaluation are x0
, fd_order
and side
.
Attributes
Name | Description |
---|---|
T | Transpose of the Derivative. |