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.4.0.tar.gz (915.8 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.4.0-cp312-abi3-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.12+Windows x86-64

tsdynamics-5.4.0-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.4.0-cp312-abi3-musllinux_1_2_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

tsdynamics-5.4.0-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.4.0-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.4.0-cp312-abi3-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

tsdynamics-5.4.0-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.4.0.tar.gz.

File metadata

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

File hashes

Hashes for tsdynamics-5.4.0.tar.gz
Algorithm Hash digest
SHA256 9b6cec35ec7cb4428d17616c730a5742fe77af0e32f5144d6086d7461322ad3a
MD5 916afd7dacac8df8bb17f58ae58c4003
BLAKE2b-256 f07271a5a5a918ecb395fd9d1c25e9c4d8a34f46f3bd9a472c12a18443935441

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.4.0.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.4.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: tsdynamics-5.4.0-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.4.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 28d82c56a1ffbd3fdd517ff03a4e713a0346ff3e1165469c1f2595887308fa7a
MD5 8a007fb41b26068d895ffec2834bc041
BLAKE2b-256 b2dda508c63555cc30ef11516af3bbe90ec4535cb1eafa2c66cba18b43f32c45

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.4.0-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.4.0-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.4.0-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 18d52f3a9381d9ad650a9fa22c849cd2ecd0e23335f7f4c0738643a6eb1f6e81
MD5 32f14b6bbcfa541d4a399212cfbd6071
BLAKE2b-256 28b63aa81957da798d8ddf0d27653dfa11bee56430a26769d3a59b77bdb6d519

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.4.0-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.4.0-cp312-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.4.0-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5987f3f5b627a87fdbf55a68f4b3b5594048629a9ae343f73d80174e22bab8e0
MD5 5b761c81654af879d9c12258e87ddaec
BLAKE2b-256 55d940109bce5ac56c300c8133ed779014b97f0a24df9fa7eca6fa01cfe8d4e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.4.0-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.4.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.4.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 536beaeec8c2585b7b335e261e036ef9e59e6b787e96f22c375b097e2bada9a9
MD5 3346adafd60855ddbf8ece5003a1a391
BLAKE2b-256 f909765fda7a7bc358f1dd8a855bd5207676518c9b0603b757acfa4abed578c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.4.0-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.4.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.4.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0adf04ea5d93829e43243fdb553e31d7083c06fc9079ad9f1228a54d982515aa
MD5 10436d878e8e77e2d52d4aee2c27ebbb
BLAKE2b-256 4b2ffa30e35f28d442de31de148f50fe93ffa7ea611043eacc06d41c6ea18574

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.4.0-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.4.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.4.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea2d964e467ebd6ae4257206de52520872ccc18cf4b990edbb1cd9e65faa0b40
MD5 3f1cfc1cce1acd8a59e9f248001ac75b
BLAKE2b-256 907651b53a3e099c30ed90a08ea86b507d7223a03deb5cb3e675d0625f92c6e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.4.0-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.4.0-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tsdynamics-5.4.0-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c42bf50ebb8f30ac55381e9e88b5039b60919b04531174a136b7b35686a4cb9f
MD5 b6255f849660703c3ed68ad83a9c2ea4
BLAKE2b-256 602554347d616b27277d61b9778c1f37130a3d36ed38eb3aa654cd8ec59ac5d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for tsdynamics-5.4.0-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