Skip to content

compas_acoustics.lab

Virtual lab: scattering coefficients of 3D surfaces (ISO 17497-1/-2).

Classes

ReceiverGrid

ReceiverGrid(directions, weights, radius)

Bases: object

Receiver points on a hemisphere, with the solid angle each represents.

Parameters:

Name Type Description Default
directions (array - like, shape(n, 3))

Unit vectors from the sample centre to the receivers.

required
weights (array - like, shape(n))

Solid angle (Voronoi cell area on the unit sphere) of each receiver; they sum to 2 pi on a hemisphere.

required
radius float

Distance of the receivers from the origin.

required

Methods:

hemisphere classmethod
hemisphere(spacing_deg, radius)

Receivers on the upper hemisphere, nominally spacing_deg apart (ISO 17497-2 section 6.2.2).

A Fibonacci (golden-angle) spiral of ceil(2 pi / spacing^2) points; the weights are the areas of the spherical Voronoi cells of the points together with their mirror images in z = 0, which keeps the tiling symmetric.

ScatteringResult

ScatteringResult(method, bands, s_bands, octave_bands, s_octaves, filled_octaves, s_angle, source_colatitude, source_azimuth, source_weights, receiver_directions, polar_sample_db, polar_reference_db, polar_source_indices=None, unconverged_octaves=None, warnings=None, generation=None, name=None, d_angle=None, d_bands=None, d_octaves=None)

Bases: _PackageDtype, Data

Scattering and diffusion coefficients of a sample, measured by a free-field method (ISO 17497-2; Heimes & Vorländer eq. 3 and eq. 11).

Use compas_acoustics.lab.scattering.measure_scattering to make one.

Parameters:

Name Type Description Default
method str

The method: "geometric" (heuristic, see generation["heuristic"]), "kirchhoff" or "bem".

required
bands list of int

The nominal one-third-octave centres in Hz.

required
s_bands list of float

The random-incidence scattering coefficient per band (Paris weighting of s_angle).

required
octave_bands list of int

The simulated octaves in Hz: 125...4000 by default, 125...8000 with the extended range.

required
s_octaves list of float

The mean of the one-third-octave values inside each simulated octave (ISO 354 §8.3, ISO 11654).

required
filled_octaves list of int

The material octaves that were not simulated and take the nearest simulated octave's value.

required
s_angle ndarray

The directional scattering coefficient, shape (n_sources, n_bands): Heimes & Vorländer eq. 3 per frequency, averaged per band (eq. 11); for "geometric" the heuristic s_max·(1 − exp(−(k h)²)) at the bands' exact centres.

required
source_colatitude ndarray

The source directions in degrees, shape (n_sources,).

required
source_azimuth ndarray

The source directions in degrees, shape (n_sources,).

required
source_weights ndarray

Their Paris random-incidence weights, summing to 1.

required
receiver_directions ndarray

Unit vectors from the sample to the receivers, shape (n_receivers, 3).

required
polar_sample_db ndarray

The levels at the receivers per source direction and simulated octave, shape (n_preview, n_octaves, n_receivers), float32: the mean of |p|² over the simulation frequencies in the octave, in dB relative to the reference's maximum for the same source and octave (for "geometric": the cells' energy per steradian, the same at every octave). −300 dB where the level is 0. Stored rounded to 0.1 dB, the resolution ISO 17497-2 §8.5 presents polar responses at.

required
polar_reference_db ndarray

The levels at the receivers per source direction and simulated octave, shape (n_preview, n_octaves, n_receivers), float32: the mean of |p|² over the simulation frequencies in the octave, in dB relative to the reference's maximum for the same source and octave (for "geometric": the cells' energy per steradian, the same at every octave). −300 dB where the level is 0. Stored rounded to 0.1 dB, the resolution ISO 17497-2 §8.5 presents polar responses at.

required
polar_source_indices list of int

The sources whose polar levels the result holds, as indices into the source arrays (source_colatitude ...): every source of a result of compas_acoustics.lab.measure_scattering. By default the first n_preview sources.

None
unconverged_octaves list of int

The simulated octaves holding a frequency at which the solver did not converge (BEM; see generation["unconverged"]): their values are unreliable.

None
warnings list of str

Where the result falls outside the standards or the method's validity.

None
generation dict

How the result was made: method, preset, band range, speed of sound, grid sizes and the solver's own record.

None
d_angle ndarray

