Expand description
This algorithm uses Tree Code to group source bodies, as an approximation. It leads to O(N(log N))
computation time, where N is the number of bodies. Canonical use cases include gravity, and charged
particle simulations.
See the readme for details, including an example.
Structs§
- BhConfig
- Cube
- A cubical bounding box. length=width=depth.
- Node
- Tree
- A recursive tree. Each node can be subdivided Terminates with
NodeType::NodeTerminal.
Traits§
- Body
Model - We use this to allow for arbitrary body (or particle etc) types in application code to
use this library. Substitute
chargeformassas required.
Functions§
- run_bh
- Calculate force using the Barnes Hut algorithm. The force function passed
as a parameter has signature
(acc_dir: Vec3 (unit), mass_src: f64, distance: f64) -> Vec3id_targetis the index in the body array used to make the tree; it prevents self-interaction. Note thatmasscan be interchanged withcharge, or similar.