Rhett Allain’s video about how to build a 3D mass on a spring was the kick that made me start building Python simulations, so it’s no surprise that I’ve had a lot of fun building many different kinds of oscillators. Here are some of them.
- Pendula
- Simple Pendulum (with or without graphs)
- Damped Pendulum (with or without graphs)
- Fully Adjustable Pendula (you get the idea)
Mass on a Spring
A classic.

View here, with access to the code here.
Adjustable Mass on a Spring
One of my hopes for these projects is that they’ll be useful in classrooms and for building physical intuition. This is fundamentally the same simulation as the one above, but this time the important values are adjustable. You can watch the effect of changing the spring constant, for example, in real time and see how the oscillation changes.

View here, with access to the code here.
Adjustable Hanging Mass on a Spring
Similar to the last simulator, only this time the mass is hanging vertically and an additional slider is in place to let the user adjust the strength of gravity. There are also options for displaying (scaled versions of) the Net, Spring, and Gravitational force on the ball as it oscillates, and an additional option to display the height at which gravity and the spring force would be in equilibrium.

View here, with access to the code here.
Coupled Masses in One Dimension
Once you’re confident with a mass on a spring, the next natural step is to add another mass, coupled to the first one with a second spring. But this is physics; let’s get rid of gravity before doing that. This and the next simulation are not adjustable, but could be easily modified to be so.

View here, with access to the code here.
Doubly Coupled Masses in One Dimension
And once you have coupled masses, the next natural thing to do is to add a third. That, though, would be a little too predictable–and it doesn’t add much to intuition. Instead, we can add another wall and couple the right mass to it.

View here, with access to the code here.
Coupled Masses in Three Dimensions
After I watched Rhett’s video and followed along for myself, my first step was to couple his oscillator to one beneath with a second spring. This, in fact, was the first simulation I made; all the simpler ones followed later on. I also have a version of this program where the starting positions of both masses are adjustable but for reasons that escape me it doesn’t work on Trinket like the rest of these programs do. It works on my computer, though. If you’re interested in accessing that program, please get in touch!

Simple Pendulum
Another classic: A simple pendulum oscillating back and forth. This program compares the trajectories of two ways of modeling the pendulum. The brighter sphere uses the small-angle approximation familiar to most physics students, while the shadow sphere uses a more exact result. By comparing the two, you can see where the small-angle approximation works and where it fails.
View here, with access to the code here. For a program that graphs the angles of both pendular over time, see here.
Damped Pendula
Similar to the program above, but with adjustable damping. The graphing program is especially helpful here because it shows very clearly when you’ve found critical damping.

View here, with access to the code here and a version that displays the graph here.
Fully Adjustable Pendula With Graphs
Of course, once you’ve played with a pendulum a bit, you want a version where you can change anything and everything. So here you go!