tfc package#

Subpackages#

Submodules#

tfc.mtfc module#

class tfc.mtfc.mtfc(n: tuple[int, ...] | list[int] | ndarray[Any, dtype[int32]] | ndarray[Any, dtype[int64]] | ndarray[Any, dtype[int16]] | ndarray[Any, dtype[int8]], nC: _SupportsArray[dtype[bool_ | integer[Any]]] | _NestedSequence[_SupportsArray[dtype[bool_ | integer[Any]]]] | bool | int | _NestedSequence[bool | int], deg: int, dim: int = 2, basis: Literal['CP', 'LeP', 'FS', 'ELMTanh', 'ELMSigmoid', 'ELMSin', 'ELMSwish', 'ELMReLU'] = 'CP', x0: tuple[int | float | complex, ...] | list[int | float | complex] | ndarray[Any, dtype[Any]] | Array = [], xf: tuple[int | float | complex, ...] | list[int | float | complex] | ndarray[Any, dtype[Any]] | Array = [], backend: Literal['C++', 'Python'] = 'C++')[source]#

Bases: object

This is the multivariate TFC class. It acts as a container that holds:

  • The linear map from the domain of the DE to the domain of the free-function.

  • The necessary JAX code that enables automatic differentiation of the constrained experssion and Jacobians of the residual with respect to the unknown coefficients in the linear combination of basis functions that make up the free function.

  • Other useful TFC related functions such as collocation point creation.

In addition, this class ties these methods together to form a utility that enables a higher level of code abstraction such that the end-user scripts are simple, clear, and elegant implementations of TFC.

Parameters:
  • n (IntListOrArray) – Number of points to use per-dimension when discretizing the domain. List or array must be same length as number of dimensions.

  • nC (IntArrayLike) –

    Number of functions to remove from the beginning of free function linear expansion. This variable is used to account for basis functions that are linearly dependent on support functions used in the construction of the constrained expressions. The constraints for each dimension can be expressed in 1 of 2 ways. Note that a value of -1 is used to indicate no constraints exist for a particular dimension.

    1. As an integer. When expressed as an integer, the first nC basis functions are removed from the free function.

    2. As a list or array. When expressed as a list or array, the basis functions corresponding to the numbers given by the list or array are removed from the free function.

  • deg (uint) – Degree of the basis function expansion.

  • dim (pint) – Number of dimensions in the domain.

  • basis (Literal["CP","LeP","FS","ELMTanh","ELMSigmoid","ELMSin","ELMSwish","ELMReLU"], optional) – This optional keyword argument specifies the basis functions to be used. (Default value = “CP”)

  • x0 (NumberListOrArray) – Specifies the beginning of the DE domain. (Default value = None)

  • xf (NumberListOrArray) – Specifies the end of the DE domain. (Default value = None)

  • backend (Literal["C++", "Python"]) – This optional keyword sets the backend used to compute the basis functions. The C++ can be used with JIT, but can only be used for doubles. The Python backend can be used for other field types, e.g., complex numbers, but does not have JIT translations. Instead, pejit must be used to set the basis function outputs as compile time constants in order to JIT.

