GeneralFlowEnvironment#

class acoular.environments.GeneralFlowEnvironment

Bases: Environment

An acoustic environment with a generic flow field.

This class provides the facilities to calculate the travel time (distances) between grid point locations and microphone locations in a generic flow field with non-uniform velocities that depend on the location. The algorithm for the calculation uses a ray-tracing approach that bases on rays cast from every microphone position in multiple directions and traced backwards in time. The result is interpolated within a tetrahedal grid spanned between these rays.

See also

scipy.interpolate.LinearNDInterpolator

Piecewise linear interpolator in N > 1 dimensions.

Examples

>>> import numpy as np
>>> import acoular as ac
>>>
>>> # Instantiate the flow field
>>> flow_field = ac.OpenJet(v0=10.0, D=0.4, l=3.121)
>>>
>>> # Create an instance of GeneralFlowEnvironment
>>> environment = ac.GeneralFlowEnvironment(
...     ff=flow_field,  # Use the custom flow field
...     N=300,  # Number of rays
...     Om=np.pi,  # Maximum solid angle
... )
ff

The flow field object describing the velocity field, which must be an instance of FlowField.

N

The number of rays used per solid angle \(\Omega\). Defaults to 200.

Om

The maximum solid angle (in steradians) used in the ray-tracing algorithm. Default is numpy.pi.

digest

A unique identifier based on the environment properties. (read-only)

idict

A dictionary for storing precomputed interpolators to optimize repeated calculations. (internal use)

apparent_r(gpos, mpos=0.0)

Compute the apparent distance (sound travel path length) between two sets of points.

This method calculates the apparent distance (multiplied by the speed of sound) between points gpos and mpos in a 3-D space with a generic flow field. The calculation uses a ray-tracing approach to account for non-uniform flow effects on sound propagation.

Parameters:
gposnumpy.ndarray of floats

The coordinates of the first set of points (e.g., grid points). Should be of shape (3, N), where N is the number of points and each row represents x, y, z coordinates.

mposfloat or numpy.ndarray of floats, optional

The coordinates of the second set of points (e.g., microphone positions). If a scalar is provided, it is treated as the origin (0, 0, 0). If an array is given, it should have shape (3, M), where M is the number of points. Default is 0.0.

Returns:
numpy.ndarray of floats

The apparent distances (sound travel path lengths) between each point in gpos and mpos. The result is an array of:

  • shape (N,) if mpos is a single point, or

  • shape (N, M) if mpos consists of multiple points.

Notes

This method uses ray-tracing and interpolation to compute the apparent distances in a non-uniform flow field. The results are scaled by the speed of sound c.

get_interpolator(roi, x0)

Generate an interpolator for ray travel times based on a region of interest.

This method computes the ray trajectories starting from a given microphone position (x0) through a region of interest (roi). The rays’ paths are integrated numerically using a system of differential equations, and the resulting points are used to construct a convex hull. A linear interpolator is then created to estimate travel times for arbitrary points within the region.

Parameters:
roinumpy.ndarray of floats

Array representing the region of interest (ROI), where each column corresponds to a point in the 3D space \((x, y, z)\), shape (3, M).

x0numpy.ndarray of floats

Array representing the location of the microphone in 3D Cartesian coordinates, shape (3,).

Returns:
scipy.interpolate.LinearNDInterpolator object

A linear interpolator object for estimating travel times for 3D positions within the computed ray trajectories.

c

The speed of sound in the environment. Default is 343.0, which corresponds to the approximate speed of sound at 20°C in dry air at sea level, if the unit is m/s.

roi

The region of interest (ROI) for calculations. (Not needed for most types of environment.) Default is None.