SPH#

Pusher kernels#

struphy.pic.pushing.kernels.push_v_sph_pressure.push_v_sph_pressure_kernels.push_v_sph_pressure(dt: float, stage: int, args_markers: MarkerArguments, args_domain: DomainArguments, boxes: int[:, :], neighbours: int[:, :], holes: bool[:], periodic1: bool, periodic2: bool, periodic3: bool, kernel_type: int, h1: float, h2: float, h3: float, gravity: float[:], kappa: float)[source]#

Update each marker \(p\) according to

\[\frac{\mathbf v_p^{n+1} - \mathbf v_p^n}{\Delta t} = \mathbf g - \sum_{i=1}^N w_i \left( \frac{\kappa}{\rho^{N,h}(\boldsymbol \eta_p)} + \frac{\kappa}{\rho^{N,h}(\boldsymbol \eta_i)} \right) DF^{-\top}\nabla W_h(\boldsymbol \eta_p - \boldsymbol \eta_i) \,,\]

where \(\mathbf g\) is a constant acceleration, the second term corresponds to the pressure gradient in the isothermal closure (with constant \(\kappa\)), and \(DF^{-\top}\) denotes the inverse transpose Jacobian arising in the pull back of the gradient of the smoothing kernel \(W_h\) chosen from sph_smoothing_kernels.

The smoothed SPH density is given by

\[\rho^{N,h}(\boldsymbol \eta_p) = \sum_j w_j \, W_h(\boldsymbol \eta_p - \boldsymbol \eta_j)\,.\]

This kernel requires:

  • The density \(\rho^{N,h}(\boldsymbol \eta_p)\) to be pre-computed for each particle and stored at markers[first_free_idx, :])

  • The coefficient \(w_i/\rho^{N,h}(\boldsymbol \eta_i)\) to be pre-computed for each particle and stored at markers[first_free_idx + 1, :])

This is accomplished by the kernel sph_pressure_coeffs(), which needs to be passed as an init_kernel to the Pusher.

Parameters:
  • boxes (2d array) – Box array of the sorting boxes structure.

  • neighbours (2d array) – Array containing the 27 neighbouring boxes of each box.

  • holes (bool) – 1D array of length markers.shape[1]. True if markers[:, i] is a hole.

  • periodic1 (bool) – True if periodic in that dimension.

  • periodic2 (bool) – True if periodic in that dimension.

  • periodic3 (bool) – True if periodic in that dimension.

  • kernel_type (int) – Number of the smoothing kernel.

  • h1 (float) – Kernel width in respective dimension.

  • h2 (float) – Kernel width in respective dimension.

  • h3 (float) – Kernel width in respective dimension.

  • gravity (xp.ndarray) – Constant gravitational force as 3-vector.

  • kappa (float) – Constant isothermal coefficient.

struphy.pic.pushing.kernels.push_v_sph_pressure_ideal_gas.push_v_sph_pressure_ideal_gas_kernels.push_v_sph_pressure_ideal_gas(dt: float, stage: int, args_markers: MarkerArguments, args_domain: DomainArguments, boxes: int[:, :], neighbours: int[:, :], holes: bool[:], periodic1: bool, periodic2: bool, periodic3: bool, kernel_type: int, h1: float, h2: float, h3: float, gravity: float[:], kappa: float)[source]#

Update each marker \(p\) according to

\[\frac{\mathbf v_p^{n+1} - \mathbf v_p^n}{\Delta t} = \mathbf g - \sum_{i=1}^N w_i \left( \kappa (\rho^{N,h}(\boldsymbol \eta_p))^{\gamma - 2} + \kappa (\rho^{N,h}(\boldsymbol \eta_i))^{\gamma - 2} \right) DF^{-\top}\nabla W_h(\boldsymbol \eta_p - \boldsymbol \eta_i) \,,\]

where \(\mathbf g\) is a constant acceleration, the second term corresponds to the pressure gradient in the polytropic closure (with constant \(\kappa\) and \(\gamma = 5/3\)), and \(DF^{-\top}\) denotes the inverse transpose Jacobian arising in the pull back of the gradient of the smoothing kernel \(W_h\) chosen from sph_smoothing_kernels.

