Derivative

class Derivative

class tedeous.derivative.Derivative(model)[source]

Bases: object

Interface for taking numerical derivative due to chosen calculation method.

set_strategy(strategy: str) Union[Derivative_NN, Derivative_autograd, Derivative_mat][source]

Setting the calculation method. :param strategy: Calculation method. (i.e., “NN”, “autograd”, “mat”).

Returns:

equation in input form for a given calculation method.

class Derivative_NN

class tedeous.derivative.Derivative_NN(model: Any)[source]

Bases: DerivativeInt

Taking numerical derivative for ‘NN’ method.

take_derivative(term: Union[list, int, Tensor], *args) Tensor[source]

Auxiliary function serves for single differential operator resulting field derivation. :param term: differential operator in conventional form.

Returns:

resulting field, computed on a grid.

class Derivative_autograd

class tedeous.derivative.Derivative_autograd(model)[source]

Bases: DerivativeInt

Taking numerical derivative for ‘autograd’ method.

static nn_autograd(model, points, var, axis=[0])[source]

Computes derivative on the grid using autograd method. :param model: neural network. :param points: points, where numerical derivative is calculated. :param axis: term of differentiation, example [0,0]->d2/dx2

if grid_points(x,y)

Returns:

the result of desired function differentiation

in corresponding axis.

take_derivative(term: dict, grid_points: Tensor) Tensor[source]

Auxiliary function serves for single differential operator resulting field derivation. :param term: differential operator in conventional form. :param grid_points: points, where numerical derivative is calculated.

Returns:

resulting field, computed on a grid.

class Derivative_mat

class tedeous.derivative.Derivative_mat(model)[source]

Bases: DerivativeInt

Taking numerical derivative for ‘mat’ method.

static derivative_1d(model: Tensor, grid: Tensor) Tensor[source]

Computes derivative in one dimension for matrix method. :param model: random matrix. :param grid: array of a n-D points.

Returns:

computed derivative along one dimension.

static derivative(u_tensor: Tensor, h_tensor: Tensor, axis: int, scheme_order: int = 1, boundary_order: int = 1) Tensor[source]

Computing derivative for ‘matrix’ method. :param u_tensor: function computed on a grid (n imes m matrix or multi-dimensional tensor with dim=D) :param h_tensor: computational grid with shape (u_tensor.shape, D) result of solver.grid_format_prepare(coord_list,mode=’mat’), where coord list is a list in format [x,t] or [x1,x2,x3,…] :param axis: axis along which the derivative is calculated. :param scheme_order: accuracy inner order for finite difference. Default = 1 :param boundary_order: accuracy boundary order for finite difference. Default = 2

Returns:

computed derivative.

take_derivative(term: Any, grid_points: Tensor) Tensor[source]

Auxiliary function serves for single differential operator resulting field derivation. :param term: differential operator in conventional form. :param grid_points: grid points

Returns:

resulting field, computed on a grid.