Skip to main content

Differential Equation System Solver

Project description

DESolver

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 3.0, but that's far off for now.

Latest Release

2.5.0 - Event detection has been added to the library. 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

Adaptive Methods

Explicit Methods

  1. Runge-Kutta 45 with Cash-Karp Coefficients
  2. Adaptive Heun-Euler Method

Implicit Methods

NOT YET IMPLEMENTED

Fixed Step Methods

Explicit Methods

  1. Midpoint Method
  2. Heun's Method
  3. Euler's Method
  4. Euler-Trapezoidal Method
  5. BABs9o7H Method -- Based on arXiv:1501.04345v2 - BAB's9o7H
  6. ABAs5o6HA Method -- Based on arXiv:1501.04345v2 - ABAs5o6H
  7. Runge-Kutta 5 - The 5th order integrator from RK45. Very accurate with fixed step size.

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

@de.rhs_prettifier("""[vx, x]""")
def rhs(t, state, **kwargs):
    x,vx = state

    dx  = vx
    dvx = -x

    return D.array([dx, dvx])

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-6, atol=1e-9)

a.show_system()

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, 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-2.5.9.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

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

desolver-2.5.9-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: desolver-2.5.9.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.3

File hashes

Hashes for desolver-2.5.9.tar.gz
Algorithm Hash digest
SHA256 df53f07575526c1ec25015fcab4586cfb514c9d78c6d05881e3443cc22c20102
MD5 b5d1c0687661f423ac632266ba011cf0
BLAKE2b-256 483ff92c22ec26f06dd57b8c55d0f00ff6e9d050e1f933f7404f2c850e08527c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: desolver-2.5.9-py3-none-any.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.3

File hashes

Hashes for desolver-2.5.9-py3-none-any.whl
Algorithm Hash digest
SHA256 0d1dc753e722870a0239d88b311b451ae6b07bd46bdeea6525327867c7f52653
MD5 d89d5b153c541fc117c39b051ee00731
BLAKE2b-256 91b554a02ec0d1dee65f6cecaa129300ec2e10d5ece968aad5cff85f52968081

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