PDA

View Full Version : Getting started with simulation



h3ro
10-18-2006, 06:13 AM
Hallo to all, as this is my first post here.

I am currently learning c++ and want to evolve into beeing able to program things like liquid simulations. My problem is where to start and what to do.

I have some basic knowledge about C++, but are far from beeing an expert. So, after knowing the basic, what should I do if I want to do liquids in the end? I know this will not be a one week travle, it will probably take a few years maybe?

I was now thinking of looking into openGL, is that a good idea considering what I want to do? Or is it waste of time? Well, everything I learning is good, but I think you understand what I am meaning.

I have no problem with spending some money on things needed like books. As long as they are good. I am also thinking of studying this next year at university. (Computer graphic science at Teesside, any one know if its good?)

thanks in advance

SlyMaelstrom
10-18-2006, 11:13 AM
I'm not sure what you mean by "liquid simulation". I hope I'm not being ignorant here... do you mean liquid as saying you want some kind of exact simulation or do you mean liquid as in liquid? Are you doing some analytical simulation or a physical simulation. You said OpenGL which is a graphics library so I assume you're looking to draw this simulation. The thing you should be studying, first and foremost, is Physics and probably Calculus which will help you in Physics. As for programming, you can study a graphics library like OpenGL and I would also study algorithm efficiency and programming architecture because simulations usually require fast computation and sometimes a fair amount of memory depending on how detailed this simulation is.

I'd wait for others to respond... I might have misunderstood what you were asking. I also don't know about that college, but there are some people (even moderators) on this forum from England that could probably help you with that.

Salem
10-18-2006, 11:13 AM
A start - http://en.wikipedia.org/wiki/Fluid_dynamics

> is that a good idea considering what I want to do?
It's just one aspect of the problem - being able to visualise what your calculations are telling you is a key part in any simulation field. Megabytes of numbers are pretty meaningless to all except the most hard core people in the field.

To be honest, the graphics side will be easier. Studying fluid physics at university will give you all the theoretical background to being good at the subject, and you'll have first hand experience of using other peoples modelling s/w to know what works, what doesn't and what could be done better.

Even better if you can find a course which has modules for the computational side as well.

h3ro
10-18-2006, 12:05 PM
Thanks for the replies.

I got interested in doing this after working with fluid and particles in Maya and realflow (3d programs)

One of the moduels at teesside is called "simulation" an focus on fluid and liquids. :)

SlyMaelstrom
10-18-2006, 12:49 PM
Maya? Isn't that like a $5,000+ program?

Edit: Actually, I see there is a school edition for about $400-$500

h3ro
10-18-2006, 01:09 PM
And a free one for personal use.

I am luck enugh to be working for a small firm :)

VirtualAce
10-18-2006, 01:33 PM
You will need to program a CFD solver (computational fluid dynamics) and I have no idea how to do that. But I reckon google does.

BobMcGee123
10-21-2006, 09:16 AM
CFD is the hardest area of math and physics that I have ever touched upon. I would suggest looking for pre built tools to start off. One that I've heard of is FLUent, but I'm not sure what the learning curve is to use that tool (it might not be realistic to use it).

One of my professors held up a piece of chalk, moved it very slowly sideways in front of his face, and said that to date that's the only problem that can be accurately solved with any fluid dynamics software on a PC. Anything body larger, more complex and faster moving than that basically requires a super computer to accurately compute.

An over simplified way to do CFD is to implement the physics for a mathematical sphere. These become your air molecules. You fill up a giant room full of these little spheres and then move a body through it. The body will bump into these little spheres, and various physical properties such as lift, drag, air density, temperature (etc) begin to emerge. The smaller you make the spheres, the more realistic it becomes. There are better approaches, but this works, just takes forever to compute.

h3ro
10-22-2006, 09:19 AM
If I use the Navier stoks method(not sure of the spelling, sorry) would that make life easier, or is it the same case?

VirtualAce
10-22-2006, 01:35 PM
The point of our posts is to show you that if you intend on a real-time simulation of fluid dynamics you will need the latest version of the CRAY sitting in your house. But you can come close by approximating it and using shortcuts and pre-computed tables.

Real time simulation is not about being 100% accurate because most complex problems in physics can rarely be solved 100% in real time on any PC. So do some research and find the variables that you feel you can eliminate. I'd suggest looking at the Microsoft Flight Simulator development website for a sample of what I'm talking about. They simulate an aircraft using about 10 to 12 laws of physics and even though it's not exactly perfect, it's damn close and believable.

So what is it that you want to accomplish with this and why? Can you get away with eliminating some variables and/or approximating them?

When I was coding a sky shader I could have computed the precise optical depth of one light ray from the sun to the viewer and it would have looked great, but it would have ran at about .01 FPS. I would have to integrate the equations along that ray at set points and then perform a final computation on the results of the integration. But I found an approximation function that behaves in a very similar fashion and can be run in real time.

