POV-Ray : Newsgroups : povray.advanced-users : Simplified fluid dynamics Server Time
1 Nov 2024 11:17:31 EDT (-0400)
  Simplified fluid dynamics (Message 1 to 3 of 3)  
From: Kevin Loney
Subject: Simplified fluid dynamics
Date: 2 Dec 2002 23:05:55
Message: <3dec2da3@news.povray.org>
I'm trying to implement some really simplified fluid dynamics in my particle
system, and it's not working to well, my particles are accumulating
velocities that exceed light :-P

This is how I'm trying to do it

v1, v2 = velocities of particle 1 and 2
p1, p2 = locations of particle 1 and 2
dt = the time step

Dist = vlength(p1-p2);
v1 = v1 + Fluidity * (1-abs(vdot(v1, v2))) / (pow(Dist, 1/Fluidity)+1) * v1
* dt;

so essentially I'm taking the and trying to change the direction the
particle is moving based on how parrallel the velocity vectors are, to me
this seems like the most logical thing to do, but I might be wrong. thanks
for any help

--
Kevin
http://www.geocities.com/qsquared_1999/
#macro _(r)#if(r<12)#local i=asc(substr("oqshilacefg",r,1))-97;
disc{<mod(i,7)-3,div(i,7)-1,6>,z,.4pigment{rgb 10}}_(r+1)
#end#end _(1)//KL


Post a reply to this message

From: Christopher James Huff
Subject: Re: Simplified fluid dynamics
Date: 3 Dec 2002 20:21:05
Message: <chrishuff-87319E.20180303122002@netplex.aussie.org>
In article <3dec2da3@news.povray.org>, "Kevin Loney" <klo### [at] pt2mcom> 
wrote:

> I'm trying to implement some really simplified fluid dynamics in my particle
> system, and it's not working to well, my particles are accumulating
> velocities that exceed light :-P
> 
> This is how I'm trying to do it
> 
> v1, v2 = velocities of particle 1 and 2
> p1, p2 = locations of particle 1 and 2
> dt = the time step
> 
> Dist = vlength(p1-p2);
> v1 = v1 + Fluidity * (1-abs(vdot(v1, v2))) / (pow(Dist, 1/Fluidity)+1) * v1
> * dt;
> 
> so essentially I'm taking the and trying to change the direction the
> particle is moving based on how parrallel the velocity vectors are, to me
> this seems like the most logical thing to do, but I might be wrong. thanks
> for any help

You are trying to make a force on particles based on the speed of nearby 
particles? I did something like that in my particle system patch, I 
never did enough testing to figure out if it had much effect, but it 
didn't lead to "velocity explosions". What I did was use difference in 
the velocities of nearby particles with the particle velocity to compute 
a force (maybe weighted by distance)...a very different implementation 
from yours.

You take the absolute of the dot product and use it to weight the amount 
of speed added to the particle velocity, so even particles with opposite 
velocities will accelerate each other, and never affect each others 
directions. I think you meant "*v2*dt;". And you might try other 
distance weightings, a cosine falloff might work better than that 
exponential falloff. Otherwise, unlink the power from the Fluidity 
value. And vdot(v1, v2) is proportional to the sum of the lengths of v1 
and v2, you should normalize them to get the cosine of the angle.

nv1 = vnormalize(v1);
nv2 = vnormalize(v2);
v1 += Fluidity*(1 - abs(vdot(nv1, nv2)))/(pow(Dist, FalloffExp) + 
1)*v2*dt;

Actually, the whole idea of using the dot product seems wrong. The 
particles will have no effect on each other if their directions are at 
90 degrees to each other (if you normalize the velocity vectors). I 
think you woudl be better off using the relative velocities.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Ben Birdsey
Subject: Re: Simplified fluid dynamics
Date: 3 Dec 2002 20:29:45
Message: <3DED5ABB.5000703@mail.com>
Why don't you try this one:

 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

v1, v2 = velocities of particle 1 and 2
p1, p2 = locations of particle 1 and 2
dt = the time step

Dist = vlength(p1-p2);
v1 = v1 + Fluidity * (v2-v1) * exp(-Dist/Range) * dt;

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

this will cause all the particles to approach the same velocity 
exponentially within approximately 1/Fluidity time steps.  You could 
then use Range to control the effect of distance or the "skin depth" of 
the fluid.

Implementing viscosity like this might allow you to use a very gentle 
force to keep the particles together, like

v1 = v1 + ( Fluidity1 * (v2-v1) + Fluidity2 * (p2-p1)*(Dist-Size)  )* 
exp(-Dist/Range) * dt

In this case, Size is the average distance the particles will try to 
keep from their nearest neighbor.

Let me know if either of these ideas work.

- Ben


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.