Skip to content

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:

NameTypeDescriptionDefault
x

Continuous field

required
axis

Axis along which to take the derivative

0

Returns:

TypeDescription

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:

NameTypeDescriptionDefault
x

Continuous field

required

Returns:

TypeDescription

The diagonal Jacobian of the field

diag_jacobian(x: 'FiniteDifferences', *, stagger = [0], params = None)

Diagonal Jacobian operator for finite differences fields.

Parameters:

NameTypeDescriptionDefault
x

FiniteDifferences field

required
stagger

Stagger of the derivative

[0]

Returns:

TypeDescription

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:

NameTypeDescriptionDefault
xFourierSeries

Input field

required
staggerlist

Staggering value for the returned fields. The fields are staggered in the direction of their derivative. Defaults to [0].

[0]
correct_nyquistbool

If True, uses a correction of the derivative filter for the Nyquist frequency, which preserves Hermitian symmetric and null space. See those notes for more details. Defaults to True.

True

Returns:

TypeDescription

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:

NameTypeDescriptionDefault
x

Continuous field

required

Returns:

TypeDescription

The gradient of the field

gradient(x: 'FiniteDifferences', *, stagger = [0], params = None)

Gradient operator for finite differences fields.

Parameters:

NameTypeDescriptionDefault
x

FiniteDifferences field

required
stagger

Stagger of the derivative

[0]

Returns:

TypeDescription

The gradient of the field

gradient(x: 'FourierSeries', *, stagger = [0], correct_nyquist = True, params = None)

Gradient operator for Fourier series fields.

Parameters:

NameTypeDescriptionDefault
xFourierSeries

Input field

required
staggerlist

Staggering value for the returned fields. The fields are staggered in the direction of their derivative. Defaults to [0].

[0]
correct_nyquistbool

If True, uses a correction of the derivative filter for the Nyquist frequency, which preserves Hermitian symmetric and null space. See those notes for more details. Defaults to True.

True

Returns:

TypeDescription
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:

NameTypeDescriptionDefault
xFourierSeries

Input field

required
cFourierSeries

Coefficient field

required

Returns:

TypeDescription

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:

NameTypeDescriptionDefault
x

Continuous field

required

Returns:

TypeDescription

The Laplacian of the field

laplacian(x: 'FiniteDifferences', *, params = None)

Gradient operator for finite differences fields.

Parameters:

NameTypeDescriptionDefault
x

FiniteDifferences field

required

Returns:

TypeDescription

The gradient of the field

laplacian(x: 'FourierSeries', *, params = None)

Laplacian operator for Fourier series fields.

Parameters:

NameTypeDescriptionDefault
xFourierSeries

Input field

required

Returns:

TypeDescription

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