Ideal Gas Simulation
December 2018 - September 2019

In December 2018 I started developing a program in Python to simulate an ideal gas made of elementary particles. The goal was to replace an old program being used for the Maxwell-Boltzmann Distribution lab in BSU's PHYS 309 course. The program was finished in August and implemented into the course in September.

The main requirements for the lab exercise the program needed to satisfy were:

Source code

Features & Design

Limitations

Development

The plan was initially to write the program in Java, but I switched to Python to make it more accessible for students. My only prior experience with making graphical user interfaces was with Java, so making one with Python required research into the tkinter package.

The initial inspiration for the program's design came from the old version of this falstad applet. Besides the graphical layout, both the collision and collision-checking algorithms of my simulation are based on those used in the applet (the Java source code for the applet can be found on the site).

Initially, the simulation used the same 2D collision algorithm as the applet, but this created a problem. Students would have to use the 2D, not 3D, version of the Maxwell-Boltzmann Distribution for their data analysis! While possible, conducting the lab in 2D would have created unnecessary confusion.

There were two challenges to changing the simulation to 3D which initially made me hesitant: changing the collision algorithm and displaying each particle's z-coordinate graphically. Changing the collision algorithm ended up being much easier than expected, but making the graphical change required some creativity. Rendering the particles in true 3D would have required further research and increased the hardware demands. In the end, I settled on the simple solution of adjusting the radius of the circle representing each particle according to its position along the z-axis. This means the virtual space of the simulation has two dimensions shown on screen while the third dimension is going into and out of the screen!