Gornhoth / Unity-Smoothed-Particle-Hydrodynamics

SPH in the Unity engine implemented in three different ways using MonoBehaviour, Entity-Component-System, and ComputeShader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUG: Particle managers set cell size of uniform hashgrid to 2x radius but should be 2x diameter of particle

jschatteiner opened this issue · comments

The hashgrid works on the assumption that each cell is twice as big as a particle's diameter so only 4 cells need to be considered in the neighbour search (see 'Fluid Engine Development' by Doyub Kim, year 2016, page 109). Currently, the three particle managers set the cell size to be twice as big as the particle radius instead of the particle diameter. However, the bug is not that trivial to solve because if fixed by just using the diameter times two the simulation becomes unstable.

"Fixed" now. The cell size of the hashgrid is now correct in all three methods (2 * particle diameter). The inevitable consequence is that the simulation can become unstable under certain conditions. For example, in the GPU solution when setting the number of particles to 100 000 the probability of the simulation exploding is very high. This is due to the fact that a grid cell can only contain a configured max amount of particles (500 in our case due to compute buffer limitations) and after the cell is fully filled the remaining particles that would be in the cell are not considered leading to particles clumping and activating again when space becomes available in a cell and therefore rapidly accellerating their neighbours. This is just a limitation of the hashgrid. To visualise this limitation, currently the GPU solution colors particles whose calculations are excluded from a simulation step due to exceeding a cell's max number of particles red.