Skip to main content

Extend scipy.integrate with various methods for solve_ivp

Project description

extensisq

This package extends scipy.integrate with various methods (OdeSolver classes) for the solve_ivp function.

python:3 platform:noarch license:MIT downloads pypi downloads conda release-date

Currently, several explicit Runge Kutta methods (for non-stiff problems) are provided.

Three explicit Runge Kutta methods of order 5 and two variants are implemented:

  • BS45: efficient solver with an accurate high order interpolant by Bogacki and Shampine [1]. The variant BS45_i has a free, lower order interpolant.
  • CK45: variable order solver by Cash and Karp, tailored to solve non-smooth problems efficiently [2]. The variant CK45_o is a fixed (fifth) order method with the same coefficients.
  • Ts45: relatively new solver (2011) by Tsitouras, optimized with fewer simplifying assumptions [3].

Three higher order explicit Runge Kutta methods by Prince [4] are implemented:

  • Pri6: a seventh order discrete method with fifth order error estimate, derived from a sixth order continuous method.
  • Pri7: an eighth order discrete method with sixth order error estimate, derived from a seventh order continuous method.
  • Pri8: a ninth order discrete method with seventh order error estimate, derived from an eighth order continuous method.

The numbers in the names refer to the continuous methods. These higher order methods, unlike conventional discrete methods, do not require additional function evaluations for dense output.

Installation

You can install extensisq from PyPI:

pip install extensisq

Or, if you'd rather use conda:

conda install -c conda-forge extensisq

Example

Borrowed from the the scipy documentation:

from scipy.integrate import solve_ivp
from extensisq import BS45_i

def exponential_decay(t, y): return -0.5 * y
sol = solve_ivp(exponential_decay, [0, 10], [2, 4, 8], method=BS45_i)

print(sol.t)
print(sol.y)

Note that the class BS45_i is passed to solve_ivp, not the string "BS45_i". The other methods (BS45, CK45, CK45_o, Ts45, Pri6, Pri7 and Pri8) can be used in a similar way.

More examples are available as notebooks:

  1. Duffing's equation, Bogacki Shampine method
  2. Non-smooth problem, Cash Karp method
  3. Lotka Volterra equation, all fifth order methods
  4. Riccati equation, higher order Prince methods

References

[1] P. Bogacki, L.F. Shampine, "An efficient Runge-Kutta (4,5) pair", Computers & Mathematics with Applications, Vol. 32, No. 6, 1996, pp. 15-28, ISSN 0898-1221. https://doi.org/10.1016/0898-1221(96)00141-1

[2] J. R. Cash, A. H. Karp, "A Variable Order Runge-Kutta Method for Initial Value Problems with Rapidly Varying Right-Hand Sides", ACM Trans. Math. Softw., Vol. 16, No. 3, 1990, pp. 201-222, ISSN 0098-3500. https://doi.org/10.1145/79505.79507

[3] Ch. Tsitouras, "Runge-Kutta pairs of order 5(4) satisfying only the first column simplifying assumption", Computers & Mathematics with Applications, Vol. 62, No. 2, pp. 770 - 775, 2011. https://doi.org/10.1016/j.camwa.2011.06.002

[4] P.J. Prince, "Parallel Derivation of Efficient Continuous/Discrete Explicit Runge-Kutta Methods", Guisborough TS14 6NP U.K., September 6 2018. http://www.peteprince.co.uk/parallel.pdf

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

extensisq-0.1.1.tar.gz (32.4 kB view details)

Uploaded Source

File details

Details for the file extensisq-0.1.1.tar.gz.

File metadata

  • Download URL: extensisq-0.1.1.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3.post20210118 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

File hashes

Hashes for extensisq-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ea76dac9cc110b77f245b3cc0f4b4f171f646ca30897ec3ed26abd2c7306a6e5
MD5 7f2460613c4c23907a036d7974e1d0c9
BLAKE2b-256 2e6263139aaf8e6b8935de2dcbf8deaa17fcab1da90321e3b4c52b66030b60ab

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