I am trying to write some code for a fluid simulation. I have read about Smoothed Particle Hydrodynamics (SPH) and my question is related to the properties of the smoothing kernel.

  1. How do I set the support $h$ for a kernel?

I found the following kernel function used in SPH

$$\frac{315}{64 \pi h^9}(h^2 - r^2)^3 dr$$

Since one of the properties of the kernel used is that it has to be normalized, i.e. $$\int_{-h}^{h} \frac{315}{64 \pi h^9}(h^2 - r^2)^3 dr = 1$$

  1. I think that to set the correct value for $h$ is to compute that integral, is this correct?

I ask this because with random numbers in my code I found that it just doesn't work and I start to believe it is my problem is related to the parameters of the simulation, like the support of the kernel.


The parameter $h$ is the maximum distance that two smoothed particles, $a$ and $b$, can be before the distance between them is negligible for SPH purposes. If the distance, $\vert r_a-r_b\vert>h$ then the weight is zero.

For any kernel, the integral over the particular region, e.g. $r\in(-h,\,h)$, is necessarily 1. Since $h$ is an unknown parameter, then you must solve the integral for $h$. In your case, I get $h=3/\sqrt{2\pi}\simeq1.2$.

  • $\begingroup$ So it was indeed not a parameter that I can play with? I mean, if they give the kernel I should've compute the value of $h$ ? $\endgroup$ – BRabbit27 Oct 4 '14 at 22:05
  • $\begingroup$ @BRabbit27: The value of $h$ depends on the particular kernel you have, but once the kernel is chosen, $h$ becomes effectively a parameter. $\endgroup$ – Kyle Kanos Oct 4 '14 at 22:13
  • $\begingroup$ But, for example, in the kernel given, is not that I can give any number to $h$ instead I have to compute it's value so that the integral of the kernel in the interval $[-h,h]$ equals 1, right? $\endgroup$ – BRabbit27 Oct 4 '14 at 22:25
  • $\begingroup$ @BRabbit27: Yes, you have to determine what $h$ equals such that the integral is one. Once that's computed, it's constant for the whole simulation that uses that kernel. $\endgroup$ – Kyle Kanos Oct 4 '14 at 23:03

This is a fairly old question, but given the current answer, I feel a need to add my own here as well for future reference.

$h$ is indeed an adjustable parameter. The problem with your integral is that it assumes a 1 dimensional setting while your smoothing kernel assumes a 3 dimensional setting. assuming a spherical coordinate system, the correct integral would be $$\frac{315}{64\pi h^9} \int_0^{2\pi}\int_0^\pi\int_0^hr^2(h^2 - r^2)^3 sin(\theta)dr d\theta d\phi = 1 $$ This triple integral integrates over a 3 dimensional space with length $h$, where the smoothing length $h$ is of arbitrary length and always normalizes to 1. This is pretty much how the normalization constant, $\frac{315}{64\pi h^9}$, for this particular kernel is computed. This does however mean that this constant is also not applicable if you're trying to do a 2D SPH simulation. If I've done my math right, for a 2D simulation, you should be using the normalization constant $\frac{4}{\pi h^8}$ instead

This said, SPH can be very sensitive to parameter settings, so while the kernel is normalized for any length $h$, not every length $h$ will produce stable simulations, at least not for every $m$ and $\rho_0$ where $m$ is the mass of a single particle and $\rho_0$ is the rest density.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.