yt.utilities.lib.particle_kdtree_tools module

Cython tools for working with the PyKDTree particle KDTree.

yt.utilities.lib.particle_kdtree_tools.estimate_density(tree_positions, mass, smoothing_length, kdtree, kernel_name='cubic')

Estimate density using SPH gather method.

Parameters:
  • tree_positions (array of floats with shape (n_particles, 3)) – The positions of particles in kdtree sorted order. Currently assumed to be 3D positions.

  • mass (array of floats with shape (n_particles)) – The masses of particles in kdtree sorted order.

  • smoothing_length (array of floats with shape (n_particles)) – The smoothing lengths of particles in kdtree sorted order.

  • kdtree (A PyKDTree instance) – A kdtree to do nearest neighbors searches with.

  • kernel_name (str) – The name of the kernel function to use in density estimation.

Returns:

density – The calculated density.

Return type:

array of floats with shape (n_particles)

yt.utilities.lib.particle_kdtree_tools.generate_smoothing_length(tree_positions, kdtree, n_neighbors)

Calculate array of distances to the nth nearest neighbor

Parameters:
  • tree_positions (arrays of floats with shape (n_particles, 3)) – The positions of particles in kdtree sorted order. Currently assumed to be 3D positions.

  • kdtree (A PyKDTree instance) – A kdtree to do nearest neighbors searches with

  • n_neighbors (The neighbor number to calculate the distance to) –

Returns:

smoothing_lengths – The calculated smoothing lengths

Return type:

arrays of floats with shape (n_particles, )