The smoothed SPH density is given by

\[\rho^{N,h}(\boldsymbol \eta_p) = \sum_j w_j \, W_h(\boldsymbol \eta_p - \boldsymbol \eta_j)\,.\]

This kernel requires:

  • The density \(\rho^{N,h}(\boldsymbol \eta_p)\) to be pre-computed for each particle and stored at markers[first_free_idx, :])

  • The coefficient \(w_i (\rho^{N,h}(\boldsymbol \eta_i))^{\gamma - 2}\) to be pre-computed for each particle and stored at markers[first_free_idx + 2, :])

This is accomplished by the kernel sph_pressure_coeffs(), which needs to be passed as an init_kernel to the Pusher.

Parameters:
  • boxes (2d array) – Box array of the sorting boxes structure.

  • neighbours (2d array) – Array containing the 27 neighbouring boxes of each box.

  • holes (bool) – 1D array of length markers.shape[1]. True if markers[:, i] is a hole.

  • periodic1 (bool) – True if periodic in that dimension.

  • periodic2 (bool) – True if periodic in that dimension.

  • periodic3 (bool) – True if periodic in that dimension.

  • kernel_type (int) – Number of the smoothing kernel.

  • h1 (float) – Kernel width in respective dimension.

  • h2 (float) – Kernel width in respective dimension.

  • h3 (float) – Kernel width in respective dimension.

  • gravity (xp.ndarray) – Constant gravitational force as 3-vector.

  • kappa (float) – Polytropic coefficient in the ideal gas closure.

struphy.pic.pushing.kernels.push_v_viscosity.push_v_viscosity_kernels.push_v_viscosity(dt: float, stage: int, args_markers: MarkerArguments, args_domain: DomainArguments, boxes: int[:, :], neighbours: int[:, :], holes: bool[:], periodic1: bool, periodic2: bool, periodic3: bool, kernel_type: int, h1: float, h2: float, h3: float)[source]#

Update each marker \(p\) according to

\[\frac{v_{p,j}^{n+1} - v_{p,j}^n}{\Delta t} = \frac{1}{\sqrt g(\boldsymbol \eta_p)} \sum_{i=1}^N \frac{w_i \, \sqrt g(\boldsymbol \eta_i) \, \sigma_{jm}(\boldsymbol \eta_i) \, (DF^{-1})_{km}(\boldsymbol \eta_i)}{\rho^{N,h}(\boldsymbol \eta_i)} \, (\nabla W_h)_k(\boldsymbol \eta_p - \boldsymbol \eta_i)\,,\]

where \(\sigma_{jm} = \mu \left[(\partial_{x_m} v_j^{N,h} + \partial_{x_j} v_m^{N,h}) - \tfrac{2}{3}\delta_{jm}\partial_{x_l} v_l^{N,h}\right]\) is the (Cartesian) deviatoric strain rate and \(\sqrt g = \det DF\). This is the SPH discretization of the Cartesian divergence \(\nabla_x \cdot \sigma\) written in logical coordinates (Piola form), \((\nabla_x \cdot \sigma)_j = \frac{1}{\sqrt g} \partial_{\eta_k} \bigl(\sqrt g \, (DF^{-1})_{km} \sigma_{jm}\bigr)\), with the gradient of the smoothing kernel \(W_h\) chosen from sph_smoothing_kernels.

This kernel requires the 9 coefficients

  • \(- w_i \, \sqrt g(\boldsymbol \eta_i) \, \sigma_{jm}(\boldsymbol \eta_i) \, (DF^{-1})_{km}(\boldsymbol \eta_i) / \rho^{N,h}(\boldsymbol \eta_i)\) to be pre-computed for each particle and stored at markers[first_free_idx + 3*(j+1) + k, :] for \(j, k = 0, 1, 2\)

This is accomplished by the kernel sph_viscosity_tensor(), which itself requires the mean velocity coefficients \(w_i v_{k,i} / \rho^{N,h}(\boldsymbol \eta_i)\) to be stored at markers[first_free_idx:first_free_idx + 3, :] via sph_mean_velocity_coeffs(). Both kernels must be passed as init_kernel entries to the Pusher.

