We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Particle system that simulates gas behaviour
Page Index Toggle Pages: 1
Particle system that simulates gas behaviour (Read 785 times)
Particle system that simulates gas behaviour
Apr 4th, 2009, 4:46am
 
Hello,
I am starting a project in which I would like to simulate the behaviour of gas molecules (filling a container with maximum spacing between themselves) with a particle system, but I'm having a hard time in deciding the best way to go about that.
Any suggestions?
I have medium-high programming skills in other languages, so I'd be fine with just a couple of pointers in the best direction.
Thank you in advance
Re: Particle system that simulates gas behaviour
Reply #1 - Apr 4th, 2009, 6:35am
 
maybe you can use traer physics to simulate it...
http://www.cs.princeton.edu/~traer/physics/

there is a smoke example http://www.cs.princeton.edu/~traer/smoke/
maybe if you give them some repulsive force they behave similar to what you are looking for.
I guess the only thing you have to figure out os how to keep it within a container... but it should be possible. Seems to be not that complicated.

Re: Particle system that simulates gas behaviour
Reply #2 - Apr 4th, 2009, 7:03am
 
If you have lot of particles, you might be interested by the experiment shown at gl vertexarray experiment thread.
Re: Particle system that simulates gas behaviour
Reply #3 - Apr 7th, 2009, 2:50pm
 
The real issue is going to be optimizing it in a way that it will run at a real time speed.

I would probably try to create a simple 2D spacial partitioning system like a grid to store references to the particles, as particles move between grid cells they should notify the spacial grid of their cell change

Then it will be easy to create a list of neighbors for each particle  sorted closest first using an insertion sort

(probably want to use the 4 or 9 closes cells depending on the size of your cells)

you may want to limit the neighbors to the top x number of particles in the neighbor list to reduce the number of neighbors you calculate forces for, then finally iterate through all the particles applying force from each of the neighboring particles.

You'll have to find the sweet spot where when the particles relax they're efficiently using up the grid. If your grid is to dense you'll take a performance hit for iterating over a lot of empty cells, if it's too sparse you'll end up with too many clusters of particles that end up creating a large performance penalty.

A tricky but interesting problem for sure!

Jack

Page Index Toggle Pages: 1