Newtonian mechanics and Verlet integration.

2 minute read

Published:

I have recently been dealing with Verlet integration as part of the curriculum of one of my classes. While I won’t cover the details here, I will eventually upload all the code to my GitHub account.

Verlet integration is a quick way of performing simulations where all bodies follow Newtonian mechanics. I am currently working my way up to simulating an entire galaxy (although a small one: my old MacBook can’t handle more than a few thousand stars). I have already added elastic (and inelastic, by using a coefficient) collisions to the simulation. I still need to implement a few things, like a neighbour list algorithm in order to make the program faster. (Molecular simulations show, if left unoptimized, a time complexity of order O(n^2), but implementing a neighbour list for each particle can reduce the time complexity down to O(n)).

Some of the things I’ve made:

  1. A simple pendulum with an initial deviation from equilibrium of (almost!) pi radians.

  1. A few pendulums with different starting angles, all of them small-ish. Their periods are, as expected from the well known approximation, very similar.

  1. Elastic collision implementation. (It was trickier than I imagined at first: not only you need to check for proximity, but also for appropriate motion. If the only requisite imposed to the program is that bodies be close enough, then masses that have just collided with each other and which still are in each other’s proximity will get a new velocity assigned in the next iteration, resulting in them “sticking together” in the final simulation. The remaining condition will be discussed in further detail in a coming paper I’ll upload here.)

  1. The first few plantes of the Solar System as seen from the Earth. Ptolemy would be happy.

  1. A simple visualization of the entire Solar Sytem that zooms out. (Planets not to scale, obviously). I did my best to account for planets looking smaller as the animation zooms out, but keep in mind that other than them actually following the elliptical orbits dictated by Newtonian mechanics, this is not an exact simulation.

I’m still working on the galaxy model. Let’s see how that goes. Any changes will be listed on the corresponding page.