Input preprocessing
class EquationMixin
- class tedeous.input_preprocessing.EquationMixin[source]
Bases:
objectAuxiliary 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.
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_typeClass 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.
class Equation_mat
- class tedeous.input_preprocessing.Equation_mat(grid, operator, bconds)[source]
Bases:
EquationMixinClass 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.
class Equation_autograd
- class tedeous.input_preprocessing.Equation_autograd(grid: Tensor, operator, bconds)[source]
Bases:
EquationMixinPrepares 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’