jaxdf.operators.differential
Operators
derivative
Given a field $u$, it returns the field
$$ \frac{\partial}{\partial \epsilon} u, \qquad \epsilon \in {x, y, \dots } $$
Concrete implementations:
derivative(x: 'Continuous', *, axis = 0, params = None)
Derivative operator for continuous fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Continuous field | required | |
axis | Axis along which to take the derivative | 0 |
Returns:
Type | Description |
---|---|
| Continuous field |
diag_jacobian
Given a vector field $u = (u_x,u_y,\dots)$ with the same dimensions as the dimensions of the domain, it returns the diagonal of the Jacobian matrix
$$ \left( \frac{\partial u_x}{\partial x}, \frac{\partial u_y}{\partial y}, \dots \right) $$
Concrete implementations:
diag_jacobian(x: 'Continuous', *, params = None)
Diagonal Jacobian operator for continuous fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Continuous field | required |
Returns:
Type | Description |
---|---|
| The diagonal Jacobian of the field |
diag_jacobian(x: 'FiniteDifferences', *, stagger = [0], params = None)
Diagonal Jacobian operator for finite differences fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | FiniteDifferences field | required | |
stagger | Stagger of the derivative | [0] |
Returns:
Type | Description |
---|---|
| The diagonal Jacobian of the field |
diag_jacobian(x: 'FourierSeries', *, stagger = [0], correct_nyquist = True, params = None)
Diagonal Jacobian operator for Fourier series fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | FourierSeries | Input field | required |
stagger | list | Staggering value for the returned fields. The fields are staggered in the direction of their derivative. Defaults to [0]. | [0] |
correct_nyquist | bool | If | True |
Returns:
Type | Description |
---|---|
| The vector field whose components are the diagonal entries of the Jacobian of the input field. |
gradient
Given a field $u$, it returns the vector field
$$ \nabla u = \left(\frac{\partial u}{\partial x}, \frac{\partial u}{\partial y}, \dots\right) $$
Concrete implementations:
gradient(x: 'Continuous', *, params = None)
Gradient operator for continuous fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Continuous field | required |
Returns:
Type | Description |
---|---|
| The gradient of the field |
gradient(x: 'FiniteDifferences', *, stagger = [0], params = None)
Gradient operator for finite differences fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | FiniteDifferences field | required | |
stagger | Stagger of the derivative | [0] |
Returns:
Type | Description |
---|---|
| The gradient of the field |
gradient(x: 'FourierSeries', *, stagger = [0], correct_nyquist = True, params = None)
Gradient operator for Fourier series fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | FourierSeries | Input field | required |
stagger | list | Staggering value for the returned fields. The fields are staggered in the direction of their derivative. Defaults to [0]. | [0] |
correct_nyquist | bool | If | True |
Returns:
Type | Description |
---|---|
FourierSeries | The gradient of the input field. |
heterog_laplacian
Given a field $u$ and a cofficient field $c$, it returns the field
$$ \nabla_c^2 u = \nabla \cdot (c \nabla u) $$
Concrete implementations:
heterog_laplacian(x: 'FourierSeries', c: 'FourierSeries', *, params = None)
Computes the position-varying laplacian using algorithm 4 of [Johnson, 2011].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | FourierSeries | Input field | required |
c | FourierSeries | Coefficient field | required |
Returns:
Type | Description |
---|---|
| The Laplacian of the field |
laplacian
Given a scalar field $u$, it returns the scalar field
$$ \nabla^2 u = \nabla \cdot \nabla u = \sum_{\epsilon \in {x,y,\dots}} \frac{\partial^2 u}{\partial \epsilon^2} $$
Concrete implementations:
laplacian(x: 'Continuous', *, params = None)
Laplacian operator for continuous fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Continuous field | required |
Returns:
Type | Description |
---|---|
| The Laplacian of the field |
laplacian(x: 'FiniteDifferences', *, params = None)
Gradient operator for finite differences fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | FiniteDifferences field | required |
Returns:
Type | Description |
---|---|
| The gradient of the field |
laplacian(x: 'FourierSeries', *, params = None)
Laplacian operator for Fourier series fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | FourierSeries | Input field | required |
Returns:
Type | Description |
---|---|
| The Laplacian of the field |
Utilities
get_fd_coefficients(x, order=1, stagger=0)
Returnst the stencil coefficients for a 1D Finite Differences derivative operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
FiniteDifferences
|
FiniteDifferences field |
required |
order |
int
|
Order of the derivative |
1
|
stagger |
Union[float, int]
|
Stagger of the derivative |
0
|
Returns:
Type | Description |
---|---|
Stencil coefficients |
fd_derivative_init(x, axis=0, stagger=0, *args, **kwargs)
Initializes the stencils for FiniteDifferences derivatives. Accepts an arbitrary number of positional and keyword arguments after the mandatory arguments, which are ignored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
FiniteDifferences
|
FiniteDifferences field |
required |
axis |
Axis along which to take the derivative |
0
|
|
stagger |
Stagger of the derivative |
0
|
Returns:
Type | Description |
---|---|
Stencil coefficients |
fd_diag_jacobian_init(x, stagger, *args, **kwargs)
Initializes the parameters for the diagonal Jacobian of a FiniteDifferences field. Accepts an arbitrary number of positional and keyword arguments after the mandatory arguments, which are ignored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
FiniteDifferences
|
FiniteDifferences field |
required |
stagger |
Stagger of the derivative |
required |
Returns:
Type | Description |
---|---|
Stencil coefficients |