Im-Rises / nbody-simulator-docker

N-body simulator using bruteforce method using docker for calculations

Home Page:https://im-rises.github.io/nbody-simulator-webgl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nbody-simulator-docker

cmakeLogo cppLogo openglLogo imGuiLogo glfwLogo

Description

This is a simple n-body simulator made with OpenGL for the graphics part and C++ for the logic part. The project is running on a complete docker environment.

Note
The project is a test of paralleling the calculation of the particles on different docker containers and store them in a redis database. A docker is also used to generate the video from the redis database.

Videos

demo-video.mp4

Longer video πŸš€πŸš€ here πŸš€πŸš€

How to use

To use the project, you need to have docker installed on your computer. You can download it here: https://www.docker.com/

You also need to install the following linux lib:

sudo apt-get install xvfb

You also need python3 installed on your computer. You can download it here: https://www.python.org/downloads/

Once you have installed the requirements, you can install the python libs with the following command:

pip install -r requirements.txt

This will install the required libs to generate the docker-compose.yml using the docker-compose-generator.py python script.

python3 docker-compose-generator.py <total_particles> <number_of_calculators> <simulation_recording_time>

exemple:

python3 docker-compose-generator.py 1000 4 10

This will generate a docker-compose.yml file with 4 calculators and 1000 particles and a simulation recording time of 10 seconds.

Once created you can run the docker-compose.yml with the following command:

./test.sh

An output video will be genereated in the ./src/NBodyGraphics/output_dir folder.

Dependencies

  • OpenGL version: 3.3
  • GLSL version: 330
  • GLFW version: 3.2.1
  • Glad version: 0.1.36
  • GLM version: 0.9.9
  • OpenCV version: 4.7.0-dev
  • nlhomann/json version: 3.9.1
  • libcurl version: 7.74.0

Architecture

flowchart LR
    
    subgraph Host
    
    subgraph Docker-Calculators
    docker1 & docker2 & docker...
    end
    docker1 & docker2 & docker... <--> |GET/POST| api-redis
    subgraph Redis
    api-redis
    end
    api-redis --> |Send particles| NBodyGraphics
    NBodyGraphics --> |Request update| api-redis
    subgraph Video-Generator
    end
    
    subgraph Video-Generator
    NBodyGraphics
    end
    
    NBodyGraphics --> |Save video | Volume
   
end

Logic Diagram

graph TB
    A((Start))
    B[NBodyGraphics]
    C[API-Redis]
    D[NBodycalculator1]
    E[NBodycalculator2]
    F[NBodycalculator3]
    G[NBodycalculator...]
    H[API-Redis]
    I[NBodyGraphics]
    J[Volume]
    
    A --> B
    B --> | Physic update | C
    C --> | Particle request update | D & E & F & G
    D & E & F & G --> | Send updated particles | H
    H --> | Send updated particles | I
    I --> | Do another cycle | B
    I --> | Save video | J

Libraries

docker:
https://www.docker.com/

cmake:
https://cmake.org/

glfw:
https://www.glfw.org/docs/latest/

glm:
https://glm.g-truc.net/0.9.9/index.html

glad:
https://glad.dav1d.de/

OpenGL:
https://www.opengl.org/

Json:
https://github.com/nlohmann/json

libcurl:
https://curl.se/libcurl/

Contributors

Axel COURMONT:

Quentin MOREL:

Alexis ROVILLE:

GitHub contributors

About

N-body simulator using bruteforce method using docker for calculations

https://im-rises.github.io/nbody-simulator-webgl/

License:MIT License


Languages

Language:C++ 78.3%Language:JavaScript 9.6%Language:Python 4.3%Language:CMake 2.9%Language:Shell 2.6%Language:Dockerfile 1.3%Language:Batchfile 1.0%Language:HTML 0.1%