4.1.6.1.5 pde.backends.torch.operators.spherical_sym module

This module implements differential operators on spherical grids.

SphericalLaplacian

Spherical Laplace using torch.

SphericalGradient

Spherical gradient operator using torch.

SphericalGradientSquared

Spherical gradient squared operator using torch.

SphericalDivergence

Spherical divergence operator using torch.

SphericalVectorGradient

Spherical vector gradient operator using torch.

SphericalTensorDivergence

Spherical tensor divergence operator using torch.

class SphericalDivergence(grid, bcs, *, dtype, conservative=None, method='central')[source]

Bases: TorchDifferentialOperator

Spherical divergence operator using torch.

The spherical grid assumes spherical symmetry, so that fields only depend on the radial coordinate r. The radial discretization is defined as \(r_i = r_\mathrm{min} + (i + \frac12) \Delta r\) for \(i=0, \ldots, N_r-1\), where \(r_\mathrm{min}\) is the radius of the inner boundary, which is zero by default. Note that the radius of the outer boundary is given by \(r_\mathrm{max} = r_\mathrm{min} + N_r \Delta r\).

Initialize the Spherical divergence operator.

Parameters:
  • grid (GridBase) – The grid on which the operator acts

  • bcs (BoundariesList or None) – The boundary conditions applied to the field. If None, no boundary conditions are enforced.

  • dtype (np.dtype) – The data type of the field

  • conservative (bool) – Flag indicating whether the operator should be conservative (which results in slightly slower computations). Conservative operators ensure mass conservation. If None, the value is read from the configuration option operators.conservative_stencil.

  • method (str) – The method for calculating the derivative. Possible values are ‘central’, ‘forward’, and ‘backward’.

forward(arr, args=None)[source]

Fill internal data array, apply operator, and return valid data.

Parameters:

arr (Tensor)

Return type:

Tensor

rank_in = 1

The rank of the input tensor

Type:

int

class SphericalGradient(grid, bcs, *, dtype, method='central')[source]

Bases: TorchDifferentialOperator

Spherical gradient operator using torch.

The spherical grid assumes spherical symmetry, so that fields only depend on the radial coordinate r. The radial discretization is defined as \(r_i = r_\mathrm{min} + (i + \frac12) \Delta r\) for \(i=0, \ldots, N_r-1\), where \(r_\mathrm{min}\) is the radius of the inner boundary, which is zero by default. Note that the radius of the outer boundary is given by \(r_\mathrm{max} = r_\mathrm{min} + N_r \Delta r\).

Initialize the Spherical gradient operator.

Parameters:
  • grid (GridBase) – The grid on which the operator acts

  • bcs (BoundariesList or None) – The boundary conditions applied to the field. If None, no boundary conditions are enforced.

  • dtype (np.dtype) – The data type of the field

  • method (str) – The method for calculating the derivative. Possible values are ‘central’, ‘forward’, and ‘backward’.

forward(arr, args=None)[source]

Fill internal data array, apply operator, and return valid data.

Parameters:

arr (Tensor)

Return type:

Tensor

rank_in = 0

The rank of the input tensor

Type:

int

class SphericalGradientSquared(grid, bcs, *, central=True, dtype)[source]

Bases: TorchDifferentialOperator

Spherical gradient squared operator using torch.

The spherical grid assumes spherical symmetry, so that fields only depend on the radial coordinate r. The radial discretization is defined as \(r_i = r_\mathrm{min} + (i + \frac12) \Delta r\) for \(i=0, \ldots, N_r-1\), where \(r_\mathrm{min}\) is the radius of the inner boundary, which is zero by default. Note that the radius of the outer boundary is given by \(r_\mathrm{max} = r_\mathrm{min} + N_r \Delta r\).

Initialize the Spherical gradient squared operator.

Parameters:
  • grid (GridBase) – The grid on which the operator acts

  • bcs (BoundariesList or None) – The boundary conditions applied to the field. If None, no boundary conditions are enforced.

  • central (bool) – Whether to use central differences. If False, forward and backward differences are used.

  • dtype (np.dtype) – The data type of the field

