Simulation of a gas - mixing

Home
Movies
Images
Java
PHP
Micro controllers
Fractals
Vector graphics
Projects
Links
Blog
Meta

My java applets were developed a long time ago and have not been digitally signed. Nowadays a browser will typically not allow a java applet to run unless it is signed. Getting the applets signed is somewhat expensive, and since I no longer do any java development it is unlikely that I will get the applets signed. It it still possible to run the applets, but in that case you will need to change the security policy of your browser to allow unsigned applets to run.

Below is a java simulation of a gas, where the gas molecules are treated as hard spheres. In this simulation there are two types of molecules - blue ones and red ones. Initially the molecules are sorted with all molecules of one type on one side and all molecules of the other type on the other side. The two gases are kept separated by a central wall, which can be removed. When the wall is removed the two gases will start mixing, and one would not expect them to become separated again. This is an example of an irreversible process, i.e. a process where there is a difference between forward and backward in time (the arrow of time).

The equations that govern individual collisions are unaffected by the direction time flows in. Microscopically reversion of time is equivalent to reversal of all velocities. Macroscopically, however, the situation is different, and this is due to the Second Law of Thermodynamics. The Second Law states that the entropy of an isolated system must either stay the same or increase with time. Entropy can never decrease with time. Entropy can be thought of as a measure of disorder. The simulation starts in a state with low entropy (the gases are separated) and moves to a state with higher entropy (the gases are mixed). From this higher entropy state the system can not get back to the lower entropy state, because that would decrease the entropy.



The simulation controls are hopefully self-explanatory.


This simulation is time reversible, but only for short periods of time (approximately 1 time unit in the simulation). Eventually the finite precision of the simulation will cause a collision to be missed/added when time is reversed. Initially this only affects two of the molecules, but when the two first affected molecules collide again the effect has spread to their two collision partners. In this way the effect spreads at an exponential rate through the gas, and will eventually have affected all of the molecules.

There is also a variant of this simulation, where the irreversible process simulated is instead release of a gas from a container.