Code Monkey home page Code Monkey logo

pnkraemer / diffeqzoo Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 2.0 683 KB

A zoo of implementations of differential equation problems in NumPy and JAX. Oscillators, chemical reactions, n-body problems, epidemiological models, IVPs, BVPs, and more.

Home Page: https://diffeqzoo.readthedocs.io

License: MIT License

Python 97.45% Makefile 2.55%
numerical-methods scientific-computing boundary-value-problem initial-value-problem ordinary-differential-equations jax numpy

diffeqzoo's Introduction

diffeqzoo

PyPi Version Docs GitHub stars gh-actions License Badge

So, what was the initial condition of the restricted three-body problem again?

diffeqzoo delivers all differential equation test problems in one place. It works with numpy and jax.

Installation

Get the most recent stable version from PyPi:

pip install diffeqzoo

Or directly from GitHub:

pip install git+https://github.com/pnkraemer/diffeqzoo.git

These commands assume that NumPy or JAX are installed separately by the user. Read more about installing this package here.

Features include

  • Oscillating systems (Lotka-Volterra, Fitzhugh-Nagumo, Van-der-Pol, ...)
  • Chaotic systems (Lorenz63, Lorenz96, Roessler, ...)
  • Epidemiological models (SIR, SEIR, SIRD, ...)
  • N-Body problems and celestial mechanics (Rigid-body, restricted-three-body, Pleiades, Henon-Heiles, ...)
  • Chemical reactions (HIRES, ROBER, ...)
  • Boundary value problems

As well as

  • Flexibly NumPy and JAX-backends. Other than one of those two, there are 0 (zero!) dependencies.
  • Mathematical descriptions and BibTex entries of the ODE problems
  • Compatibility with all NumPy/JAX-based ODE solvers: SciPy, JAX, Diffrax, ProbNum, Tornadox, etc..

and many more goodies.

Quick example

>>> from diffeqzoo import ivps, backend
>>> backend.select("numpy")
>>>
>>> # Create test problems like this
>>> f, u0, t_span, f_args = ivps.lotka_volterra()
>>> x = f(u0, *f_args)
>>> print(x)
[-10.  10.]
>>>
>>> # The numpy backend determines the type of input/output
>>> print(type(x))
<class 'numpy.ndarray'>
>>>
>>> # All sorts of ODEs are available, e.g., Rigid-Body:
>>> f, u0, t_span, f_args = ivps.rigid_body()
>>> print(f(u0, *f_args))
[-0.     1.125 -0.   ]
>>>
>>> ## make it jax
>>> backend.change_to("jax")
>>> f, u0, t_span, f_args = ivps.rigid_body()
>>> x = f(u0, *f_args)
>>> print(x)
[-0.     1.125 -0.   ]
>>> print(type(x))
<class 'jaxlib.xla_extension.ArrayImpl'>

Similar projects

  • F. Mazzia et al. published a test set for IVP solvers for Matlab and Fortran. There is a similar test set for BVP solvers. Neither one offers Python code, and both also run benchmarks, which diffeqzoo does not care about at all.
  • E. Hairer et al. published their stiff ODE test set, but there is no Python code
  • NonlinearBenchmark hosts datasets of nonlinear dynamical system observations. They are quite specialised problems, and don't contain the textbook problems like Lotka-Volterra, van der Pol, etc..
  • DifferentialEquations.jl provides example ODE problems in Julia.
  • ProbNum's problem zoo offers a similar set of problems to diffeqzoo (no surprise -- the set of authors intersects) but tied to ProbNum's ODE solver interface. diffeqzoo is less of an API, switches more flexibly between numpy and jax (at the time of developing), and contains more problems.
  • W. Gilpin published a benchmark for forecasting and data-driven modeling, which comes with a large number of (mostly chaotic) dynamical systems.
  • J. Meier lists a number of ODE attractors on his website.
  • GeometricProblems.jl curates a similar list of example problems with interesting geometric structure, in Julia (link)

Anything missing in this list? Please open an issue or make a pull request.

diffeqzoo's People

Contributors

boletaceae avatar pnkraemer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

diffeqzoo's Issues

Documentation for ODE problems

Must have:

  • A reference to the original paper (or whatever one can find)
  • A description of what it models, and why it is interesting

Nice to have:

  • Meanings of parameter names
  • Maths
  • Example usage of the function

Design choices

Mention the design choices somewhere (implementation as raw as possible even if it implies a slightly annoying API, implement in a way that makes it easy to use for benchmarks and papers, take second-order, non-autonomous, mass-matric, problems seriously, etc.)

Make notebooks a bit nicer

The notebooks are there and working, but

  • use the old API (with namedtuple outputs)
  • Have no text
  • Are not rendered with plots in the docs

Would be great to give them some care

Rethink conversion functionality

  • should it be a subpackage, with a more granular functionality? for BVPs, vector field conversion remains the same, but the function does not apply anymore.
  • The jacobian conversion is incorrect. It does not convert the output appropriately.
  • The functionality is not used anywhere (e.g., in the notebooks), so I have no idea how useful it is.
  • Mark somewhere that it is very experimental (even more than the rest). Complete conversion is, in the end, something the user has to do.

One-dimensional problems

What do we do with one-dimensional problems? Implement them as scalars (0-dimensional arrays), 1-dimensional arrays, or both?

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.