Skip to main content

Python bindings to SUNDIALS differential algebraic equation solvers.

Project description

scikit-SUNDAE

CI   tests   coverage   pep8

Summary

scikit-SUNDAE provides Python bindings to SUNDIALS integrators. The implicit differential algebraic (IDA) solver and C-based variable-coefficient ordinary differential equations (CVODE) solver are both included.

The name SUNDAE combines (SUN)DIALS and DAE, which stands for differential algebraic equations. Solvers specific to DAE problems are not frequently available in Python. An ordinary differential equation (ODE) solver is also included for completeness. ODEs can be categorized as a subset of DAEs (i.e., DAEs with no algebraic constraints).

Installation

scikit-SUNDAE is installable via either pip or conda. To install from PyPI use the following command.

pip install scikit-sundae

If you prefer using the conda package manager, you can install scikit-SUNDAE from the conda-forge channel using the command below.

conda install -c conda-forge scikit-sundae

Both sources contain binary installations. If your combination of operating system and CPU architecture is not supported, please submit an issue to let us know. If you'd prefer to build from source, please see the documentation.

Get Started

You are now ready to start solving. Run one of the following examples to check your installation. Afterward, check out the documentation for a full list of options (including event functions), detailed examples, and more.

# Use the CVODE integrator to solve the Van der Pol equation

from sksundae.cvode import CVODE
import matplotlib.pyplot as plt

def rhsfn(t, y, yp):
    yp[0] = y[1]
    yp[1] = 1000*(1 - y[0]**2)*y[1] - y[0]

solver = CVODE(rhsfn)
soln = solver.solve([0, 3000], [2, 0])

plt.plot(soln.t, soln.y[:, 0])
plt.show()

The CVODE solver demonstrated above is only capable of solving pure ODEs. The constant parameters and time span used above match an example given by MATLAB for easy comparison. If you are trying to solve a DAE, you will want to use the IDA solver instead. A minimal DAE example is given below for the Robertson problem. As with the CVODE example, the parameters below are chosen to match an online MATLAB example for easy comparison.

# Use the IDA integrator to solve the Robertson problem

from sksundae.ida import IDA
import matplotlib.pyplot as plt

def resfn(t, y, yp, res):
    res[0] = yp[0] + 0.04*y[0] - 1e4*y[1]*y[2]
    res[1] = yp[1] - 0.04*y[0] + 1e4*y[1]*y[2] + 3e7*y[1]**2
    res[2] = y[0] + y[1] + y[2] - 1

solver = IDA(resfn, algebraic_idx=[2], calc_initcond='yp0')
soln = solver.solve([4e-6, 4e6], [1, 0, 0], [0, 0, 0])

soln.y[:, 1] *= 1e4  # scale y1 so it is visible in the figure

plt.plot(soln.t, soln.y)
plt.legend(['y0', 'y1', 'y2'])
plt.show()

Notes:

  • If you are new to Python, check out Spyder IDE. Spyder is a powerful interactive development environment (IDE) that can make programming in Python more approachable to new users.
  • Check the solve_ivp documentation from scipy or the scipy-dae package repository if you are looking for common examples to test out and compare against. Translating an example from another package can help you learn how to use scikit-SUNDAE before trying to solve more challenging problems.

Citing this Work

This work was authored by researchers at the National Renewable Energy Laboratory (NREL). If you use use this package in your work, please include the following citation:

Randall, Corey R. "scikit-SUNDAE: Python bindings to SUNDIALS Differential Algebraic Equation solvers [SWR-24-137]." Computer software, Oct. 2024. url: https://github.com/NREL/scikit-sundae. doi: https://doi.org/10.11578/dc.20241104.3.

For convenience, we also provide the following for your BibTex:

