Model linearization function toolbox
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
Introduction: link
I. How to use
This package operates within the Python framework.
1. Required packages
- Numpy
- Matplotlib
- Control
- CasADi <-- 3 <= version <= 4
2. Usage
-
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.
II. modlinear toolbox organization
.
└── modlinear
├── cas_linearize
├── linearize_continuous
├── linearize_c2d
├── continuous_to_discrete
└── plot_matrix
Detailed introduction of each function can be found using help in python.
1. cas_linearize
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.
2. linearize_continuous
Numerical calculation
Obtain the linearized continuous A, B matrices for the continuous ODE.
3. linearize_c2d
Numerical calculation
Obtain the linearized discrete A, B matrices for the continuous ODE.
4. continuous_to_discrete
Numerical calculation
Obtain the discrete model from the continuous model, utilizing control package.
5. plot_matrix
Plot a matrix.
II. Linearization process
- 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.
III. Tutorial
There is a tutorial example to illustrate how to use the modlinear to linearize nonlinear models.
License
The project is released under the APACHE license. See LICENSE for details.
Copyright 2024 Xuewen Zhang
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Metadata
Release files for modlinear 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modlinear-1.0.2.tar.gz | 16.8 kB | Without provenance | Details for modlinear-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| modlinear-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for modlinear-1.0.2-py3-none-any.whl |
Total release size: 34.2 kB
Release files / modlinear-1.0.2.tar.gz
| Download URL | modlinear-1.0.2.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
584009dec1de575f8ec5a4a406fa92632fb2a91d8c4e4af8ca3a7c914fd6f998
|
|
BLAKE2b-256 checksum How to use checksums |
ed9780eeb7599a7056740093293423b69fa2e14340f68666033c6ec3615445d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.12
|
Release files / modlinear-1.0.2-py3-none-any.whl
| Download URL | modlinear-1.0.2-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dcc8f28d941fb8a773b1a9a422ca2115b3ba6ddcd4acbc5f2dc30d558cb54334
|
|
BLAKE2b-256 checksum How to use checksums |
433a46efe07a6f295bc6cf8ff6984a605030c291bafb0328ca57c29d9ab8d99d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.12
|
Security for modlinear 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.