Skip to main content

Fast and differentiable acoustic simulations in JAX.

Project description

logo

j-Wave: Differentiable acoustic simulations in JAX

Support License: LGPL v3 Continous Integration codecov Binder Open In Colab

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:

  1. To be differentiable
  2. To be efficient through jit compilation
  3. To be easily run on GPUs
  4. 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)

Simulated pressure field

Support

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.


Citation

arXiv

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

  1. ADSeismic.jl: a finite difference acoustic simulator with support for AD and JIT compilation in Julia.
  2. stride: a general optimisation framework for medical ultrasound tomography.
  3. k-wave-python: A python interface to k-wave GPU accelerated binaries

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jwave-0.1.2.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

jwave-0.1.2-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

Details for the file jwave-0.1.2.tar.gz.

File metadata

  • Download URL: jwave-0.1.2.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1040-azure

File hashes

Hashes for jwave-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6dfbf76f97e72e30d8b3dcd56405b4b21eae15a47be8435d1c986ee2591e59eb
MD5 ce24b9bb962fe1b6dfd3440d6756302d
BLAKE2b-256 8c7cbe94b23668749a984bcf4984eeef67f1b38bd9042d82bf87e42cd2ca6b3b

See more details on using hashes here.

File details

Details for the file jwave-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: jwave-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1040-azure

File hashes

Hashes for jwave-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9041234a126b04be4ea403aad2775f6ee40c33f47075bbd204bc488bc1ee377b
MD5 cb14924c19901d6a2dd29ba39c18ab15
BLAKE2b-256 154b69904015684481e19600cc5381e057265d701970aef5216d836e6c323fb9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page