The normalised directional diffusion coefficient d_n = (d − d_ref)/(1 − d_ref) (ISO 17497-2 eq. 6 on the intensities at the receivers, weighted by their solid angles, for the sample and for the reference), shape (n_sources, n_bands), averaged per band like s_angle. It is negative where the sample's response is less uniform than the reference's. None in a result made before d existed.

None
d_bands list of float

Its random-incidence value per band (the Paris weights of s_bands).

None
d_octaves list of float

Its mean per simulated octave, like s_octaves.

None

Attributes

scattering_coefficients property
scattering_coefficients

The coefficients on the 7 material octaves 125...8000 Hz; an octave not simulated takes the nearest simulated one's value.

ScatteringSample

ScatteringSample(sample, reference, mode, diameter, period=None, structural_depth=0.0, feature_size=None, symmetry='none', baseplate=0.01, warnings=None, name=None, reference_kind='flat')

Bases: _PackageDtype, Data

A scattering sample and its flat reference, both closed and triangulated (Heimes & Vorländer §3.2).

Use disc or as_drawn to make one.

Parameters:

Name Type Description Default
sample [`compas.datastructures.Mesh`][compas.datastructures.Mesh]

The closed sample body and the flat reference body with the same footprint, outward-oriented triangles.

required
reference [`compas.datastructures.Mesh`][compas.datastructures.Mesh]

The closed sample body and the flat reference body with the same footprint, outward-oriented triangles.

required
mode (disc, as_drawn)
"disc"
diameter float

The footprint diameter in m: the disc's, or, as drawn, the largest xy distance between outline vertices.

required
period tuple of float

The tile period (x, y) in m, in disc mode.

None
structural_depth float

The relief's height h in m: its maximum z, its minimum being at z = 0.

0.0
feature_size float

The relief's characteristic feature size in m, if known.

None
symmetry (none, rotational)
"none"
baseplate float

The thickness in m of the plate below z = 0 that closes both bodies.

0.01
warnings list of str

Problems found: ISO 17497-1 §6.3.2's depth limit h ≤ d/16, or a size that suggests millimetres.

None
reference_kind (flat, proxy)

Whether the reference is the flat footprint or a user-given proxy mesh.

"flat"

Methods:

as_drawn classmethod
as_drawn(mesh, baseplate=0.01, symmetry='none', feature_size=None, reference=None)

A relief as drawn, closed on a baseplate unless it is closed already (Heimes & Vorländer §3.2).

An open relief is walled down to z = −baseplate and closed by a bottom, like disc. A closed mesh is used as it is, its lowest point moved to z = −baseplate (so its bottom baseplate lies below z = 0); its reference is the outline of its bottom, flat at z = 0.

Parameters:

Name Type Description Default
mesh [`compas.datastructures.Mesh`][compas.datastructures.Mesh]

The detailed relief.

required
baseplate float
0.01
symmetry (none, rotational)
"none"
feature_size float
None
reference [`compas.datastructures.Mesh`][compas.datastructures.Mesh]

A proxy to use as the reference instead of the flat footprint: the simplified mesh the room model will carry the scattering coefficient on. It must be open when mesh is open and closed when mesh is closed, share its outline, and is placed with the same z shift as mesh. s then measures the share of the relief's reflection that the proxy does not reproduce.

None

Raises:

Type Description
ValueError

If the relief has not exactly one closed outline, or a closed mesh has no flat bottom, or the proxy is open where the relief is closed (or the other way round) or has another outline.

disc classmethod
disc(tile, diameter, period=None, baseplate=0.01, segments=128, offset=(0.0, 0.0), symmetry='none', feature_size=None)

A tile repeated over the plane and cropped to a disc of diameter (ISO 17497-1 §6.3.2, Heimes & Vorländer §3.2).

Parameters:

Name Type Description Default
tile [`compas.datastructures.Mesh`][compas.datastructures.Mesh]

One period of the relief; quads, n-gons and unwelded seams are fine.

required
diameter float

The disc diameter d in m.

required
period tuple of float

The tile period (x, y) in m; by default the tile's xy bounding box.

None
baseplate float

The plate thickness in m below z = 0.

0.01
segments int

The sides of the regular polygon, inscribed in the circle of radius d/2, that stands for the disc.

128
offset tuple of float

The shift (x, y) in m of the tiling relative to the disc centre at the origin.

(0.0, 0.0)
symmetry (none, rotational)
"none"
feature_size float
None

Raises:

Type Description
ValueError

