Skip to main content

A wrapped package to linearize the nonlinear continuous/discrete model. Including **numerical** and **symbolic** calculations.

Project description

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.

4. continuous_to_discrete

Plot a matrix.

II. Linearization process

  1. Indicate the set-point that will be expanded: $x_{ss}, u_{ss}, p_{ss}$.
  2. 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$

  3. 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modlinear-1.0.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

modlinear-1.0.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file modlinear-1.0.0.tar.gz.

File metadata

  • Download URL: modlinear-1.0.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.12

File hashes

Hashes for modlinear-1.0.0.tar.gz
Algorithm Hash digest
SHA256 75f1186142003764d70b22ddfff653717e084e0a870b56abee824a0ac4ee16b0
MD5 1161c5c4e4f2b12d96e5e5f4b1ba3278
BLAKE2b-256 f6fb6d3b33b3b148d59e8c1dec3d02a22a69e673cc4044006b48d7dd372379e2

See more details on using hashes here.

File details

Details for the file modlinear-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: modlinear-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.12

File hashes

Hashes for modlinear-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ffa1e85614b931e0e5ab8e7c4f25e2334c02b89d2bd70ecd635b47900d86db2
MD5 53447417f5fbeb321947d9c98d9d6120
BLAKE2b-256 55f127581addf7418adccf1fe85bf76af587ba91777122ace6d2e2552862d5a5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page