This is a 3D simulation of a dynamical system of particles, under the influence of gravity.
Consider n point masses m_1, ... ,m_n in three-dimensional space. Suppose that the force of attraction experienced between each pair of particles is Newtonian. Then, if the initial positions in space and initial velocities are specified for every particle at some present instant t_0, determine the position of each particle at every future (or past) moment of time.
N particles are generated randomly within a sphere. For each particle generated, its coordinate P(p_x, p_y, p_z)
Using classic Runge-Kutta method.
http://math.fullerton.edu/mathews/n2003/RungeKuttaMod.html
Barnes-Hut simulation
J. Barnes and P. Hut (December 1986). "A hierarchical O(N log N) force-calculation algorithm". Nature 324 (4): 446-449. doi:10.1038/324446a0.
The volume is divided up into cubic cells in an octree, so that only particles from nearby cells need to be treated individually, and particles in distant cells can be treated as a single large particle centered at its center of mass.
Using c++0x thread provided by pthread.
- N = 3 ------- file video/nbody_3.mkv
- N = 30 ------- file video/nbody_30.mkv
- N = 300 ------- file video/nbody_300.mkv
- N = 1000 ------- file video/nbody_3000.mkv
Wang Feng wang_feng@live.com
Licensed under the GPLv3.