A wrapped package to linearize the nonlinear continuous/discrete model. Including numerical and symbolic calculations.
If you have questions, remarks, technical issues etc. feel free to use the issues page of this repository. I am looking forward to your feedback and the discussion.
Github project: link
PyPI: link
Introduction: link
This package operates within the Python framework.
- Numpy
- Matplotlib
- Control
- CasADi β β <-- 3 <= version <= 4
-
Download the modlinear file and save it to your project directory.
-
Or install using pip
pip install modlinear
Then you can use the modlinear in your python project.
.
βββ modlinear
βββ cas_linearize
βββ linearize_continuous
βββ linearize_c2d
βββ continuous_to_discrete
βββ plot_matrix
Detailed introduction of each function can be found using help
in python.
Symbolic calculation
Obtain the linearized continuous/discrete A, B symbolic functions for the continuous/discrete ODE.
- Continuous/discrete A, B from continuous ODE
- Discrete A, B from discrete ODE
Due to symbolic functions, the A, B at any expand state can be easily obtained by giving the state values.
Numerical calculation
Obtain the linearized continuous A, B matrices for the continuous ODE.
Numerical calculation
Obtain the linearized discrete A, B matrices for the continuous ODE.
Numerical calculation
Obtain the discrete model from the continuous model, utilizing control
package.
Plot a matrix.
- Indicate the set-point that will be expanded:
$x_{ss}, u_{ss}, p_{ss}$ . - Compute the Jacobian of the system and obtain
$A$ ,$B$ ,$M$ , and$C$ matrix of the continuous linear system.$(x_{t+1} - x_{ss}) = A (x_t - x_{ss}) + B (u_{t} - u_{ss}) + M (p_{t} - p_{ss})$ $y_k = C x_k$ which equals to:
$(x_{k+1} - x_{ss}) = A (x_k - x_{ss}) + [B, M] [u_k - u_{ss}, z_k -z_{ss}]^T$ - Transform the continuous linear system to discrete linear system and obtain
$A_{dis}$ ,$B_{dis}$ ,$M_{dis}$ , and$C_{dis}$ .$(x_{k+1} - x_{ss}) = A_{dis} (x_k - x_{ss}) + B_{dis} (u_{k} - u_{ss}) + M_{dis} (p_{k} - p_{ss})$ $y_k = C_{dis} x_k$
Note: This procedure is applicable to all systems.
There is a tutorial example to illustrate how to use the modlinear to linearize nonlinear models.
The project is released under the APACHE license. See LICENSE for details.