synthesizer.particle.utils

A submodule containing utility functions for particle distributions.

Functions

synthesizer.particle.utils.calculate_smoothing_lengths(coordinates, kernel_gamma=1.4, num_neighbours=32, speedup_fac=2, dimension=3, boxsize=None)[source]

Calculate smoothing lengths based on the kth nearest neighbour distance.

This is approximately what is done in SPH codes to calculate the smoothing length for each particle.

Adapted from the Swiftsimio implementation (https://github.com/SWIFTSIM/swiftsimio)

Parameters:
  • coordinates (unyt_array) – The coordinates to calculate the smoothing lengths for.

  • kernel_gamma (float, optional) – The kernel gamma of the kernel being used. (default: 1.4)

  • num_neighbours (int, optional) – The number of neighbours to encompass.

  • speedup_fac (int, optional) – A parameter that neighbours is divided by to provide a speed-up by only searching for a lower number of neighbours. For example, if neighbours is 32, and speedup_fac is 2, we only search for 16 (32 / 2) neighbours, and extend the smoothing length out to (speedup)**(1/dimension) such that we encompass an approximately higher number of neighbours. A factor of 2 gives smoothing lengths the same as the full search within 10%, good enough for visualisation.

  • dimension (int, optional) – The dimensionality of the problem (used for speedup_fac calculation).

  • boxsize (unyt_array, optional) – The boxsize to use for the periodic boundary conditions. If None, no periodic boundary conditions are used

Returns:

An unyt array of smoothing lengths.

Return type:

unyt_array

Examples using synthesizer.particle.utils.calculate_smoothing_lengths

Plot line of sight optical depth calculations

Plot line of sight optical depth calculations

Plot line of sight diagnostics

Plot line of sight diagnostics

Rotating particle distributions

Rotating particle distributions
synthesizer.particle.utils.rotate(coordinates, phi=unyt_quantity(0, 'rad'), theta=unyt_quantity(0, 'rad'), rot_matrix=None)[source]

Rotate 3D array of coordinates.

Parameters:
  • coordinates (np.ndarray of float) – 1D or 2D array of coordinates

  • phi (unyt_quantity) – The angle in radians to rotate around the z-axis. If rot_matrix is defined this will be ignored.

  • theta (unyt_quantity) – The angle in radians to rotate around the y-axis. If rot_matrix is defined this will be ignored.

  • rot_matrix (array-like, float) – A 3x3 rotation matrix to apply to the coordinates instead of phi and theta.

Returns:

coordinates (np.array)

transformed coordinate array