Giter Club home page Giter Club logo

duncdennis / lorenzpy Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 2.54 MB

A Python package to simulate and measure chaotic dynamical systems.

Home Page: https://duncdennis.github.io/lorenzpy/

License: MIT License

Python 100.00%
chaos chaos-theory dynamical-systems lorenz lorenz-attractor lyapunov lyapunov-exponents python attractor double-pendulum henon-map kuramoto-sivashinsky logistic-map lorenz96 mackey-glass nonlinear rossler-attractor simulation chaotic-dynamical-systems chaotic-systems

lorenzpy's Introduction

LorenzPy

A Python package to simulate and measure chaotic dynamical systems.

Code style: black Ruff codecov license: MIT Python versions


Flow-Attractors


⚙️ Installation

To install only the core functionality:

$ pip install lorenzpy

To install with the additional plotting functionality. This also installs matplotlib. ⚠️ Plotting functionality not in a useful state.

$ pip install lorenzpy[plot]

▶️ Usage

LorenzPy can be used to simulate and measure chaotic dynamical systems. The following example shows how to simulate the famous Lorenz63 system, and measure its largest Lyapunov exponent from the Lorenz63 iterator:

import lorenzpy as lpy

# Initialize the Lorenz63 simulation object with a RK4 time step of dt=0.05
l63_obj = lpy.simulations.Lorenz63(dt=0.05)

# Simulate 5000 steps of the Lorenz63 system:
data = l63_obj.simulate(5000)    # -> data.shape = (5000,3)

# Calculate the largest Lyapunov exponent from the l63_obj iterator:
iterator = l63_obj.iterate
lle = lpy.measures.largest_lyapunov_exponent(
    iterator_func=iterator,
    starting_point=l63_obj.get_default_starting_pnt(),
    dt=l63_obj.dt
)
# -> lle = 0.905144329...

The calculated largest Lyapunov exponent of 0.9051... is very close to the literature value of 0.90561.

For more examples see the examples folder.

💫 Supported systems

Name Type System Dimension
Lorenz63 autonomous dissipative flow 3
Roessler autonomous dissipative flow 3
ComplexButterfly autonomous dissipative flow 3
Chen autonomous dissipative flow 3
ChuaCircuit autonomous dissipative flow 3
Thomas autonomous dissipative flow 3
WindmiAttractor autonomous dissipative flow 3
Rucklidge autonomous dissipative flow 3
Halvorsen autonomous dissipative flow 3
DoubleScroll autonomous dissipative flow 3
Lorenz96 autonomous dissipative flow variable
DoublePendulum conservative flow 4
Logistic noninvertible map 1
Henon dissipative map 2
SimplestDrivenChaoticFlow conservative flow 2 space + 1 time
KuramotoSivashinsky PDE variable
MackeyGlass delay differential equation variable

📗 Documentation

⚠️ Further notes

  • So far the usefulness of this package is very limited. The authors main purpose to creating this package was to learn the full workflow to develop a Python package. More information about the development process can be found in CONTRIBUTING.md.
  • The plotting functionality, which can be installed with pip install lorenzpy[plot] is not tested so far.
  • See Pynamical for a similar package

Footnotes

  1. Sprott, Julien Clinton, and Julien C. Sprott. Chaos and time-series analysis. Vol. 69. Oxford: Oxford university press, 2003.

lorenzpy's People

Contributors

duncdennis avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

summuk

lorenzpy's Issues

Wrong type-annotation for solver argument in simulation object initialization

(Version v0.0.2 of LorenzPy)

The type annotations of all systems using the solver argument are wrong. There are three different kinds of problems:

  1. For all autonomous flows, the type-annotation for the solver argument uses str twice:
    def __init__(
        self,
        sigma: float = 10.0,
        rho: float = 28.0,
        beta: float = 8 / 3,
        dt: float = 0.03,
        solver: str | str | Callable[[Callable, float, np.ndarray], np.ndarray] = "rk4",
    ):
  1. For MackeyGlass the type-annotation is only specifed as Callable:
    def __init__(
        self,
        a: float = 0.2,
        b: float = 0.1,
        c: int = 10,
        tau: float = 23.0,
        dt: float = 0.1,
        solver: str | Callable = "rk4",
    ) -> None:
  1. For SimplestDrivenChaotic there is no type annotation for solver:
    def __init__(self, omega: float = 1.88, dt: float = 0.1, solver="rk4") -> None:
        """Initialize the SimplestDrivenChaotic simulation object."""
        super().__init__(dt, solver)
        self.omega = omega

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.