English | 简体中文
Large-scale N-Body particle simulation system supporting million-particle GPU parallel computation and real-time visualization.
- High-Performance GPU Computing — CUDA parallel computation, million-particle real-time simulation
- Multiple Force Algorithms:
- Direct N² — O(N²) exact computation
- Barnes-Hut — O(N log N) tree approximation
- Spatial Hash — O(N) grid-based neighbor search
- Real-Time Visualization — CUDA-OpenGL interop, no CPU-GPU data transfer
- Multi-Integrator — Euler, Velocity Verlet, Leapfrog
- Interactive Control — Camera rotation/zoom, real-time parameter adjustment
- CUDA Toolkit 11.0+, CMake 3.18+, C++17
- OpenGL 3.3+, GLFW, GLEW
- GPU CC 7.0+
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j$(nproc)# Default simulation
./n_body_sim
# Custom parameters
./n_body_sim --particles 100000 --algorithm barnes-hut --dt 0.001| Particles | Direct N² | Barnes-Hut | Spatial Hash |
|---|---|---|---|
| 10K | 60 FPS | 120+ FPS | 120+ FPS |
| 100K | ~1 FPS | 60+ FPS | 90+ FPS |
| 1M | — | 15+ FPS | 30+ FPS |
Tested on RTX 3060
MIT License