Skip to content

jwave.geometry

BLISensors

Band-limited interpolant (off-grid) sensors.

Parameters:

Name Type Description Default
positions Tuple of List of float

Sensor positions.

required
n Tuple of int

Grid size.

required

Attributes:

Name Type Description
positions Tuple[jnp.ndarray]

Sensor positions

n Tuple[int]

Grid size.

__call__(p, u, v)

Returns the values of the field p at the sensors positions.

Parameters:

Name Type Description Default
p Field

The field to be sampled.

required

Medium

Bases: Module

summary

Parameters:

Name Type Description Default
eqx _type_

description

required

Raises:

Type Description
ValueError

description

TypeError

description

ValueError

description

Returns:

Name Type Description
_type_

description

int_pml_size: int property

Returns the size of the PML layer as an integer

max_attenuation property

Calculate and return the maximum attenuation.

This property uses the attenuation method/function and applies the amax function from JAX's numpy (jnp) library to find the maximum attenuation value.

Returns:

Type Description

The maximum attenuation value.

max_density property

Calculate and return the maximum density.

This property uses the density method/function and applies the amax function from JAX's numpy (jnp) library to find the maximum density value.

Returns:

Type Description

The maximum density value.

max_sound_speed property

Calculate and return the maximum sound speed.

This property uses the sound_speed method/function and applies the amax function from JAX's numpy (jnp) library to find the maximum sound speed value.

Returns:

Type Description

The maximum sound speed value.

min_attenuation property

Calculate and return the minimum attenuation.

This property uses the attenuation method/function and applies the amin function from JAX's numpy (jnp) library to find the minimum attenuation value.

Returns:

Type Description

The minimum attenuation value.

min_density property

Calculate and return the minimum density.

This property uses the density method/function and applies the amin function from JAX's numpy (jnp) library to find the minimum density value.

Returns:

Type Description

The minimum density value.

min_sound_speed property

Calculate and return the minimum sound speed.

This property uses the sound_speed method/function and applies the amin function from JAX's numpy (jnp) library to find the minimum sound speed value.

Returns:

Type Description

The minimum sound speed value.

__infer_type_parameter__(*args, **kwargs) classmethod

Inter the type parameter from the arguments. Defaults to FourierSeries if the parameters are all floats

__init_type_parameter__(t) classmethod

Check whether the type parameters is valid.

Sensors

Sensors structure

Attributes:

Name Type Description
positions Tuple[List[int]]

sensors positions

Example

x_pos = [10,20,30,40]
y_pos = [30,30,30,30]
sensors = geometry.Sensors(positions=(x_pos, y_pos))

__call__(p, u, rho)

Returns the values of the field u at the sensors positions.

Parameters:

Name Type Description Default
u Field

The field to be sampled.

required

to_binary_mask(N)

Convert sensors to binary mask

Parameters:

Name Type Description Default
N Tuple[int]

grid size

required

Returns:

Type Description

jnp.ndarray: binary mask

Sources

Sources structure

Attributes:

