Skip to content

Latest commit

 

History

History
55 lines (32 loc) · 1.3 KB

File metadata and controls

55 lines (32 loc) · 1.3 KB

Python Gravity Simulation

A 3D n-body gravity simulation written in Python.

Installation

Clone the repository and install in a virtual environment:

git clone https://github.com/callummscott/gravity_simulation.git
cd gravity_simulation
python -m venv .venv
source .venv/bin/activate    # on Windows: .venv\Scripts\activate
pip install -e .

To include test dependencies, use pip install --group test instead.

Requires Python 3.12 or newer.

Usage

Run the simulation with:

python -m gravity_simulation

This runs the simulation with default settings and displays a 3D plot of the resulting trajectories.

To change the settings for the simulation, such as:

  • the number of particles
  • the number and size of the timesteps
  • the maximum masses, distances, and speeds of the randomly-generated particles
  • the number of points displayed in the final plot
  • and more...

just check out and edit the contents of the config.yaml.

Tests

First install the optional test dependencies and then run the test suite from the project root with pytest.

What now?

Thanks for reading! If you want to read a little bit more about the thought behind the code, check out docs/deep-dive.md.

Enjoy messing around with it! - Callum