synthesizer.kernel_functions

A module defining SPH kernels integrated along the line-of-sight.

This module provides a class for calculating SPH kernels integrated along the line-of-sight. The kernels are used in smoothed particle hydrodynamics (SPH) simulations to compute the density of particles in a given volume. The kernels are defined as functions of the distance from the center of the kernel and are integrated along the line-of-sight to obtain the density distribution.

Available kernels include:
  • uniform

  • sph_anarchy

  • gadget_2

  • cubic

  • quintic

Example usage:

kernel = Kernel(name=”sph_anarchy”, binsize=10000) kernel_data = kernel.get_kernel()

Functions

synthesizer.kernel_functions.cubic(r)[source]

Calculate the cubic kernel.

Parameters:

r (float) – The distance from the center of the kernel.

Returns:

The value of the cubic kernel.

Return type:

float

synthesizer.kernel_functions.gadget_2(r)[source]

Calculate the Gadget-2 kernel.

Parameters:

r (float) – The distance from the center of the kernel.

Returns:

The value of the Gadget-2 kernel.

Return type:

float

synthesizer.kernel_functions.quintic(r)[source]

Calculate the quintic kernel.

Parameters:

r (float) – The distance from the center of the kernel.

Returns:

The value of the quintic kernel.

Return type:

float

synthesizer.kernel_functions.sph_anarchy(r)[source]

Calculate the SPH Anarchy kernel.

Parameters:

r (float) – The distance from the center of the kernel.

Returns:

The value of the SPH Anarchy kernel.

Return type:

float

synthesizer.kernel_functions.uniform(r)[source]

Calculate the uniform kernel.

Parameters:

r (float) – The distance from the center of the kernel.

Returns:

The value of the uniform kernel.

Return type:

float

Classes

class synthesizer.kernel_functions.Kernel(name='sph_anarchy', binsize=10000)[source]

A class describing a SPH kernel integrated along the line-of-sight.

Line of sight distance along a particle, l = 2*sqrt(h^2 + b^2), where h and b are the smoothing length and the impact parameter respectively. This needs to be weighted along with the kernel density function W(r), to calculate the los density. Integrated los density,

D = 2 * integral(W(r)dz) from 0 to sqrt(h^2-b^2),

where r = sqrt(z^2 + b^2), W(r) is in units of h^-3 and is a function of r and h. The parameters are normalized in terms of the smoothing length, helping us to create a look-up table for every impact parameter along the line-of-sight. Hence we substitute x = x/h and b = b/h.

This implies

D = h^-2 * 2 * integral(W(r) dz) for x = 0 to sqrt(1.-b^2).

The division by h^2 is to be done separately for each particle along the line-of-sight.

W_dz(z, b)[source]

Calculate the kernel density function W(r) as a function of z.

Parameters:
  • z (float) – The distance along the line-of-sight.

  • b (float) – The impact parameter.

Returns:

The value of the kernel density function W(r).

Return type:

float

create_kernel()[source]

Save the computed kernel for easy look-up as .npz file.

get_kernel()[source]

Compute the kernel.

i.e. h^-2 * 2 * integral(W(r) dz) from x = 0 to sqrt(1.-b^2) for various values of b.

Returns:

The kernel values for each impact parameter.

Return type:

np.ndarray

Examples using synthesizer.kernel_functions.Kernel

Line of sight example

Line of sight example

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