Sign in to follow this  

introduction to fluid simulation?

This topic is 3445 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im interested in learning about fluid simulation. I have done a little bit of reading already, and I know about some of the different ways you can simulate fluid (eg navier-stokes, shallow-water, ect..). But, all the places I read about this stuff assumes the reader knows alot about fluid simulation already, and is an expert with solving complex differential equations and such. I dont exactly have any kind of degree in mathematics (yet), and havent taken a differential equations class. So, Im wondering if anybody knows of any online resources I can look at as very shallow introduction to this kind of stuff, that explains how it works, for example how to numerically solve some of the equations involved in fluid simulation? Actually, I think thats the main part im confused on; how exactly does one go about solving these equations? i know that they cannot be solved in closed form and must be evaluated numerically, but how is this done? Alot of the code I have looked at has to use some form of iteration, and they use terms like "advection", ect... but none of the papers i have looked at actually define what that means at a high level. Thanks, Chris

Share this post


Link to post
Share on other sites
Fluid dynamics is a very low-level subject if you want to go into any detail. We only covered it at fourth-year in my physics degree because the maths is quite tortuous, and it's pretty much impossible to get anywhere without some quite nasty-looking PDEs. Saying that, you could look out for a book called "Physical Fluid Dynamics" by Tritton, which is quite experimental i.e. explains some down-to-earth examples of real-life fluid flows without dwelling too much on the maths. Having said that, it's still not exatly entry-level I'm afraid, so depends how brave you're feeling!

Share this post


Link to post
Share on other sites
The name for what you're interested in is "Computational Fluid Dynamics" (maybe you already know this). As far as I know, there is no simple explanation without a lot of math background, and the reason for this is probably because even mathematicians don't fully understand it.

Im glossing over a lot of details here, but basically the idea is that if you use physical principles of liquids like conservation of mass, F=ma for infintessimal small volumes or liquid, and so on, then you get the Navier-stokes equations. The Navier-stokes are nonlinear PDE, and they are really really hard to solve.

They are so hard that if you make "substantial progress" towards a mathematical theory to fully understand them, then you can win 1 million dollars and be considered one of the greatest mathematicians of the century.

So basically what people do is take special cases. For example, if the water is shallow, or if the dimension is 2, or if the viscosity is zero, or if the fluid is incompressible, or if there are other properties of the liquid that restrict it, etc, then the Navier-stokes equations become simpler, but still very hard to solve. Then they do approximations such as chopping the space into discrete pieces, and at this point numerical solutions can be found, but the math is still at the graduate level.

I think you'd need the following math to be able to read papers on the subject and understand wtf they are talking about:
Multivariable Calculus
Linear Algebra
Differential Equations
Complex Analysis (just the basics)
Numerical Analysis
Partial Differential Equations

Share this post


Link to post
Share on other sites
To piggy back on what has been said, I know a guy that was hired by an oil company in his graduate program to develop mathematical equations for the flow of crude through their pipelines, with the purpose of optimizing flow which cuts costs. One *single equation* in the analysis was roughly four pages long. This is not trivial stuff.

Share this post


Link to post
Share on other sites
I took a class on the Navier-Stokes equation where we used it to create the Burgers-Rott Tornado Model. In my experience Maze Master has listed all of the subjects you need to be familiar with. I don't agree with only needing to know the basics of complex analysis though. As far as I know there is no way to ease yourself into fluid flow. Its going to hurt every step of the way. That said its pretty awesome stuff and I hope you stick with it.

Share this post


Link to post
Share on other sites
The Bridson/Müller-Fischer course notes immediately sprang to my mind too, but without a solid grasp of linear algebra and differential equations the average tyro stands very little chance of getting much out of them. IMHO, however, there's pretty much no way around this. If you want to do grown-up simulation, you have to use grown-up math. Intuitions on what real-world processes the math represent are all but nonexistent. Hell, much of the math involved in CFD was developed because it was needed for physics! Coderchris, if you feel like getting your feet wet (no pun intended), check out Stam's CFD stuff. Don't count on understanding more than half of it yet, though.

Share this post


Link to post
Share on other sites
A very simple introduction can be found here:
http://www.gamasutra.com/view/feature/1549/practical_fluid_dynamics_part_1.php

Share this post


Link to post
Share on other sites
Jos Stam has written a few relatively simple articles on this topic. You can find them all in PDF format here:

http://www.dgp.toronto.edu/~stam/

They include an article on how to make a real-time fluid simulation for games.

cheers,
Michael

Share this post


Link to post
Share on other sites
Thank you all for being so helpful

I guess the basic conclusion here is that I'm in for quite a ride :O

I've heard about the one million dollars for solving the equations, so I never really planed on trying to do that :P
I just want to understand how to simulate numerically (Which I guess is the only way it can actually be done at the time).

I have take all the undergrad calculus classes my university has to offer (including multi-var), and I'm not too shabby with it; Iv also got some linear algebra under my belt, but differential equations...they are still alien to me.

I guess the first place for me to start is learning about diffy-q's and how to solve them, how hard could it be?

Again thanks for all the nice references and info
-Chris

Share this post


Link to post
Share on other sites
So it was about books?( and not online resources? :D )

