Skip to main content

Python bindings to the classic ZVODE ODE solver

Project description

zvode

Python bindings to the classic ZVODE ODE solver.

Tests PyPI Python License Docs

ZVODE is a variable-coefficient ODE solver for stiff and non-stiff systems of first-order ordinary differential equations with complex-valued state, written by P. N. Brown, G. D. Byrne, and A. C. Hindmarsh [2]. It is part of ODEPACK and uses a fixed-leading-coefficient Adams or BDF method, selectable by the user.

This package exposes two interfaces to ZVODE:

  • Procedural APIsolve_complex_ivp(fun, tspan, y0, ...): a single-call function in the spirit of scipy.integrate.odeint. This is the recommended starting point.
  • OdeSolver APIZVODE / ZVODE_BDF / ZVODE_Adams: a scipy.integrate.OdeSolver subclass for use with scipy.integrate.solve_ivp.

The underlying Fortran source has been modified; extern/README.md documents the changes.

Warning: This integrator is currently not thread-safe. You cannot have two threads using the ZVODE integrator simultaneously.

Table of Contents:

Installation

pip install zvode          # procedural API only (numpy only)
pip install zvode[scipy]   # also enables ZVODE / ZVODE_BDF / ZVODE_Adams (requires SciPy)

The OdeSolver classes (ZVODE, ZVODE_BDF, ZVODE_Adams) are a SciPy add-on: they subclass scipy.integrate.OdeSolver so they can be passed as the method argument to scipy.integrate.solve_ivp. If your code only uses solve_complex_ivp you do not need SciPy.

To install locally from source:

pip install .              # procedural API only
pip install ".[scipy]"     # also install SciPy
pip install ".[test]"      # run the test suite (includes SciPy)

Quick start

Procedural API — solve_complex_ivp

solve_complex_ivp is the recommended entry point. Pass the RHS function, a time span, and an initial condition; get back a result object with sol.t, sol.y, and integration statistics (sol.nfev, sol.njev, …) as attributes.

from zvode import solve_complex_ivp

def rhs(t, y):
    return [-100j * y[0] + y[1], -1j * y[1]]

def jac(t, y):
    return [[-100j, 1.0], [0.0, -1j]]

sol = solve_complex_ivp(
    fun=rhs,
    tspan=(0.0, 5.0),
    y0=[1.0 + 0j, 0.0 + 1j],
    method='BDF',
    jac=jac,
)

print(sol)

See the documentation for output modes, banded Jacobians, backward integration, compiled callbacks, and other options.

OdeSolver API (scipy-compatible)

Pass a ZVODE_* class as the method argument to scipy.integrate.solve_ivp.

Non-stiff problem — rotating complex exponential:

import numpy as np
from scipy.integrate import solve_ivp
from zvode import ZVODE_Adams

sol = solve_ivp(
    fun=lambda t, y: -1j * y,
    t_span=(0.0, 10.0),
    y0=[1.0 + 0.0j],
    method=ZVODE_Adams,
)

Stiff problem — with a user-supplied Jacobian:

from zvode import ZVODE_BDF

sol = solve_ivp(
    fun=lambda t, y: -1j * y,
    t_span=(0.0, 10.0),
    y0=[1.0 + 0.0j],
    method=ZVODE_BDF,
    jac=lambda t, y: [[-1j]],
)

More OdeSolver examples are in the docs/ folder on GitHub.

Limitations

  • complex floats (fp64) only
  • no event-handling/root-finding capabilities
  • not thread-safe (ZVODE uses global Fortran COMMON blocks)
  • no solution back-tracking available
  • only dense or banded Jacobians
  • no built-in mass matrix support (a constant mass matrix can be handled by pre-factoring with LU decomposition)

Links

ODEPACK & SUNDIALS

Python / R ecosystem

SciPy has historically provided a ZVODE wrapper through scipy.integrate.ode, a stateful, class-based interface (integrator='zvode'). As of SciPy 1.17, the underlying Fortran source was replaced with a C translation of ZVODE that is thread-safe.

Building from source

Building requires a C compiler and a Fortran compiler with Fortran 2003 support. The code has been tested with gfortran (passing -std=f2003).

