Any way to simulate vacuum?

The project I'm working on allows users to build their own contraptions by cutting out and designing pieces, and then assemble them all together into a machine.

Now, one of the basic machines will be an air pump. I should be able to simulate air pressure moving out of the pump as several small circles, all crowding each other, however, I want a "flap" to open drawing in new air once the air has been pushed out. Here are a few (crappy) images describing the process.
Image
Image
Image

Any ideas or workarounds? Any other libraries out there that can simulate this?
It's just for a game, so it doesn't need to be exact, just believable.
Seems difficult and resource-intensive if you plan on actually rendering the 'air-balls'?

I'm a complete newb, but if that's the way you're going, I think I'd look into joints and springs. Put one end on the balls and the other end where-ever you want the balls to go (towards a vacuum or away from pressure).
I frequent the kirupa.com forums more often, so I asked the same question there, but thought I would also ask here as this forum is more on topic with the question.
http://www.kirupa.com/forum/showthread.php?t=340759

One of the main recommended ideas was to calculate how many air particles are within a certain area, and then compare that number to an adjacent "area". If there is a difference in the amount of particles, the one with more will want to move to the one with less (which is pretty much exactly how real air pressure works), so I believe I will go with that idea.

Is there any way to make air particles want to move from one general area to another? Gravity isn't really what I am looking for, since that will keep the particles constantly moving in one direction, but I want them more to move to somewhere in the general area to even out the pressure across the two spaces.



As for the performance, I am worried about that, but I'm hoping it's possible to "cache" the machine running and only compare the input over a set amount of time to the output. The calculation would be done on the server, and whenever the player runs the invention, it uses those precalculated values.
Competent and helpful people at that site, it seems. I prefer the 'official' adobe forums for questions about as3 though.

In any case, I think their idea of the boundaries and testing rectangles could be combined with my suggestion of using springs.

You could set up some form of monitoring for the particles, so they know their nearest, say 5, neighbours. You then attach a spring to each of the neighbours, with definitions that will attempt to push away all the neighbours as far as possible.

That should give you a nice simulation of air pressure. At least they should distribute nicely (if there aren't too many obstructions, I guess).
If you don't look at it as a vacuum and rather like the 'particles' pushing away from each other, using some sort of gaussian relax (find close pairs, push the ones that are within a certain limit apart), the vacuum-effect should pretty much happen by itself. That could end up being very expensive in AS3 though.

Edit: Ah, didn't read the previous post 😛

Original thread: https://box2d.org/forum/viewtopic.php?t=4136