MateusZitelli / N-Body_Barnes_Hut

N-Body simulation in linearithmic time
GNU General Public License v2.0
3 stars 3 forks source link

Switch to a different integration scheme #2

Open mvoelschow opened 7 years ago

mvoelschow commented 7 years ago

Hi Mateus,

I took a quick look at your source code. Congrats, your work is amazing, keep it up!

However, one big flaw of your program is that you're using a simple explicit Euler integration scheme to update your particle position which is very very crude. Further, you don't have any kind of adaptive stepsize control (based on some desired per-step error), nor do you check energy conservation. You should consider switching to a more robust integration scheme such as - at least - a Leapfrog or Velocity Verlet method. A higher-order Runge-Kutta-Nyström integrator with energy conservation checks might also work out. That would make your simulations much more accurate and physical.

Best regards, Marcel

MateusZitelli commented 7 years ago

Hi @altair080 ,

Thank you for the feedback, happy that you like it!

I made this project for a algorithms class, so my focus at the time was in the method and data structure used. Now in this period I'm having a class with numerical calculus and you gave me a good idea to improve this project as project to the course. Do you have any good references for the methods that you highlighted?

Cheers, Mateus.