Summer course – Physics simulations in Python

Gravity simulation
Simulation of gravitational motion of objects in Python

During summer 2010, I took a course where we learned how to program in python; specifically for finding numerical solutions for ordinary differential equations using Runge-Kutta. Most of the things we did were physics-related, though for the final project it didn’t have to be.

Bead on Wire
Bead on a wire, under the effect of gravity

I learned quite a bit from this course; Python is really easy to use and understand. Before this, the only things I knew how to program were the things we learned in CS102 (not very much; our hardest assignment for that class was to write a program that converted formatted data to a more readable format), and some really simple ActionScript things for Flash.

If you’d like to see the programs I wrote for this class, you can find them here. It was written in Python 3.1 (I think) and requires pygame. The final project is in that zip file as well, but I think I’ll make a separate post for that.

Also important note: the code is incredibly inefficient because this was before I learned “proper” programming methods and efficiency, I kinda just did what worked and disregarded time complexity and the overhead associated with making and filling huge multidimensional arrays.

DLD dice project

Starting off with the oldest thing I can find, here’s a video of a digital logic design project last semester. Using a shift register, 7-segment display (and driver), some LEDs a push-button and some NAND gates (I think it was NAND, I don’t remember exactly; might have been NOR gates), we had to simulate a dice roll. It’s pretty much just cycling through 1-6 in a non-linear order really quickly, so what you get depends on how long you hold the button down. It changes really fast so you can’t really time your presses to get the desired number (I mean, unless you have super fast reflexes).