Operators#
Module for operators vectorize implementation. Differential operators are used to write any differential problem. These operators are implemented to work on different accellerators: CPU, GPU, TPU or MPS. All operators take as input a tensor onto which computing the operator, a tensor with respect to which computing the operator, the name of the output variables to calculate the operator for (in case of multidimensional functions), and the variables name on which the operator is calculated.
- grad(output_, input_, components=None, d=None)[source]#
Perform gradient operation. The operator works for vectorial and scalar functions, with multiple input coordinates.
- Parameters:
output (LabelTensor) – the output tensor onto which computing the gradient.
input (LabelTensor) – the input tensor with respect to which computing the gradient.
components (list(str)) – the name of the output variables to calculate the gradient for. It should be a subset of the output labels. If None, all the output variables are considered. Default is None.
d (list(str)) – the name of the input variables on which the gradient is calculated. d should be a subset of the input labels. If None, all the input variables are considered. Default is None.
- Returns:
the gradient tensor.
- Return type:
- div(output_, input_, components=None, d=None)[source]#
Perform divergence operation. The operator works for vectorial functions, with multiple input coordinates.
- Parameters:
output (LabelTensor) – the output tensor onto which computing the divergence.
input (LabelTensor) – the input tensor with respect to which computing the divergence.
components (list(str)) – the name of the output variables to calculate the divergence for. It should be a subset of the output labels. If None, all the output variables are considered. Default is None.
d (list(str)) – the name of the input variables on which the divergence is calculated. d should be a subset of the input labels. If None, all the input variables are considered. Default is None.
- Raises:
TypeError – div operator works only for LabelTensor.
ValueError – div operator works only for vector fields.
ValueError – div operator must derive all components with respect to all coordinates.
- Returns:
the divergenge tensor.
- Return type:
- laplacian(output_, input_, components=None, d=None, method='std')[source]#
Compute Laplace operator. The operator works for vectorial and scalar functions, with multiple input coordinates.
- Parameters:
output (LabelTensor) – the output tensor onto which computing the Laplacian.
input (LabelTensor) – the input tensor with respect to which computing the Laplacian.
components (list(str)) – the name of the output variables to calculate the Laplacian for. It should be a subset of the output labels. If None, all the output variables are considered. Default is None.
d (list(str)) – the name of the input variables on which the Laplacian is calculated. d should be a subset of the input labels. If None, all the input variables are considered. Default is None.
method (str) – used method to calculate Laplacian, defaults to ‘std’.
- Raises:
ValueError – for vectorial field derivative with respect to all coordinates must be performed.
NotImplementedError – ‘divgrad’ not implemented as method.
- Returns:
The tensor containing the result of the Laplacian operator.
- Return type:
- advection(output_, input_, velocity_field, components=None, d=None)[source]#
Perform advection operation. The operator works for vectorial functions, with multiple input coordinates.
- Parameters:
output (LabelTensor) – the output tensor onto which computing the advection.
input (LabelTensor) – the input tensor with respect to which computing the advection.
velocity_field (str) – the name of the output variables which is used as velocity field. It should be a subset of the output labels.
components (list(str)) – the name of the output variables to calculate the Laplacian for. It should be a subset of the output labels. If None, all the output variables are considered. Default is None.
d (list(str)) – the name of the input variables on which the advection is calculated. d should be a subset of the input labels. If None, all the input variables are considered. Default is None.
- Returns:
the tensor containing the result of the advection operator.
- Return type: