Lyapunov exponents and covariant Lyapunov vectors utilities
Project description
clvlib
clvlib is a library for computing Lyapunov exponents and Covariant Lyapunov Vectors (CLVs) with NumPy and PyTorch. Lyapunov exponents are computed using Benettin's algorithm [1]. The NumPy implementation uses a sign-corrected Householder QR step for re-orthonormalisation, and the CLVs are computed using Ginelli's algorithm [2].
The variational stepper used to integrate the variational system is modular. Standard Euler, RK2, RK4, and discrete-time steppers are bundled, but you can register your own functions for the integrators.
Installation
pip install clvlib
Install the PyTorch backend only if you need it:
pip install "clvlib[pytorch]"
Quickstart
import numpy as np
from clvlib.numpy import lyap_analysis_from_ic
# Lorenz '63 system ----------------------------------------------------------
SIGMA = 10.0
RHO = 28.0
BETA = 8.0 / 3.0
def lorenz(t: float, x: np.ndarray) -> np.ndarray:
return np.array(
[
SIGMA * (x[1] - x[0]),
x[0] * (RHO - x[2]) - x[1],
x[0] * x[1] - BETA * x[2],
],
dtype=float,
)
def jacobian(t: float, x: np.ndarray) -> np.ndarray:
return np.array(
[
[-SIGMA, SIGMA, 0.0],
[RHO - x[2], -1.0, -x[0]],
[x[1], x[0], -BETA],
],
dtype=float,
)
times = np.linspace(0.0, 40.0, 4001)
x0 = np.array([8.0, 0.0, 30.0], dtype=float)
LE, LE_history, Q_history, R_history, clv_history, D_history, traj = lyap_analysis_from_ic(
lorenz,
jacobian,
x0,
times,
stepper="rk4",
)
print("Asymptotic Lyapunov exponents:", LE)
See tutorials/lorenz_numpy_quickstart.ipynb for the NumPy walkthrough, and tutorials/lorenz_pytorch_quickstart.ipynb for the PyTorch version.
Want only the most unstable directions? Pass n_lyap=k to any of the Lyapunov helpers (lyap_exp, lyap_analysis, and their _from_ic counterparts) to compute just the leading k exponents/BLVs/CLVs.
Angles and instantaneous CLVs
from clvlib.numpy import compute_angles, principal_angles, compute_ICLE
# Pairwise vector angles
cosine, theta = compute_angles(clv_history[:, :, 0], clv_history[:, :, 1])
# Principal angles between subspaces
angles = principal_angles(clv_history[:, :, -1:], clv_history[:, :, :-1])
# Instantaneous covariant exponents sampled every k_step iterations
icle = compute_ICLE(jacobian, traj, times, clv_history, k_step=1)
Citation
If clvlib contributes to your published work, please cite it as:
@software{consonni_clvlib_2025,
author = {Riccardo Consonni, Luca Magri},
title = {clvlib: a library to compute covariant Lyapunov vectors},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.19741279},
url = {https://doi.org/10.5281/zenodo.19741279},
}
License
Published under the MIT License. See LICENSE for the full text.
References
[1] Benettin, G., Galgani, L., Giorgilli, A., & Strelcyn, J.-M. (1980). Lyapunov characteristic exponents for smooth dynamical systems and for Hamiltonian systems; a method for computing all of them. Part 1: Theory. Meccanica, 15(1), 9–20.
[2] Ginelli, F., Poggi, P., Turchi, A., Chaté, H., Livi, R., & Politi, A. (2007). Characterizing dynamics with covariant Lyapunov vectors. Physical Review Letters, 99(13), 130601.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clvlib-0.1.5.tar.gz.
File metadata
- Download URL: clvlib-0.1.5.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
805e3353318a957a59b5da3005e1479240481471846e4bfb72cc4e54aefd064b
|
|
| MD5 |
0e6acb62e38de034d039ff22d4a815fa
|
|
| BLAKE2b-256 |
3503a0b6b657ca159c11a32cb720ae5b41ce4cf87b966f0ffd75c205d22120e1
|
Provenance
The following attestation bundles were made for clvlib-0.1.5.tar.gz:
Publisher:
publish.yml on MagriLab/clvlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clvlib-0.1.5.tar.gz -
Subject digest:
805e3353318a957a59b5da3005e1479240481471846e4bfb72cc4e54aefd064b - Sigstore transparency entry: 1382266077
- Sigstore integration time:
-
Permalink:
MagriLab/clvlib@5634da314c828be300785fa8d4fa5bba82bbe09b -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MagriLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5634da314c828be300785fa8d4fa5bba82bbe09b -
Trigger Event:
release
-
Statement type:
File details
Details for the file clvlib-0.1.5-py3-none-any.whl.
File metadata
- Download URL: clvlib-0.1.5-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f97fc18436a0ceb1e397cfa7bfc7b5e280d72e0dc4c903f1a9edb63762d4c069
|
|
| MD5 |
7d9be2cc91d00c5e710ee4ac0608cff2
|
|
| BLAKE2b-256 |
d39b6409f275ac7b5d1cf0eada144e3c0b2db9a99e8f9a35c1d6ff4d8a8a7ac9
|
Provenance
The following attestation bundles were made for clvlib-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on MagriLab/clvlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clvlib-0.1.5-py3-none-any.whl -
Subject digest:
f97fc18436a0ceb1e397cfa7bfc7b5e280d72e0dc4c903f1a9edb63762d4c069 - Sigstore transparency entry: 1382266116
- Sigstore integration time:
-
Permalink:
MagriLab/clvlib@5634da314c828be300785fa8d4fa5bba82bbe09b -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MagriLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5634da314c828be300785fa8d4fa5bba82bbe09b -
Trigger Event:
release
-
Statement type: