Monday, August 27, 2007

Particles in a Box

So I was playing with MATLAB again, instead of learning Spanish. 'No hablo espanol' is everything I need to know, isn't it?

I modelled particles in a 3D box. You can set the mass, particle-size, average-speed, gravity, number of particles, box size, and some more settings that can also be randomized.

The particles do collide with each other and with the walls. These collisions are purely elastic, but 'Newtonian real' in 3D space.

Well... here is the first animated result with 9 3D balls as particles:
Here is a video of 400 little particles in a box. More than thousand collisions occur in this video.

And here you can see what happens when 100 particles of mass 10 (red) and 100 particles of mass 1 (blue) are combined. It's a sideview of the 3D box.

And here a slow version of a lot of particles, again in a little box.

All not very exciting to view, but it was fun to work on. I can tell more about the physics, but I'll do that on request. Most of us have done the same (linear momentum) calculations on paper and in 1D, at high school.

Oxygen vs Nitrogen
40 oxygen molecules, 160 nitrogen molecules and gravity. Red is oxygen (m=32), blue is nitrogen(m=28). Small weird wind on cybrbeasts request. The wind part doesn't work in a very real way, but it doesn't really interfere with the results of the simulation. Video!


cybrbeast said...

Cool, you can write tour own physics programs :)
Now do a particle simulation with particles weighing 32 and 28 and gravity, and wind :)
It might shed some light on our discussion of why N2 and O2 don't unmix in the atmosphere.

ExpendableAsset said...

I'd be very interested in that explanation. Go on!

cybrbeast said...

You did it! :)
It seem to stay pretty well mixed.

From wiki
""Below the turbopause at an altitude of about 100 km (not far from the mesopause), the Earth's atmosphere has a more-or-less uniform composition (apart from water vapor) as described above; this constitutes the homosphere.[3] However, above about 100 km, the Earth's atmosphere begins to have a composition which varies with altitude. This is essentially because, in the absence of mixing, the density of a gas falls off exponentially with increasing altitude, but at a rate which depends on the molar mass. Thus higher mass constituents, such as oxygen and nitrogen, fall off more quickly than lighter constituents such as helium, molecular hydrogen, and atomic hydrogen. Thus there is a layer, called the heterosphere, in which the earth's atmosphere has varying composition. As the altitude increases, the atmosphere is dominated successively by helium, molecular hydrogen, and atomic hydrogen. The precise altitude of the heterosphere and the layers it contains varies significantly with temperature.""
So the gasses do unmix but only at high altitude.