The Barnes–Hut simulation (named after Josh Barnes and Piet Hut) is an approximation algorithm for performing an n-body simulation. It is notable for having order O(n log n) compared to a direct-sum algorithm which would be O(n2).[1]
The simulation volume is usually divided up into cubic cells via an octree (in a three-dimensional space), 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 the cell's center of mass (or as a low-order multipole expansion). This can dramatically reduce the number of particle pair interactions that must be computed.
Some of the most demanding high-performance computing projects do computational astrophysics using the Barnes–Hut treecode algorithm, such as DEGIMA.[2]
Algorithm
The Barnes–Hut tree
In a three-dimensional n-body simulation, the Barnes–Hut algorithm recursively divides the n bodies into groups by storing them in an octree (or a quad-tree in a 2D simulation). Each node in this tree represents a region of the three-dimensional space. The topmost node represents the whole space, and its eight children represent the eight octants of the space. The space is recursively subdivided into octants until each subdivision contains 0 or 1 bodies (some regions do not have bodies in all of their octants). There are two types of nodes in the octree: internal and external nodes. An external node has no children and is either empty or represents a single body. Each internal node represents the group of bodies beneath it, and stores the center of mass and the total mass of all its children bodies.
- Particle distribution resembling two neighboring galaxies.
- Complete Barnes–Hut tree. (Nodes that do not contain particles are not drawn)
- Nodes of the Barnes–Hut tree used for calculating the force acting on a particle at the point of origin.
- n-Body simulation based on the Barnes–Hut algorithm.
Calculating the force acting on a body
To calculate the net force on a particular body, the nodes of the tree are traversed, starting from the root. If the center of mass of an internal node is sufficiently far from the body, the bodies contained in that part of the tree are treated as a single particle whose position and mass is respectively the center of mass and total mass of the internal node. If the internal node is sufficiently close to the body, the process is repeated for each of its children.
Whether a node is or isn't sufficiently far away from a body, depends on the quotient , where s is the width of the region represented by the internal node, and d is the distance between the body and the node's center of mass. The node is sufficiently far away when this ratio is smaller than a threshold value θ. The parameter θ determines the accuracy of the simulation; larger values of θ increase the speed of the simulation but decreases its accuracy. If θ = 0, no internal node is treated as a single body and the algorithm degenerates to a direct-sum algorithm.
See also
References and sources
- References
- ↑ Pfalzner, Susanne; Gibbon, Paul (1996). Many-body tree methods in physics. Cambridge [u.a.]: Cambridge Univ. Press. pp. 2, 3. ISBN 978-0-521-49564-6.
- ↑ T. Hamada; et al. (2009). "A novel multiple-walk parallel algorithm for the Barnes-Hut treecode on GPUs – towards cost effective, high performance N-body simulation". Comp. Sci. Res. Dev. 24 (1–2): 21–31. doi:10.1007/s00450-009-0089-1. S2CID 31071570.
- Sources
- J. Barnes & P. Hut (December 1986). "A hierarchical O(N log N) force-calculation algorithm". Nature. 324 (4): 446–449. Bibcode:1986Natur.324..446B. doi:10.1038/324446a0. S2CID 4267861.
- J. Dubinski (October 1996). "A Parallel Tree Code". New Astronomy. 1 (2): 133–147. arXiv:astro-ph/9603097v1. Bibcode:1996NewA....1..133D. doi:10.1016/S1384-1076(96)00009-7. S2CID 119464486.
- U. Becciani; R. Ansalonib; V. Antonuccio-Delogua; G. Erbaccic; M. Gamberaa & A. Pagliarod (October 1997). "A parallel tree code for large N-body simulation: dynamic load balance and data distribution on a CRAY T3D system". Computer Physics Communications. 106 (1–2): 105–113. arXiv:physics/9709003. Bibcode:1997CoPhC.106..105B. doi:10.1016/S0010-4655(97)00102-1. S2CID 18428101.
- T. Ventimiglia & K. Wayne. "The Barnes–Hut Algorithm". Retrieved 30 March 2012.
External links
- Treecodes, J. Barnes
- Parallel TreeCode Archived 2013-04-02 at the Wayback Machine
- HTML5/JavaScript Example Graphical Barnes–Hut Simulation
- PEPC – The Pretty Efficient Parallel Coulomb solver, an open-source parallel Barnes–Hut tree code with exchangeable interaction kernel for a multitude of applications
- Parallel GPU N-body simulation program with fast stackless particles tree traversal
- Barnes-Hut galaxy simulator at beltoforion.de