Modelling a Gas with Object Oriented Programming
The basic idea of this script is to animate balls (or gas particles) and calculate the time to the next collision. Then the code moves all the balls forward in time to that point. Then it works out how the two balls will collide outputting the final velocities of two balls in question. This basically runs on a loop and can be seen in the animation below.
Thermodynamic variables are calculated at each point, such as total kinetic energy, pressure and volume. These can then be used to test the ideal gas laws, which fitted the results when the balls were small in comparison to the container. However, van der Waals equation of state must be used with larger balls, since there is less volume available for the balls.
Also added a function to plot the velocity distribution of the balls, which did follow the expected Maxwell-Boltzmann distribution. Also, can show that the kinetic theory of gases (that they are made of particles) can be used to explain Brownian motion.
For the full results see the report.
Finding Favourite Language on GitHub
Just a fun small script that attempts to find the favourite language of a GitHub user. Taught me how to parse websites with urllib and use APIs.