xpektra : Modular framework for spectral methods
xpektra is a Python library that provides a modularframework for spectral methods. xpektra provide fundamental mathematical building blocks which can be used to construct complex spectral methods. It is built on top of JAX and Equinox, making it easy to use spectral methods in a differentiable way.
License
xpektra is distributed under the GNU Lesser General Public License v3.0 or later. See COPYING and COPYING.LESSER for the complete terms. © 2025 ETH Zurich (Mohit Pundir).
Features
- Modular building blocks for spectral methods which can be easily combined to create complex solid mechanics problems.
- Extensible design allowing users to define their own operators and spaces such as Fourier-Galerkin, Moulinec and Suquet, Displacement-based, etc.
- Differentiable operations using JAX
- Implicit differentiation support which allows for computationally efficient Homogenization and Multiscale simulations.
Installation
Install the current release from PyPI:
pip install xpektra
For development work, clone the repository and install it in editable mode (use your preferred virtual environment tool such as uv or venv):
git clone https://github.com/smec-ethz/xpektra.git
cd xpektra
pip install -e .
Usage
xpektra provides modular blocks by defining a few operators and spaces that can be used to construct complex spectral methods. These operators and spaces are:
SpectralSpace: Defines the spectral space on which the methods are defined, this includes the FFT, IFFT, and other spectral transforms.TensorOperator: Defines the tensor operator which performs tensor operations on quantities living on the grid, the operator automatically figures out the order of the tensor.Scheme: Defines the scheme for discretization which is then used to construct the gradient operator. Currently,CartesianSchemeis the only scheme available but one can easily define new schemes by subclassing theSchemeclass.make_field: Defines the field on which the methods are defined, this includes the field operations and the field creation.ProjectionOperator: Defines the projection operator which projects the stress field onto the spectral space. Currently,GalerkinProjectionis the only projection operator available but one can easily define new projection operators by subclassing theProjectionOperatorclass.
Benchmarking
Check the Live Benchmark Dashboard to see the performance of xpektra at Live Benchmark Dashboard.
👉 Where to contribute
If you have a suggestion that would make this better, please fork the repo and create a pull request on github.com/smec-ethz/xpektra. Please use that repository to open issues or submit merge requests. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Metadata
Release files for xpektra 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xpektra-0.5.0.tar.gz | 14.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xpektra-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 MB
Release files / xpektra-0.5.0.tar.gz
| Download URL | xpektra-0.5.0.tar.gz |
|---|---|
| Size | 14.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad079ea021bd6229b4d69efadd1986080d714a6da7fd6599dbe4debde6890af0
|
|
BLAKE2b-256 checksum How to use checksums |
a948db30f0e1bcb237fbc11f90ad3fa6619e63524c872fa3ad66745b3eebcd7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / xpektra-0.5.0-py3-none-any.whl
| Download URL | xpektra-0.5.0-py3-none-any.whl |
|---|---|
| Size | 36.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dba99d1402cd6d2bb4260e01bd05838cd4e46826d6582d8bdc5aa085a3ba161
|
|
BLAKE2b-256 checksum How to use checksums |
38be76a52e5cd20f79ecd83f4e9287ad5a1c3e2f16f0b7058036955278c94cfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|