Parameters:
  • boxes (2d array) – Box array of the sorting boxes structure.

  • neighbours (2d array) – Array containing the 27 neighbouring boxes of each box.

  • holes (bool) – 1D array of length markers.shape[1]. True if markers[:, i] is a hole.

  • periodic1 (bool) – True if periodic in that dimension.

  • periodic2 (bool) – True if periodic in that dimension.

  • periodic3 (bool) – True if periodic in that dimension.

  • kernel_type (int) – Number of the smoothing kernel.

  • h1 (float) – Kernel width in respective dimension.

  • h2 (float) – Kernel width in respective dimension.

  • h3 (float) – Kernel width in respective dimension.

Coefficient kernels#

struphy.pic.pushing.kernels.sph_pressure_coeffs.sph_pressure_coeffs_kernels.sph_pressure_coeffs(alpha: float[:], output_indices: int[:], args_markers: MarkerArguments, args_domain: DomainArguments, boxes: int[:, :], neighbours: int[:, :], holes: bool[:], periodic1: bool, periodic2: bool, periodic3: bool, kernel_type: int, h1: float, h2: float, h3: float)[source]#

For each particle, evaluate

  • the density \(\rho^{N,h}(\boldsymbol \eta_i)\) and store it at markers[output_indices[0], :])

  • the coefficient \(w_i/\rho^{N,h}(\boldsymbol \eta_i)\) and store it at markers[output_indices[1], :])

  • the coefficient \(w_i (\rho^{N,h}(\boldsymbol \eta_i))^{\gamma - 2}\) and store it at markers[output_indices[2], :])

where the smoothed SPH density is given by

\[\rho^{N,h}(\boldsymbol \eta_i) = \sum_j w_j \, W_h(\boldsymbol \eta_i - \boldsymbol \eta_j)\,.\]
struphy.pic.pushing.kernels.sph_isotherm_kappa.sph_isotherm_kappa_kernels.sph_isotherm_kappa(alpha: float[:], output_indices: int[:], args_markers: MarkerArguments, args_domain: DomainArguments)[source]#

Store a constant isothermal coefficient of one at the requested column.

struphy.pic.pushing.kernels.sph_mean_velocity_coeffs.sph_mean_velocity_coeffs_kernels.sph_mean_velocity_coeffs(alpha: float[:], output_indices: int[:], args_markers: MarkerArguments, args_domain: DomainArguments, boxes: int[:, :], neighbours: int[:, :], holes: bool[:], periodic1: bool, periodic2: bool, periodic3: bool, kernel_type: int, h1: float, h2: float, h3: float)[source]#

For each particle, evaluate the smoothed SPH density \(\rho^{N,h}(\boldsymbol \eta_i)\) and store the coefficient

  • \(w_i v_{k,i} / \rho^{N,h}(\boldsymbol \eta_i)\) at markers[output_indices[k], :] for \(k = 0, 1, 2\)

where the smoothed SPH density is given by

\[\rho^{N,h}(\boldsymbol \eta_i) = \sum_j w_j \, W_h(\boldsymbol \eta_i - \boldsymbol \eta_j)\,.\]

These coefficients serve as kernel weights so that one can evaluate the SPH mean velocity field

\[v_k^{N,h}(\boldsymbol \eta_i) = \sum_j \frac{w_j \, v_{k,j}}{\rho^{N,h}(\boldsymbol \eta_j)} \, W_h(\boldsymbol \eta_i - \boldsymbol \eta_j)\,.\]
struphy.pic.pushing.kernels.sph_viscosity_tensor.sph_viscosity_tensor_kernels.sph_viscosity_tensor(alpha: float[:], output_indices: int[:], args_markers: MarkerArguments, args_domain: DomainArguments, boxes: int[:, :], neighbours: int[:, :], holes: bool[:], periodic1: bool, periodic2: bool, periodic3: bool, kernel_type: int, h1: float, h2: float, h3: float, mu: float)[source]#

