Skip to content

This project permits to easily see how the different bodies in a set of celestial bodies, for example the solar system, how they influence the others and how they are influenced by them. So, anyone who want to see, for example, how the solar system runs, or any other set of celestial bodies does.

License

Notifications You must be signed in to change notification settings

art-test-stack/stars_gui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stargazers MIT License LinkedIn


Logo

STARS GUI

This project has to purpose to create an animation of celestial bodies and they gravitational interactions, according to Newton's law and Euler's resolution.

This project permits to easily see how the different bodies in a set of celestial bodies, for example the solar system, how they influence the others and how they are influenced by them. So, anyone who want to see, for example, how the solar system runs, or any other set of celestial bodies does, can use it as a first step to see how a little piece of our universe can work !

However, it is only good as a first step, the equations used here are very basic, even if they handdle a big variety of situations.


Explore the docs »

Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

The Implementation

This project easily implement a resolution of Newton's gravitational law equation using Euler's method for a problem. For a defined number of celestial objects, the program compute the trajectory and provide a playful representation. The program also copute all the interactions between the different stars.

It can handles different objects called CelestialBody in the code, with different positions from the middle, velocity, masses etc... All of the details are bellow in Parameters part.

Built With

  • Numpy
  • tkinter

Getting Started

Installation

  1. Clone the repo

    git clone git@github.com:art-test-stack/stars_gui.git
  2. Create a virtual environment

    For example I use virtualenv:

    virtualenv -p python 3.10 venv
  3. Install pip packages

    pip install -r requirements.txt

The Parameters:

The different basic parameters can be found on constants.py.

from dataclasses import dataclass
from typing import List

@dataclass
class CelestialBodyBase:
    name: str 
    r_i : float
    v_i : List[float]
    mass: float
    color: str
  • name: the name of the celestial body
  • r_i: the distance to the middle of the canva (the biggest body is placed their). The angle is randomly set up on the circle defined by the middle and the radius.
  • v_i: the absolute velocity of the celestial body
  • mass: the mass of the celestial object
  • color: the color of the celestial object

The Equations:

According to Newton's law, for a set of $n$ celestial objects, we have the force applied to the $i$-th object given by:

$$F_i = - Gm_i \sum_{j=1, j\neq i}^n \frac{m_j}{r^2}\vec{u_{ij}}$$

where,

  • $G$: is the universal gravitational constant
  • $m_i$: is the mass of the $i$-th object
  • $r$: is the distance between the two objects $j$ and $i$
  • $\vec{u_{ij}}$: is the unitar vector from $i$ to $j$

Then for evey object $i$, we compute its acceleration at time-step $t$, which is simply:

$$a_i(t) = F_i(t) / m_i$$

Then, using Euler's resolution method, we have:

$$dv_i(t) = a_i(t) \cdot dt$$

$$dx_i(t) = dv_i(t) \cdot dt$$

Hence, we can compute the new velocity, the one at time $t+dt$:

$$v_i(t + dt) := v_i(t) + dv_i(t)$$

And the new position:

$$x_i(t + dt) := x_i(t) + dx_i(t)$$

Notice that the computation have been made not considering the type of the referential. In the program, everything are compute in an euclidian one.

Run The Animation:

Just run:

python main.py

Usage

After having followed every part above, python should open a window looking live the one bellow.

Logo

You can add some objects by giving them some particularities. By default, when you start simulation, it runs with all the planetaries of the solar system, plus the sun and the objects you added.

Roadmap

  • Make interactive GUI
  • Select manually different options
  • Live simulation
  • Change equations
  • Black Holes

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Arthur Testard - testardarthur@gmail.com

Project Link: https://github.com/art-test-stack/stars_gui

(back to top)

About

This project permits to easily see how the different bodies in a set of celestial bodies, for example the solar system, how they influence the others and how they are influenced by them. So, anyone who want to see, for example, how the solar system runs, or any other set of celestial bodies does.

Topics

Resources

License

Stars

Watchers

Forks

Languages