swiftsimio.visualisation.projection_backends.gpu module

Kernel evaluation on the GPU.

swiftsimio.visualisation.projection_backends.gpu.kernel(r: float32, H: float32) float32[source]

Single precision kernel implementation for swiftsimio.

This is the Wendland-C2 kernel as shown in Denhen & Aly (2012) [1].

Parameters:
  • r (np.float32) – Radius used in kernel computation.

  • H (np.float32) – Kernel width (i.e. radius of compact support for the kernel).

Returns:

Contribution to the density by the particle.

Return type:

np.float32

Notes

This is the cuda-compiled version of the kernel, designed for use within the gpu backend. It has no double precision cousin.

References

swiftsimio.visualisation.projection_backends.gpu.scatter_gpu(x: float64, y: float64, m: float32, h: float32, box_x: float64, box_y: float64, img: float32) None[source]

Create a weighted scatter plot.

Computes contributions to from particles with positions (x,`y`) with smoothing lengths h weighted by quantities m. This includes periodic boundary effects.

Parameters:
  • x (np.ndarray[np.float64]) – Array of x-positions of the particles. Must be bounded by [0, 1].

  • y (np.ndarray[np.float64]) – Array of y-positions of the particles. Must be bounded by [0, 1].

  • m (np.ndarray[np.float32]) – Array of masses (or otherwise weights) of the particles.

  • h (np.ndarray[np.float32]) – Array of smoothing lengths of the particles.

  • box_x (np.float64) – Box size in x, in the same rescaled length units as x and y. Used for periodic wrapping.

  • box_y (np.float64) – Box size in y, in the same rescaled length units as x and y. Used for periodic wrapping.

  • img (np.ndarray[np.float32]) – The output image.

Notes

Explicitly defining the types in this function allows for a performance improvement. This is the cuda version, and as such can only be run on systems with a supported GPU. Do not call this where cuda is not available (checks can be performed using swiftsimio.optional_packages.CUDA_AVAILABLE).

swiftsimio.visualisation.projection_backends.gpu.scatter(x: float64, y: float64, m: float32, h: float32, res: int, box_x: float64 = 0.0, box_y: float64 = 0.0) ndarray[source]

Create a weighted scatter plot in parallel.

Creates a weighted scatter plot. Computes contributions from particles with positions (x,`y`) with smoothing lengths h weighted by quantities m. This includes periodic boundary effects.

Parameters:
  • x (np.ndarray[np.float64]) – Array of x-positions of the particles. Must be bounded by [0, 1].

  • y (np.ndarray[np.float64]) – Array of y-positions of the particles. Must be bounded by [0, 1].

  • m (np.ndarray[np.float32]) – Array of masses (or otherwise weights) of the particles.

  • h (np.ndarray[np.float32]) – Array of smoothing lengths of the particles.

  • res (int) – The number of pixels along one axis, i.e. this returns a square of res * res.

  • box_x (np.float64) – Box size in x, in the same rescaled length units as x and y. Used for periodic wrapping.

  • box_y (np.float64) – Box size in y, in the same rescaled length units as x and y. Used for periodic wrapping.

Returns:

Pixel grid of quantity.

Return type:

np.ndarray[np.float32, np.float32, np.float32]

See also

scatter

Creates 2D scatter plot from SWIFT data.

Notes

Explicitly defining the types in this function allows a performance improvement.

swiftsimio.visualisation.projection_backends.gpu.scatter_parallel(x: float64, y: float64, m: float32, h: float32, res: int, box_x: float64 = 0.0, box_y: float64 = 0.0) ndarray

Create a weighted scatter plot in parallel.

Creates a weighted scatter plot. Computes contributions from particles with positions (x,`y`) with smoothing lengths h weighted by quantities m. This includes periodic boundary effects.

Parameters:
  • x (np.ndarray[np.float64]) – Array of x-positions of the particles. Must be bounded by [0, 1].

  • y (np.ndarray[np.float64]) – Array of y-positions of the particles. Must be bounded by [0, 1].

  • m (np.ndarray[np.float32]) – Array of masses (or otherwise weights) of the particles.

  • h (np.ndarray[np.float32]) – Array of smoothing lengths of the particles.

  • res (int) – The number of pixels along one axis, i.e. this returns a square of res * res.

  • box_x (np.float64) – Box size in x, in the same rescaled length units as x and y. Used for periodic wrapping.

  • box_y (np.float64) – Box size in y, in the same rescaled length units as x and y. Used for periodic wrapping.

Returns:

Pixel grid of quantity.

Return type:

np.ndarray[np.float32, np.float32, np.float32]

See also

scatter

Creates 2D scatter plot from SWIFT data.

Notes

Explicitly defining the types in this function allows a performance improvement.