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

Uploaded CPython 3.12+Windows x86-64

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

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12+macOS 11.0+ ARM64

tsdynamics-5.3.1-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.3.1.tar.gz.

File metadata

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

File hashes

Hashes for tsdynamics-5.3.1.tar.gz
Algorithm Hash digest
SHA256 95250c4863e16f77a852da7e5b62caa9c5808db9688480bea99240bf24baf110
MD5 7a5c68cf3ac412c7d6aa75354d592514
BLAKE2b-256 9e8ba9a319e3aa4210ad1d823cbd61831eeade89e94d3bc663653903a4413112

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: tsdynamics-5.3.1-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.3.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4b5e4c824bc8be178827f3362572d767623726662a4541b4eb954ca066f21707
MD5 0a39bb545aa4f8c382d942302d83f1be
BLAKE2b-256 fd04f807d5baa2b855fca1a7a35060d2444c2aa6afc81ac73bdbab0291d862ed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.1-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4e068bacee61c2690aa35707185e0b0c507bbe012c8d3015338b815da280875e
MD5 1b987edc0675764d9f721377967c32b9
BLAKE2b-256 dc967c9a3c1a13b557853ba5c1d85fadc95bf6eea4d62ba6f5df5fa5d14f4843

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.1-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4fdba28532a9c2e87d577f5c9b4289fc44ffbc1a2b0fac515e498f8d638338b8
MD5 3bd4921d400f834c314d5153ffeafdeb
BLAKE2b-256 04fc445c60ca2d3c34a8f19bea6bfc835726ac675657a6f6d645de938e9762e2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62c8551ecbfd435454b439f5612ba28ea9dd4cd7d6634f06aa3b83dbb5bb4d9d
MD5 ae9bc5e8cdf4686eefadb0ef2810461b
BLAKE2b-256 7172c9db82c3f5e2655009c6a74116a83191eaa980db3dd89f4525b583141e61

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e78fc969362eedceb9606358e19b9c19773e176221e05d88698c9b37e39106dc
MD5 5baf8677502dd6116b84463d2210e595
BLAKE2b-256 f72e0b7b83485d0be1d89179d7614a9d6133a6370b0b8ffe5c62ee5871c79d1a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 787d456b4ff8e3ab581270afe0a1f6eebd51a40219ed9f02cfd41f4890897548
MD5 d1d009d004f891f3667698c2f53a69a1
BLAKE2b-256 848170a15b6b6c28c8302f4f15c056a4326aa55306a1e92225e245c9c461f2d8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.1-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 056b1f50ce9279dfa341ad91ad5714457fc8013bb2e1bc3d86b9d2790d2a2404
MD5 d469b58135e730e651ab7b8e019c35af
BLAKE2b-256 a82763a8bfea80ee6a521a6e95c6f3ad098a6c4edc5a79f5c62b1bf5fd6c0e25

See more details on using hashes here.

Provenance

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