54 lines
929 B
Python
54 lines
929 B
Python
import numpy as np
|
|
|
|
#Declare these as units to make code clearer
|
|
Position = np.array
|
|
Velocity = np.array
|
|
Acceleration = np.array
|
|
Mass = int
|
|
|
|
####################
|
|
# USEFUL CONSTANTS
|
|
####################
|
|
EARTH_MASS = 5.972e24 #kg
|
|
EARTH_RADIUS = 6.378e6 #meters
|
|
EARTH_ORBITAL_VELOCITY = 29.78e3
|
|
AU = 149_597_870_700 #meters
|
|
|
|
MOON_MASS = 7.34767309e22
|
|
MOON_ORBITAL_VELOCITY = 1.022e3 #m/s relative to earth
|
|
|
|
SUN_MASS = 1.989e30 #kg
|
|
SUN_RADIUS = 6.957e8 #meters
|
|
|
|
#NORMALIZING CONSTANTS
|
|
G = 6.67430e-11
|
|
r_0 = EARTH_RADIUS #1.496e11
|
|
m_0 = 5.972e24
|
|
t_0 = np.sqrt((r_0**3) / (G*m_0))
|
|
|
|
def norm_pos(pos):
|
|
return pos / r_0
|
|
|
|
def real_pos(pos):
|
|
return pos * r_0
|
|
|
|
def norm_mass(mass):
|
|
return mass / m_0
|
|
|
|
def real_mass(mass):
|
|
return mass * m_0
|
|
|
|
def norm_time(time):
|
|
return time / t_0
|
|
|
|
def real_time(time):
|
|
return time * t_0
|
|
|
|
def norm_vel(vel):
|
|
return vel / (r_0/t_0)
|
|
|
|
def real_vel(vel):
|
|
return vel * (r_0/t_0)
|
|
|
|
|