Fast and differentiable acoustic simulations in JAX.
Project description
j-Wave: Differentiable acoustic simulations in JAX
Install | Tutorials | Documentation | Changelog
j-Wave is a library of simulators for acoustic applications. It is heavily inspired by k-Wave—a substantial portion of j-Wave is a port of k-Wave in JAX—and it's intended to be used as a collection of modular blocks that can be easily incorporated into any machine learning pipeline.
Embracing the philosophy of JAX, j-Wave is developed with the following principles in mind:
- To be differentiable
- To be efficient through
jit
compilation - To be easily run on GPUs
- To be easily customizable
Install
Follow the instructions to install Jax with CUDA support if you wish to use your GPU.
Next, simply install jwave
using pip:
pip install jwave
For more information, refer to the Linux installation guide.
Due to JAX's limited support on Windows, j-Wave can only be run on Windows machines using the Windows Subsystem for Linux. Please refer to the Installation on Windows guide for more details.
Example
This example simulates an acoustic initial value problem, which is often used as a simple model for photoacoustic acquisitions:
from jax import jit
from jwave import FourierSeries
from jwave.acoustics.time_varying import simulate_wave_propagation
from jwave.geometry import Domain, Medium, TimeAxis
from jwave.utils import load_image_to_numpy
# Simulation parameters
N, dx = (256, 256), (0.1e-3, 0.1e-3)
domain = Domain(N, dx)
medium = Medium(domain=domain, sound_speed=1500.)
time_axis = TimeAxis.from_medium(medium, cfl=0.3, t_end=.8e-05)
# Initial pressure field
p0 = load_image_to_numpy("docs/assets/images/jwave.png", image_size=N)/255.
p0 = FourierSeries(p0, domain)
# Compile and run the simulation
@jit
def solver(medium, p0):
return simulate_wave_propagation(medium, time_axis, p0=p0)
pressure = solver(medium, p0)
Support
If you encounter any problems with the code or wish to propose new features, please feel free to open an issue. If you need general guidance, wish to discuss something, or just want to say hi, don't hesitate to leave a message in our Discord channel.
Contributing
Contributions are absolutely welcome! Most contributions start with an issue. Please don't hesitate to create issues in which you ask for features, give feedback on performances, or simply want to reach out.
To make a pull request, please look at the detailed Contributing guide for how to do it, but fundamentally keep in mind the following main guidelines:
- If you add a new feature or fix a bug:
- Make sure it is covered by tests
- Add a line in the changelog using
kacl-cli
- If you changed something in the documentation, make sure that the documentation site can be correctly build using
mkdocs serve
Citation
If you use jwave
for your research, please consider citing it as:
@article{stanziola2022jwave,
author={Stanziola, Antonio and Arridge, Simon R. and Cox, Ben T. and Treeby, Bradley E.},
title = {j-Wave: An open-source differentiable wave simulator},
publisher = {arXiv},
year = {2022},
}
Related Projects
ADSeismic.jl
: a finite difference acoustic simulator with support for AD and JIT compilation in Julia.stride
: a general optimisation framework for medical ultrasound tomography.k-wave-python
: A python interface to k-wave GPU accelerated binaries
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jwave-0.2.1.tar.gz
.
File metadata
- Download URL: jwave-0.2.1.tar.gz
- Upload date:
- Size: 33.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b187421c0af67eca17e1f94bd21a94286e4536e50c58c9f4cbaab7d1ad5d422e |
|
MD5 | c1796032030562e379e32cec3e54f900 |
|
BLAKE2b-256 | 2ec3533191417df40a5e6aca18fb1f12deea1741b05c113c181e9c59717f75c9 |
File details
Details for the file jwave-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: jwave-0.2.1-py3-none-any.whl
- Upload date:
- Size: 40.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16cfcbc1f00b64cc1bd95a1769ae421c2f439bef80aca3dacdebdc4bdafd5d35 |
|
MD5 | 11d5944d8f2ef7c7443fe1eb61f86943 |
|
BLAKE2b-256 | 665321b2af9e42c92d2ceb44c7c4f8525231b7ad7991498ca96a1b73debbcd80 |