1. The orbit of a planet follows an ellipse pattern with the Sun at one focus
2. A line joining the Sun and an orbiting planet will cover equal areas with equal intervals of time
3. The square of a planet's orbital period is proportional to the cube of the length of the orbit's semimajor axis
$mr\omega\ = \frac{GmM}{r^2}$
$\omega\ = \frac{2\pi}{T}$
$T = 2\pi\sqrt{\frac{r^3}{GM}}$
$T = 2\pi\sqrt{\frac{r^3}{G(M + m)}}$
1. T = planet orbital period, or time for one full revolution around the star, in seconds
2. r = radius of the planet's orbit from the star (center of mass from center of mass)
3. G = gravitational constant, 6.67*10^-11
4. M = mass of the center star being orbited
5. m = mass of the planet orbiting around the center star
$\omega = \frac{2\pi}{T}$
$\theta = \omega t$
# Importing calculation software
import numpy as np
import pandas as pd
import pylab as pl
#Position of a planet in radians after a certain time t
def compute_angle_position(M, m, t, r):
G = 6.67e-11
T = (2*np.pi)*np.sqrt((r**3)/(G*(M+m)))
omega = (2*np.pi)/T
return(omega*t)
#This cell simply checks if the formula above is correct. For data of earth's orbit around the sun, after 365 days written in seconds we should get a displacement of close to 2pi radians.
theta = compute_angle_position(1.99e30, 5.97e24, 365*24*3600, 1.5e11)
print(theta)
6.2540280526809795
#This will compute the angular positions of Earth and Venus after one Earth year.
theta_venus = []
theta_earth = []
times = []
for t in range(0, 365):
times.append(t)
theta_venus.append(compute_angle_position(1.99e30, 4.88e24, t*24*3600, 1.08e11))
theta_earth.append(compute_angle_position(1.99e30, 5.97e24, t*24*3600, 1.5e11))
#This cell will create a graph relating the positions of Earth and Venus after one Earth year.
pl.plot(times, theta_venus, label="Venus")
pl.plot(times, theta_earth, label="Earth")
pl.xlabel("Time (Days)")
pl.ylabel("Angular displacement (radians)")
pl.legend()
<matplotlib.legend.Legend at 0x7f619703a7f0>
$\hat{r}_v = \cos\theta_{\rm inner} \hat{i} + \sin\theta_{\rm inner} \hat{j}$
$\hat{r}_e = \cos\theta_{\rm outer} \hat{i} + \sin\theta_{\rm outer} \hat{j}$
$\hat{r}_{\rm inner} . \hat{r}_{\rm outer} = \cos\theta_{\rm inner} \cos\theta_{\rm outer} + \sin\theta_{\rm inner} \sin\theta_{\rm outer}$
"""The function below takes the masses of the two planets, the mass of the star,
the radii of the planets, and the time since the last alignment, and calculates the
dot product of the unit radial vectors of the two planets connecting the star.
PARAMETERS:
===========
t = Elapsed time at which the angular position is being computed (days)
m1 = Mass of the inner planet (default = mass of Venus)
m2 = Mass of the outer planet (default = mass of Earth)
m_star = Mass of the star (default = mass of the Sun)
r1 = Radius of the orbit of the inner planet (default = radius of orbit of Venus)
r2 = Radius of the orbit of the outer planet (default = radius of orbit of Earth)
RETURNS:
========
dot product of the radial vectors of the two planets with their star.
"""
def dot_product_rad_vect(t, m1=4.88e24, m2=5.97e24, m_star=1.99e30, r1=1.08e11, r2=1.5e11):
twoPi = 2*np.pi
theta_planet_inner = compute_angle_position(m_star, m1, t*24*3600, r1)
theta_planet_outer = compute_angle_position(m_star, m2, t*24*3600, r2)
dot_prod = np.cos(theta_planet_inner)*np.cos(theta_planet_outer) +\
np.sin(theta_planet_inner)*np.sin(theta_planet_outer)
return dot_prod
times = [] # To store the times for graphing
dot_prods = [] # To store the dot products for graphing
for t in range(0, 10*365): # To graph for ten years, calculated in days
times.append(t)
dot_prods.append(dot_product_rad_vect(t))
# This cell will graph time in days vs dot product of radial position vectors
pl.rcParams.update({'font.size': 18})
pl.figure(figsize=(25,6))
pl.plot(times, dot_prods)
pl.xlabel("Time (days)")
pl.ylabel("Dot product of the radial position vectors")
pl.show()
#This code will make sure that only the relative maximum points are taken for each peak.
T = []
for ii in range(1, len(times)-1):
if (dot_prods[ii-1] < dot_prods[ii]) and (dot_prods[ii] > dot_prods[ii+1]):
T.append(times[ii])
# This code will add lines at the graph peaks, or points of alignment
pl.rcParams.update({'font.size': 18})
pl.figure(figsize=(25,6))
pl.plot(times, dot_prods)
for thisT in T: # Plotting vertical lines at the points of alignment
pl.plot([thisT, thisT], [-1, 1], 'r--')
pl.xlabel("Time (days)")
pl.ylabel("Dot product of the radial vectors")
pl.ylim([-1.1, 1.1])
pl.show()
# Display of alignment times
print("Consecutive alignment times for the next ten years after initial alignment:")
for tt in T:
print("{} years".format(round(tt/365, 2)))
Consecutive alignment times for the next ten years after initial alignment: 1.58 years 3.16 years 4.73 years 6.31 years 7.89 years 9.47 years
"""This function takes given masses and orbital radii of the planets as
an array, as well as the mass of the star and the time since the last alignment, and calculates
the sum of the dot products of the unit radial vectors connecting the star and one of
the planets with the other planets.
PARAMETERS:
===========
t = Elapsed time at which the angular position is being computed (days)
m_array = Array of the masses of all the planets.
r_array = Array of the radii of the orbits of all the planets
m_star = Mass of the star (default = mass of the Sun)
RETURNS:
========
Sum of the dot product of the radial vectors.
"""
def multiple_planet_alignment(t, m_array, r_array, m_star=1.99e30):
twoPi = 2*np.pi
theta_planet_first = compute_angle_position(m_star, m_array[0], t*24*3600, r_array[0])
dot_prod = 0
for ii in range(1, len(m_array)):
theta_planet = compute_angle_position(m_star, m_array[ii], t*24*3600, r_array[ii])
dot_prod += np.cos(theta_planet_first)*np.cos(theta_planet) +\
np.sin(theta_planet_first)*np.sin(theta_planet)
return dot_prod
m_array = [4.88e24, 5.97e24]
r_array = [1.08e11, 1.5e11]
times_new = [] # To store the time steps for plotting
dot_prods_new = [] # To store the dot product for plotting
for t in range(0, 10*365):
times_new.append(t)
dot_prods_new.append(multiple_planet_alignment(t, m_array, r_array))
pl.rcParams.update({'font.size': 18})
pl.figure(figsize=(25,6))
pl.plot(times_new, dot_prods_new)
pl.xlabel("Time (days)")
pl.ylabel("Dot product of the radial vectors")
pl.show()
# This cell will graph the time in days versus sum of the dot products of the radial vectors
m_array = [3.29e23, 4.88e24, 5.97e24, 6.39e23]
r_array = [5.79e10, 1.08e11, 1.5e11, 2.28e11, 2.27e11]
times_triple = []
dot_prods_triple = []
for t in range(0, 100*365):
times_triple.append(t)
dot_prods_triple.append(multiple_planet_alignment(t, m_array, r_array))
pl.rcParams.update({'font.size': 18})
pl.figure(figsize=(25,6))
pl.plot(times_triple, dot_prods_triple)
pl.xlabel("Time (days)")
pl.ylabel("Sum of dot products of the radial vectors")
pl.show()
# Finding the peaks of the graph above
peaks_triple = []
peak_values = []
for ii in range(1, len(times_triple)-1):
if (dot_prods_triple[ii-1] < dot_prods_triple[ii]) and (dot_prods_triple[ii] > dot_prods_triple[ii+1]):
peak_values.append(dot_prods_triple[ii])
peaks_triple.append(times_triple[ii])
# Making sure that only the peaks are listed in the graph
peaks_triple = np.array(peaks_triple)
peak_values = np.array(peak_values)
# Graphing the times and relative peaks of the function
pl.rcParams.update({'font.size': 18})
pl.figure(figsize=(25,6))
pl.plot(peaks_triple, peak_values)
pl.xlabel("The times at which peaks are seen in days")
pl.ylabel("The peak values ")
pl.show()
cases = peak_values > 2.9 # How many cases of the sum of dot products > 2.9
print(np.sum(cases))
8
cases = peak_values > 2.99 # How many cases of the sum of dot products > 2.99
print(np.sum(cases))
1
# Printing the alignment time(s) in Earth years
peaks_triple[cases]/365
print("Years until next alignment: {} years".format(peaks_triple[cases]/365))
Years until next alignment: [64.65479452] years