Author: Nicholas Hunt-Walker
Date: Nov 18, 2014
Purpose: I want to simulate measurements for a human being accelerating up to light speed. In the future, I want to add more complicated stuff like the actual spaceship and whatnot. But let's start simple
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import os
First thing's first, an orbit at constant distance. Let's make sure that I know what I'm doing.
dt = 1
time = np.arange(0,3E3+dt,dt) # seconds
n = len(time)
M_planet = 5.97219E24 #kg; Earth
R_planet = 6.371E6 #m; Earth
r = 1E3 #m; starting distance above surface
G = 6.67384E-11
## Initial conditions
f1 = 1.
f2 = 200.
f3 = 600.
g_potential = G * M_planet / (R_planet + r)
v = np.sqrt(2*g_potential)
v_ang1 = v / (R_planet + f1*r)
v_ang2 = v / (R_planet + f2*r)
v_ang3 = v / (R_planet + f3*r)
x1_0 = R_planet + f1*r
y1_0 = 0
theta1_0 = np.arcsin(y1_0/(R_planet + f1*r))
x2_0 = R_planet + f2*r
y2_0 = 0
theta2_0 = np.arcsin(y2_0/(R_planet + f2*r))
x3_0 = R_planet + f3*r
y3_0 = 0
theta3_0 = np.arcsin(y2_0/(R_planet + f3*r))
theta1 = np.zeros(n)
x1 = np.zeros(n)
y1 = np.zeros(n)
theta1[0] = theta1_0
x1[0] = x1_0
y1[0] = y1_0
theta2 = np.zeros(n)
x2 = np.zeros(n)
y2 = np.zeros(n)
theta2[0] = theta2_0
x2[0] = x2_0
y2[0] = y2_0
theta3 = np.zeros(n)
x3 = np.zeros(n)
y3 = np.zeros(n)
theta3[0] = theta3_0
x3[0] = x3_0
y3[0] = y3_0
for ii in range(1, n):
rtot1 = R_planet + f1*r
theta1[ii] = theta1[ii-1] + v_ang1*dt
x1[ii] = rtot1*np.cos(theta1[ii])
y1[ii] = rtot1*np.sin(theta1[ii])
rtot2 = R_planet + f2*r
theta2[ii] = theta2[ii-1] + v_ang2*dt
x2[ii] = rtot2*np.cos(theta2[ii])
y2[ii] = rtot2*np.sin(theta2[ii])
rtot3 = R_planet + f3*r
theta3[ii] = theta3[ii-1] + v_ang3*dt
x3[ii] = rtot3*np.cos(theta3[ii])
y3[ii] = rtot3*np.sin(theta3[ii])
plt.figure(figsize=(6,6))
plt.plot(x1,y1)
plt.plot(x2,y2)
plt.plot(x3,y3)
plt.show()
Let's try this same thing with simple vertical projectile motion
## Setup the time steps and parameters of the potential
dt = 1.
time = np.arange(0.,3E3+dt,dt) # seconds
n = len(time)
M_planet = 5.97219E24 #kg; Earth
R_planet = 6.371E6 #m; Earth
G = 6.67384E-11
## Setup initial conditions
y0 = 0. #m; starting distance above surface
v0 = 50. #m/s
a0 = G*M_planet/(R_planet + y0)**2
## Setup arrays to be filled
y = np.zeros(n)
v = np.zeros(n)
a = np.zeros(n)
y[0] = y0
v[0] = v0
a[0] = a0
## Functions of time/position
def adot(y):
return G*M_planet/(R_planet + y)**2
def vdot(v1, a):
return v1 + a*dt
def ydo
for ii in range(n):
y[ii+1] =