# 4.2.2.5. pde.grids.operators.spherical_sym module

This module implements differential operators on spherical grids

 make_laplace make a discretized laplace operator for a spherical grid make_gradient make a discretized gradient operator for a spherical grid make_divergence make a discretized divergence operator for a spherical grid make_vector_gradient make a discretized vector gradient operator for a spherical grid make_tensor_divergence make a discretized tensor divergence operator for a spherical grid make_poisson_solver make a operator that solves Poisson's equation
make_divergence(grid, safe=True, conservative=True)[source]

make a discretized divergence operator for a spherical grid

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$$.

Warning

This operator ignores the θ-component of the field when calculating the divergence. This is because the resulting scalar field could not be expressed on a SphericalSymGrid.

Parameters:
• grid (SphericalSymGrid) – The polar grid for which this operator will be defined

• safe (bool) – Add extra checks for the validity of the input

• conservative (bool) – Flag indicating whether the operator should be conservative (which results in slightly slower computations). Conservative operators ensure mass conservation.

Returns:

A function that can be applied to an array of values

Return type:

OperatorType

make a discretized gradient operator for a spherical grid

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$$.

Parameters:

grid (SphericalSymGrid) – The polar grid for which this operator will be defined

Returns:

A function that can be applied to an array of values

Return type:

OperatorType

make a discretized gradient squared operator for a spherical grid

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$$.

Parameters:
• grid (SphericalSymGrid) – The polar grid for which this operator will be defined

• central (bool) – Whether a central difference approximation is used for the gradient operator. If this is False, the squared gradient is calculated as the mean of the squared values of the forward and backward derivatives.

Returns:

A function that can be applied to an array of values

Return type:

OperatorType

make_laplace(grid, conservative=True)[source]

make a discretized laplace operator for a spherical grid

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$$.

Parameters:
• grid (SphericalSymGrid) – The polar grid for which this operator will be defined

• conservative (bool) – Flag indicating whether the laplace operator should be conservative (which results in slightly slower computations). Conservative operators ensure mass conservation.

Returns:

A function that can be applied to an array of values

Return type:

OperatorType

make_poisson_solver(bcs, method='auto')[source]

make a operator that solves Poisson’s equation

The polar grid assumes polar 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$$.

Parameters:
Returns:

A function that can be applied to an array of values

Return type:

OperatorType

make_tensor_divergence(grid, safe=True, conservative=False)[source]

make a discretized tensor divergence operator for a spherical grid

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$$.

Parameters:
• grid (SphericalSymGrid) – The polar grid for which this operator will be defined

• safe (bool) – Add extra checks for the validity of the input

• conservative (bool) – Flag indicating whether the operator should be conservative (which results in slightly slower computations). Conservative operators ensure mass conservation.

Returns:

A function that can be applied to an array of values

Return type:

OperatorType

make_tensor_double_divergence(grid, safe=True, conservative=True)[source]

make a discretized tensor double divergence operator for a spherical grid

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$$.

Parameters:
• grid (SphericalSymGrid) – The polar grid for which this operator will be defined

• safe (bool) – Add extra checks for the validity of the input

• conservative (bool) – Flag indicating whether the operator should be conservative (which results in slightly slower computations). Conservative operators ensure mass conservation.

Returns:

A function that can be applied to an array of values

Return type:

OperatorType

make a discretized vector gradient operator for a spherical grid

Warning

This operator ignores the two angular components of the field when calculating the gradient. This is because the resulting field could not be expressed on a SphericalSymGrid.

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$$.

Parameters:
Returns:

A function that can be applied to an array of values

Return type:

OperatorType