Delete orbiter/units.py
This commit is contained in:
parent
7fb4415371
commit
11a6549896
@ -1,74 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
#Declare these as units to make code clearer
|
|
||||||
class HighPrecisionVector(np.ndarray):
|
|
||||||
def __new__(cls, input_array, *args, **kwargs):
|
|
||||||
decimal_array = [Decimal(i) for i in input_array]
|
|
||||||
obj = np.asarray(decimal_array).view(cls)
|
|
||||||
return obj
|
|
||||||
|
|
||||||
class HighPrecisionMatrix(np.ndarray):
|
|
||||||
def __new__(cls, dim1, dim2, *args, **kwargs):
|
|
||||||
decimal_array = [Decimal(0) for _ in range(dim1)]
|
|
||||||
decimal_matrix = [decimal_array for _ in range(dim2)]
|
|
||||||
obj = np.asarray(decimal_matrix).view(cls)
|
|
||||||
return obj
|
|
||||||
|
|
||||||
class Position(HighPrecisionVector):
|
|
||||||
pass
|
|
||||||
class Velocity(HighPrecisionVector):
|
|
||||||
pass
|
|
||||||
class Acceleration(HighPrecisionVector):
|
|
||||||
pass
|
|
||||||
|
|
||||||
Mass = Decimal
|
|
||||||
|
|
||||||
####################
|
|
||||||
# USEFUL CONSTANTS
|
|
||||||
####################
|
|
||||||
EARTH_MASS = Decimal(5972 * 10**21) #kg
|
|
||||||
EARTH_RADIUS = Decimal(6378 * 10**3) #meters
|
|
||||||
EARTH_ORBITAL_VELOCITY = Decimal(29780) # m/s
|
|
||||||
AU = Decimal(149_597_870_700) #meters
|
|
||||||
|
|
||||||
MOON_MASS = Decimal(734767309 * 10**14)
|
|
||||||
MOON_ORBITAL_VELOCITY = Decimal(1022) #m/s relative to earth
|
|
||||||
|
|
||||||
SUN_MASS = Decimal(1989 * 10**27) #kg
|
|
||||||
SUN_RADIUS = Decimal(6957 * 10**5) #meters
|
|
||||||
|
|
||||||
pi_approx = Decimal("3.14159265358979323846264338327950288419716939937510")
|
|
||||||
|
|
||||||
|
|
||||||
#NORMALIZING CONSTANTS
|
|
||||||
G = Decimal(6.67430e-11)
|
|
||||||
r_0 = Decimal(EARTH_RADIUS) #1.496e11
|
|
||||||
m_0 = Decimal(5.972e24)
|
|
||||||
t_0 = np.sqrt((r_0**3) / (G*m_0))
|
|
||||||
|
|
||||||
def norm_pos(pos):
|
|
||||||
return Decimal(pos) / Decimal(r_0)
|
|
||||||
|
|
||||||
def real_pos(pos):
|
|
||||||
return pos * Decimal(r_0)
|
|
||||||
|
|
||||||
def norm_mass(mass):
|
|
||||||
return Decimal(mass) / Decimal(m_0)
|
|
||||||
|
|
||||||
def real_mass(mass):
|
|
||||||
return Decimal(mass) * Decimal(m_0)
|
|
||||||
|
|
||||||
def norm_time(time):
|
|
||||||
return Decimal(time) / Decimal(t_0)
|
|
||||||
|
|
||||||
def real_time(time):
|
|
||||||
return Decimal(time) * Decimal(t_0)
|
|
||||||
|
|
||||||
def norm_vel(vel):
|
|
||||||
return vel / Decimal(r_0/t_0)
|
|
||||||
|
|
||||||
def real_vel(vel):
|
|
||||||
return vel * Decimal(r_0/t_0)
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user