Running a CFD in real time on a computer is simply not an option here. You are going to have to do quite a bit of research to figure out how to approximate it.

h3ro
10-22-2006, 02:28 PM
This thread basicly turned into a "how to do fluid simulations" which was not what I intended, but probably contributed do myself :P What was really my question, was what I should learn/focus on before trying to do stuff like fluid. As there are probably no point of looking into AI programing if I want to do fluid and so on?

Thanks

VirtualAce
10-22-2006, 11:10 PM
That is a completely vague question. So you get a completely vague answer.

Stuff.

Sang-drax
10-23-2006, 01:29 AM
FEMLAB (now called COMSOL) is a program which solves partial differential equations. It can do what you are after. However, it is not simple to use and require a fair amount of math knowledge.


was what I should learn/focus on before trying to do stuff like fluid.
Mathematics, some good keywords are: "calculus", "analysis", "partial differential equations", "continuum mechanics" and "finite element method".

.

h3ro
10-23-2006, 02:24 AM
OK, so the hard part of doing fluid simulations are not really the programing but the math itself?

maxorator
10-23-2006, 05:27 AM
FEMLAB (now called COMSOL) is a program which solves partial differential equations. It can do what you are after. However, it is not simple to use and require a fair amount of math knowledge.


Mathematics, some good keywords are: "calculus", "analysis", "partial differential equations", "continuum mechanics" and "finite element method".
Don't forget physics!

OK, so the hard part of doing fluid simulations are not really the programing but the math itself?
You can always tell a computer "I want a green pixel", but it's not easy to know where you want to put it.

h3ro
10-23-2006, 06:15 AM
OK, so I should start learning a bit more physics and math than I allready know. Probably a bit more than what I will learn at high school.

I guess I will have my hand full trying to get a grasp of c++ basic and the fundamental of fluid simulation itself, so accually building a simple engine myself.

Does anyone happen to know a tutorial which accually guids you thrugh the making of a fluid simulation software of some kind? Or a good particle tutorial, I have seen some but it would be great to see a few more. I have seen the ones at gameDEV.

Also, on last question. If I make the fluid particle based (the other might be that as well, I dont know) and than use inter particle collision to simulate it? I think that some 3d sofware does it this way.

Happy_Reaper
10-23-2006, 08:09 AM
OK, so I should start learning a bit more physics and math than I allready know. Probably a bit more than what I will learn at high school.


Yes, and probably more than you're likely to learn at university, too. PDEs are no walk in the park.

Draco
10-26-2006, 11:33 PM
As has been wisely said before, you need a LOT of advanced math and physics to make any type of fluid simulator. Don't feel like you should give up, but keep in mind that it's a subject of many doctorate degree studies. Something you haven't said is whether you want to write a fluid simulation that will be accurate, or just have good graphics. If you're looking for accuracy you need to look into the Finite Element Method. If not, you should look into how Maya does its liquids as the method is almost certainly different. Again, gain a lot of ground in at least math before you try to write your own simulator. It's more fun to jump in, but the preparation makes a world of difference.

h3ro
10-27-2006, 05:27 PM
Well, I dont intend to write something for scientific use, but I want to look really. You know, have a life like feeling. But my aim is to use if for computer graphics, so if the force of the fluid does not match really world...well, it does not matter as long as it looks good.

I have started doing openGL, is that good for me, or is openGL not good for displaying this kind of stuff?

I think I will make it particle based, as it looks a bit easyer, atleast the math side of it. Thank god for good research papers writen by clever people :)

thanks

docfreezzzz
11-12-2006, 03:04 PM
In order to answer your question on what you need to study to program something like Fluent.

Fluent is what is referred to as a CFD (computational fluid dynamics) solver. It is in the most basic of terms approximating the Navier Stokes equation solutions using various iterative methods. I am a Mechanical Engineering student with an AOC in energy systems and being completely honest, the math is brutal.

At the very least I would recommend Calculus up to Calculus III and Partial Differential equations study. You will also need a very thorough understanding of fluid mechanics and the ability to hand solve basic problems in order to understand the physical meaning of these solvers. This is one of the most complex mathematical fields I have yet to encounter and a college degree would be the best way to approach the subject.

On the bright side, there are several very good open source solvers out there such as OpenFOAM and Phoenix. I would suggest taking the necessary courses and then reverse engineering some of the other solvers on the market. However, without being too negative most of the code used in even commercial solvers such as Fluent is grandfather code and really hasn't changed much as far as the brute mathematics involved. Most of the work in this field is done on optimization techniques and that question is better directed to a computer science or computer engineering major.

Best of luck.
Nick