Member-only story
Resonance with a Damped-Driven Mass-Spring System in Python
Physicists like to say that pretty much everything can be modeled as just a mass connected to a spring. I mean, it’s not completely untrue. The mass on a spring appears in lots of different problems. But what about an oscillating mass WITH some type of frictional force? What about a mass-spring with a driving force? This is what we are going to build — in python. It’s going to be awesome.
Mass with a Spring
If you want to build a complicated model, the best option is to start with something simple and make sure that works correctly and then add the complicated parts. That’s what I’m going to do here. So, let’s consider a mass connected to a spring without friction and without a driving force. Just a plain simple harmonic oscillator.
Of course, this all starts with the force due to a spring. Here is a mass connected to a spring. I’ve connected the other end of the spring to some “anchor” point (this will be important later).
Here are the key details for the force due to a spring.
- The force is in the same direction as the spring. It can either push or pull — which ever way is…