Name Type Description
positions Tuple[List[int]

source positions

signals List[jnp.ndarray]

source signals

dt float

time step

domain Domain

domain

Example

x_pos = [10,20,30,40]
y_pos = [30,30,30,30]
signal = jnp.sin(jnp.linspace(0,10,100))
signals = jnp.stack([signal]*4)
sources = geometry.Source(positions=(x_pos, y_pos), signals=signals)

to_binary_mask(N)

Convert sources to binary mask

Parameters:

Name Type Description Default
N Tuple[int]

grid size

required

Returns:

Type Description

jnp.ndarray: binary mask

TimeAxis

Temporal vector to be used for acoustic simulation based on the pseudospectral method of k-Wave

Attributes:

Name Type Description
dt float

time step

t_end float

simulation end time

Nt property

Returns the number of time steps

from_medium(medium, cfl=0.3, t_end=None) staticmethod

Construct a TimeAxis object from kGrid and Medium

Parameters:

Name Type Description Default
grid kGrid
required
medium Medium
required
cfl float

The CFL number. Defaults to 0.3.

0.3
t_end [float]

The final simulation time. If None, it is automatically calculated as the time required to travel from one corner of the domain to the opposite one.

None

to_array()

Returns the time-axis as an array

TimeHarmonicSource dataclass

TimeHarmonicSource dataclass

Attributes:

Name Type Description
domain Domain

domain

amplitude Field

The complex amplitude field of the sources

omega float

The angular frequency of the sources

on_grid(t=0.0)

Returns the complex field corresponding to the sources distribution at time $t$.

bli_function(x0, x, n, include_imag=False)

The function used to compute the band limited interpolation function.

Parameters:

Name Type Description Default
x0 jnp.ndarray

Position of the sensors along the axis.

required
x jnp.ndarray

Grid positions.

required
n int

Size of the grid

required
include_imag bool

Include the imaginary component?

False

Returns:

Type Description
jnp.ndarray

jnp.ndarray: The values of the function at the grid positions.

circ_mask(N, radius, centre)

Generate a 2D binary mask representing a circle within a 2D grid.

The mask is an ndarray of size N with 1s inside the circle (defined by a given centre and radius) and 0s outside.

Parameters:

Name Type Description Default
N Tuple[int, int]

The shape of the output mask (size of the grid). It should be in the format (x_size, y_size).

required
radius float

The radius of the circle.

required
centre Union[List[float], Tuple[float, float]]

The coordinates of the centre of the circle in the format (x, y).

required

Returns:

Name Type Description
mask np.ndarray

The 2D mask as a numpy ndarray of integers. The shape of the mask is N. Values inside the circle are 1, and values outside the circle are 0.

fibonacci_sphere(n, radius, centre, cast_int=True)

Generate evenly distributed points on the surface of a sphere using the Fibonacci Sphere method.

n (int): The number of points to generate. radius (float): The radius of the sphere. centre (tuple or np.ndarray): The (x, y, z) coordinates of the center of the sphere. cast_int (bool, optional): If True, points will be rounded and converted to integers. Default is True.

x, y, z (tuple): The x, y, and z coordinates of the points on the sphere.

get_line_transducer(domain, position, width, angle=0)

Construct a line transducer (2D)

points_on_circle(n, radius, centre, cast_int=True, angle=0.0, max_angle=2 * np.pi)

Generate points on a circle.

Parameters:

Name Type Description Default
n int

Number of points.

required
radius float

Radius of the circle.

required
centre tuple

Centre coordinates of the circle (x, y).

required
cast_int bool

If True, points will be rounded and converted to integers. Default is True.

True
angle float

Starting angle in radians. Default is 0.

0.0
max_angle float

Maximum angle to reach in radians. Default is 2*pi (full circle).

2 * np.pi

Returns:

Type Description
Tuple[List[float], List[float]]

x, y (tuple): Lists of x and y coordinates of the points.

sphere_mask(N, radius, centre)

Generate a 3D binary mask representing a sphere within a 3D grid.

The mask is an ndarray of size N with 1s inside the sphere (defined by a given centre and radius) and 0s outside.

Parameters:

Name Type Description Default
N Tuple[int, int, int]

The shape of the output mask (size of the grid). It should be in the format (x_size, y_size, z_size).

required
radius float

The radius of the sphere.

required
centre Union[List[float], Tuple[float, float, float]]

The coordinates of the centre of the sphere in the format (x, y, z).

required

Returns:

Name Type Description
mask np.ndarray

The 3D mask as a numpy ndarray of integers. The shape of the mask is N. Values inside the sphere are 1, and values outside the sphere are 0.

unit_fibonacci_sphere(samples=128)

Generate evenly distributed points on the surface of a unit sphere using the Fibonacci Sphere method.

From https://stackoverflow.com/questions/9600801/evenly-distributing-n-points-on-a-sphere

Parameters:

Name Type Description Default
samples int

The number of points to generate. Default is 128.

128

Returns:

Name Type Description
points list

A list of tuples representing the (x, y, z) coordinates of the points on the sphere.