General Presentation
Link to the github page
What is an nbody simulation ?
In physics and astronomy, an N-body simulation is a simulation of a dynamical system of particles, usually under the influence of physical forces, such as gravity. N-body simulations are widely used tools in astrophysics, from investigating the dynamics of few-body systems like the Earth-Moon-Sun system to understanding the evolution of the large-scale structure of the universe.
Source : wikipedia
Description of the project
The purpose of this project was to create an n-body particle simulator and run it on a Docker environment to record a video of the simulation. We also attempted to parallelize the calculations of particle interactions by using multiple Docker containers to perform the physical calculations of the simulation.
More details about the project’s architecture and dependencies can be found on the Github page of the project.
My contribution to the project
Database and API
We had to create a database to store all the particles of the simulation, allowing the different docker containers to access the particles of the simulation.
That’s why during the project, I implemented a Redis database, which is a NoSQL in-memory database. Storing the data in-memory provides the advantage of faster access compared to a traditional database, which aligns with our requirements. Since we wanted the simulation to run as quickly as possible, we aimed for fast read and write operations to the database.
Subsequently, I developed a JavaScript API to make calls to the Redis database from all the containers.
The Redis database was containerized using the official Redis image, and the API used a customized image based on Alpine.
Docker compose
In order to set up the simulation quickly, I created a Python script to generate the docker-compose file based on the number of containers used for parallelizing the calculations and the number of particles wanted in the simulation.