RepositoryC++USUnited States
PWhiddy

PWhiddy/Nbody-Gravity

A small but powerful nbody gravity simulator with a built-in renderer

113stars
15forks
1issues
0views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: dark-matter

#1 Repository of the week

1
TINIX TRENDING·Topic: nbody

#1 Repository of the week

1
TINIX TRENDING·Topic: gravity

#1 Repository of the week

Nbody Gravity Simulator

Implements the Barnes–Hut algorithim to handle the gravitional interaction of over a million particles in 3D space. Currently set up to generate disks of particles Includes a renderer that produces high quailty PPM images of the simulation. These can be compiled into animations. Example

Setup

Use build.bash to create the program. That's it! Executing "run" will immediately start simulating and rendering to the images folder until canceled or frame limit is reached. Note: This may consume significant storage space.

Note: Some versions of clang on MacOS do not support openmp. You can build using another compiler or simply by removing the -fopenmp option from build.sh (this will incur a performance decrease of course)

Initial conditions parameters can be modified in the Constants.h file, and are baked into the program so build must be run again after making changes.

If you have ffmpeg you can use createVideo.bash to generate a video from the images.

Images

Initialized as a uniform disk alt tag

Higher disk mass alt tag

"Hot" Disk alt tag

Outtakes

Many interesting things happened as I frequenty broke my code alt tag alt tag alt tag alt tag

Similar Projects

Discover other similar projects and AI models.

RepositoryC++
jrouwe/JoltPhysics

A multi core friendly rigid body physics and collision detection library. Written in C++. Suitable for games and VR applications. Used by Horizon Forbidden West and Death Stranding 2.

12.7k
Dec 3, 2026
RepositoryC++
MarcVivas/N-body

N-body simulation made with C++ and OpenGL

56
May 24, 2025
RepositoryPython
st-tech/ppf-contact-solver

A contact solver for physics-based simulations involving 👚 shells, 🪵 solids, 🪢 rods, 🧱 rigid bodies and ⏳ sand.

4.6k
Nov 28, 2026
RepositoryRust
avianphysics/avian

ECS-driven 2D and 3D physics engine for the Bevy game engine.

3.3k
Nov 30, 2026
RepositoryPython
Xin-YuXiao/Awesome-AI-for-Astronomy

A curated list of papers for AI in Astronomy & Astrophysics.

427
Dec 1, 2026
RepositoryPython
gwastro/pycbc

Core package to analyze gravitational-wave data, find signals, and study their parameters. This package was used in the first direct detection of gravitational waves (GW150914), and is used in the ongoing analysis of LIGO/Virgo data.

395
Nov 27, 2026
RepositoryPython
lenstronomy/lenstronomy

Multi-purpose lens modeling software package

226
Dec 1, 2026
RepositoryPython
PyAutoLabs/PyAutoLens

PyAutoLens: Open-Source Strong Gravitational Lensing

189
Nov 28, 2026
RepositoryC
SWIFTSIM/SWIFT

Modern astrophysics and cosmology particle-based code. Mirror of gitlab developments at https://gitlab.cosma.dur.ac.uk/swift/swiftsim

164
Nov 26, 2026