Radiosity fast#

This class represents an optimized radiosity implementation. It includes the following features:

  • It is optimized for speed

  • It supports various forms and relationships of patches

  • It supports BRDFs

Warning

This class contains a known issue in the energy exchange calculation for non-perfectly Lambertian surfaces. The problem will be fixed in a future release.

class sparrowpy.DirectionalRadiosityFast(walls_points: ndarray, walls_normal: ndarray, walls_up_vector: ndarray, patches_points: ndarray, n_patches: int, patch_to_wall_ids: ndarray, visibility_matrix: ndarray = None, visible_patches: ndarray = None, form_factors: ndarray = None, form_factors_tilde: ndarray = None, frequencies: ndarray = None, brdf: list[ndarray] = None, brdf_index: ndarray = None, brdf_incoming_directions: list[Coordinates] = None, brdf_outgoing_directions: list[Coordinates] = None, patch_2_brdf_outgoing_index: ndarray = None, air_attenuation: ndarray = None, speed_of_sound: float = None, etc_time_resolution: float = None, etc_duration: float = None, distance_patches_to_source: ndarray = None, energy_init_source: ndarray = None, energy_exchange_etc: ndarray = None)[source]#

Radiosity object for directional scattering coefficients.

Methods:

bake_geometry()

Bake the geometry by calculating all the form factors.

calculate_direct_sound(receivers)

Calculate the direct sound at the receivers.

calculate_energy_exchange(speed_of_sound, ...)

Calculate the energy exchange between patches.

check()

Check the input data for consistency.

collect_energy_receiver_mono(receivers[, ...])

Collect the energy at the receivers.

collect_energy_receiver_patchwise(receivers)

Collect the energy for each patch at the receivers without summing up the patches.

from_dict(input_dict)

Create an object from a dictionary.

from_polygon(polygon_list, patch_size)

Create a Radiosity object for directional scattering coefficients.

from_read(filename)

Read the object to a far file.

init_source_energy(source)

Initialize the source energy.

set_air_attenuation(air_attenuation)

Set air attenuation factor in Np/m.

set_wall_brdf(wall_indexes, brdf, ...)

Set the wall BRDF representing scattering and absorption.

to_dict()

Convert the object to a dictionary.

write(filename[, compress])

Write the object to a far file.

Attributes:

form_factors

Return the form factor.

n_bins

Return the number of frequency bins.

n_patches

Return the total number of patches.

n_walls

Return the number of walls.

patches_area

Return the area of the patches.

patches_center

Return the center of the patches.

patches_normal

Return the normal of the patches.

patches_points

Return the points of the patches.

patches_size

Return the size of the patches.

speed_of_sound

Return the speed of sound in m/s.

visibility_matrix

Return the visibility matrix.

walls_area

Return the area of the walls.

walls_center

Return the center of the walls.

walls_normal

Return the normal of the walls.

walls_points

Return the points of the walls.

walls_up_vector

Return the up vector of the walls.

bake_geometry()[source]#

Bake the geometry by calculating all the form factors.

calculate_direct_sound(receivers)[source]#

Calculate the direct sound at the receivers.

It includes the spreading loss, air attenuation and source directivity.

Parameters:

receivers (pf.Coordinates) – receiver Coordinates in of cshape (n_receivers).

Returns:

  • direct_sound (np.ndarray) – energy of the direct sound at the receivers in shape (n_receivers, n_bins)

  • n_sample_delay (np.ndarray) – number of samples for the delay at the receivers in shape (n_receivers, )

calculate_energy_exchange(speed_of_sound, etc_time_resolution, etc_duration, max_reflection_order=-1, recalculate=False)[source]#

Calculate the energy exchange between patches. # todo? make first order to first reflection.

check()[source]#

Check the input data for consistency.

collect_energy_receiver_mono(receivers, direct_sound=False)[source]#

Collect the energy at the receivers.

Parameters:
  • receivers (pf.Coordinates) – receiver Coordinates in of cshape (n_receivers).

  • direct_sound (bool, optional) – If True, the direct sound is collected as well, by default False. The direct sound includes spreading loss, air attenuation and source directivity.

Returns:

etc – energy collected at the receiver in cshape (n_receivers, n_bins)

Return type:

pf.TimeData

collect_energy_receiver_patchwise(receivers)[source]#

Collect the energy for each patch at the receivers without summing up the patches.

Parameters:

receivers (pf.Coordinates) – receiver Coordinates in of cshape (n_receivers).

Returns:

etc – energy collected at the receiver in cshape (n_receivers, n_patches, n_bins)

Return type:

pf.TimeData

property form_factors#

Return the form factor.

classmethod from_dict(input_dict: dict)[source]#

Create an object from a dictionary. Used for read write.

classmethod from_polygon(polygon_list, patch_size)[source]#

Create a Radiosity object for directional scattering coefficients.

Parameters:
  • polygon_list (list[Polygon]) – list of patches

  • patch_size (float) – maximal patch size in meters.

classmethod from_read(filename)[source]#

Read the object to a far file.

init_source_energy(source)[source]#

Initialize the source energy.

Parameters:

source (pf.Coordinates, sparrowpy.sound_object.SoundSource) – definition of the source position for Coordinates object and orientation and directivity for SoundSource object. If no directivity is given, the directivity is set to 1 for all frequencies.

property n_bins#

Return the number of frequency bins.

property n_patches#

Return the total number of patches.

property n_walls#

Return the number of walls.

property patches_area#

Return the area of the patches.

property patches_center#

Return the center of the patches.

property patches_normal#

Return the normal of the patches.

property patches_points#

Return the points of the patches.

property patches_size#

Return the size of the patches.

set_air_attenuation(air_attenuation: FrequencyData)[source]#

Set air attenuation factor in Np/m.

Parameters:

air_attenuation (pyfar.FrequencyData) – Air attenuation factor in Np/m.

set_wall_brdf(wall_indexes: list[int], brdf: FrequencyData, incoming_directions: Coordinates, outgoing_directions: Coordinates)[source]#

Set the wall BRDF representing scattering and absorption.

For the incoming and outgoing directions, the radius is ignored as it only represents a direction. The BRDF assumes an up vector of (1, 0, 0) and a normal vector of (0, 0, 1). Therefore, the incoming and outgoing directions must not have negative z-components. For each wall, the incoming and outgoing directions are rotated to align with the given wall’s normal vector and up vector.

Parameters:
  • wall_indexes (list[int]) – List of wall indices for the given BRDF data.

  • brdf (pf.FrequencyData) – BRDF data with shape (n_incoming_directions, n_outgoing_directions).

  • incoming_directions (pf.Coordinates) – Incoming directions of the BRDF data.

  • outgoing_directions (pf.Coordinates) – Outgoing directions of the BRDF data.

property speed_of_sound#

Return the speed of sound in m/s.

to_dict() dict[source]#

Convert the object to a dictionary.

property visibility_matrix#

Return the visibility matrix.

property walls_area#

Return the area of the walls.

property walls_center#

Return the center of the walls.

property walls_normal#

Return the normal of the walls.

property walls_points#

Return the points of the walls.

property walls_up_vector#

Return the up vector of the walls.

write(filename, compress=True)[source]#

Write the object to a far file.