Show HN: Harmony of the Spheres – Gravity Simulator
thehappykoala.github.io
thehappykoala.github.io
It's pretty good except it runs a lot slower than it has to.
The default step size is too small for most cases so you have to wait a long time for the planets to move around.
When I tried increasing the step size with the slider I'd inevitably increase it too much and the planets would fly away.
Personally I always use RK4 and similar algorithms with adaptive step size, mostly because it is a pain to tune the step size by hand
https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods#Ad...
also if planets are passing close to each other you may need a shorter step when you are close and a longer step when you are far away.
RK4 or RK5 with adaptive timesteps will make your demo much better with very little work.
There are methods that use higher order derivatives and other tricks to take large steps, for instance I like this method
https://github.com/alexrudy/bsint
If you were integrating the solar system for millions of years you would want a symplectic integrator.
https://en.wikipedia.org/wiki/Symplectic_integrator
this might not be more accurate than another integrator but it will preserve phase space area which makes it possible that the long-term dynamics will "look like" the real long-term dynamics. (Otherwise it certainly won't!)
If it were me in cases where there is a central large mass I would integrate in spherical or cylindrical coordinates, probably I would use a predictor-corrector method.
Many thanks for your feedback! Implementing an integrator with an adaptive time step is on my bucket list of features that I intend to implement, as tweaking the time step manually, especially with the freaking slider, is somewhat of a pain in the neck. Another reason for why I want to implement an adaptive time step is that collisions don't really work with a fixed one as sometimes a mass will travel farther in one time step than the radius (I use a simple radius check for collisions since it doesn't require that much computing power) of the body it is smacking into, and as such the hit won't get registered, which looks kind of shoddy (implemented collisions but removed them for this reason).I've had an eye on the RK45 method, but I'm definitely going to give implementing the Bulirsch-Stoer Integrator a go as I want the user to be able to select the integrator they want to run a scenario with (right now I've just implemented Euler and RK4). As for using spherical or cylindrical coordinates, the thing is that the intention is for the user to be able to, for instance, add another sun to our solar system to marvel at all the cosmic shenanigans that would take place, so while a lot of the scenarios start out with a single large mass, that might not be the case for long if the user has a penchant for destruction.
https://landgreen.github.io/physics/notes/electromagnetism/p...
Every body in the simulation start out with a set of initial position and velocity vectors. For the solar system scenarios, I got these vectors from NASA JPL's Horizon System (https://ssd.jpl.nasa.gov/horizons.cgi#top), so the orbit of Juno that you are observing is its actual orbit... Its eccentricity (the extent to which the shape of the orbit departs from a perfect circle) is extremely high; at its closest point, the orbit brings Juno right above the cloud tops of Jupiter, and at its furthest point Juno finds itself beyond Themisto (one of Jupiter's irregular Moons which I should perhaps add to the scenario). Juno was meant to have a less eccentric orbit, but as technical problems were encountered when they were going to fire Juno's thrusters to reduce the eccentricity of the orbit, NASA played it safe and let Juno stay on its eccentric orbit. One of the advantages of this is that Juno only spends a very short amount of time in Jupiter's insanely powerful and to a spacecraft damaging magnetic field, so the technical mishap is probably one of the reasons JunoCam is still operating and giving us beautiful images of Jupiter's swirling clouds! Here's a gif from WikiPedia showing how stretched out Juno's orbit is https://en.wikipedia.org/wiki/Juno_(spacecraft)#/media/File:.... Sorry for the long rant, but I find these things to be awesomely fascinating.
You've got nothing to apologize for, that was fascinating! I knew its orbit had some eccentricity, but I didn't know it was that much!
I recently learned about it and wanted to try it after playing with KSP, but it seems it's Windows only.
...aaaand there goes all the work I was planning to do on the winter holidays!
Thank you.