Skip to content

Commit

Permalink
Moving to new jaxdf (#220)
Browse files Browse the repository at this point in the history
* removed missing function from test_geometry
* added setting class for time domain simulations (TimeWavePropagationSettings )
* upgraded jaxdf
* use jaxdf.Module
  • Loading branch information
astanziola authored Nov 24, 2023
1 parent 6884aff commit 7d02164
Show file tree
Hide file tree
Showing 13 changed files with 508 additions and 234 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed
- Fixed arguments error in helmholtz notebook

### Changed
- `Medium` objects are now `jaxdf.Module`s, which is based on `equinox` modules. It is also a [parametric module for dispatching operators](https://beartype.github.io/plum/parametric.html), meaning that there's a type difference betwee `Medium[FourierSeries]` and `Medium[FiniteDifferences]`, for example.
- The settings of time domain acoustic simulations are now set using a `TimeWavePropagationSettings`. This also includes an attribute to explicity set the reference sound speed.

### Added
- Added a logger in `jwave.logger`

### Removed
- Removed `pressure_from_density` from `jwave.acoustics.conversion`, as it was a duplicate

## [0.1.5] - 2023-09-27
### Added
- Added `numbers_with_smallest_primes` utility to find grids with small primes for efficient FFT when using FourierSeries
Expand Down
23 changes: 0 additions & 23 deletions jwave/acoustics/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,6 @@
import numpy as np
from jax import numpy as jnp

from jwave.geometry import Sensors


def pressure_from_density(sensors_data: jnp.ndarray, sound_speed: jnp.ndarray,
sensors: Sensors) -> jnp.ndarray:
r"""
Calculate pressure from acoustic density given by the raw output of the
timestepping scheme.
Args:
sensors_data: Raw output of the timestepping scheme.
sound_speed: Sound speed of the medium.
sensors: Sensors object.
Returns:
jnp.ndarray: Pressure time traces at sensor locations
"""
if sensors is None:
return jnp.sum(sensors_data[1], -1) * (sound_speed**2)
else:
return jnp.sum(sensors_data[1], -1) * (sound_speed[sensors.positions]**
2)


def db2neper(
alpha: jnp.ndarray,
Expand Down
6 changes: 3 additions & 3 deletions jwave/acoustics/time_harmonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ def _cbs_norm_units(medium, omega, k0, src):
# Update fields
src = FourierSeries(src.on_grid, domain)
if issubclass(type(medium.sound_speed), FourierSeries):
medium.sound_speed = FourierSeries(c, domain)
else:
medium.sound_speed = c
c = FourierSeries(c, domain)

medium = medium.replace("sound_speed", c)

# Update k0
k0 = k0 * _conversion["dx"]
Expand Down
Loading

0 comments on commit 7d02164

Please sign in to comment.