PyBaMM_DiffSol
This is a demonstration of how to use DiffSol to solve a PyBaMM model.
Installation
To install the package from PyPI, run the following command:
pip install pybamm_diffsol
Usage
Use the following code to solve an PyBaMM SPM model using DiffSol and PyBaMM and compare the timings. You can change the outputs and inputs to any other parameters/variables in the model.
Note that this is only a demonstration and is only tested with the SPM model. It may not work with other models.
from pybamm_diffsol import PybammDiffsol, Pybamm2Diffsl
import numpy as np
import timeit
import pybamm
outputs = ["Voltage [V]"]
inputs = ["Current function [A]"]
# read model from spm.ds file to a string
model_str = Pybamm2Diffsl(pybamm.lithium_ion.SPM()).to_str(inputs, outputs)
model = PybammDiffsol(model_str)
t_eval = np.array([0.0, 3600.0])
t_interp = np.linspace(0.0, 3600.0, 100)
params = np.array([1.0])
n = 1000
def diffsol_bench():
model.solve(params, t_interp, t_eval)
diffsol_time = timeit.timeit(diffsol_bench, number=n) / n
print("Diffsol time: ", diffsol_time)
# solver pybamm spm model
spm = pybamm.lithium_ion.SPM()
t_eval = np.array([0.0, 3600.0])
t_interp = np.linspace(0.0, 3600.0, 100)
params = spm.default_parameter_values
for inpt in inputs:
params[inpt] = "[input]"
geometry = spm.default_geometry
params.process_model(spm)
params.process_geometry(geometry)
mesh = pybamm.Mesh(geometry, spm.default_submesh_types, spm.default_var_pts)
disc = pybamm.Discretisation(mesh, spm.default_spatial_methods)
disc.process_model(spm)
solver = pybamm.IDAKLUSolver()
inputs = {inpt: 1.0 for inpt in inputs}
solver.solve(spm, t_eval=t_eval, inputs=inputs)
def pybamm_bench():
sol = solver.solve(spm, t_eval=t_eval, inputs=inputs)
# force evalulation of the outputs
for output in outputs:
sol[output].data[0]
pybamm_time = timeit.timeit(pybamm_bench, number=n) / n
print("Pybamm time: ", pybamm_time)
print("Speedup: ", pybamm_time / diffsol_time)
Metadata
Release files for pybamm-diffsol 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pybamm_diffsol-0.0.1.tar.gz | 22.3 kB | Details |
Built distributions (wheels)
Total release size: 44.3 MB
Release files / pybamm_diffsol-0.0.1.tar.gz
| Download URL | pybamm_diffsol-0.0.1.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
449af699c9ed5d6166a54d24a43341fc786bf25ed5486229e16725f1595cec46
|
|
BLAKE2b-256 checksum How to use checksums |
17f3baf4c18e12bba3b3cb38e7b24c10d3217c4e68861601606340f111ad99e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.10 PyPy 3.10 7.3 |
|
SHA-256 checksum How to use checksums |
27a21e5bd9805b308a7b7030bbd5caf16210e9496b04321e45d0e617af43b4e9
|
|
BLAKE2b-256 checksum How to use checksums |
82c61b81f729b2fdb67eeec07908c5a47e7c4a09bc2caafe3dd1cd6606e98b06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pybamm_diffsol-0.0.1-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 2.2 MB |
| Tags | Linux glibc 2.17+ x86-32 PyPy 3.10 PyPy 3.10 7.3 |
|
SHA-256 checksum How to use checksums |
594408a90c04c0f0254392538c83ceb944f1221231cb890bd334fddcd72c6e6a
|
|
BLAKE2b-256 checksum How to use checksums |
e10da5020725028f44bed04d4e14cfa15705fa0e9f1ef13bb13971a3af47b7a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
531187df83790403926b5ec7ce41b1598c2a492209f7ee82ef0c2a19cc68fd1c
|
|
BLAKE2b-256 checksum How to use checksums |
51a8b982cd1a5c363a4a18198f9b6b9c173e184f436acea45eb37fa1dc7d102e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pybamm_diffsol-0.0.1-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 2.2 MB |
| Tags | Linux glibc 2.17+ x86-32 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
f553e32a6b8fd1a150cbd278b9f263710a590707fd00f827a079c736ea20049f
|
|
BLAKE2b-256 checksum How to use checksums |
b486c044ccea1da024257b30f5dcf1c2a4bf68bd4a53b733e3cef90caaec2c3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
cf720623b63b7723c40bcadee141c813be46e612083d4909b315e6dc2b0262ee
|
|
BLAKE2b-256 checksum How to use checksums |
c7e6b5ca5c2e27f1fbed5820bd9fd9e00412a452d19e80894633f0edbfb19cd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp312-cp312-win_amd64.whl
| Download URL | pybamm_diffsol-0.0.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9ed151ee75bdd837d12454456a93caa257fed301eebeec2a32dc47dd022de4c9
|
|
BLAKE2b-256 checksum How to use checksums |
d2fd685dc6c3afe81b8dd3364f96f39a64f02042c45478c576810ed7cea5ad52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
be5f6ccd3ca794140aee4b25f52ca8034e5c45df6b1aaf7e1cc8f281d5e2a2e3
|
|
BLAKE2b-256 checksum How to use checksums |
5b3781955ae78b1b99e85a84904a3bd61d71f7d686738e6c50dd4d52d66824d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pybamm_diffsol-0.0.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
c6c29fa72c119ab6cc3b39f76a8cef600ac1b7eb2dcfb5e79f67275f44b98739
|
|
BLAKE2b-256 checksum How to use checksums |
2e3846cd3c747931ca8d5e7919517995693e33165aeaea9e9e8f41120b304d29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
529ef3fcbb696e3256ac949f18c42e4f58751bd422bcd67c39dd2e02c016dd8e
|
|
BLAKE2b-256 checksum How to use checksums |
ad1f56de09f319f55fb1bceeb46c6215a6f3740876928a3ca404fadaf7dd2a91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp311-cp311-win_amd64.whl
| Download URL | pybamm_diffsol-0.0.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
62ed97773585d961aa219bcf55df80049a702fe60e442d6e828399a2c9fffa70
|
|
BLAKE2b-256 checksum How to use checksums |
d1e2606da5e998b385633d7912d682163e85e5c5a786ac126aee65ab7e3a9569
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5ad951eb23cb408318ccc49ad769685341a7f2497106b9d1e8acbeea29020db9
|
|
BLAKE2b-256 checksum How to use checksums |
53dd2328dd13553c9fdf7f8a5e31a932a7b02616d10ff5fa4a0eb563f29b1da2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pybamm_diffsol-0.0.1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
e0a2e63361d75ae2a73224559816c212aeaaf0cd4d4dae0534c78b0d0523ab3f
|
|
BLAKE2b-256 checksum How to use checksums |
431738b94616fa267a72e10392712188498e56cc63e3e3401cf377f386d3146e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
6ace04aec9c7b19ff344315fca0c24ad3ca71bef99db2d541533dfd7d7d54408
|
|
BLAKE2b-256 checksum How to use checksums |
219b7bb9a71ce6d2367967ee65c6d12a5a1de6ac7a7f85dcbd85fee833086b92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp310-cp310-win_amd64.whl
| Download URL | pybamm_diffsol-0.0.1-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7fcde7835038a1dc8c2fe8c648182b3791287d2a3e825deaeb0cfaec07b38018
|
|
BLAKE2b-256 checksum How to use checksums |
1b30f2fee4afe5948de0dcdbefc2a1299457fd7f6ebf2ce4982976a4d567520b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5e77def4f931a434393924e7bb55285178187407789b2ec26b43a9c96376f170
|
|
BLAKE2b-256 checksum How to use checksums |
afc2adab224f38fa834d9dae8408be3867426214d63b061877d24c7427e6535d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pybamm_diffsol-0.0.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
a7296243bea409361a651a797d749220aaaec74440e6f65f781332c8c345271c
|
|
BLAKE2b-256 checksum How to use checksums |
6d368b200b3194e747226767fafde0ffe33277c52e0ec1a45c46b0896ee45c2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp39-cp39-win_amd64.whl
| Download URL | pybamm_diffsol-0.0.1-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1b50bec83fb7f2b10d44821d8732dcc2abb3a54ddcdc24518843480cf4dc08a3
|
|
BLAKE2b-256 checksum How to use checksums |
49e3fdc2a0785a6f1d58e4e2889e3c5ecf22fc838f807b5200fb4de731ababff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
6e04c4d668416e4e604bd0fc9f98ef8ff2024369e13f51589da27455eb28566b
|
|
BLAKE2b-256 checksum How to use checksums |
67f7161e8f74838797ef834418b366e8991dbe1cb1a9195615e1da19dbedcfdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pybamm_diffsol-0.0.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
e7ecd8a60022f134fe1a1b229e855c178d31e77c4ef27afd13db9c8aeace415b
|
|
BLAKE2b-256 checksum How to use checksums |
b8430c1d4c606f56525df1f5a5d01426264391b5af4a2d69210f9b52c8391893
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp38-cp38-win_amd64.whl
| Download URL | pybamm_diffsol-0.0.1-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4516cff9308d147544667d386867774b6c70925dc96d26b19274309ee5a91b5e
|
|
BLAKE2b-256 checksum How to use checksums |
2c1b5b7816ed64b78b83f83b1733224df00e2bc07de5e13e3fd4a5322d21eb71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pybamm_diffsol-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
791dd487e7ea5e932e276010b9b42f7a0fde6122ab6d5de2b31e99ac2f1d407b
|
|
BLAKE2b-256 checksum How to use checksums |
2000d5f785436eb46216e494e014bfb95924bf1e23aba8ff904dc8658a993641
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|
Release files / pybamm_diffsol-0.0.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pybamm_diffsol-0.0.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
c7e48335c75a5904820a7ec1dbf7226f3f60f0d551d6f9cc64300056973f3883
|
|
BLAKE2b-256 checksum How to use checksums |
5e803e28df63873584769790bd0acb536dd2aaf7ea0c433e55704d265750df15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.7.8
|