The SPH (Smoothed particle hydrodynamics) model uses the "interaction" between nearest particles to calculate the pressure. Then the presure gradient is used to get the acceleration.
I have noticed that when a fluid particle falls on the free surface, it bounces back up, also causing the free surface particles to almost form a void. Why?
im not the one that did it but I have done a lot of experimenting with sph (check out my channel, the water oil one is the most recent ,its at the bottom) but before anything get farmialliar with verlet physics if you are not already. I make a constraint between all particles touching eachother (within a certain radius). now the springyness of the constraint depends on the distance and what you want your fluid to look like. Then simply solve all of the constraints. :)
Thanks for the help :] I posted that several months ago & already found this out. It's still unstable, but I know the problem & I'm just not smart enough right now to find the single magical line of code that would solve my problem! :)
to solve my instabilities/compression, I just solve the constraints 3-4 times a frame... it took me forever to figure out but it only took 3 minutes to code it in
My problem is figuring out how to move the particle to a certain distance away from a particle. I know how to figure out how much it has to move, but I can't figure out how to apply it. It's probably really simple, but I really have no experience in this kind of math.
to answer your question luke that got removed for some reason? idk why
no I was just saying how to do the part that said "physics stuff here" and make sure you have a variable to make sure you only check collisions once between all points like so
for i:point = eachin pointlist i.done = true for j:point = eachin pointlist
if i.done = false then 'do physics stuff endif next
If you use a double loop the program works very slow (because is n^2 order), will be better to do list with the particles in collision with each one at every time.
thats why I use fixed grid and other stuff but I figured that might complicate rather than simplify things for luketheduke since he was just asking how to make the water react right
lol, I know that there are much more efficient ways of doing it, but I just wanted to do the easiest way for me. Thanks for all of the help. And natethegreatBlitzMax, I deleted the comment. I think I was going to ask another question or something, but I had solved it myself.
Hi! Nice demo!
Do you use particle-particle collisions or is it a collision-free model (use pressure force)? Thanks!
NoctumDeVir 1 year ago
Thanks for comment.
The SPH (Smoothed particle hydrodynamics) model uses the "interaction" between nearest particles to calculate the pressure. Then the presure gradient is used to get the acceleration.
jahkr 1 year ago
I have noticed that when a fluid particle falls on the free surface, it bounces back up, also causing the free surface particles to almost form a void. Why?
maettino 3 years ago
Could you explain how you did this? I tried to make something like this, but the particles clustered into a ball.
luketheduke0 3 years ago
im not the one that did it but I have done a lot of experimenting with sph (check out my channel, the water oil one is the most recent ,its at the bottom) but before anything get farmialliar with verlet physics if you are not already. I make a constraint between all particles touching eachother (within a certain radius). now the springyness of the constraint depends on the distance and what you want your fluid to look like. Then simply solve all of the constraints. :)
natethegreatBlitzMax 2 years ago
Thanks for the help :] I posted that several months ago & already found this out. It's still unstable, but I know the problem & I'm just not smart enough right now to find the single magical line of code that would solve my problem! :)
luketheduke0 2 years ago
to solve my instabilities/compression, I just solve the constraints 3-4 times a frame... it took me forever to figure out but it only took 3 minutes to code it in
natethegreatBlitzMax 2 years ago
My problem is figuring out how to move the particle to a certain distance away from a particle. I know how to figure out how much it has to move, but I can't figure out how to apply it. It's probably really simple, but I really have no experience in this kind of math.
luketheduke0 2 years ago
oh yeah. it took a bit of experimenting for me to figure this out.
in my engine the user gives the following parameters:
outer radius
inner radius
inside springyness
outside springyness
even the best of engines is unstable if these values are not experimented with
the outer radius is how far the particle has to be from another particle before they interact
the inner radius is the ideal distance between two particles
continued...
natethegreatBlitzMax 2 years ago
now first I calculate the distance
dx = x1-x2
dy = y1-y2
dist = do the distance formula
then I divide the dx and dy by the distance to give me a vector one unit long
dx = dx / dist
dy = dy / dist
then multiply that by the length you want it to be like this to account for elasticity:
continued
natethegreatBlitzMax 2 years ago
dx = dx * (length*elasticity + dist*(1-elasticity)/2
same for dy
and you have a solved constraint/force between the particles
natethegreatBlitzMax 2 years ago
Comment removed
luketheduke0 2 years ago
to answer your question luke that got removed for some reason? idk why
no I was just saying how to do the part that said "physics stuff here" and make sure you have a variable to make sure you only check collisions once between all points like so
for i:point = eachin pointlist i.done = true for j:point = eachin pointlist
if i.done = false then 'do physics stuff endif next
next
i suspect this is your problem
natethegreatBlitzMax 2 years ago
also you might want to put your types into arrays instead of lists... its generally much faster
natethegreatBlitzMax 2 years ago
If you use a double loop the program works very slow (because is n^2 order), will be better to do list with the particles in collision with each one at every time.
jahkr 2 years ago
thats why I use fixed grid and other stuff but I figured that might complicate rather than simplify things for luketheduke since he was just asking how to make the water react right
natethegreatBlitzMax 2 years ago
lol, I know that there are much more efficient ways of doing it, but I just wanted to do the easiest way for me. Thanks for all of the help. And natethegreatBlitzMax, I deleted the comment. I think I was going to ask another question or something, but I had solved it myself.
luketheduke0 2 years ago
cool, well im glad I helped
natethegreatBlitzMax 2 years ago
:] It worked! Thank you! It's extremely inefficient, but it works!
luketheduke0 2 years ago
no problem... and you must use a fixed grid optimization if you want maximum efficiency :)
natethegreatBlitzMax 2 years ago