For each particle, evaluate the smoothed SPH density \(\rho^{N,h}(\boldsymbol \eta_i)\) and the deviatoric strain rate, and store the 9 coefficients

  • \(- w_i \, \sqrt g(\boldsymbol \eta_i) \, \sigma_{jm}(\boldsymbol \eta_i) \, (DF^{-1})_{km}(\boldsymbol \eta_i) / \rho^{N,h}(\boldsymbol \eta_i)\) at markers[output_indices[3*j + k], :] for \(j, k = 0, 1, 2\)

where \(\sqrt g = \det DF\), the smoothed SPH density is given by

\[\rho^{N,h}(\boldsymbol \eta_i) = \sum_l w_l \, W_h(\boldsymbol \eta_i - \boldsymbol \eta_l)\,,\]

and the deviatoric strain rate is the traceless symmetric part of the Cartesian mean velocity gradient,

\[\sigma_{jm}(\boldsymbol \eta_i) = \mu\bigl[ \partial_{x_m} v_j^{N,h}(\boldsymbol \eta_i) + \partial_{x_j} v_m^{N,h}(\boldsymbol \eta_i) - \tfrac{2}{3}\delta_{jm} \, \partial_{x_l} v_l^{N,h}(\boldsymbol \eta_i)\bigr]\,, \qquad \partial_{x_m} v_j^{N,h} = \sum_k \partial_{\eta_k} v_j^{N,h} \, (DF^{-1})_{km}\,.\]

The factor \(\sqrt g \, DF^{-1}\) puts the tensor in divergence (Piola) form, \((\nabla_x \cdot \sigma)_j = \frac{1}{\sqrt g} \partial_{\eta_k} \bigl(\sqrt g \, (DF^{-1})_{km} \sigma_{jm}\bigr)\), such that these coefficients serve as kernel weights to evaluate the viscous force

\[(-\nabla \cdot \Pi_{\textrm{vis}})^{N,h}_j(\boldsymbol \eta_i) = -\frac{1}{\sqrt g(\boldsymbol \eta_i)} \sum_l \frac{ w_l \, \sqrt g(\boldsymbol \eta_l) \, \sigma_{jm}(\boldsymbol \eta_l) \, (DF^{-1})_{km}(\boldsymbol \eta_l)}{\rho^{N,h}(\boldsymbol \eta_l)} \, (\nabla W_h)_k(\boldsymbol \eta_i - \boldsymbol \eta_l)\,.\]

This kernel requires the coefficients of the mean velocity \(v_k^{N,h}\) for each particle to be pre-evaluated and stored at markers[first_free_idx:first_free_idx + 3, :], which can be achieved by the kernel sph_mean_velocity_coeffs().

Evaluation kernels#

struphy.pic.sph_eval_kernels.distance(x: float, y: float, periodic: bool) → float[source]#

Return the signed one-dimensional distance x - y, adjusted for periodicity on [0, 1].

Parameters:
  • x (float) – Two coordinates on the domain.

  • y (float) – Two coordinates on the domain.

  • periodic (bool) – If True, the result is folded into \((-\tfrac{1}{2}, \tfrac{1}{2}]\) so that the shortest path across the periodic boundary is returned.

Returns:

Signed distance x - y, adjusted for periodicity.

Return type:

float

struphy.pic.sph_eval_kernels.naive_evaluation_kernel(args_markers: MarkerArguments, eta1: float, eta2: float, eta3: float, holes: bool[:], periodic1: bool, periodic2: bool, periodic3: bool, index: int, kernel_type: int, h1: float, h2: float, h3: float) → float[source]#

Perform a single-point SPH evaluation of a function \(\rho: [0, 1]^3 \to \mathbb R\) in the following sense:

\[\rho(\boldsymbol \eta_i) = \sum_{j=0}^{N-1} \rho_j\, W_h(\boldsymbol \eta_i - \boldsymbol \eta_j)\,.\]

The coefficients \(\rho_j\) must be available in the marker array, stored at some index self.markers[index, j]. In case that derivative=k where k is not zero, the k-th component of the gradient of \(\rho\) is computed:

