3 ms·
For long simulations I'd like to increase the timestep, but then RK4 becomes less accurate. For the n body problem, do symplectic integrators work well?
by jasmcole 8y ago
For long simulations I'd like to increase the timestep, but then RK4 becomes less accurate. For the n body problem, do symplectic integrators work well?
- alkonaut 8y agoYes, the difference is enormous. Use e.g Verlet integration and it’s much more stable. That it’s also much simpler and more elegant RK4 is an added bonus.
- the_happy_koala 8y agoIf for whatever reason you have time and would like to make a contribution, I think doing so should be quite easy as I think you'd just have to subclass the Euler class. You can get an idea of how to do this by looking at how I did it with the RK4 subclass (https://github.com/TheHappyKoala/Harmony-of-the-Spheres/tree/master/src/js/Physics/Integrators https://github.com/TheHappyKoala/Harmony-of-the-Spheres/tree...). If not, I'll add Verlet integration myself one of these days, but right now I'm working on introducing a particle system so that I can simulate the rings of Saturn (the particles will feel the gravity of all the masses in the simulation, but they won't exert a gravitational force on the other particles and masses in the simulation; this way you should be able to have fun distorting the rings of Saturn with a celestial object of your choice).
- the_happy_koala 8y agoI'm working on implementing an integrator with an adaptive time step, so that the time step is high when masses are far away from each other and just coasting, but low when they get close to each other and interesting things happen; think the orbit of a comet getting altered as it encounters Jupiter after a long journey from the Oort cloud. As things are now, such a scenario would be painfully slow to simulate if you want to maintain accuracy, but if you speed up the time step, nothing remotely realistic will come out of the simulator... So good point, and I hope I'll be able to cobble together a solution soon enough :D. As for symplectic integrators, I'm not sure they stay symplectic if you alter the time step, but I could be wrong!