A BLAS library is required at link time (located by CMake's find_package(BLAS)). On Linux, OpenBLAS or a vendor BLAS (MKL, BLIS, …) should all work. On macOS, the system Accelerate framework is picked up automatically.

# Example: Ubuntu / Debian
sudo apt update
sudo apt install gfortran libopenblas-dev
pip install -v ".[test]"
# Example: macOS (Homebrew)
brew update
brew install gfortran
pip install -v ".[test]"

To control which BLAS library is used, add the option,

pip install ... \
  -C "cmake.args=-DBLA_VENDOR=<blas_vendor>"

The list of BLAS/LAPACK vendors can be found here

Debug build

Passing -DZVODE_DEBUG (equivalent to -DZVODE_DEBUG=1) enables extra assertions and diagnostic output in the C extension:

pip install -v ".[test]" \
  -C "cmake.args=-DCMAKE_C_FLAGS=-DZVODE_DEBUG"

Changelog

See CHANGELOG.md for version history.

License

zvode is distributed under the BSD license. See LICENSE for details.

Contributing

Bug reports and suggestions are welcome via the issue tracker. The most useful reports are:

  • Documentation errors — typos, incorrect parameter descriptions, or misleading examples.
  • Integration failures — cases where the solver returns a wrong result, fails to converge, or raises an unexpected error. A minimal reproducer (ODE, initial condition, tolerances) is very helpful.
  • Feature requests — even if a feature is not planned, requests help track what practitioners actually need.

References

[1] A. C. Hindmarsh, "ODEPACK, A Systematized Collection of ODE Solvers," in Scientific Computing, R. S. Stepleman et al. (eds.), North-Holland, Amsterdam, 1983 (vol. 1 of IMACS Transactions on Scientific Computation), pp. 55–64. https://computing.llnl.gov/projects/odepack

[2] P. N. Brown, G. D. Byrne, and A. C. Hindmarsh, "VODE, A Variable-Coefficient ODE Solver," SIAM J. Sci. Stat. Comput., 10 (1989), pp. 1038–1051. https://doi.org/10.1137/0910062

[3] G. D. Byrne and A. C. Hindmarsh, "A Polyalgorithm for the Numerical Solution of Ordinary Differential Equations," ACM Trans. Math. Soft., 1(1), pp. 71–96, 1975. https://doi.org/10.1145/355626.355636

For a broader perspective on the history and design philosophy behind ODEPACK and related solvers, see the SIAM oral history interview with Alan C. Hindmarsh.

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

zvode-0.3.0.tar.gz (281.4 kB view details)

Uploaded Source

Built Distributions

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

zvode-0.3.0-cp313-cp313-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

zvode-0.3.0-cp313-cp313-macosx_14_0_arm64.whl (821.3 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

zvode-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

zvode-0.3.0-cp312-cp312-macosx_14_0_arm64.whl (821.3 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

zvode-0.3.0-cp311-cp311-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

zvode-0.3.0-cp311-cp311-macosx_14_0_arm64.whl (821.3 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

zvode-0.3.0-cp310-cp310-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

zvode-0.3.0-cp310-cp310-macosx_14_0_arm64.whl (821.3 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

zvode-0.3.0-cp39-cp39-manylinux_2_28_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

zvode-0.3.0-cp39-cp39-macosx_14_0_arm64.whl (821.3 kB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

Details for the file zvode-0.3.0.tar.gz.

File metadata

  • Download URL: zvode-0.3.0.tar.gz
  • Upload date:
  • Size: 281.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for zvode-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f281670dc24e57ebecaada9d62cbff134ae35261e45520d4251d04aeea046e1d
MD5 fe9032cb83b21a551220da4eb1781c65
BLAKE2b-256 17a8c1fec9bfc1b5a60355546ddb4db13f0bd3d9f1bb9935c34ff55322a65e18

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b64e92445b07d6e6c1ec6d897094527359a537e5623cb060f6bec086bd0bc5ce
MD5 2314fe3fca9e8071b3d1ec47901b5d25
BLAKE2b-256 f5f3be060525e4708347dbfddb5d5ca634efd6eff10e53c3f0ef18712ce14074

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 98530fe0d9a2b68aa81cc78d15eabbcc4e8711e53fa3a427ac185bcc0a65b5a2
MD5 e60ea37d2c41af2459b890265d54a139
BLAKE2b-256 583c68becdb676075a31e0945691bec00c6a7f3fc10d1537d40ee51ffad74887

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7ef7fb951d71e4a24da3e542bc2464d72f18afb34384f40228f1ea2f7af13dbd
MD5 21c7545a7022dbca342a59254da36d0b
BLAKE2b-256 655a15020392f424067195f84800aa1f5ea8623e7ba95391a7ea18a3fcaea29b

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0417287deeb94ee65e810670ad474284d441974a6313fc81ee195c55ada0d604
MD5 561c14716e6af4bd2f97f784d7e39a36
BLAKE2b-256 28b0790e2afe9ed6de7610dcbc16cca9abca08540337ffc8d641cabb596c5697

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00109b484905cfbd8133438124b9766f910e36ac9d0578749a24d171ddd30bf5
MD5 5b1f9ed7f687781d6e3625a2271d2c8e
BLAKE2b-256 18ac174de2b9ea4d349de3a53880fda7bdcb00cfabe93b4081a4579913b9988d

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 77af1043e7972ed09800cc42401c9bd94415829d9d04df7404c89d54b5297218
MD5 987d5671522b0322a449d0f7ccc34efb
BLAKE2b-256 55f01f7ae3e2ac48ae70c421ce5f5e78598fd565749fd49e8299b1f000017d7d

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d86b57ee6ba600a2f856a431969a26a594805e3ebb6f3c5551dbf99da8fda347
MD5 312d6bff54ed1bb7a1406d66b5e22dc1
BLAKE2b-256 fe46babd7fc4ba580a8cbe39bafc554ebeba23eb743282ec2e652ff7005cb89a

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 eea14686616fe1507293e7b35300d60ab607b2cc0ee288efde69e76c081c04d5
MD5 ff24ef6f49ec5d84e1d4f2f85e252745
BLAKE2b-256 1676e3abebd450176354761b125cd6a42e902098ae606726b180209408dc784e

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2f168e4c770bd75a00e77b1122c7e5002be627e4c5211480b051324d2fe03264
MD5 a192e1ff2d6d3afe2bf47fa8e60d6b0c
BLAKE2b-256 c70011da816fce539f974bbb0b9f752a8ae60b94308a7e91ae6540addbdc6d9f

See more details on using hashes here.

File details

Details for the file zvode-0.3.0-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for zvode-0.3.0-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f5bf813f56bc2af0d2ff836d26054c853821ffb3ef159eca40491fe83ea76cc1
MD5 efaf366363fa3296b483eb7f282bb4ca
BLAKE2b-256 e1d3ba600acf252470ca7667582b555961e7ef814cdd48c9990c862028935a2d

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