Skip to main content

Zero-warmup Rust-engine ODE/DDE/SDE integration, discrete maps, and chaos analysis for dynamical systems.

Project description

TSDynamics

Python CI Release Docs PyPI codecov

Dynamical systems in Python: 151 built-in systems, a native Rust integration engine, and a chaos-analysis toolkit — with the simplest system-definition contract anywhere.

You write the math (one symbolic method); TSDynamics lowers it to a native Rust engine and handles integration, Lyapunov spectra, bifurcation diagrams, Poincaré sections, attractors & basins — and even the documentation page for your system.

A spinning Lorenz attractor
A built-in Lorenz attractor — integrated, spun, and saved to a GIF (code below).

import tsdynamics as ts

lor = ts.Lorenz()
traj = lor.integrate(final_time=100.0, dt=0.01)
traj["x"]                              # named component access
lor.lyapunov_spectrum()                # → [0.91, ~0, -14.57]
ts.kaplan_yorke_dimension(_)           # → ~2.06

📖 Documentation: https://el3ssar.github.io/TSDynamics/


Define your own system

import tsdynamics as ts

class Rossler(ts.ContinuousSystem):
    params = {"a": 0.2, "b": 0.2, "c": 5.7}
    dim = 3
    variables = ("x", "y", "z")            # optional niceties

    @staticmethod
    def _equations(y, t, *, a, b, c):
        x, yv, z = y(0), y(1), y(2)
        return (-yv - z, x + a * yv, b + z * (x - c))

That's the whole contract. The class auto-registers: every analysis tool works on it, the test-suite sweeps it, and the docs build renders its equations (LaTeX, straight from the symbolics) and its attractor — zero extra steps. Delay systems use y(0, t - tau); maps implement _step/_jacobian (signature order validated at import); SDEs add a _diffusion term.

From equations to figures

Every system produces a Trajectory, and every Trajectory knows how to plot itself (to_plot_spec auto-detects the right kind from the data). The plot is a backend-neutral spec you tweak fluently, then render or save to matplotlib, plotly (interactive), or a three.js / JSON export.

Bifurcation diagram of the logistic map, with the period-doubling onsets marked — orbit_diagram is one call, and .bifurcation_points() finds the cascade ($r_1 = 3$, $r_2 = 1 + \sqrt6 \approx 3.449$, …):

import numpy as np, tsdynamics as ts
from tsdynamics.viz import Annotation

orbit = ts.orbit_diagram(ts.Logistic(), "r", np.linspace(2.8, 4.0, 2000))
pts = orbit.bifurcation_points()

spec = orbit.to_plot_spec().relabel(x="r", y="x*", title="Logistic bifurcation")
spec.style(color="k", s=0.2, alpha=0.5)                  # tiny semi-transparent dots
spec.annotations = [
    Annotation("vline", x=pts[i], text=lbl, style={"color": "red", "linestyle": "--"})
    for i, lbl in [(0, " r₁"), (1, " r₂"), (3, " r₄")]
]
spec.save("bifurcation.png", size=(1600, 700))

Logistic bifurcation diagram

A PDE, too — the Kuramoto–Sivashinsky equation is a built-in spatially extended system; its space–time field is auto-detected and drawn as a heatmap:

ks = ts.KuramotoSivashinsky(N=128, L=22.0)
traj = ks.integrate(final_time=200.0, dt=0.25)
traj.to_plot_spec().save("ks.png")        # 128-mode space–time field

Kuramoto–Sivashinsky space–time field

The spinning attractor at the top is the same to_plot_spec, animated:

traj = ts.Lorenz().integrate(final_time=100.0, dt=0.01)
spec = traj.to_plot_spec()
spec.style(axes=False).trail(None).camera(spin=0.4)      # full curve, no axes, rotate
spec.animate(fps=30, duration=10, loop=True)
spec.save("lorenz.gif")

A taste of the analysis layer

import numpy as np, tsdynamics as ts

# Poincaré section of the Rössler attractor (root-refined crossings)
section = ts.poincare_section(ts.Rossler(), plane=("y", 0.0, "up"), n=500)

# Fixed points of the Hénon map, with stability
ts.fixed_points(ts.Henon())
# [FixedPoint([-1.1314 -0.3394], unstable), FixedPoint([0.6314 0.1894], unstable)]

# Maximal Lyapunov exponent — no Jacobian needed
ts.max_lyapunov(ts.Lorenz(ic=[1, 1, 1]), dt=0.05)        # ≈ 0.9

Plus: attractors & basins of any flow or map, correlation/Rényi fractal dimensions, permutation/sample/dispersion entropy, RQA (recurrence quantification), surrogate hypothesis tests, delay embedding (Takens, optimal τ, Cao/FNN), GALI & the 0–1 chaos test, and Lyapunov exponents from a bare time series (Kantz/Rosenstein).

Highlights

  • Three families, one interface

    • ODEs

    • DDEs

    • SDEs

    • Discrete Maps

  • 151 built-in systems with literature parameters.

  • Native engine: equations lower to a Rust engine (an SSA-tape interpreter, with a Cranelift JIT alongside) in-process; parameters are runtime values, so changing them is free and there is no compile step or cache.

  • Composition — a PoincareMap of a flow is a discrete map, so orbit_diagram(PoincareMap(Rossler(), ("y", 0.0)), "c", values) draws the bifurcation diagram of a flow in one line.

  • Backend-neutral plotting — one PlotSpec IR renders to matplotlib, plotly (interactive + animated HTML), three.js, or JSON, with a fluent styling/theming vocabulary.

