N-body gravity simulation in 2 or 3 dimensions using numpy
Find a file
Michael Bradley a72b709214
All checks were successful
Lint / MyPy (push) Successful in 1m5s
Make MyPy happy
You know, I don't think this makes it more readable.
The problem is really that MPL's typed interface isn't very good, especially when dealing with 3D graphs, so I've gotta do a bunch of workaround to get around it.
2025-02-23 11:38:32 -05:00
.forgejo/workflows Try using setup-python 2025-02-23 07:11:58 -05:00
data Add 3d state with many large masses 2023-10-08 13:13:14 -04:00
.gitignore Add MyPy 2025-02-23 05:52:28 -05:00
data.py Make MyPy happy 2025-02-23 11:38:32 -05:00
gen_data.py Clean up and comment 2025-01-02 01:42:26 +13:00
main.py Clean up and comment 2025-01-02 01:42:26 +13:00
physics.py Clean up and comment 2025-01-02 01:42:26 +13:00
README.md Clean up and comment 2025-01-02 01:42:26 +13:00
requirements.txt Fix bad requirements.txt 2025-02-23 07:20:52 -05:00

nbody

Threw this together to get more comfortable with Numpy. Can simulate a few hundred bodies in 2 or 3 dimensions without much hassle.

To set up:

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

To run:

# 2d simulation
./main.py -f 2d/simple.csv

# 3d simulation, increased gravity
./main.py -f 3d/some.csv -g 30

To create a new start state:

# New 3d simulation of 100 particles in 300x200 box with max velocity components 2 and mass up to 3
./gen_data.py -c 100 -w 300 -h 200 -v 2 -m 3 > data/2d/new.csv

# New 3d simulation of 500 particles in 1000^3 box with velocity components up to 3 and mass up to 5
./gen_data.py -c 500 -d 1000 -w 1000 -h 1000 -v 3 -m 5 > data/3d/new.csv