# How to choose $h$ in SPH?

I have a 2D implementation of smoothed particle hydrodynamics up and running, however when I tried to move it to 3D, using the appropriate 3D kernels, particles always tend to go apart from each other. Since my 2D implementation works fine and the only thing I've changed are the kernels, the only parameter that affect them is the length of the support.

Is there a good way to calculate a good value for $h$ rather than just randomly checking?

I'm not an expert in SPH and so others should chime in as well, but here's one consideration: $h$ needs to be chosen so that within a neighborhood of radius $h$ around a point, there are other points. So $h$ is related to the average distance between points. The thing that's different between 2d and 3d is that with the same number of points, their average distance is much larger in 3d. For example, if you scatter $10^6$ points in a 2d domain that is the unit square, then on average they are 0.001 apart ($10^6$ particles in 2d form, if placed purposely, a $1000\times 1000$ lattice) where in 3d they are 0.01, i.e., 10 times farther apart (because in 3d, they form a $100\times 100\times 100$ lattice). You will have to adjust your $h$ correspondingly.

• So in order to get more or less the same results in 3D the size of $h$ should be bigger? At least in the example you have, to have the same amount of neighboring particles $h$ should be at least 10 bigger, am I right? – BRabbit27 Dec 2 '14 at 13:52
• Yes. Alternatively, in order to get the same accuracy, you need to choose $O(h^{-d})$ particles where $d$ is the dimension of your domain. – Wolfgang Bangerth Dec 3 '14 at 1:20

Two things. Ensure the summation of kernel values which is $\sum (m/\rho) W(r,h)$ is amounting to 1.0 to a desired accuracy. Check if you are using correct value for mass of each particle, if computed from reference density. If you use the same value of h as in 2d, it is supposed to give a stable simulation.

The most important is that the kernels have to be normalised within the influence radius $\Delta$:

$\int_{-\Delta}^\Delta W(r-r',h)dr'=1$.

The initial interparticle distance in the grid should be calculated as

$dx=\sqrt{\frac{\Delta^2\pi}{n}}$

in 2D or

$dx=\sqrt[3]{\frac{4\Delta^3\pi}{3n}}$

in 3D. $n$ is the estimated number of neighbours: $n\approx20$ in 2D and $n\approx 50$ in 3D.

If these are satisfied and we assume that the parameters are physically correct, both 2D and 3D simulations should be stable using the same parameters.