forward(arr, args=None)[source]

Fill internal data array, apply operator, and return valid data.

Parameters:

arr (Tensor)

Return type:

Tensor

rank_in = 0

The rank of the input tensor

Type:

int

class SphericalLaplacian(grid, bcs, *, dtype, conservative=None)[source]

Bases: TorchDifferentialOperator

Spherical Laplace using torch.

The spherical grid assumes spherical symmetry, so that fields only depend on the radial coordinate r. The radial discretization is defined as \(r_i = r_\mathrm{min} + (i + \frac12) \Delta r\) for \(i=0, \ldots, N_r-1\), where \(r_\mathrm{min}\) is the radius of the inner boundary, which is zero by default. Note that the radius of the outer boundary is given by \(r_\mathrm{max} = r_\mathrm{min} + N_r \Delta r\).

Initialize the Spherical Laplacian operator.

Parameters:
  • grid (GridBase) – The grid on which the operator acts

  • bcs (BoundariesList or None) – The boundary conditions applied to the field. If None, no boundary conditions are enforced.

  • dtype (np.dtype) – The data type of the field

  • conservative (bool) – Flag indicating whether the Laplace operator should be conservative (which results in slightly slower computations). Conservative operators ensure mass conservation. If None, the value is read from the configuration option operators.conservative_stencil.

forward(arr, args=None)[source]

Fill internal data array, apply operator, and return valid data.

Parameters:

arr (Tensor)

Return type:

Tensor

rank_in = 0

The rank of the input tensor

Type:

int

class SphericalTensorDivergence(grid, bcs, *, dtype, conservative=False)[source]

Bases: TorchDifferentialOperator

Spherical tensor divergence operator using torch.

The spherical grid assumes spherical symmetry, so that fields only depend on the radial coordinate r. The radial discretization is defined as \(r_i = r_\mathrm{min} + (i + \frac12) \Delta r\) for \(i=0, \ldots, N_r-1\), where \(r_\mathrm{min}\) is the radius of the inner boundary, which is zero by default. Note that the radius of the outer boundary is given by \(r_\mathrm{max} = r_\mathrm{min} + N_r \Delta r\).

Initialize the Spherical tensor divergence operator.

Parameters:
  • grid (GridBase) – The grid on which the operator acts

  • bcs (BoundariesList or None) – The boundary conditions applied to the field. If None, no boundary conditions are enforced.

  • dtype (np.dtype) – The data type of the field

  • conservative (bool) – Flag indicating whether the operator should be conservative (which results in slightly slower computations). Conservative operators ensure mass conservation. If None, the value is read from the configuration option operators.conservative_stencil.

forward(arr, args=None)[source]

Fill internal data array, apply operator, and return valid data.

Parameters:

arr (Tensor)

Return type:

Tensor

rank_in = 2

The rank of the input tensor

Type:

int

class SphericalVectorGradient(grid, bcs, *, dtype, method='central')[source]

Bases: TorchDifferentialOperator

Spherical vector gradient operator using torch.

The spherical grid assumes spherical symmetry, so that fields only depend on the radial coordinate r. The radial discretization is defined as \(r_i = r_\mathrm{min} + (i + \frac12) \Delta r\) for \(i=0, \ldots, N_r-1\), where \(r_\mathrm{min}\) is the radius of the inner boundary, which is zero by default. Note that the radius of the outer boundary is given by \(r_\mathrm{max} = r_\mathrm{min} + N_r \Delta r\).

Initialize the Spherical vector gradient operator.

Parameters:
  • grid (GridBase) – The grid on which the operator acts

  • bcs (BoundariesList or None) – The boundary conditions applied to the field. If None, no boundary conditions are enforced.

  • dtype (np.dtype) – The data type of the field

  • method (str) – The method for calculating the derivative. Possible values are ‘central’, ‘forward’, and ‘backward’.

forward(arr, args=None)[source]

Fill internal data array, apply operator, and return valid data.

Parameters:

arr (Tensor)

Return type:

Tensor

rank_in = 1

The rank of the input tensor

Type:

int