xlsindy.euler_lagrange module
This module primarly focus on symbolic variable and enable to do the different manipulation in order to get the experiment matrix
- xlsindy.euler_lagrange.compute_euler_lagrange_equation(lagrangian_expr: Expr, symbol_matrix: ndarray, time_symbol: Symbol, coordinate_index: int) Expr
Compute the Euler-Lagrange equation for a given generalized coordinate.
- Parameters:
lagrangian_expr (sp.Expr) – The symbolic expression of the Lagrangian.
symbol_matrix (np.ndarray) – The matrix of symbolic variables (external forces, positions, velocities, and accelerations).
time_symbol (sp.Symbol) – The symbolic variable representing time.
coordinate_index (int) – The index of the generalized coordinate for differentiation.
- Returns:
The Euler-Lagrange equation for the specified generalized coordinate.
- Return type:
sympy.Expr
- xlsindy.euler_lagrange.create_experiment_matrix(num_coords: int, catalogs: ndarray, symbol_matrix: ndarray, position_values: ndarray, velocity_values: ndarray, acceleration_values: ndarray) ndarray
Create the SINDy experiment matrix.
For each function in the catalog create the times series of function for each coordinate. This matrix will afterward undergo the regression in order to retrieve the parse expression.
- Parameters:
num_coords (int) – Number of generalized coordinates.
catalogs (list) – array of catalog function of shape (p,n)
symbol_matrix (sp.Matrix) – Symbolic variable matrix for the system.
position_values (np.array) – Array of positions at each time step.
velocity_values (np.array) – Array of velocities.
acceleration_values (np.array) – Array of accelerations.
- Returns:
The experiment matrix.
- Return type:
experiment_matrix (np.array (sampled_steps * num_coords, catalog_lenght))
- xlsindy.euler_lagrange.jax_create_experiment_matrix(num_coords: int, catalogs: ndarray, symbol_matrix: ndarray, position_values: ndarray, velocity_values: ndarray, acceleration_values: ndarray, forces_values: ndarray) List[ndarray]
Create the SINDy experiment matrix.
For each function in the catalog create the times series of function for each coordinate. This matrix will afterward undergo the regression in order to retrieve the parse expression.
- Parameters:
num_coords (int) – Number of generalized coordinates.
catalogs (list) – array of catalog function of shape (p,n)
symbol_matrix (sp.Matrix) – Symbolic variable matrix for the system.
position_values (np.array(num_coordinate,sampled_step)) – Array of positions at each time step.
velocity_values (np.array(num_coordinate,sampled_step)) – Array of velocities.
acceleration_values (np.array(num_coordinate,sampled_step)) – Array of accelerations.
forces_values (np.ndarray(num_coordinate,sampled_step)) – Array of external forces.
- Returns:
Experiment matrix.
- Return type:
np.array
- xlsindy.euler_lagrange.newton_from_lagrangian(lagrangian_expr: Expr, symbol_matrix: ndarray, time_symbol: Symbol) List[Expr]
Compute all the equation from the lagrangian in order to get newton system.
- Parameters:
lagrangian_expr (sp.Expr) – The symbolic expression of the Lagrangian.
symbol_matrix (np.ndarray) – The matrix of symbolic variables (external forces, positions, velocities, and accelerations).
time_symbol (sp.Symbol) – The symbolic variable representing time.
- Returns:
The Newton equations of the system.
- Return type:
List[sympy.Expr]