1

I'm currently writing an SPH Solver using CUDA on https://github.com/Mathiasb17/sph_opengl.

I have pretty good results and performances but in my mind they still seem pretty weird for some reason :

In some implementations, i saw that a particle does not contribute to its own internal forces (which would be 0 anyways due to the formulas), but it does contribute to its own density.

My simulations work "pretty fine" (i don't like "pretty fine", i want it perfect) and in my implementation a particle does not contribute to its own density.

Besides when i change the code so it does contribute to its own density, the resulting simulation becomes way too unstable (particles explode).

I asked this to a lecturer in physics based animation, he told me a particle should not contribute to its density, but did not give me specific details about this assertion.

Any idea of how it should be ?

Mathias B.
  • 343
  • 2
  • 12
  • Hello Mathias, I am trying to do my own SPH simulation and me and my Professor are stuck in, what it seems to be, a very simple matter. Would you help us? Question: When you calculate a force field, say velocity for instance, you plug the vector velocities (vx,vy,vz) or the total velocity ( sqrt(vx^2+vy^2+vz^2) ? We do not know what to plug in each equation and if we should separate each coordinate. If we separate the coordinates to calculate the force field, should we do the same for the kernel function? Thank you! – zeh Jan 14 '20 at 11:11
  • 1
    Hi zeh, a force field is always a vector field and you should always plug the vector in your calculation. You can check the implementation of my kernels here : https://github.com/Mathiasb17/Nereus though i haven't maintained it for a long while – Mathias B. Jan 14 '20 at 12:52
  • Hello Mathias, thanks for the answer. Should I plug the vector distance (x,y,z) also in the kernel function? What if this distance is negative? Wouldnt it be inside the kernel definition? What exactly is this r in these kernel functions when it comes to a 3D simulation? [Example of kernel and the r variable](https://imgur.com/u3uqz84) – zeh Jan 14 '20 at 13:18
  • 1
    Hi zeh, in the equations when a term appears in bold (**r**) for example, it is a vector component, else it is a scalar. Here **r** is the position of the particle in space, and by definition a distance cannot be negative :^). – Mathias B. Jan 16 '20 at 16:54
  • 1
    Besides, your kernel should be normalized, meaning W(**r**, h) equals W(**-r**, h) – Mathias B. Jan 16 '20 at 17:00

1 Answers1

1

As long as you calculate the density with the summation formula instead of the continuity equation, yes you need to do it with self-contribution.

Here is why:

SPH is an interpolation scheme, which allows you to interpolate a specific value in any position in space over a particle cloud. Any position means you are not restricted to evaluate it on a particle, but anywhere in space. If you do so, obviously you need to consider all particles within the influence radius. From this point of view, it is easy to see that interpolating a quantity at a particle's position does not influence its contribution.

For other quantities like forces, where the derivative of some quantity is approximated, you don't need to apply self-contribution (that would lead to the evaluation of 0/0).

To discover the source of the instability:

  • check if the kernel is normalised
  • are the stiffness of the liquid and the time step size compatible (for the weakly compressible case)?
curious_amateur
  • 220
  • 2
  • 8
  • Thank you for this clarification. I arrived pretty much at the same conclusion and after some debugging, it happens that i used a particle mass too important for the interaction radius of the simulation. This is working great now. Somehow i forgot about this post and also forgot to mark it as resolved. – Mathias B. Aug 31 '17 at 07:14