SPDEax
Composable spatial discretisations and operators for solving SPDEs with Diffrax
SPDEax is a library for constructing spatially discretised PDEs and SPDEs which can then be timestepped using Diffrax. This includes:
- a lightweight Field abstraction for storing spatial discretisations over grids
- a composable and extensible operator framework
- periodic, finite-difference differential operators
Divergence,Gradient,Laplacian, etc. - compatibility with
jit,grad,vmap, etc. - inter-operability with Lineax
Installation
git clone https://github.com/kamran-arora/SPDEax.git
pip install -e .
To install with tests and/or examples, use
pip install -e ".[test,examples]"
Quickstart
Solving a one-dimensional heat equation is extremely easy!
import jax
import jax.numpy as jnp
import spdeax as spx
import diffrax as dfx
jax.config.update("jax_enable_x64", True)
x0 = (0.0,)
x_final = (2 * jnp.pi,)
spatial_shape = (128,)
ic = spx.ScalarField.discretise_fn(
x0,
x_final,
spatial_shape,
lambda x: jnp.sin(x),
coordinates="unpacked",
)
lplc = spx.Laplacian()
sol = dfx.diffeqsolve(
terms=dfx.ODETerm(lambda t, y, args: lplc(y)),
solver=dfx.Euler(),
t0=0.0,
t1=1.0,
dt0=1e-3,
y0=ic,
saveat=dfx.SaveAt(t1=True),
max_steps=10**4,
)
Further examples
For more examples showcasing the functionality of the library, see examples. These include
non_linear_heat.ipynb- we demonstrate how a discretisation of $\partial_x((1+u^2)\partial_x u)$ is trivial to represent in SPDEax
stochastic_heat.ipynb- we demonstrate how to solve SPDEs using SPDEax
- in particular, we show how to wrap Lineax operators to output an
AbstractFieldfor use indiffrax.ControlTerm
batching.ipynb- we demonstrate how batching is handled in SPDEax
custom_advection_operator.ipynb- we show how to define your own custom
AbstractOperatorusing a one-dimensional advection problem as an example
- we show how to define your own custom
two_dimensional_heat.ipynb- we demonstrate that SPDEax is dimension-agnostic!
dean_kawasaki.ipynb- we show how an advanced SPDE can be solved with relative ease
Future development ideas
- add support for Dirichlet and Neumann boundary conditions
- add timesteppers for semi-linear (S)PDEs e.g. exponential Euler-type methods
- add documentation
- add
TensorField
Metadata
Release files for spdeax 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 | Provenance | Actions |
|---|---|---|---|---|
| spdeax-0.0.1.tar.gz | 14.3 kB | Without provenance | Details for spdeax-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spdeax-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for spdeax-0.0.1-py3-none-any.whl |
Total release size: 36.6 kB
Release files / spdeax-0.0.1.tar.gz
| Download URL | spdeax-0.0.1.tar.gz |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e05a17f66c0179bcacdcb671e5104c6376b9a59b40abc0ccff5c27be59bb938b
|
|
BLAKE2b-256 checksum How to use checksums |
8051d9baa06a56d695e8fc06e0ca69ad410602f419ebbdb66eb21e0754f3b361
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.9
|
Release files / spdeax-0.0.1-py3-none-any.whl
| Download URL | spdeax-0.0.1-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09d17054a456f4cb7327f0178651bd0ceb12aae6ebdf9cc896eb97a602f5d50c
|
|
BLAKE2b-256 checksum How to use checksums |
3d851b040139da8bd78d8134cb0cb34220e275b477048a68e7ce6d91aa43d5ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.9
|
Security for spdeax 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.