H(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the basis function matrix for the points specified by *x.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

H – Basis function matrix.

Return type:

NDArray

Hx(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the derivative of the basis function matrix for the points specified by *x with respect to the first variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hx – Derivative of the basis function matrix with respect to the first variable.

Return type:

NDArray

Hx2(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the second derivative of the basis function matrix for the points specified by *x with respect to the first variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hx2 – Second derivative of the basis function matrix with respect to the first variable.

Return type:

NDArray

Hx2y(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the mixed derivative (second order derivative with respect to the first variable and first order with respect to the second variable) of the basis function matrix for the points specified by *x.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hx2y – Mixed derivative of the basis function matrix with respect to the first variable.

Return type:

NDArray

Hxy(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the mixed derivative (first order derivative with respect to the first variable and first order with respect to the second variable) of the basis function matrix for the points specified by *x.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hxy – Mixed derivative of the basis function matrix with respect to the first variable.

Return type:

NDArray

Hy(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the derivative of the basis function matrix for the points specified by *x with respect to the second variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hy – Derivative of the basis function matrix with respect to the second variable.

Return type:

NDArray

Hy2(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the second derivative of the basis function matrix for the points specified by *x with respect to the second variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hy2 – Second derivative of the basis function matrix with respect to the second variable.

Return type:

NDArray

Hz(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the derivative of the basis function matrix for the points specified by *x with respect to the third variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hz – Derivative of the basis function matrix with respect to the third variable.

Return type:

NDArray

SetupJAX()[source]#

This function is used internally by TFC to setup autograd primatives and create desired behavior when taking derivatives of TFC constrained expressions.

tfc.utfc module#

class tfc.utfc.HybridUtfc(tfcClasses)[source]#

Bases: object

This class combines TFC classes together so that multiple basis functions can be used simultaneously in the solution. Note, that this class is not yet complete.

Parameters:

tfcClasses (list of utfc classes) – This list of utfc classes make up the basis functions used in the HybridUtfc class.

H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

H – Basis function matrix.

Return type:

NDArray

d2H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the second derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d2H – Second derivative of the basis function matrix.

Return type:

NDArray

d3H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the third derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d3H – Third derivative of the basis function matrix.

Return type:

NDArray

d4H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the fourth derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d4H – Fourth derivative of the basis function matrix.

Return type:

NDArray

d8H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the eighth derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d8H – Eighth derivative of the basis function matrix.

Return type:

NDArray

dH(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

dH – Derivative of the basis function matrix.

Return type:

NDArray

class tfc.utfc.utfc(N: int, nC: _SupportsArray[dtype[bool_ | integer[Any]]] | _NestedSequence[_SupportsArray[dtype[bool_ | integer[Any]]]] | bool | int | _NestedSequence[bool | int], deg: int, basis: Literal['CP', 'LeP', 'FS', 'ELMTanh', 'ELMSigmoid', 'ELMSin', 'ELMSwish', 'ELMReLU'] = 'CP', x0: float | None = None, xf: float | None = None, backend: Literal['C++', 'Python'] = 'C++')[source]#

Bases: object

This is the univariate TFC class. It acts as a container that creates and stores:

  • The linear map between the free function domain (z) and the problem domain (x).

  • The basis functions or ELMs that make up the free function.

  • The necessary JAX code that enables automatic differentiation of the free function.

  • Other useful TFC related functions such as collocation point creation.

In addition, this class ties these methods together to form a utility that enables a higher level of code abstraction such that the end-user scripts are simple, clear, and elegant implementations of TFC.

Parameters:
  • N (int) – Number of points to use when discretizing the domain.

  • nC (IntArrayLike) –

    Number of functions to remove from the free function linear expansion. This variable is used to account for basis functions that are linearly dependent on support functions used in the construction of the constrained expressions. It can be expressed in 1 of 2 ways.

    1. As an integer. When expressed as an integer, the first nC basis functions are removed from the free function.

    2. As a list or array. When expressed as a list or array, the basis functions corresponding to the numbers given by the list or array are removed from the free function.

  • deg (int) – Degree of the basis function expansion. This number is one less than the number of basis functions used before removing those specified by nC.

  • x0 (float, optional) – Specifies the beginning of the DE domain. (Default value = 0)

  • xf (float) – This required keyword argument specifies the end of the DE domain.

  • basis (Literal["CP","LeP","FS","ELMTanh","ELMSigmoid","ELMSin","ELMSwish","ELMReLU"], optional) – This optional keyword argument specifies the basis functions to be used. (Default value = “CP”)

H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

H – Basis function matrix.

Return type:

NDArray

d2H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the second deriative of H. See documentation of H for more details.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d2H – Second derivative of the basis function matrix.

Return type:

NDArray

d4H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the fourth deriative of H. See documentation of H for more details.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d4H – Fourth derivative of the basis function matrix.

Return type:

NDArray

d8H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the eighth deriative of H. See documentation of H for more details.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d8H – Eighth derivative of the basis function matrix.

Return type:

NDArray

dH(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the deriative of H. See documentation of ‘H’ for more details.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

H – Derivative of the basis function matrix.

Return type:

NDArray

Module contents#

class tfc.HybridUtfc(tfcClasses)[source]#

Bases: object

This class combines TFC classes together so that multiple basis functions can be used simultaneously in the solution. Note, that this class is not yet complete.

Parameters:

tfcClasses (list of utfc classes) – This list of utfc classes make up the basis functions used in the HybridUtfc class.

H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

H – Basis function matrix.

Return type:

NDArray

d2H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the second derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d2H – Second derivative of the basis function matrix.

Return type:

NDArray

d3H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the third derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d3H – Third derivative of the basis function matrix.

Return type:

NDArray

d4H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the fourth derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d4H – Fourth derivative of the basis function matrix.

Return type:

NDArray

d8H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the eighth derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d8H – Eighth derivative of the basis function matrix.

Return type:

NDArray

dH(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the derivative of the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

dH – Derivative of the basis function matrix.

Return type:

NDArray

class tfc.mtfc(n: tuple[int, ...] | list[int] | ndarray[Any, dtype[int32]] | ndarray[Any, dtype[int64]] | ndarray[Any, dtype[int16]] | ndarray[Any, dtype[int8]], nC: _SupportsArray[dtype[bool_ | integer[Any]]] | _NestedSequence[_SupportsArray[dtype[bool_ | integer[Any]]]] | bool | int | _NestedSequence[bool | int], deg: int, dim: int = 2, basis: Literal['CP', 'LeP', 'FS', 'ELMTanh', 'ELMSigmoid', 'ELMSin', 'ELMSwish', 'ELMReLU'] = 'CP', x0: tuple[int | float | complex, ...] | list[int | float | complex] | ndarray[Any, dtype[Any]] | Array = [], xf: tuple[int | float | complex, ...] | list[int | float | complex] | ndarray[Any, dtype[Any]] | Array = [], backend: Literal['C++', 'Python'] = 'C++')[source]#

Bases: object

This is the multivariate TFC class. It acts as a container that holds:

  • The linear map from the domain of the DE to the domain of the free-function.

  • The necessary JAX code that enables automatic differentiation of the constrained experssion and Jacobians of the residual with respect to the unknown coefficients in the linear combination of basis functions that make up the free function.

  • Other useful TFC related functions such as collocation point creation.

In addition, this class ties these methods together to form a utility that enables a higher level of code abstraction such that the end-user scripts are simple, clear, and elegant implementations of TFC.

Parameters:
  • n (IntListOrArray) – Number of points to use per-dimension when discretizing the domain. List or array must be same length as number of dimensions.

  • nC (IntArrayLike) –

    Number of functions to remove from the beginning of free function linear expansion. This variable is used to account for basis functions that are linearly dependent on support functions used in the construction of the constrained expressions. The constraints for each dimension can be expressed in 1 of 2 ways. Note that a value of -1 is used to indicate no constraints exist for a particular dimension.

    1. As an integer. When expressed as an integer, the first nC basis functions are removed from the free function.

    2. As a list or array. When expressed as a list or array, the basis functions corresponding to the numbers given by the list or array are removed from the free function.

  • deg (uint) – Degree of the basis function expansion.

  • dim (pint) – Number of dimensions in the domain.

  • basis (Literal["CP","LeP","FS","ELMTanh","ELMSigmoid","ELMSin","ELMSwish","ELMReLU"], optional) – This optional keyword argument specifies the basis functions to be used. (Default value = “CP”)

  • x0 (NumberListOrArray) – Specifies the beginning of the DE domain. (Default value = None)

  • xf (NumberListOrArray) – Specifies the end of the DE domain. (Default value = None)

  • backend (Literal["C++", "Python"]) – This optional keyword sets the backend used to compute the basis functions. The C++ can be used with JIT, but can only be used for doubles. The Python backend can be used for other field types, e.g., complex numbers, but does not have JIT translations. Instead, pejit must be used to set the basis function outputs as compile time constants in order to JIT.

H(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the basis function matrix for the points specified by *x.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

H – Basis function matrix.

Return type:

NDArray

Hx(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the derivative of the basis function matrix for the points specified by *x with respect to the first variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hx – Derivative of the basis function matrix with respect to the first variable.

Return type:

NDArray

Hx2(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the second derivative of the basis function matrix for the points specified by *x with respect to the first variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hx2 – Second derivative of the basis function matrix with respect to the first variable.

Return type:

NDArray

Hx2y(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the mixed derivative (second order derivative with respect to the first variable and first order with respect to the second variable) of the basis function matrix for the points specified by *x.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hx2y – Mixed derivative of the basis function matrix with respect to the first variable.

Return type:

NDArray

Hxy(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the mixed derivative (first order derivative with respect to the first variable and first order with respect to the second variable) of the basis function matrix for the points specified by *x.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hxy – Mixed derivative of the basis function matrix with respect to the first variable.

Return type:

NDArray

Hy(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the derivative of the basis function matrix for the points specified by *x with respect to the second variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hy – Derivative of the basis function matrix with respect to the second variable.

Return type:

NDArray

Hy2(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the second derivative of the basis function matrix for the points specified by *x with respect to the second variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hy2 – Second derivative of the basis function matrix with respect to the second variable.

Return type:

NDArray

Hz(*x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the derivative of the basis function matrix for the points specified by *x with respect to the third variable.

Parameters:
  • *x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

Hz – Derivative of the basis function matrix with respect to the third variable.

Return type:

NDArray

SetupJAX()[source]#

This function is used internally by TFC to setup autograd primatives and create desired behavior when taking derivatives of TFC constrained expressions.

class tfc.utfc(N: int, nC: _SupportsArray[dtype[bool_ | integer[Any]]] | _NestedSequence[_SupportsArray[dtype[bool_ | integer[Any]]]] | bool | int | _NestedSequence[bool | int], deg: int, basis: Literal['CP', 'LeP', 'FS', 'ELMTanh', 'ELMSigmoid', 'ELMSin', 'ELMSwish', 'ELMReLU'] = 'CP', x0: float | None = None, xf: float | None = None, backend: Literal['C++', 'Python'] = 'C++')[source]#

Bases: object

This is the univariate TFC class. It acts as a container that creates and stores:

  • The linear map between the free function domain (z) and the problem domain (x).

  • The basis functions or ELMs that make up the free function.

  • The necessary JAX code that enables automatic differentiation of the free function.

  • Other useful TFC related functions such as collocation point creation.

In addition, this class ties these methods together to form a utility that enables a higher level of code abstraction such that the end-user scripts are simple, clear, and elegant implementations of TFC.

Parameters:
  • N (int) – Number of points to use when discretizing the domain.

  • nC (IntArrayLike) –

    Number of functions to remove from the free function linear expansion. This variable is used to account for basis functions that are linearly dependent on support functions used in the construction of the constrained expressions. It can be expressed in 1 of 2 ways.

    1. As an integer. When expressed as an integer, the first nC basis functions are removed from the free function.

    2. As a list or array. When expressed as a list or array, the basis functions corresponding to the numbers given by the list or array are removed from the free function.

  • deg (int) – Degree of the basis function expansion. This number is one less than the number of basis functions used before removing those specified by nC.

  • x0 (float, optional) – Specifies the beginning of the DE domain. (Default value = 0)

  • xf (float) – This required keyword argument specifies the end of the DE domain.

  • basis (Literal["CP","LeP","FS","ELMTanh","ELMSigmoid","ELMSin","ELMSwish","ELMReLU"], optional) – This optional keyword argument specifies the basis functions to be used. (Default value = “CP”)

H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the basis function matrix for the points specified by x.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

H – Basis function matrix.

Return type:

NDArray

d2H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the second deriative of H. See documentation of H for more details.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d2H – Second derivative of the basis function matrix.

Return type:

NDArray

d4H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the fourth deriative of H. See documentation of H for more details.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d4H – Fourth derivative of the basis function matrix.

Return type:

NDArray

d8H(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the eighth deriative of H. See documentation of H for more details.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

d8H – Eighth derivative of the basis function matrix.

Return type:

NDArray

dH(x: ndarray[Any, dtype[_ScalarType_co]] | Array, full: bool = False) ndarray[Any, dtype[_ScalarType_co]][source]#

This function computes the deriative of H. See documentation of ‘H’ for more details.

Parameters:
  • x (JaxOrNumpyArray) – Points to calculate the basis functions at.

  • full (bool, optional) – If true then the values specified by nC to the utfc class are ignored and all basis functions are computed. (Default value = False)

Returns:

H – Derivative of the basis function matrix.

Return type:

NDArray