Skip to main content

Differential Equation System Solver

Project description

DESolver

Build Status Documentation Status codecov BCH compliance

This is a python package for solving Initial Value Problems using various numerical integrators. Many integration routines are included ranging from fixed step to symplectic to adaptive integrators.

Implicit integrators are intended for release 4.0, but that’s far off for now.

Documentation

Documentation is now available at desolver docs! This will be updated with new examples as they are written, currently the examples show the use of pyaudi.

Latest Release

3.0.0 - PyAudi support has been finalised. It is now possible to do numerical integrations using gdual variables such as gdual_double, gdual_vdouble and gdual_real128 (only on select platforms, refer to pyaudi docs for more information). Install desolver with pyaudi support using pip install desolver[pyaudi]. Documentation has also been added and is available at desolver docs.

2.5.0 - Event detection has been added to the module. It is now possible to do numerical integration with terminal and non-terminal events.

2.2.0 - PyTorch backend is now implemented. It is now possible to numerically integrate a system of equations that use pytorch tensors and then compute gradients from these.

Use of PyTorch backend requires installation of PyTorch from here.

To Install:

Just type

pip install desolver

Implemented Integration Methods

Explicit Methods

Adaptive Methods
  1. Runge-Kutta 14(12) with Feagin Coefficients [NEW]

  2. Runge-Kutta 10(8) with Feagin Coefficients [NEW]

  3. Runge-Kutta 8(7) with Dormand-Prince Coefficients [NEW]

  4. Runge-Kutta 4(5) with Cash-Karp Coefficients

  5. Adaptive Heun-Euler Method

Fixed Step Methods
  1. Runge-Kutta 4 - The classic RK4 integrator

  2. Runge-Kutta 5 - The 5th order integrator from RK45 with Cash-Karp Coefficients.

  3. BABs9o7H Method – Based on arXiv:1501.04345v2 - BAB’s9o7H

  4. ABAs5o6HA Method – Based on arXiv:1501.04345v2 - ABAs5o6H

  5. Midpoint Method

  6. Heun’s Method

  7. Euler’s Method

  8. Euler-Trapezoidal Method

Implicit Methods

NOT YET IMPLEMENTED

Minimal Working Example

This example shows the integration of a harmonic oscillator using DESolver.

import desolver as de
import desolver.backend as D

def rhs(t, state, k, m, **kwargs):
    return D.array([[0.0, 1.0], [-k/m,  0.0]])@state

y_init = D.array([1., 0.])

a = de.OdeSystem(rhs, y0=y_init, dense_output=True, t=(0, 2*D.pi), dt=0.01, rtol=1e-9, atol=1e-9, constants=dict(k=1.0, m=1.0))

print(a)

a.integrate()

print(a)

print("If the integration was successful and correct, a[0].y and a[-1].y should be near identical.")
print("a[0].y  = {}".format(a[0].y))
print("a[-1].y = {}".format(a[-1].y))

print("Maximum difference from initial state after one oscillation cycle: {}".format(D.max(D.abs(a[0].y-a[-1].y))))

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

desolver-3.0.1.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

desolver-3.0.1-py3-none-any.whl (62.7 kB view details)

Uploaded Python 3

File details

Details for the file desolver-3.0.1.tar.gz.

File metadata

  • Download URL: desolver-3.0.1.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0.post20200112 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

File hashes

Hashes for desolver-3.0.1.tar.gz
Algorithm Hash digest
SHA256 5dbc2d3c7e8ad6302daf874660dba3bde96ccf6f9cf3c592b32df96ae6d3734a
MD5 907b36251f065884f5dbea27d3a59db6
BLAKE2b-256 9dcf665cb572404f39f08d1e7cdcd0134ce065e4b61b9300a824642fdc1b4aad

See more details on using hashes here.

File details

Details for the file desolver-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: desolver-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 62.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0.post20200112 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

File hashes

Hashes for desolver-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d378cfe8182ca4b954e037727fb8e4107001b03fd7e6a5c5cb4f8295c80ed84a
MD5 2438f53e1714e9b5118410c25ea9671a
BLAKE2b-256 164b2dc3b7d20ee6cb723e2e35ef983886931c54b67be97058cad23e6a47cb5e

See more details on using hashes here.

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