N-Body Simulation in Python

What is the N-Body Problem?

In physics, the n-body problem is the problem of predicting the individual motions of a group of celestial objects interacting with each other gravitationally. Solving this problem has been motivated by the desire to understand the motions of the Sun, Moon, planets, and visible stars. (Wikipedia).

Project #1

Use the algorithm/code described in the " Astrophysics: N-Body Simulation in Python" video.

Convert from VPython to graphics.py (graphics library). See VPython .

Is there a different graphics library you would rather use for this project?

Links

n-body problem (Wikipedia)

Astrophysics: N-Body Simulation in Python (YouTube)

Python Physics: Using Web VPython to Illustrate a Physics Question (YouTube)

These equations are not needed for this project but may help you understand the code better.

Force, Mass, and Accelerations

F = m*a F force on an object m mass of an object a acceleration

Distance Traveled Under Acceleration

d = v*Δt + ½*a*Δt2 Finds the distance traveled (d) of an object with an initial velocity (v), acceleration (a), and time (Δt) traveled. d distance traveled v initial velocity (speed and direction) Δt time traveled a acceleration

Note: A mass accelerating at 32 f/s2 will travel 16 feet in one second, not 32 feet.

The Gravitation Force Between Two Objects

G*m1*m2 F = ------- r2 F is an attractive force acting along a line joining the two centers of mass G gravitational constant m1 mass of object 1 m2 mass of object 2 r distance between the center of the two masses

Momentum

Note: Newton's first law states that every object will remain at rest or in uniform motion in a straight line unless acted on by an external force.

Momentum is a measure of how much motion an object has. It is determined by its mass and velocity. Essentially, it reflects how difficult it is to stop a moving object, with more momentum indicating greater resistance to change in motion. (e.g. A truck is harder to stop than a bicycle.)

p = m*v p object's momentum m object's mass v object's velocity (speed and direction)

A force applied to an object for a specific time interval will cause a change in its momentum.

In other words, To change the momentum of an object, you need to either change its mass or its velocity, or both.

Δp = m*Δv Δp change in momentum m mass (does not change in this project) Δv change in velocity (speed and direction)