# Modes (Basis functions)¶

## Function Spaces¶

class modepy.FunctionSpace[source]

An opaque object representing a finite-dimensional function space of functions $$\mathbb R^n \to \mathbb R$$.

spatial_dim

$$n$$ in the above definition, the number of spatial dimensions in which the functions in the space operate.

space_dim

The number of dimensions of the function space.

class modepy.PN(spatial_dim, order)[source]

The function space of polynomials with total degree $$N$$ = order.

$P^N:=\operatorname{span}\left\{\prod_{i=1}^d x_i^{n_i}:\sum n_i\le N\right\}.$
order
__init__(spatial_dim, order)[source]
class modepy.QN(spatial_dim, order)[source]

The function space of polynomials with maximum degree $$N$$ = order:

$Q^N:=\operatorname{span} \left \{\prod_{i=1}^d x_i^{n_i}:\max n_i\le N\right\}.$
order
__init__(spatial_dim, order)[source]
modepy.space_for_shape(shape: modepy.shapes.Shape, order: int) [source]

Return an unspecified instance of FunctionSpace suitable for approximation on shape attaining interpolation error of $$O(h^{\text{order}+1})$$.

This functionality provides sets of basis functions for the reference elements in modepy.shapes.

## Basis Retrieval¶

exception modepy.BasisNotOrthonormal[source]
class modepy.Basis[source]
orthonormality_weight()[source]
mode_ids

Return a tuple of of mode (basis function) identifiers, one for each basis function. Mode identifiers should generally be viewed as opaque. They are hashable. For some bases, they are tuples of length matching the number of dimensions and indicating the order along each reference axis.

functions

Return a tuple of (callable) basis functions of length matching mode_ids. Each function takes a vector of (r,s,t) reference coordinates as input.

Return a tuple of basis functions of length matching mode_ids. Each function takes a vector of (r,s,t) reference coordinates as input.

modepy.basis_for_space(space: modepy.spaces.FunctionSpace, shape: modepy.shapes.Shape) [source]
modepy.orthonormal_basis_for_space(space: modepy.spaces.FunctionSpace, shape: modepy.shapes.Shape) [source]
modepy.monomial_basis_for_space(space: modepy.spaces.FunctionSpace, shape: modepy.shapes.Shape) [source]

## Jacobi polynomials¶

modepy.jacobi(alpha, beta, n, x)[source]

Evaluate Jacobi polynomials of type $$(\alpha, \beta)$$ with $$\alpha, \beta > -1$$ and $$\alpha+\beta \ne -1$$ at a vector of points x for order n. The points x must lie on the interval $$[-1,1]$$.

Returns

a vector of $$P^{(\alpha, \beta)}_n$$ evaluated at all x.

The polynomials are normalized to be orthonormal with respect to the Jacobi weight $$(1-x)^\alpha(1+x)^\beta$$.

Observe that choosing $$\alpha=\beta=0$$ will yield the Legendre polynomials.

Evaluate the derivative of jacobi(), with the same meanings and restrictions for all arguments.

## Conversion to Symbolic¶

modepy.symbolicize_function(f, dim, ref_coord_var_name='r')[source]

For a function f (basis or gradient) returned by one of the functions in this module, return a pymbolic expression representing the same function.

Parameters

dim – the number of dimensions of the reference element on which basis is defined.

New in version 2020.2.

Adapts multiple one-dimensional bases into a tensor product basis.

Parameters
• bases_1d – a sequence (one entry per axis/dimension) of sequences (representing the basis) of 1D functions representing the approximation basis.

• grad_bases_1d – a sequence (one entry per axis/dimension) representing the derivatives of bases_1d.

## PKDO basis functions¶

modepy.modes.pkdo_2d(order, rs)[source]

Evaluate a 2D orthonormal (with weight 1) polynomial on the unit simplex.

Parameters
• order – A tuple (i, j) representing the order of the polynomial.

• rsrs, rs are arrays of $$(r,s)$$ coordinates. (See Coordinates on the triangle)

Returns

a vector of values of the same length as the rs arrays.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

Evaluate the derivatives of pkdo_2d().

Parameters
• order – A tuple (i, j) representing the order of the polynomial.

• rsrs, rs are arrays of $$(r,s)$$ coordinates. (See Coordinates on the triangle)

Returns

a tuple of vectors (dphi_dr, dphi_ds), each of the same length as the rs arrays.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

modepy.modes.pkdo_3d(order, rst)[source]

Evaluate a 2D orthonormal (with weight 1) polynomial on the unit simplex.

Parameters
• order – A tuple (i, j, k) representing the order of the polynomial.

• rsrst, rst, rst are arrays of $$(r,s,t)$$ coordinates. (See Coordinates on the tetrahedron)

Returns

a vector of values of the same length as the rst arrays.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

Evaluate the derivatives of pkdo_3d().

Parameters
• order – A tuple (i, j, k) representing the order of the polynomial.

• rsrs, rs, rs are arrays of $$(r,s,t)$$ coordinates. (See Coordinates on the tetrahedron)

Returns

a tuple of vectors (dphi_dr, dphi_ds, dphi_dt), each of the same length as the rst arrays.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

## Monomials¶

modepy.modes.monomial(order, rst)[source]

Evaluate the monomial of order order at the points rst.

Parameters
• order – A tuple (i, j,…) representing the order of the polynomial.

• rstrst, rst are arrays of $$(r,s,...)$$ coordinates. (See Coordinates on the triangle)

• rstrst, rst are arrays of $$(r,s,...)$$ coordinates. (See Coordinates on the triangle)