PySPH Diffusion - AlexanderPuckhaber/FluidSimulationThesis GitHub Wiki
Simulating Diffusion in PySPH
The PySPH software makes it easy to add new variables to particles. To add a solute to a solution of SPH particles, all the researcher has to do is add a variable for the solute concentration for all the particles.
Diffusion Equations
Chemicals such as table salt (NaCL) tend to dissolve in water. However, they take time to dissolve, spreading outward from high concentration to low. Krištof, P., Beneš, B., Křivánek, J., & Št'ava, O. (2009) cite a paper by Mohangan (2005) and state the equation in equation 19. Essentially, the diffusion gradient is multiplied by the kernel of particle interaction and the diffusion speed -- for all neighbor particles.
It was tested in the hydrostatic_tank_materials test program, which I modified from hydrostatic_tank. In it, there is a tank filled with liquid. The particle in the bottom center starts with a material concentration of 50.0, and all the other particles are initialized with 5.0
Here is what the first draft looked like:
material_amount:
material_velocity:

Here is what the second draft looks like. In this version, the diffusion_velocity is multiplied by WIJ, which is the kernel interaction value between the destination and source particles.
material_amount:
material_velocity:

Conclusion:
WIJ (interaction amount) definitely gets to values over 1.00, because it increases the material velocity much more than without it. As a result, the solute spreads more quickly.
The approach that multiplies the material_velocity by WIJ is definitely better because it effectively makes the diffusion speed smoother. Looking at the first frame of material_velocity for the version without WIJ, the material velocity is constant in the nearest neighbors to the high concentration particle. In reality, the closest of the nearest neighbors should have more material flowing, so the second approach is better.
Additionally, there seems to be some noise in the form of shockwave formations in the material_velocity for the first version. The nearest neighbors list has a strict cutoff distance, so it could be that there are actually shockwaves in the fluid that are slightly changing the distances between particles and messing with the diffusion. The second approach doesn't have this problem because the material_velocity is blended with distance, which falls of to zero for the particles on the edge of the radius.