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

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 not thread-safe. You cannot have two threads using the ZVODE integrator simultaneously.

Table of Contents:

Quick start

Procedural API — solve_complex_ivp (new in 0.2.0)

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 docs/how-to-procedural-api.md for output modes, banded Jacobians, backward integration, 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.

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)

Solver options

solve_complex_ivp key parameters

Parameter Type Default Description
fun callable RHS f(t, y) → array_like. With in_place=True: f(t, y, dy) fills dy in place.
tspan array-like (t0, tf) collects every accepted step; three or more values output at exactly those times; (t0, tf) with save_steps=False returns only the endpoint.
y0 array-like Initial state; cast to complex128.
method 'BDF' or 'Adams' 'BDF' BDF (max order 5) for stiff problems; Adams (max order 12) for non-stiff.
rtol float or array 1e-3 Relative error tolerance, per component or global.
atol float or array 1e-6 Absolute error tolerance, per component or global.
jac callable or None None Jacobian jac(t, y). Dense: return (n, n); banded: return (lband + uband + 1, n). Estimated by finite differences if omitted.
lband, uband int or None None Lower/upper half-bandwidths; activates the banded solver path.
save_steps bool True Collect every accepted step (True) or return only the endpoint (False). Ignored when tspan has three or more elements.

OdeSolver API options

Keyword arguments accepted by ZVODE / ZVODE_BDF / ZVODE_Adams; passed through unchanged when supplied via solve_ivp.

Option Type Default Description
lmm 'BDF' or 'Adams' 'BDF' Linear multistep method. BDF (max order 5) for stiff problems; Adams (max order 12) for non-stiff. Fixed by the ZVODE_BDF and ZVODE_Adams subclasses.
rtol float or array 1e-3 Relative error tolerance, per component or global.
atol float or array 1e-6 Absolute error tolerance, per component or global.
jac callable or None None Jacobian jac(t, y). Dense: (n, n) array; banded: (lband + uband + 1, n) array. Estimated by finite differences if omitted.
lband, uband int or None None Lower/upper half-bandwidths; activates the banded solver path.

Note — For stiff problems, f must be analytic (each component must be an analytic function of each state variable). For stiff systems where f is not analytic, use a real-valued solver on the equivalent doubled real system.

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

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.

Links

ZVODE upstream

Resource URL
ODEPACK https://computing.llnl.gov/projects/odepack
Netlib mirror https://netlib.org/ode/zvode.f
Netlib mirror (Sandia) https://netlib.sandia.gov/ode/zvode.f
SUNDIALS https://computing.llnl.gov/projects/sundials

Python / R ecosystem

Resource URL
scipy.integrate.OdeSolver (base class) https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.OdeSolver.html
scipy.integrate.ode (legacy ZVODE wrapper) https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.ode.html
R wrappers — deSolve zvode https://www.rdocumentation.org/packages/deSolve/versions/1.42/topics/zvode

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

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.

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.2.0.tar.gz (105.0 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.2.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.2.0-cp313-cp313-macosx_14_0_arm64.whl (814.8 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

zvode-0.2.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.2.0-cp312-cp312-macosx_14_0_arm64.whl (814.8 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

zvode-0.2.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.2.0-cp311-cp311-macosx_14_0_arm64.whl (814.8 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

zvode-0.2.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.2.0-cp310-cp310-macosx_14_0_arm64.whl (814.8 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

zvode-0.2.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.2.0-cp39-cp39-macosx_14_0_arm64.whl (814.8 kB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for zvode-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4410c7772001f7085d9bc9c4a8b4abedaf35541f1b07937d410a117d2bdd0f69
MD5 9d429edb8b72ff3dc5ed5e7764b3326c
BLAKE2b-256 a568063d883415d4fe82eefb19c89132a1d891ff5c9df70c35b97110409c2d7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7f09a9f956da6f5ddd23841a89a7e39d85cee34b2a127562511a037e14a7d228
MD5 59c3faa18416db6fa422863d191a64e1
BLAKE2b-256 123b17ab03afb3487e35b76886de4d142d1455986f7d9ef8b3c1c7c29adecd56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8cd7321009a7790fdc5a9ba694b4b625ab74fff5df3558fab6f899c043424519
MD5 201116535e07bd0e6ea66c57ceccd725
BLAKE2b-256 f2313c428d99bd248c524336db0a962a548abc5a3600210c7890f4022b934e48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 09532d3a0eb9c340ca042b17f78c7315b655f2de9bd59eee37940a714a142310
MD5 e8e65da79cae332b16fc005347ce21e3
BLAKE2b-256 494eaef7c4275037e834b9370fcec45a174a4bb0439c40086bd4a031432c445d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 363aa024effe00fc8e6b64271180377f0ad820afe7029f418ec0f3ee8d222e0f
MD5 e5fe815527e3a316ea6143e1d0c0ae8d
BLAKE2b-256 8e107fd73b5bc6a3d33222e0ef5c969c05e2eb525ae210aa584ccfdaee3cf1b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b68f7b465e31fb675fee795fd3485691b99af479b7d8deb5705007fae778c6c9
MD5 ed91fdb4260626f7e054f0ede38bff3a
BLAKE2b-256 8935153ed482b36d1f9ea4e9c9066c5d07100a1078c52a368fface38b78a4ce8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 252c698a1e6e184d2a50706bb3eb24d2694a008e782ccb1607f8cfbc4d7c59cc
MD5 af7c474ecece3f8029a707d888a44794
BLAKE2b-256 ed784845fe1a09bcf45ffb497c8d1777c23bfe034fac8194a77f9f4a6ebfa7f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7a2cbb88ae87c869cfacf1e0ca98b16f681cc445f4fb4ce357b3cffd3ff2ee39
MD5 40e3e6ea91e1572f4e5b8169d1fb71a4
BLAKE2b-256 30e684916b431084bddf4c7e447fe31c90297eac2c20ae729372c6878e6383d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 44fa9753eb28df07b4f9f82916d6b0dffedd83994a67f5e3dd5e9d44bb408d6b
MD5 097cf25e5207bb4a2fb812eba1abf1d5
BLAKE2b-256 be92e6910b8875821b8ac8d80ddeafc667e0ae1e841d8aaabb07d7cacffd883a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f635d19841404170ffd45c9fbf9f62d128c9befd3f58310a79ea42a40e067b96
MD5 c1479523cac2f63719fe876149f9377b
BLAKE2b-256 709ca0cdbe229bb399b1e8a728de5100d9ff6c757cd9dc0a6358e52254908bbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zvode-0.2.0-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e4dc83ace2106da320bc5ee2a8557e459d10dcd81625a38a0ad27b921d8cbd60
MD5 aff2025b7e08bd87a5a67e35b451bb35
BLAKE2b-256 5acfe1c41d5bbade8d53a0a86cf5c01347e856cfd9c5ba44ea9a04b117de5165

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