Input preprocessing

class EquationMixin

class tedeous.input_preprocessing.EquationMixin[source]

Bases: object

Auxiliary class. This one contains some methods that uses in other classes.

static equation_unify(equation: dict) dict[source]

Adding ‘var’ to the ‘operator’ if it’s absent or convert to list ‘pow’ and ‘var’ if it’s int or float.

Parameters:

operator – operator in input form.

Returns:

equation with unified for solver parameters.

Return type:

equation

static closest_point(grid: Tensor, target_point: float) int[source]

Defines the closest boundary point to the grid. :param target_point: boundary point.

Returns:

position of the boundary point on the grid.

static convert_to_double(bnd: Union[list, array]) float[source]

Converts points to double type.

Parameters:

bnd – array or list of arrays points that should be converted

Returns:

bnd with double type.

static search_pos(grid: Tensor, bnd) list[source]

Method for searching position bnd in grid.

Parameters:
  • grid – array of a n-D points.

  • bnd – points that should be converted.

Returns:

list of positions bnd on grid.

static bndpos(grid: Tensor, bnd: Tensor) Union[list, int][source]

Returns the position of the boundary points on the grid.

Parameters:
  • grid – grid for coefficient in form of torch.Tensor mapping.

  • bnd – boundary conditions.

Returns:

list of positions of the boundary points on the grid.

class EquationInt

class Equation_NN

class tedeous.input_preprocessing.Equation_NN(grid: Tensor, operator: Union[dict, list], bconds, h: float = 0.001, inner_order: str = '1', boundary_order: str = '2')[source]

Bases: EquationMixin, Points_type

Class for preprocessing input data: grid, operator, bconds in unified form. Then it will be used for determine solution by ‘NN’ method.

operator_to_type_op(dif_direction: list, nvars: int, axes_scheme_type: str) list[source]

Function serves applying different schemes to a different point types for entire differentiation direction.

Parameters:
  • dif_direction – differentiation direction, (example:d2/dx2->[[0,0]])

  • nvars – dimensionality of the problem.

  • axes_scheme_type – ‘central’ or combination of ‘f’ and ‘b’.

Returns:

list, where the conventional operator changed to steps and signs (see scheme_build function description).

finite_diff_scheme_to_grid_list(finite_diff_scheme: list, grid_points: Tensor) list[source]

Method that converts integer finite difference steps in term described in Finite_diffs class to a grids with shifted points, i.e. from field (x,y) -> (x,y+h).

Parameters:
  • finite_diff_scheme – operator_to_type_op one term

  • grid_points – grid points that will be shifted corresponding to finite diff scheme

Returns:

list, where the steps and signs changed to grid and signs.

checking_coeff(coeff: Union[int, float, Tensor], grid_points: Tensor)[source]

Checks the coefficient type

Parameters:
  • coeff – coefficient in equation operator.

  • grid_points – if coeff is callable or torch.Tensor

Returns:

coefficient

type_op_to_grid_shift_op(fin_diff_op: list, grid_points) list[source]

Converts operator to a grid_shift form. Includes term coefficient conversion. Coeff may be integer, function or array, last two are mapped to a subgrid that corresponds point type.

Parameters:
  • fin_diff_op – operator_to_type_op result.

  • grid_points – grid points that will be shifted corresponding to finite diff scheme.

Returns:

final form of differential operator used in the algorithm for

single grid type.

Return type:

shift_grid_op

one_operator_prepare(operator: dict, grid_points: Tensor, points_type: str) dict[source]

Method for operator preparing, there is construct all predefined methods.

Parameters:
  • operator – operator in input form

  • grid_points – see type_op_to_grid_shift_op method

  • points_type – points type of grid_points

Returns:

prepared operator

operator_prepare() list[source]

Method for all operators preparing. If system case is, it will call ‘one_operator_prepare’ method for number of equations times.

Returns:

list of dictionaries, where every dictionary is the result of

’one_operator_prepare’

apply_bnd_operators(bnd_operator: dict, bnd_dict: dict) list[source]

Method for applying boundary operator for all points type in bnd_dict.

Parameters:
  • bnd_operator – boundary operator in input form.

  • bnd_dict – dictionary (keys is points type, values is boundary points).

Returns:

final form of differential operator used in the algorithm for

subset grid types.

bnd_prepare() list[source]

Method for boundary conditions preparing to final form.

Returns:

list of dictionaries where every dict is one boundary condition

class Equation_mat

class tedeous.input_preprocessing.Equation_mat(grid, operator, bconds)[source]

Bases: EquationMixin

Class realizes input data preprocessing (operator and boundary conditions preparing) for ‘mat’ method.

operator_prepare() list[source]

Method realizes operator preparing for ‘mat’ method using only ‘equation_unify’ method.

Returns:

final form of differential operator used in the algorithm.

point_position(bnd) list[source]

Define position of boundary points on the grid.

Parameters:

bnd

Returns:

list of positions, where boundary points intersects on the grid.

bnd_prepare() list[source]

Method for boundary conditions preparing to final form.

Returns:

list of dictionaries where every dict is one boundary condition

class Equation_autograd

class tedeous.input_preprocessing.Equation_autograd(grid: Tensor, operator, bconds)[source]

Bases: EquationMixin

Prepares equation for autograd method (i.e., from conventional form to input form).

checking_coeff(coeff: Union[int, float, Tensor]) Union[int, float, Tensor][source]

Checks the coefficient type

Parameters:

coeff – coefficient in equation operator.

Returns:

coefficient

one_operator_prepare(operator: dict) dict[source]

Method for all operators preparing. If system case is, it will call ‘one_operator_prepare’ method for number of equations times.

Returns:

list of dictionaries, where every dictionary is the result of

’one_operator_prepare’

operator_prepare() list[source]

Method for all operators preparing. If system case is, it will call ‘one_operator_prepare’ method for number of equations times.

Returns:

list of dictionaries, where every dictionary is the result of

’one_operator_prepare’

bnd_prepare()[source]

Method for boundary conditions preparing to final form Returns ——- prepared_bnd : list

list of dictionaries where every dict is one boundary condition