HANS gets an upgrade

It’s rare that any of my projects get a mid-life upgrade (or do much more than gather dust on a shelf once completed), but HANS is that rare project with long-term entertainment value. It sat on my desk happily calculating the state of our inner solar system for over a year, before I began to get a bit bored with it. Our inner solar system just isn’t that exciting to watch (and I got tired of having to reset it every 3 months or so when the Sun started to drift away). What could I do to spice things up a little bit?

Around the time boredom was beginning to set in, the Trappist-1 system was all over the news, and I decided that this was exactly what HANS needed. I wrote the software for HANS as a generic N-body gravity simulator, even though all it was simulating was the inner 2 AU of our solar system. Simulating the Trappist-1 system was basically just a matter of generating a dataset with starting conditions and letting it run. Fun new features:

  • Simulation of the Trappist-1 sun, and its 7 earth-like planets
  • Randomized starting conditions – I can’t actually find ‘real’ ephemeris data for the system, so I generate starting conditions (including orbital radii, planetary masses, etc.) within the known ranges listed on the wikipedia page. HANS actually uses a random seed derived from jitter in the chip’s internal RC oscillator every time it’s powered on, so I actually get unique starting conditions every time I restart. This is one of my favorite parts, as I get a slightly different experiment every time I cycle the power.
  • Some cosmetic upgrades – I added an earth-year counter to the display, as well as a randomly generated star-field in the background. I also cleaned up the update routines for drawing the planets so that the graphics are smoother, along with adding a ‘ghosting’ effect for the planets that helps show their velocity better.
  • A stability upgrade – Since my planets have randomly generated starting positions along their orbits (and their masses vary each time I restart), the simulator now calculates the net momentum of all of the planets in the system at the beginning of time, and imparts an equal and opposite momentum to the sun. This seems to have completely solved my ‘drift’ problem, and the system has been stable for over 100 Earth-years so far! I also increased the timestep to about 60 seconds (from 10 seconds), which both makes it more entertaining to watch and doesn’t seem to have negatively impacted long-term stability.

So let the experimenting begin! If any of the planets collide with each other or fly off into space, I’ll be sure to send the TRAPPISTs a warning. In the mean time, my desk-side distraction device is now much more entertaining =)