@misc{Randall-2024,
  title = {{scikit-SUNDAE: Python bindings to SUNDIALS Differential Algebraic Equation solvers [SWR-24-137]}},
  author = {Randall, Corey R.},
  doi = {10.11578/dc.20241104.3},
  url = {https://github.com/NREL/scikit-sundae},
  month = {Oct.},
  year = {2024},
}

You should also cite SUNDIALS following their recommendations here. Lastly, if you use the sparse linear solver, please cite the SuperLU_MT library using their reference guide.

Acknowledgements

scikit-SUNDAE was originally inspired by scikits-odes which also offers Python bindings to SUNDIALS. The API for scikit-SUNDAE was mostly adopted from scikits-odes; however, all of our source code is original. If you are comparing the two:

  1. scikits-odes: includes solvers from daepack, scipy, and SUNDIALS. The package only provides source distributions, so users must configure and compile SUNDIALS on their own; however, this gives users maximum flexibility to compile against SUNDIALS builds with their choice of precision, optional solvers, etc.
  2. scikit-SUNDAE: only includes SUNDIALS solvers. Provides sparse solvers, more flexible events function capabilities (e.g., direction detection and terminal flags), and scipy-like output not available in scikits-odes. Both binary and source distributions are available; however, we prioritize compatibility with SUNDIALS releases on conda-forge over general user-compiled builds.

Our binary distributions include pre-compiled dynamic SUNDIALS libraries that also reference libraries like SuperLU_MT, OpenBLAS, and LAPACK. These are self-contained and will not affect other, existing installations you may already have. To be in compliance with each library's distribution requirements, all scikit-SUNDAE distributions include a summary of all licenses (see the LICENSES_bundled file). Note that we only link against and distribute packages with a BSD-3 license. Some solvers and options, like KLU, have LGPL licenses and are therefore not compatible to implement nor distribute.

Contributing

If you'd like to contribute to this package, please look through the existing issues. If the bug you've caught or the feature you'd like to add isn't already reported, please submit a new issue. You should also read through the developer guidelines if you plan to work on the issue yourself.

Disclaimer

This work was authored by the National Renewable Energy Laboratory (NREL), operated by Alliance for Sustainable Energy, LLC, for the U.S. Department of Energy (DOE). The views expressed in the repository do not necessarily represent the views of the DOE or the U.S. Government.

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

scikit_sundae-1.1.1.tar.gz (56.0 kB view details)

Uploaded Source

Built Distributions

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

scikit_sundae-1.1.1-cp314-cp314-win_amd64.whl (8.4 MB view details)

Uploaded CPython 3.14Windows x86-64

scikit_sundae-1.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (20.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scikit_sundae-1.1.1-cp314-cp314-macosx_11_0_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.14macOS 11.0+ x86-64

scikit_sundae-1.1.1-cp314-cp314-macosx_11_0_arm64.whl (8.6 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

scikit_sundae-1.1.1-cp313-cp313-win_amd64.whl (8.3 MB view details)

Uploaded CPython 3.13Windows x86-64

scikit_sundae-1.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (20.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scikit_sundae-1.1.1-cp313-cp313-macosx_11_0_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ x86-64

scikit_sundae-1.1.1-cp313-cp313-macosx_11_0_arm64.whl (8.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

scikit_sundae-1.1.1-cp312-cp312-win_amd64.whl (8.3 MB view details)

Uploaded CPython 3.12Windows x86-64

scikit_sundae-1.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (20.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scikit_sundae-1.1.1-cp312-cp312-macosx_11_0_x86_64.whl (15.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ x86-64

scikit_sundae-1.1.1-cp312-cp312-macosx_11_0_arm64.whl (8.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

scikit_sundae-1.1.1-cp311-cp311-win_amd64.whl (8.3 MB view details)

Uploaded CPython 3.11Windows x86-64

scikit_sundae-1.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (20.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scikit_sundae-1.1.1-cp311-cp311-macosx_11_0_x86_64.whl (15.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

scikit_sundae-1.1.1-cp311-cp311-macosx_11_0_arm64.whl (8.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

scikit_sundae-1.1.1-cp310-cp310-win_amd64.whl (8.3 MB view details)

Uploaded CPython 3.10Windows x86-64

scikit_sundae-1.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (20.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scikit_sundae-1.1.1-cp310-cp310-macosx_11_0_x86_64.whl (15.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

scikit_sundae-1.1.1-cp310-cp310-macosx_11_0_arm64.whl (8.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file scikit_sundae-1.1.1.tar.gz.

File metadata

  • Download URL: scikit_sundae-1.1.1.tar.gz
  • Upload date:
  • Size: 56.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for scikit_sundae-1.1.1.tar.gz
Algorithm Hash digest
SHA256 8a88c015c5ad3b5cb5a594cd5fad90fc382fa0a500b345159783a6adbf0f59a4
MD5 2b433e75eabba6ce75fd4d7f9167f138
BLAKE2b-256 7ef43c9cca7094ab1ab94e4a0ac31ddfe697e5f0a9cedddb2c7b4f2e6c4b1218

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d53a0cd1fa227e3b173e884341c187360dee303d4c099e6c55963ef684abca2c
MD5 d29a619b7cc2b1190e96324e4766134d
BLAKE2b-256 5ae8510ee59a44a54a2d6bd444e0a02e53f705fe203d300712aa8f77939bb758

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0eaa899313f9a0bdef7b184757165fdec47811314040774e367cc80582f17c04
MD5 a3a999e98fc82ecc816e300449628d88
BLAKE2b-256 9676a65a96f2582d4b2f5712bf3b933ab8fb4c97a2da640c16798fe67738a9e8

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp314-cp314-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp314-cp314-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 9435a2e5c7d36fc8cd03b918576d19133eeaebf0d1d5b2476ced80ef4cd3035e
MD5 fc4dfc97e86836876843fb5cec881a89
BLAKE2b-256 a09a1c6724e0fac95728fea41922e13a0f7d3c38df9e57511c6d76535d1a7c0b

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dbf568b891e610a590a77ea8227da66586c37e8bb6961c70285f3bfa9753195a
MD5 47cf5bf3abb22e17d3e830e0e98a2a08
BLAKE2b-256 fd0d7e8197b31221ac9102ca43e6922a931ffbbd17e80574fc285807813efcf9

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c759a68973ffef7be2f467110feb73a9a2991046f865f9dce8d02a27ebf039a9
MD5 8e4144be437711601d143799b56b19e6
BLAKE2b-256 eed157c3055a5bc67ebbcfad8196414955fe0678c54989dfb7ff349a1285590d

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ef5397f000267028ac7e01bdeb2f8dfa748ac54852b7dffcfa3f80526f9b6aee
MD5 3811fe4d300828c8528bf8f323e69fcd
BLAKE2b-256 1539e20dff0fe9c8a9b359a010de35ffa72d09988d8789c6f3d053a5de18abc1

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp313-cp313-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp313-cp313-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 3274bc2b6fc291985be35f10cd5213ae9ba01f42305ac7970b23bdfe4751c20b
MD5 8726b0af75047053a41fcfc21fd36b61
BLAKE2b-256 394700102421d417981e94d8d0c9a0320c789159fa1475d46dba9d97adca92a5

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b4ef2c8559d3c708b410c7ab00c594990192dfb2a8ca5d1b9ab5db3df179204
MD5 ec552aa0e64b56cd023cfd3f9d4d8220
BLAKE2b-256 2b8d2d9308f4f41e7e4fd4b8b64bab5b4924d0397312e85f78ac4086b7012b30

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fb6b57944841756bd6674e9ba41398fa1ddf7261372cd0c945b4be861818e78f
MD5 9dfbaadc010a38036374eb4b87c2ab7d
BLAKE2b-256 99decf5845342a91a517600dead11a17937f14f926878d5a011aef39e7e63e34

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 31955ea3147af4c0aad0312e05dfd1b27f0155237c744350677d93d9b1e07293
MD5 a7c2e628bedf7e9d211790643ce2921b
BLAKE2b-256 0af1074cc826e8c9fae1dc92a723a89063959faf95fef2bf23ead41e67636d15

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp312-cp312-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 5234cf5cd832ce9a0a37af5e5835519cbd9a5738f7474fdeaf858e511f9f480f
MD5 f505053ca4053ce21c6b0b8b56e91a7b
BLAKE2b-256 6b713d69ba2356232a2d8d13af83d7f62401f0c9b72ce5eedb2daeda2aff1913

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b7c03b6582300fa099380d8f316d39a061600fac6e1f7b343ca19276aaa7be5
MD5 9367b78709de7a0c360cc651cb8c18e7
BLAKE2b-256 a13fdafc8552be885a205e49eeb0b97a7d4ff46d72efcfb6056a8690f5497709

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fb8c3da62c27e2b1a36804cf35f38da1b326dbb87ec28795936c54808da68c10
MD5 4ed2d9a61a471abae6767fdfdd2070ea
BLAKE2b-256 d8d6c04448ee439a70c95a33bcdc367aec02924f7e82ae09d123e932b9e8857e

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b5b7853fa8e7319d82ebd949ca68fcd296a1cd49bcb450b3048ff013e7b136d5
MD5 67f578a2bae1f446d4deb051db73607a
BLAKE2b-256 14c12c21175f58e00eacfe8cb67149d3e15ac0032d58ec092baccf022a507928

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 ef0892d80bd56ab4d53aec667f807e7e87dd1a7a5fa54794d372b0b8fdb4e07c
MD5 c39ffef7ac84a8bc55ccb32305185201
BLAKE2b-256 c078c0656af533fb39ef5f0758c033c523018a7141abbb4a35b7bfd65b99f3d0

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee24a8002c4408665bb4946ba265287dc5c862e31b74683189be761c3c1234b3
MD5 d4615211d418f0b8e77c81ae89a65e93
BLAKE2b-256 39de1feb327b6908913efcee6d0a17d5124e318396c110c33504c665f9b8d14a

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bcbef78e49c7c6087ef1dd13f8ebf55db72f777e683f6f81554edf391e2dd84c
MD5 c295a7284254e7dd07173e78270a9e40
BLAKE2b-256 5609853f6a8ff4d392376292f89244868c671dc92f010e7f393c6fdb41b3be1a

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe91e680085f739bb08ff123051385b391f0f7dfd34a20789438c2cdf66c93f7
MD5 d886416936500a2251dbc2f2693c177e
BLAKE2b-256 0fa290ccb9eaf2eaa8c0742a8e63ec9a17f049098f071e381caae3228e68c1fe

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 27d024e055e55b05ba3f9c238179ba8ba3391d0b19c22af119355046fd6c6edf
MD5 b5daf901c752dca1df34db456f65edbf
BLAKE2b-256 c8ab04e7173f3c96cbac8d76f73d08fa14c8a96a7a03e0f70866b3ac18c8a44d

See more details on using hashes here.

File details

Details for the file scikit_sundae-1.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for scikit_sundae-1.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 11fab78aa36a3465a12aed743bdb57a8b4c8bf0c202fe6c4abe95452e06e6399
MD5 a9b79678f4dce8ab01b30f3b5fff54f6
BLAKE2b-256 7de1d48b121d031f836cee9d66b42abc71258de9336c916ea0abddccb08a45db

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