This Mathematica simulation is an agent-based universe in which each agent reacts to each other according to Newton's law of universal gravitation. Everything is discrete, including time.
The questions of interest are:
- How does the initial velocity of one planet affect its trajectory around the sun? How about mass? Location?
- By calculating the gravitational potential (also known as Newtonian potential) energy and the kinetic energy, we will investigate whether the total energy can be conserved in a discrete universe.
First, because of the complexity of simulating the entire solar system, only the sun and one planet are included in this model. The sun is set to be initially located at the origin. This origin position (xp, yp), the initial velocities (xv, yv), and the mass of the planet can be manipulated in the model. Each agent will interact with each other according to Newton's law of universal gravitation:
F = G * (m1 * m2) / r2
where:
F is the force between the masses,
G is the gravitational constant,
m1 is the first mass,
m2 is the second mass, and
r is the distance between the centers of the masses.
In this equation, r is calculated as √((xp1 - xp2)2 + (yp1 - yp2)2)
After that, we can apply the Newton's law of motion: F = m * a to derive the acceleration vector of each sun. Since we have the initial velocity (vt), we can obtain the velocity (v0) after each unit of time (potentially every second) using the equation vt = v0 + at. The suns will move accordingly to their velocity vectors (xv, yv) and arrive at new positions. Since our universe is discreet, we can only report the positions of all the suns discreetly at each given time. At each given time and velocity, we can calculate the total energy of each sun using the gravitational potential energy formula and kinetic energy formula:
U = -m * ∑ [G * (M / r)]
Ek = 1/2 * m * v2
The total energy of the entire universe is then calculated and presented in a graph.
By selecting the initial values for: location (distance of the planet from the sun), mass (in this simulation, we will assume the sun and the planet have equal masses), and velocity (initial velocity of the planet), we can look at how the planet would orbit around the sun.