\[\textrm{derivative}=k:\qquad [\nabla \rho(\boldsymbol \eta_i)]_k = \sum_{j=0}^{N-1} \rho_j \frac{\partial W_h}{\partial \eta_k}(\boldsymbol \eta_i - \boldsymbol \eta_j)\,.\]

The possible choices for \(W_h\) are listed in Smoothing kernels and in ker_dct().

ATTENTION: The sum is done over all particles in the markers array (ignoring holes and ghost particles), no neighbour search is performed. Hence, the cost of this evaluation is \(\mathcal{O}(N)\) in the number of particles, and it should only be used for testing and verification purposes. Boundaries are always treated as periodic (mirror images held by ghost particles are not included).

Parameters:
  • args_markers (MarkerArguments) – Container holding the markers array and the total number of particles Np.

  • eta1 (float) – Evaluation point in logical space.

  • eta2 (float) – Evaluation point in logical space.

  • eta3 (float) – Evaluation point in logical space.

  • holes (bool[:]) – 1D array of length markers.shape[1]. True if particle i is a hole (inactive).

  • periodic1 (bool) – True if the domain is periodic in that dimension.

  • periodic2 (bool) – True if the domain is periodic in that dimension.

  • periodic3 (bool) – True if the domain is periodic in that dimension.

  • index (int) – Column index in the markers array of the coefficient \(\beta_k\) multiplying the kernel.

  • kernel_type (int) – Integer identifier of the smoothing kernel. See Smoothing kernels.

  • h1 (float) – Kernel width in the respective dimension.

  • h2 (float) – Kernel width in the respective dimension.

  • h3 (float) – Kernel width in the respective dimension.

Returns:

SPH estimate of \(b\) at the evaluation point.

Return type:

float

struphy.pic.sph_eval_kernels.box_based_kernel(args_markers: MarkerArguments, eta1: float, eta2: float, eta3: float, loc_box: int, boxes: int[:, :], neighbours: int[:, :], holes: bool[:], periodic1: bool, periodic2: bool, periodic3: bool, index: int, kernel_type: int, h1: float, h2: float, h3: float) → float[source]#

Perform a single-point SPH evaluation of a function \(\rho: [0, 1]^3 \to \mathbb R\) in the following sense:

\[\rho(\boldsymbol \eta_i) = \sum_{j=0}^{N-1} \rho_j\, W_h(\boldsymbol \eta_i - \boldsymbol \eta_j)\,.\]

The coefficients \(\rho_j\) must be available in the marker array, stored at some index self.markers[index, j]. In case that derivative=k where k is not zero, the k-th component of the gradient of \(\rho\) is computed:

\[\textrm{derivative}=k:\qquad [\nabla \rho(\boldsymbol \eta_i)]_k = \sum_{j=0}^{N-1} \rho_j \frac{\partial W_h}{\partial \eta_k}(\boldsymbol \eta_i - \boldsymbol \eta_j)\,.\]

The possible choices for \(W_h\) are listed in Smoothing kernels and in ker_dct().

The sum is restricted to the 27 neighbouring boxes of the box containing \(\boldsymbol\eta_i\), making the cost \(\mathcal{O}(1)\) in the number of particles when the kernel support is proportional to the box size.

Parameters:
  • eta1 (float) – Evaluation point in logical space.

  • eta2 (float) – Evaluation point in logical space.

  • eta3 (float) – Evaluation point in logical space.

  • loc_box (int) – Box of the evaluation point.

  • boxes (2d array) – Box array of the sorting boxes structure.

  • neighbours (2d array) – Array containing the 27 neighbouring boxes of each box.

  • markers (array[float]) – Markers array.

  • Np (int) – Total number of particles.

  • holes (bool) – 1D array of length markers.shape[1]. True if markers[:, i] is a hole.

  • periodic1 (bool) – True if periodic in that dimension.

  • periodic2 (bool) – True if periodic in that dimension.

  • periodic3 (bool) – True if periodic in that dimension.

  • index (int) – Column index in markers array where the value multiplying the kernel in the evaluation is stored.

  • kernel_type (int) – Number of the smoothing kernel.

  • h1 (float) – Kernel width in respective dimension.

  • h2 (float) – Kernel width in respective dimension.

  • h3 (float) – Kernel width in respective dimension.

Smoothing kernels#

struphy.pic.sph_smoothing_kernels.trigonometric_uni(x: float, h: float) → float[source]#

Uni-variate kernel S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_trigonometric_uni(x: float, h: float) → float[source]#

Derivative of S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.gaussian_uni(x: float, h: float) → float[source]#

Uni-variate S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_gaussian_uni(x: float, h: float) → float[source]#

Derivative of S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.linear_uni(x: float, h: float) → float[source]#

Uni-variate S(x, h) = (1 - x)/h if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_linear_uni(x: float, h: float) → float[source]#

Derivative of S(x, h) = (1 - x)/h if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.trigonometric_1d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1d kernel S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_trigonometric_1d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Derivative of S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.gaussian_1d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1d kernel S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_gaussian_1d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Derivative of S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.linear_1d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1d kernel S(x, h) = (1 - x)/h if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_linear_1d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Derivative of S(x, h) = (1 - x)/h if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.trigonometric_2d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_trigonometric_2d_1(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_trigonometric_2d_2(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

2nd component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.gaussian_2d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Tensor product of kernels S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_gaussian_2d_1(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of Tensor product of kernels S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_gaussian_2d_2(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

2nd component of gradient of Tensor product of kernels S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.linear_2d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_linear_2d_1(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_linear_2d_2(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

2nd component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.trigonometric_3d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_trigonometric_3d_1(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_trigonometric_3d_2(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

2nd component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_trigonometric_3d_3(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

3rd component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.gaussian_3d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Tensor product of kernels S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_gaussian_3d_1(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of Tensor product of kernels S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_gaussian_3d_2(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

2nd component of gradient of Tensor product of kernels S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_gaussian_3d_3(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

3rd component of gradient of Tensor product of kernels S(x, h) = 1/(sqrt(pi)*h/3) * exp(-(x**2/(h/3)**2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.linear_isotropic_3d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Smoothing kernel S(r,h) = C(h)F(r/h) with F(x) = 1-x if x<1, 0 else, and C(h)=3/(pi*h^3) is a normalization coefficient so the the kernel has unit integral.

struphy.pic.sph_smoothing_kernels.grad_linear_isotropic_3d_1(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of S(r,h) = C(h)F(r/h) with F(x) = 1-x if x<1, 0 else, and C(h)=3/(pi*h^3) is a normalization coefficient so the the kernel has unit integral.

struphy.pic.sph_smoothing_kernels.grad_linear_isotropic_3d_2(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of S(r,h) = C(h)F(r/h) with F(x) = 1-x if x<1, 0 else, and C(h)=3/(pi*h^3) is a normalization coefficient so the the kernel has unit integral.

struphy.pic.sph_smoothing_kernels.grad_linear_isotropic_3d_3(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of S(r,h) = C(h)F(r/h) with F(x) = 1-x if x<1, 0 else, and C(h)=3/(pi*h^3) is a normalization coefficient so the the kernel has unit integral.

struphy.pic.sph_smoothing_kernels.linear_3d(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_linear_3d_1(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

1st component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_linear_3d_2(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

2nd component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.grad_linear_3d_3(r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

3rd component of gradient of Tensor product of kernels S(x, h) = pi/4/h * cos(x*pi/2) if |x|<1, 0 else.

struphy.pic.sph_smoothing_kernels.smoothing_kernel(kernel_type: int, r1: float, r2: float, r3: float, h1: float, h2: float, h3: float) → float[source]#

Each smoothing kernel is normalized to 1.

The kernel type numbers must have 3 digits, where the last digit is reserved for the gradient; if a kernel has the type number n, the i-th components of its gradient has the number n + i. This means we have space for 99 kernels (and its gradient components) in principle.

  • 1d kernels <= 330

  • 2d kernels <= 660

  • 3d kernels >= 670

If you add a kernel, make sure it is also added to ker_dct().