SPH fluid in game

Started by
8 comments, last by mrr 14 years ago
Hello I need 3D SPH fluid simulation in my game, so I have started to research SPH, also Ive started to write a simple summary of how to do it. Id post it here if I new how. Each particle should have the same mass, so I will store position,velocity field, particle density for each particle. What I have problems with are the boundaries. (To make it simple I will only use non-moving boundaries) I understand so far that adding fixed boundary particles are the way to go? But what is the simplest way to make boundaries repulsive ? I have seen implementations with added repulsive forces.. are there easier ways?
Advertisement
Ok I might I have figured out a way, I post it if anyone else is doing SPH.

fi(ri) = A*summ(Nj*W(ri-rj,h))

Thus adding a force in the average direction of the surface normals at each boundary particle in range h and scale by distance using the kernel..

ri position vector
rj position vector

fi force on particle i

A constant
Nj Normal at boundary particle
W Kernel

I have no idea if this will work, I read a paper and it also included velocity why is that needed?

(For no-slip,free-slip force I understand velocity is needed.)

Now Im not sure this force is needed at all!

Supposedly having boundary particles with a density will create a pressure keeping other particles away..why do some make an extra force?
Still not very clear on the boundary force..
Ive tried like crazy to find "Smooth Particle Hydrodynamics for Dummies" but to no use..

Ive read 10 papers now getting crazzzyyy!!!....

To spare anyone else the same torment, I document here the two ways I found one simple method and one other I can understand, to get a boundary with no-slip.

Method 1) If particle goes outside boundary detect it does and put it back with reverse velocity
This method is easiest but supposed to be very bad.

Method 2) Boundary, Ghost particles

a) Set fixed boundary particles on the boundary with 0 velocity, and initial density at start.

b) add ghost particles (mirrored in the tangent of the boundary) for every real particle within range h of the boundary.

c) Set the velocity of these ghost particles to the opposite of the real particles, but with same density.

d) After this the SPH process of finding density, viscosity etc should include the boundary particles and the ghost ones.

e) The ghost ones must be replaced every step, the boundary ones can remain but always 0 velocity.

I think a test that it works would be to update the velocity of the boundary particles, and it should remain close to 0..







Hi,

I have not experimented met particle boundaries yet (i.e. boundaries made from particles), but I did work with the first method you describe: when a particle hits a boundary, reflect its velocity along the normal of that boundary.

The big disadvantage of this method is that your fluid simulation will tend to get unstable when boundary collision are occuring. Or you will get stuttering particles near boundaries. A way to counter this, is to scale the velocity a bit (i.e. lower it's value) and instead of reflecting it, making it parallel to the boundary. This means that particles hitting a boundary will now slide off of it.

Yet another way to handle boundaries, is to calculate a repulsion force that is dependent on the distance the particle has crossed the boundary. So when a particle crosses a boundary, you would do the following:

1. put the particles position to where it intersected the boundary
2. Add a force to the particle which is parallel to the boundary normal and whose value is determined by the distance the particle has overstepped the boundary.

Note that it is better if you also include some randomness when scaling this force, this will have a better effect on stability.

Hope this helps, boundary collissions are very hard to handle when working with SPH :)
Yes it helps.
I am beginning to get my head around this.

If I use a repulsion force like you describe, will it handle no-slip condition to?
I'm not sure what you mean by no-slip condition. But when I tried the method repulsion force method it gave better results for stability than when I let the particles slide of the boundary.
There seems to be two things they do in most SPH sims at the boundaries.

One is the repulsive force.

The other is a force that negates the tangential force
so that the motion parallel to a boundary is reduced the closer you
get to the boundary that is called no-slip.

This can be ignored then it is called free-slip.


no-slip is closer to reality.
I hadn't heard of that boundary method, so I can't say anything about it. But it shouldn't be hard to combine both methods, since they are both forces. Not sure what this will give in terms of results, but it's worth a try :-)
It will make fluid go slow close to a surface..there is a resistance to the flow from the surface.

Also i think..
if you imagine a thin blade cutting through the water it will drag water along it's sides..even though the pressure force is small from the edge.

This topic is closed to new replies.

Advertisement