No project description provided
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybamm_diffsol-0.0.1.tar.gz.
File metadata
- Download URL: pybamm_diffsol-0.0.1.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
449af699c9ed5d6166a54d24a43341fc786bf25ed5486229e16725f1595cec46
|
|
| MD5 |
af724763502a33ddbe128b62301a0ab4
|
|
| BLAKE2b-256 |
17f3baf4c18e12bba3b3cb38e7b24c10d3217c4e68861601606340f111ad99e4
|
File details
Details for the file pybamm_diffsol-0.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27a21e5bd9805b308a7b7030bbd5caf16210e9496b04321e45d0e617af43b4e9
|
|
| MD5 |
aa02cdbf5d48de56a05269d988885143
|
|
| BLAKE2b-256 |
82c61b81f729b2fdb67eeec07908c5a47e7c4a09bc2caafe3dd1cd6606e98b06
|
File details
Details for the file pybamm_diffsol-0.0.1-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.2 MB
- Tags: PyPy, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
594408a90c04c0f0254392538c83ceb944f1221231cb890bd334fddcd72c6e6a
|
|
| MD5 |
27d8cf0600559515f15434461d01bc82
|
|
| BLAKE2b-256 |
e10da5020725028f44bed04d4e14cfa15705fa0e9f1ef13bb13971a3af47b7a6
|
File details
Details for the file pybamm_diffsol-0.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
531187df83790403926b5ec7ce41b1598c2a492209f7ee82ef0c2a19cc68fd1c
|
|
| MD5 |
c183deb944f393d61786e2ab25c21be4
|
|
| BLAKE2b-256 |
51a8b982cd1a5c363a4a18198f9b6b9c173e184f436acea45eb37fa1dc7d102e
|
File details
Details for the file pybamm_diffsol-0.0.1-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.2 MB
- Tags: PyPy, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f553e32a6b8fd1a150cbd278b9f263710a590707fd00f827a079c736ea20049f
|
|
| MD5 |
e3c362df313b8c264be1684f6f3ccf50
|
|
| BLAKE2b-256 |
b486c044ccea1da024257b30f5dcf1c2a4bf68bd4a53b733e3cef90caaec2c3d
|
File details
Details for the file pybamm_diffsol-0.0.1-cp313-cp313-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp313-cp313-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.13, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf720623b63b7723c40bcadee141c813be46e612083d4909b315e6dc2b0262ee
|
|
| MD5 |
215cfe9adcfb38323b1b8e6494f9b7e9
|
|
| BLAKE2b-256 |
c7e6b5ca5c2e27f1fbed5820bd9fd9e00412a452d19e80894633f0edbfb19cd7
|
File details
Details for the file pybamm_diffsol-0.0.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ed151ee75bdd837d12454456a93caa257fed301eebeec2a32dc47dd022de4c9
|
|
| MD5 |
201a03547428d1ded2c48e1b23e25ee8
|
|
| BLAKE2b-256 |
d2fd685dc6c3afe81b8dd3364f96f39a64f02042c45478c576810ed7cea5ad52
|
File details
Details for the file pybamm_diffsol-0.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be5f6ccd3ca794140aee4b25f52ca8034e5c45df6b1aaf7e1cc8f281d5e2a2e3
|
|
| MD5 |
87b6bedee7ae0690037cab9e444ecebd
|
|
| BLAKE2b-256 |
5b3781955ae78b1b99e85a84904a3bd61d71f7d686738e6c50dd4d52d66824d2
|
File details
Details for the file pybamm_diffsol-0.0.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6c29fa72c119ab6cc3b39f76a8cef600ac1b7eb2dcfb5e79f67275f44b98739
|
|
| MD5 |
1cbf83fe198a17c8d6455917afbc0c37
|
|
| BLAKE2b-256 |
2e3846cd3c747931ca8d5e7919517995693e33165aeaea9e9e8f41120b304d29
|
File details
Details for the file pybamm_diffsol-0.0.1-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
529ef3fcbb696e3256ac949f18c42e4f58751bd422bcd67c39dd2e02c016dd8e
|
|
| MD5 |
96b25343caebb8b8fdb4d036e5bc27bf
|
|
| BLAKE2b-256 |
ad1f56de09f319f55fb1bceeb46c6215a6f3740876928a3ca404fadaf7dd2a91
|
File details
Details for the file pybamm_diffsol-0.0.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62ed97773585d961aa219bcf55df80049a702fe60e442d6e828399a2c9fffa70
|
|
| MD5 |
e7031e493846d0bde1a04b00895d19a1
|
|
| BLAKE2b-256 |
d1e2606da5e998b385633d7912d682163e85e5c5a786ac126aee65ab7e3a9569
|
File details
Details for the file pybamm_diffsol-0.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ad951eb23cb408318ccc49ad769685341a7f2497106b9d1e8acbeea29020db9
|
|
| MD5 |
59ab2e61a5f0fc7c94d89a0a77e2fe94
|
|
| BLAKE2b-256 |
53dd2328dd13553c9fdf7f8a5e31a932a7b02616d10ff5fa4a0eb563f29b1da2
|
File details
Details for the file pybamm_diffsol-0.0.1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0a2e63361d75ae2a73224559816c212aeaaf0cd4d4dae0534c78b0d0523ab3f
|
|
| MD5 |
d3bf77087156b96a1af26fcc67a22811
|
|
| BLAKE2b-256 |
431738b94616fa267a72e10392712188498e56cc63e3e3401cf377f386d3146e
|
File details
Details for the file pybamm_diffsol-0.0.1-cp311-cp311-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ace04aec9c7b19ff344315fca0c24ad3ca71bef99db2d541533dfd7d7d54408
|
|
| MD5 |
d798460971b257b89fdaaa44c7845e67
|
|
| BLAKE2b-256 |
219b7bb9a71ce6d2367967ee65c6d12a5a1de6ac7a7f85dcbd85fee833086b92
|
File details
Details for the file pybamm_diffsol-0.0.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fcde7835038a1dc8c2fe8c648182b3791287d2a3e825deaeb0cfaec07b38018
|
|
| MD5 |
0b33d06c4b1347c9052ebd14c7936426
|
|
| BLAKE2b-256 |
1b30f2fee4afe5948de0dcdbefc2a1299457fd7f6ebf2ce4982976a4d567520b
|
File details
Details for the file pybamm_diffsol-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e77def4f931a434393924e7bb55285178187407789b2ec26b43a9c96376f170
|
|
| MD5 |
d4c5abae88ee0fd2d418fce9c7fa407c
|
|
| BLAKE2b-256 |
afc2adab224f38fa834d9dae8408be3867426214d63b061877d24c7427e6535d
|
File details
Details for the file pybamm_diffsol-0.0.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7296243bea409361a651a797d749220aaaec74440e6f65f781332c8c345271c
|
|
| MD5 |
2e887d00326f23640966edb7978d234c
|
|
| BLAKE2b-256 |
6d368b200b3194e747226767fafde0ffe33277c52e0ec1a45c46b0896ee45c2c
|
File details
Details for the file pybamm_diffsol-0.0.1-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b50bec83fb7f2b10d44821d8732dcc2abb3a54ddcdc24518843480cf4dc08a3
|
|
| MD5 |
7629eebcca8d6380ac085d7c9b4dcd75
|
|
| BLAKE2b-256 |
49e3fdc2a0785a6f1d58e4e2889e3c5ecf22fc838f807b5200fb4de731ababff
|
File details
Details for the file pybamm_diffsol-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e04c4d668416e4e604bd0fc9f98ef8ff2024369e13f51589da27455eb28566b
|
|
| MD5 |
3ad4aa814e6cd59e156396159cdd9df7
|
|
| BLAKE2b-256 |
67f7161e8f74838797ef834418b366e8991dbe1cb1a9195615e1da19dbedcfdc
|
File details
Details for the file pybamm_diffsol-0.0.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7ecd8a60022f134fe1a1b229e855c178d31e77c4ef27afd13db9c8aeace415b
|
|
| MD5 |
fbc31c746aeb1e70279605c6a4677e57
|
|
| BLAKE2b-256 |
b8430c1d4c606f56525df1f5a5d01426264391b5af4a2d69210f9b52c8391893
|
File details
Details for the file pybamm_diffsol-0.0.1-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4516cff9308d147544667d386867774b6c70925dc96d26b19274309ee5a91b5e
|
|
| MD5 |
e8866ef0e785c5c202efea58807a1292
|
|
| BLAKE2b-256 |
2c1b5b7816ed64b78b83f83b1733224df00e2bc07de5e13e3fd4a5322d21eb71
|
File details
Details for the file pybamm_diffsol-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
791dd487e7ea5e932e276010b9b42f7a0fde6122ab6d5de2b31e99ac2f1d407b
|
|
| MD5 |
dca2666bc9cf38507916cb1259cfc283
|
|
| BLAKE2b-256 |
2000d5f785436eb46216e494e014bfb95924bf1e23aba8ff904dc8658a993641
|
File details
Details for the file pybamm_diffsol-0.0.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pybamm_diffsol-0.0.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7e48335c75a5904820a7ec1dbf7226f3f60f0d551d6f9cc64300056973f3883
|
|
| MD5 |
81af7a04dac6333847b76651f385a42f
|
|
| BLAKE2b-256 |
5e803e28df63873584769790bd0acb536dd2aaf7ea0c433e55704d265750df15
|