Skip to main content

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

pip install spdeax

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 AbstractField for use in diffrax.ControlTerm
  • batching.ipynb
    • we demonstrate how batching is handled in SPDEax
  • custom_advection_operator.ipynb
    • we show how to define your own custom AbstractOperator using a one-dimensional advection problem as an example
  • 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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spdeax 0.0.2
File Size Uploaded Provenance Actions
spdeax-0.0.2.tar.gz 14.3 kB Without provenance Details for spdeax-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spdeax 0.0.2
File Interpreter ABI Platform Actions
spdeax-0.0.2-py3-none-any.whl Python 3 none any Details for spdeax-0.0.2-py3-none-any.whl

Total release size: 36.5 kB

Release files / spdeax-0.0.2.tar.gz

Download URL spdeax-0.0.2.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3bf2ad9d61382106efb3e3e3067ce07d9e5f88d9f9823ce0078555ae966ef5c6
BLAKE2b-256 checksum
How to use checksums
af3f391c3070c6a0dcca43b2025b7f0e401bf5d096177e12b17381e5a2b3a46f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.9

Release files / spdeax-0.0.2-py3-none-any.whl

Download URL spdeax-0.0.2-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e1daea0d3c9357d9a8738d27899735ede369a3a0cb8fe8e4dfbca781efc96cd
BLAKE2b-256 checksum
How to use checksums
ebbeeb1adbd784be5c9bef873c6e77dec7616ce1939d482c0e818383a7e51045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.9

Security for spdeax 0.0.2

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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page