/MA2O2-Course-Project

This repository contains the source files for the MA202 Course Project. The scripts are written in VPython. It is recommended to run them on https://glowscript.org/ or on

Primary LanguagePython

Iterative solutions for n-body simulations.

image

Code for investigating the behaviour of particles in the vicinity of $n$ massive objects. When a 3rd body is added to a 2-body system, no analytical solution exists. For the undertaking, we consider particles to be massless bodies, while massive bodies (understandably) have mass.

Techniques used include the Verlet Integration, the Euler Cromer method, using Newton's Law of Gravitation. Future plans include adding relativistic physics to the simulation.

The scripts are written in VPython. It is recommended to run them on https://glowscript.org. Check out an implementation of a binary star system collapsing here.


The velocity-Verlet algorithm

image

Verlet integration is a method used to solve the Newton’s equations of motion. It is an algorithm to perform the integration for solving the Newton’s equations. Velocity verlet method is an algorithm which has similarities to the leapfrog method. The only difference is that the velocity and position are calculated at the same value fo the time variable. The algorithm consists of clear steps to find the solution. This method uses the approach where it explicitly incorporates the velocity, solving the problem of the first time step in the basic Verlet algorithm.

Compute π‘₯(𝑑+Δ𝑑)=𝑣(𝑑)+12π‘Ž(𝑑)Δ𝑑2
Compute π‘Ž(𝑑+Δ𝑑) using the updated position
Compute 𝑣(𝑑+Δ𝑑)=𝑣(𝑑)+12(π‘Ž(𝑑)+π‘Ž(𝑑+Δ𝑑))Δ𝑑

The Euler-CrΓΆmer method

At every time step $i$ we compute the position $(x, y, z)$ and the velocity along $x$ and $y$ axis $(vx, vy, vz)$

image

– First we calculate the distance ri from the reference celestial object.
– Calculate the values of vx,i+1, vy,i+1 and vz,i+1 as vx,i+1 = v,xi+ax,i βˆ†t, vy,i+1 = vy,
  i +ay,i βˆ†t and vz,i+1 = vz,i +az,i βˆ†t.
– Now compute xi+1,yi+1 and zi+1 using vx,i+1, vy,i+1 and vz,i+1 as xi+1 = xi + vx,i+1 βˆ†t, 
  yi+1 = yi + vy,i+1 βˆ†t and zi+1 = zi + vz,i+1 βˆ†t.
– Now compute ax,i+1, ay,i+1 and az,i+1 using the new position values xi+1, yi+1 and zi+1.
– Memorize these positions xi+1, yi+1 and zi+1 and also accelerations ax,i+1, ay,i+1 and 
  az,i+1 for the next iteration.

Credits

This has been a group effort by Rahul Chembakasseril, Progyan Das, Varad Sardeshpande, Saniya Patwardhan, and Rahul Lalani.