90 likes | 255 Views
Barnes-Hut Algorithm CS498lvk. Abhinav S Bhatele Feb 14th, ‘06. Introduction. The algorithm was presented in "A Hierarchical O(n log n) force calculation algorithm" by J. Barnes and P. Hut in Nature, v. 324, December 1986
E N D
Barnes-Hut AlgorithmCS498lvk Abhinav S Bhatele Feb 14th, ‘06
Introduction • The algorithm was presented in "A Hierarchical O(n log n) force calculation algorithm" by J. Barnes and P. Hut in Nature, v. 324, December 1986 • It is a solution to the N-body problem and is widely used in astrophysics • It has been thoroughly parallelized • However it is not accurate as some other methods like the Fast Multipole Method (FMM)
Sequential Algorithm • t = 0 • while t < t_final • for i = 1 to n • compute f(i) = force on particle i • move particle i under force f(i) for time dt • end for • compute interesting properties of particles • t = t + dt • end while
Forces on a particle • Three major forces: • External force • Nearest Neighbour forces • Far Field Forces – these are the ones difficult to parallelize • The third force calculation takes 0(n2) – which is reduced to 0(n log n) by use of divide and conquer algorithms • To reduce the no. of particles in the force calculation, we use quad-trees and oct-trees • Make use of adaptive quad-trees when distribution of particles bounded in the box is uneven
Broad Overview • Main Steps: • Initialize the tree • In every iteration: • Compute the center of mass and total mass of each subtree • Compute the forces on each particle • Update the positions according to the forces • Migrate the particles
Parallelization • The step which we should parallelize to see reasonable effects: • Calculating forces on particles • For the sake of simplicity we might not parallelize: • Computing centroids and masses • Updating the particles • Migrating them