If the cropped relief has holes or parts, i.e. not exactly one closed outline.

SourceGrid

SourceGrid(colatitude, azimuth)

Bases: object

Incidence directions of the sources, with Paris random-incidence weights.

Parameters:

Name Type Description Default
colatitude (array - like, shape(n))

Colatitude of each source in degrees (0 = straight above the sample).

required
azimuth (array - like, shape(n))

Azimuth of each source in degrees.

required
Notes

Presets: survey is ISO 17497-2 Table 1 (colatitude 0, 30 and 60 degrees, azimuth step 60 degrees, 13 sources), and standard uses colatitudes 0..80 degrees in 10 degree steps with a 30 degree azimuth step (97 sources). The Paris weights (Kuttruff, Room Acoustics) of a ring are (sin^2(theta_hi) - sin^2(theta_lo)) / n_azimuth, with ring bounds at the midpoints between consecutive colatitudes, 0 degrees below the first ring and 90 degrees above the last.

Attributes

directions property
directions

Unit vectors from the sample towards the sources, shape (n, 3).

paris_weights property
paris_weights

Random-incidence weights (Paris), summing to 1, shape (n,).

Methods:

preset classmethod
preset(name, symmetry='none')

Build one of the named source grids.

Parameters:

Name Type Description Default
name (survey, standard)
"survey"
symmetry (none, rotational)

"rotational" keeps azimuth 0 only.

"none"

Functions:

band_average

band_average(values)

Arithmetic mean of each consecutive triple on the last axis (Heimes eq. 11).

Parameters:

Name Type Description Default
values ndarray

Last axis of length 3 * n_bands.

required

Returns:

Type Description
ndarray

Last axis of length n_bands.

diffusion_coefficient

diffusion_coefficient(intensity, weights, axis=1)

Directional diffusion coefficient of a scattered pattern (ISO 17497-2).

Implements eq. 6 of ISO 17497-2 with receiver weights:

.. math::

d = \frac{\dfrac{\left(\sum_i \tilde{w}_i I_i\right)^2}
                {\sum_i \tilde{w}_i I_i^2} - 1}{n - 1},
\qquad \tilde{w}_i = \frac{w_i\, n}{\sum_j w_j}

where :math:I_i is the intensity at receiver :math:i, :math:w_i its weight (for example the solid angle it stands for), and :math:n the number of receivers. The weights are normalised to mean 1, so equal weights reproduce the standard unweighted formula and only their ratios matter.

Parameters:

Name Type Description Default
intensity ndarray

Intensity per receiver, receivers along axis: :math:|p|^2 in the far field, or the energy per steradian of the geometric method.

required
weights ndarray

Receiver weights, one per receiver; broadcast along axis.

required
axis int

Receiver axis. Default is 1.

1

Returns:

Type Description
ndarray

Diffusion coefficient with axis removed, 1 for a uniform pattern and 0 when one receiver carries everything (with equal weights). Where the pattern is identically zero the coefficient is 0 rather than NaN.

fill_octaves

fill_octaves(octaves, values)

Expand simulated octaves to all material octaves; a missing one takes the nearest simulated octave's value.

Parameters:

Name Type Description Default
octaves list of int

Simulated octave centres.

required
values ndarray

Last axis: one value per simulated octave.

required

Returns:

Type Description
tuple

(filled, pairs): values on the 7 octaves of Defaults.DEFAULT_FREQUENCY_BANDS and the (filled, source) pairs.

fold_to_octaves

fold_to_octaves(values, nominal)

Mean of the one-third-octave values inside each octave (ISO 354 §8.3, ISO 11654).

Each band belongs to the octave whose nominal centre is nearest on a log scale (125 <- 100, 125, 160; ...; 8000 <- 6300, 8000, 10000).

Parameters:

Name Type Description Default
values ndarray

Last axis: one value per band in nominal.

required
nominal ndarray

Nominal band centres.

required

Returns:

Type Description
tuple

(octaves, means): the octave centres with at least one band and their means on the last axis.

measure_scattering

measure_scattering(sample, method='geometric', preset=None, band_range=ISO_BAND_RANGE, air=None, name=None, **solver_options) -> ScatteringResult

Measure the scattering and diffusion coefficients of a sample in a virtual free field (ISO 17497-2; Heimes & Vorländer 2025).

