This project creates a QWidget used for simulating a gravitational system of N bodies in two dimensions.
This widget was created using Python v3.8, and using CMake v3.12. These versions are a minimum requirement. It is also recommended that you create a virtual environment and activate it before starting the installation process.
The first step is to clone the code in this repository using git:
git clone [email protected]:robertapplin/N-Body-Simulations.git
Then install the python environment requirements and Qt dependencies using pip:
pip install -r requirements.txt
Next, from within the project source directory, build and install the project. If this command fails, try running it as admin.
python setup.py install
The n-body-simulations package can now be found in the site-packages of your virtual environment.
You can also build the code locally from git bash, from your source directory and with your virtual environment activated. Pass the following
flags to the first cmake command below: -DPYTHON_EXECUTABLE
, Dpybind11_DIR
, DCMAKE_INSTALL_PREFIX
, DCMAKE_INSTALL_LIBDIR
cmake --preset=vs-debug .
cmake --build ../build
From python, you can now import and open the widget as follows:
from n_body_simulations.startup import startup_widget
startup_widget()
It is also possible to embed the widget into an existing interface.
The purpose of this project was to develop my programming skills by creating a maintainable and well-tested cross-platform application. In this project I have created a simulator for N-Body gravitational systems which allows the collision and merging of bodies. The docs folder contains example *.txt files which can be loaded into this widget.
The following units have been used for this project:
Quantity | Measured in | Unit |
---|---|---|
Mass | Solar masses | M* |
Position | Astronomical units | au |
Time | Days | d |
Velocity | Astronomical units per day | au/d |
The widget has several options which are found above the data table:
The widget also includes an interactive plot where you can: