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

Uploaded CPython 3.12+Windows x86-64

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

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12+macOS 11.0+ ARM64

tsdynamics-5.3.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.3.0.tar.gz.

File metadata

  • Download URL: tsdynamics-5.3.0.tar.gz
  • Upload date:
  • Size: 911.0 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.0.tar.gz
Algorithm Hash digest
SHA256 a6934c38bf3d5f0c045c23021af475166e4a89c7698407177e600046c3099f55
MD5 67177d10492523cf274a18529b9de26c
BLAKE2b-256 3a90c1563423ee1e168f5d516db2cbc13df323acd7f1d3c341a8d92bbcb2e991

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: tsdynamics-5.3.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.3.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3b0a07d4aa22e6ee2ac396dafdc349c05927b3f663b800db43f2b8dfbdd88838
MD5 afbb8b5a6ec2f3aa5579cedeb84ce129
BLAKE2b-256 e1de387cfdab02740861936389e004cb2f249350516b26ace07aa1b7d3150276

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.0-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a7c63d5a0b9fd2fec45cac8cebfe4797cf5c38b1331c035e86097ec3c3bed863
MD5 93903ed32552378ecdd853380f3cc7c5
BLAKE2b-256 37b152b2f147c29a17b14726161a355aa7bd4847769e2a094fdce5eede646c9d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.0-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 64e554fef4b0a95fff3a32cd08e20c5a2fcbd65f93419e0df323c974d8d70280
MD5 efe533daac0cc9ce7f78b76b6d956da2
BLAKE2b-256 e48f0cdfa0b8f66119b1275538d4e923c9ef92404011686ff366186917f38820

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22bb42efa8937e606251126f711750fbf23b8edfa0dbd72602be332d5495e490
MD5 79cbca25d12a1d29c27d72ff5cba29df
BLAKE2b-256 01268dfcfcc4c34488a221e73af133a1384c2c6cb8f2813646a8f71cebff3c2a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b48279139c0d64d5ba2e55ab09256e826a21144e21525b733945c9ca9e850631
MD5 192c402fe87e3cc6e7612e53f27b85a0
BLAKE2b-256 3d24e4842e78afaef3b3ce41d7e3cc6c2e107e089138a71d4ba3b60e40941875

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e6d6e810540a30dcdcef3413d49ba671ff809b145c2cdc650df8f95ca818336
MD5 47042aefd7e8c7a9437470a09377fb72
BLAKE2b-256 6a9019b284d1264f5efb8e3e00a211199a3a0d49434920a3564daf5ce3071d56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tsdynamics-5.3.0-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dcf1555582a590d44fc226b1f1c84d227ac3089cb7c01392d7ce5b5893a92a73
MD5 7158158992325c5f5c27163e565a48a0
BLAKE2b-256 cc90b9d355d146c7d958aaf51aee5d1ef4e871bd931f92db7a370b93d346e866

See more details on using hashes here.

Provenance

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