Three methods, all on the same source grids, bands and averaging:

  • "geometric" (the default, seconds): a fast heuristic preview, not a wave solution (compas_acoustics.lab.geometric). It needs trimesh (ideally with the embreex backend), which the lab extra installs on Python ≥ 3.11 only (pip install compas_acoustics[lab]); method="kirchhoff" runs without them (Rhino's Python 3.9 included). n_rays specular rays per source, aimed at the footprint, reflect off the rigid sample and the rigid reference (mounted in a baffle at z = 0) and are binned on a receiver hemisphere of bin_deg cells. s_max per source is one minus the overlap of the two energy histograms, the lost fraction (rays still bouncing after max_bounces) counted as one more bin; the per-band s = s_max·(1 − exp(−(k h)²)) is imposed at each band's exact centre, with h = max(2 σ, |mean|) of the height difference between the sample and the reference over the footprint (a relief: twice its standard deviation; a box: its height). There is no phase and no diffraction: no rim, no cavity resonance. d comes from the cells' energy per steradian and is the same at every band, as are the polar levels; both depend on bin_deg. The result is marked generation["heuristic"] and warned about; more than 1 % lost rays for any source is warned about too, and so is a depth curve below 0.5 at the highest band while the mean s_max exceeds 0.05 (s close to 0 although the rays scatter), and so is an object whose mean height above the plane exceeds twice the spread of its relief (a closed mesh on a backing thicker than baseplate: the backing sets the depth; pass its thickness as baseplate).
  • "kirchhoff": physical optics, the correlation coefficient below.
  • "bem": the boundary element method (mesh2scattering/NumCalc, needs Python ≥ 3.11 and the lab extra), the same correlation.

For the wave methods the correlation coefficient (Mommertz 2000; Heimes & Vorländer eq. 3) of the sample's and the reference's pressures on a receiver hemisphere of radius 10·d, at receiver spacing min(5°, 50·λ_min/d) (ISO 17497-2 §6.2.2, Heimes eq. 6), is computed per source direction and frequency, averaged over the three frequencies of each one-third-octave band (eq. 11), weighted over the sources with the Paris weights for random incidence, and averaged per octave (ISO 354 §8.3, ISO 11654).

Every method also returns the normalised diffusion coefficient d_n = (d − d_ref)/(1 − d_ref), d from ISO 17497-2 eq. 6 on the intensities at the receivers weighted by their solid angles (|p|² for the wave methods, per frequency, then averaged per band like s), with the same random incidence and octaves as s (result.d_angle, d_bands, d_octaves).

A batchable solver (solver.batchable: Kirchhoff) runs source batch by source batch, each batch reduced to its correlation coefficients before the next, so the pressures of all sources are never held at once (a batch holds at most 512 MB of them). The polar levels are kept for every source direction, listed in result.polar_source_indices. A Kirchhoff run estimated longer than 10 minutes is warned about before it starts (estimate_seconds): the default "standard" preset on a 0.8 m disc takes about 5 minutes on 14 cores.

Known limitations of the BEM (2026-10-24, Heimes & Vorländer's sine surface, d = 0.8 m): below about 700 Hz NumCalc's iterative solves do not converge and those bands are wrong; such steps are listed in generation["unconverged"], warned about in result.warnings and their octaves in result.unconverged_octaves. Where it converges, the BEM's s sits 0.03–0.10 below Heimes & Vorländer's in 11 of the 12 checked one-third octaves (Λ/λ ≥ 0.5, per angle at 31.5° and 61.74°); see BemSolver.

Parameters:

Name Type Description Default
sample [`compas_acoustics.lab.sample.ScatteringSample`][compas_acoustics.lab.sample.ScatteringSample]
required
method (geometric, kirchhoff, bem)

The heuristic geometric preview (default, fast), physical optics, or the boundary element method.

"geometric"
preset (survey, standard)

The source grid; by default DEFAULT_PRESETS[method]: "standard" for every method. Comparisons between methods should pass the same preset.

"survey"
band_range tuple of float

The nominal one-third-octave centres simulated, inclusive: ISO_BAND_RANGE (100-5000 Hz, ISO 17497-1/-2 §5) by default, EXTENDED_BAND_RANGE for the extension to 8 kHz beyond the standards.

ISO_BAND_RANGE
air [`compas_acoustics.room.AirConditions`][compas_acoustics.room.air.AirConditions]

Gives the speed of sound; the default air by default.

None
name str

The result's name; the sample's by default.

None
**solver_options

For "geometric", passed to geometric_response: n_rays (rays per source, 50000), bin_deg (receiver cell spacing in degrees, 10), max_bounces (20) and seed (of the footprint points, 0); they are recorded in generation. For the wave methods, passed to the solver: KirchhoffSolver(shadowing, chunk, workers) or BemSolver(cache_dir, numcalc_path, max_elements, ...).

{}

Returns:

Type Description
[`compas_acoustics.lab.results.ScatteringResult`][compas_acoustics.lab.results.ScatteringResult]

Raises:

Type Description
ValueError

If the method is not supported, or the preset or band range is invalid.

TypeError

If a solver option is not one of the method's.

ImportError

If method="geometric" and trimesh or its ray backend is missing; the message names method="kirchhoff" as the way out.

RuntimeError

If the solver returned non-finite pressures.

normalised_diffusion

normalised_diffusion(d, d_reference)

Diffusion coefficient of a sample relative to its flat reference.

.. math::

d_n = \frac{d - d_{ref}}{1 - d_{ref}}

Parameters:

Name Type Description Default
d ndarray

Diffusion coefficient of the sample.

required
d_reference ndarray

Diffusion coefficient of the reference, broadcastable against d.

required

Returns:

Type Description
ndarray

Normalised diffusion coefficient, 0 where d_reference >= 1 (a fully diffuse reference leaves nothing to gain) rather than NaN or infinity.

random_incidence

random_incidence(s_angle, source_grid)

Random-incidence scattering coefficient from per-direction values.

Weights the coefficient of each source direction with the Paris weights (Kuttruff), :math:s_{rand} = \sum_i w_i s_i, which approximate the :math:\cos\theta\,\sin\theta diffuse-field weighting and sum to 1.

Parameters:

Name Type Description Default
s_angle ndarray

Coefficients with the sources along axis 0.

required
source_grid SourceGrid

Source grid providing paris_weights.

required

Returns:

Type Description
ndarray

Weighted average over axis 0.

receiver_spacing

receiver_spacing(diameter, f_max, c)

Receiver spacing in degrees: min(5, 50 * lambda_min / d) (ISO 17497-2 section 6.2.2, Embrechts eq. 6, Heimes eq. 6).

Parameters:

Name Type Description Default
diameter float

Footprint diameter d of the sample (m).

required
f_max float

Highest frequency (Hz).

required
c float

Speed of sound (m/s).

required

scattering_freefield

scattering_freefield(p_sample, p_reference, weights, axis=1)

Correlation scattering coefficient of a sample against its flat reference.

Implements the free-field correlation method of Mommertz (2000), written as eq. 3 in Heimes & Vorländer (2025):

.. math::

s = 1 - \frac{\left|\sum p_1 p_0^* w\right|^2}
             {\sum |p_1|^2 w \cdot \sum |p_0|^2 w}

where :math:p_1 is the pressure with the sample, :math:p_0 the pressure with the reference, and the sums run over the receivers.

Parameters:

Name Type Description Default
p_sample ndarray

Complex pressure of the sample, receivers along axis.

required
p_reference ndarray

Complex pressure of the reference, same shape as p_sample.

required
weights ndarray

Receiver weights, one per receiver; broadcast along axis.

required
axis int

Receiver axis. Default is 1.

1

Returns:

Type Description
ndarray

Scattering coefficient with axis removed. Where both patterns are identically zero the coefficient is 0 rather than NaN.

simulation_frequencies

simulation_frequencies(band_range=ISO_BAND_RANGE)

Three frequencies per band, fc * 2**(-1/9), fc, fc * 2**(1/9), ascending.

ISO 17497-2 §7.4.4 asks for at least three points per band; band values are their mean (Heimes eq. 11).

Returns:

Type Description
ndarray

Shape (3 * n_bands,).

third_octave_centres

third_octave_centres(band_range=ISO_BAND_RANGE)

Nominal and exact centres of the one-third-octave bands in an inclusive range.

The exact centres are 1000 * 10**(n / 10) (ISO 266; ISO 354 §5, ISO 17497-2 §5).

Parameters:

Name Type Description Default
band_range tuple of float

Lowest and highest nominal centre, both inclusive; lo == hi gives a single band. A value is mapped to the band with the nearest exact centre. Must lie within 100...8000 Hz.

ISO_BAND_RANGE

Returns:

Type Description
tuple of np.ndarray

(nominal, exact) for the bands in the range.

Raises:

Type Description
ValueError

If the range lies outside 100...8000 Hz or is reversed.