# Value of density when there are no or very few neighbours in SPH simulation

I am trying to implement SPH using the directions shown in this paper.

The density needs to be updated using the formula

$$\rho(\mathbf{x}_i)=\sum_j m_jW_\text{default}(\mathbf{x}_i-\mathbf{x}_j,h)$$

The smoothing kernel is $$W_\text{default}(\mathbf{r},h)=\frac{315}{64\pi h^9}\cases{(h^2-||\mathbf{r}||^2)^3,\quad 0\leq\mathbf{r}\leq h\\0,\quad\quad\quad\quad\quad ||\mathbf{r}||>h}$$

If there are no particles within the smoothing length($$h$$), won't the density of a particle become zero based on this formula?

## 3 Answers

Yes. You need to choose the radius $h$ large enough that for each particle, there is always a significant number of other particles within the first particle's radius.

• That would make the amount of particles I need for the simulation really high. How do I handle rogue particles in case I'm simulating the particles in a huge space? I'll have to check if the density is zero and cancel all calculations for that particle? – punitjajodia Jan 30 '15 at 12:59
• If you don't want to increase the number of particles, you have to choose $h$ large enough. – Wolfgang Bangerth Jan 31 '15 at 3:39

Actually, the density never becomes zero because of self-contribution (i=j). However, you need neighboring particles, unless the sampling of mass density is poor. The optimal number of neighbors is around 20 in 2D and 50 in 3D.

You can also check the discussion about the calculation of the desired smoothing length here.

Yes, density will become zero if there is no particle. That's why it is very important in SPH to have particles well distributed. Also must select smoothing length large enough, such that you will always end up with a minimum number of particles in the kernel and use numerical techniques to keep particles well distributed.