Install

pip install tsdynamics            # or: uv add tsdynamics

A prebuilt abi3 wheel (manylinux / musllinux / macOS / Windows) bundles the native Rust engine. No Rust toolchain and no C compiler needed to install or run. Optional plotting extra: tsdynamics[plot,interactive] (matplotlib, plotly).

Development

git clone https://github.com/El3ssar/TSDynamics && cd TSDynamics
uv sync --group dev --group docs
uv run pytest -m "not slow" --no-cov     # fast tier
uv run pytest --no-cov                   # full local suite
TSD_DOCS_FIGURES=0 uv run mkdocs serve   # docs preview

Releases are automated: conventional-commit PR titles drive semantic-release on merge see CONTRIBUTING.

License

MIT © Daniel Estevez

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

tsdynamics-5.2.6.tar.gz (909.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tsdynamics-5.2.6-cp312-abi3-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.12+Windows x86-64

tsdynamics-5.2.6-cp312-abi3-musllinux_1_2_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ x86-64

tsdynamics-5.2.6-cp312-abi3-musllinux_1_2_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

tsdynamics-5.2.6-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

tsdynamics-5.2.6-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

tsdynamics-5.2.6-cp312-abi3-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

tsdynamics-5.2.6-cp312-abi3-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file tsdynamics-5.2.6.tar.gz.

File metadata

  • Download URL: tsdynamics-5.2.6.tar.gz
  • Upload date:
  • Size: 909.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for tsdynamics-5.2.6.tar.gz
Algorithm Hash digest
SHA256 d39e296848a04ae0d99dbefa22b4807702cca1a34313d8b865e4f00e7fa38482
MD5 a3ce4202ab46d08bac0b45ef0b5e16ac
BLAKE2b-256 18f382761d3080500fa2e9f0a71d807839bcd45efddf434bfe3c5ac0c17701cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.2.6.tar.gz:

Publisher: release.yml on El3ssar/TSDynamics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsdynamics-5.2.6-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: tsdynamics-5.2.6-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for tsdynamics-5.2.6-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6d1fd77f9196d5f9c9c2a2fd75ca6f942c522d111e5197ac09a4d5cc772473dc
MD5 b1896e806c53c47b7f01b57f8d848dfc
BLAKE2b-256 1dca1730ea28e7b874ea687a41342c903dc5117a4e09338ddb679b5712e57629

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.2.6-cp312-abi3-win_amd64.whl:

Publisher: release.yml on El3ssar/TSDynamics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsdynamics-5.2.6-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.2.6-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 853d8c195f97522c20aeb98db8ca793d49b753c014b59e288fa09b705e9c834c
MD5 828777c70d1f1e5a619acf9280e65c3e
BLAKE2b-256 af472ad684a2bdb04f0074332144d7f6a998dfbed78d454d43e7329aff5977f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.2.6-cp312-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on El3ssar/TSDynamics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsdynamics-5.2.6-cp312-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.2.6-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8ccbf2b43e53519c946e75a69ca00359af6f58db57f1f40cee38dcd667fadd7b
MD5 9a8fa3ad15bc223f4a869dc04de3feb2
BLAKE2b-256 18f412457abcd827dcb7cc16bdac225d9cbb8311ce5b3a9cbea8efd8e760c1dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.2.6-cp312-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on El3ssar/TSDynamics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsdynamics-5.2.6-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.2.6-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d6f2d8ce054409804550105583331a6106ba6ef6d6241770e6387d6e8ce3b4e
MD5 c67591ed92681315ec8e3f04e00af6d8
BLAKE2b-256 bbacd460faedb193ea68cfbc469fa4ed733a4252e03aec4f4ddf8491a7187af5

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.2.6-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on El3ssar/TSDynamics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsdynamics-5.2.6-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.2.6-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c93d63de1b669b51d75d7246cbb34e6940516eeece53ef220da0266909513ab1
MD5 e0fcf981a9610914a064f14d90b39104
BLAKE2b-256 2a36e4efa9dfbe7f1615c06a2d1085e7b84610960ba2cefe88631a2bf125be2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.2.6-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on El3ssar/TSDynamics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsdynamics-5.2.6-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.2.6-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 978e5f329555cec143d5dc634ffabbde342093962b572acac4f1791a66a6cde0
MD5 d444220838a80711b57d4c0fc975f251
BLAKE2b-256 089cbe311944d771cb7a7882d0528793c8e2b014fa5a620cb6e7756d037f2020

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.2.6-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on El3ssar/TSDynamics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tsdynamics-5.2.6-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.2.6-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8fadd6a6f45bb32ad2e7349d49ebf20cf794bf49de90964cd830ba7a5a74a2db
MD5 2045e3ffd2faa694032b702f729fc0df
BLAKE2b-256 5ec636ff983c462fab3734d1c134fbbf825b37723b5d01cc3e0e62c19d9612a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.2.6-cp312-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on El3ssar/TSDynamics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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