I really enjoyed reading Computation Methods for Fluid Dynamics by Joel H. Ferziger, some time ago for a Project( University ).Easy read, really. But it lacked some more specific information( it's good for beginners ). A better book is "Computational Fluid Dynamics" by John D. Anderson. And the Stam's papers are very interesting for people interested in animation( someone posted the link ).

Share this post


Link to post
Share on other sites
The math is a bit involved, yes, but it's not that hard if you know a bit of calculus & linear algebra. It's not like you have to derive everything from scratch, more like understanding how to implement the formulas and methods (and in many cases pseudo-code is provided).

Like many have already stated, Bridson & Müller is imho the best reference for getting started with CFD. There is also some useful information in Mark Carlson's Phd Thesis, chapter 3: http://www.cc.gatech.edu/~carlson/papers/carlson-thesis.pdf

But really the best way to overcome obstacles on your road to implementing a fully functional fluid solver is to ask questions when you run into a problem you can't figure out.






Share this post


Link to post
Share on other sites
Quote:
But really the best way to overcome obstacles on your road to implementing a fully functional fluid solver is to ask questions when you run into a problem you can't figure out.


Ok :)

Well, I have a small question about the euler equations (I figure those are the simplest)

Heres the equations I found:
http://mathworld.wolfram.com/EulersEquationsofInviscidMotion.html

I don't quite understand how they are taking the gradient of u (in the second term). I could have sworn you could only take the gradient of a scalar field...

Also, in general the equation doesnt make sense to me. "du/dt" would result in a vector, as would "grad P / p". while "u dot grad u" would be a scalar.

There must be some other meaning to "u dot grad u"

Share this post


Link to post
Share on other sites
Hey again.

Check out Bridson/Müller, Chapter 1 and 1.3.2 specfically which deals exactly with this question.

Taking the gradient of a vector-valued function results in something called a Jacobian, which is a matrix of first order partial derivatives (more on this here (http://en.wikipedia.org/wiki/Jacobian)).

You can think of it as taking the gradient of the scalar fields that make up each component in the vector field. Try reading Bridson, chapter 1. There are some quite graspable explanations of many of these concepts to be found.


Regards,

Marcus.

Share this post


Link to post
Share on other sites
remember, a matrix transform is linear. locally a differentiable vector valued function can be approximated with a matrix, which as someone already pointed out is called the jacobian.

Share this post


Link to post
Share on other sites
Quote:
Original post by coderchris
Quote:
But really the best way to overcome obstacles on your road to implementing a fully functional fluid solver is to ask questions when you run into a problem you can't figure out.


Ok :)

Well, I have a small question about the euler equations (I figure those are the simplest)

Heres the equations I found:
http://mathworld.wolfram.com/EulersEquationsofInviscidMotion.html

I don't quite understand how they are taking the gradient of u (in the second term). I could have sworn you could only take the gradient of a scalar field...

Also, in general the equation doesnt make sense to me. "du/dt" would result in a vector, as would "grad P / p". while "u dot grad u" would be a scalar.

There must be some other meaning to "u dot grad u"


The equation is (almost)right.

"u dot grad u" is actually:

d(uj.ui)/dxj, i=1,2,3 and j=1,2,3

The equations, using the "Einstein's notation", can be written:

d(ui)/dt + d(uj.ui)/dxj = -dp/dxi ( with p = P/rho ) i=1,2,3 and j = 1,2,3

When an index appears only once in a product, it designates a vector component. A product where an index appears twice is in fact a summation. A dot product would be written:

v1 * v2 = v1i.v2i ( i = 1,2,3 )
= v11.v21 + v12.v22 + v13.v23


( Wikipedia:
"According to this convention, when an index variable appears twice in a single term, once in an upper (superscript) and once in a lower (subscript) position, it implies that we are summing over all of its possible values." )

So in d(uj.ui)/dxj, the index i appears once, and it's logical since an index appearing only once in a product designates a vector component.
So the expression developped, is:

d(uj.ui)/dxj = d(u1.ui)/dx1 + d(u2.ui)/dx2 + d(u3.ui)/dx3 for i = 1,2,3

So for the x component of the equation we have:

d(u1)/dt + d(u1.u1)/dx1 + d(u2.u1)/dx2 + d(u3.u1)/dx3 = -dp/dx1

A good explanation of these equations are given in "Computational Methods for Fluid Dynamics" and it's the most intuitive explanation( better than the one provided by my Fluid Mechanics professor, even if, it is less complete ).

Note: of course, rho being constant, we know that the divergence of u equals zero...So, plugging that in the above equation, we have:

d(u1)/dt + u1.d(u1)/dx1 + u1.d(u1)/dx1 + u2.d(u1)/dx2 + u1.d(u2)/dx2 + u3.d(u1)/dx2 + u1.d(u3)/dx3 = -dp/dx1
=>d(u1)/dt + u1.d(u1)/dx1 + u2.d(u1)/dx2 + u3.d(u1)/dx3 = -dp/dx1 ( d(ui)/dxi = 0 )

Hence:

d(ui)/dt + u.grad(ui) = -dp/dxi, i=1,2,3

We generally calculate the gradiant of a scalar function, not the gradiant of a vectorial function( vector field ). I don't even know if the gradiant of a vector field do exist. The jacobian is something else( matrix built with the partial derivatives of the components of a vector field.

And finally, the dimensions are coherent:


[d(ui)/dt] = [L][T]¯1 [T]¯1 = [L][T]¯²;
[u.grad(ui)] = [L][T]¯1 [L][T]¯1 [L]¯1 = [L][T]¯²;
[dp/dxi] = [M][L][T]¯² [L]¯² [M]¯1[L]³ [L]¯1 = [L][T]¯²


[Edited by - johnstanp on August 13, 2008 10:50:43 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this