############################################## # calculates all functions for space travels # # constant acceleration a during whole trip # using special relativity and Python. # # T: rocket time (moved system), t: earth time # s or d: distance travelled, v: velocity, # a: acceleration # # 10/2004 Wolfgang.Urban@schule.at ############################################## from math import log, exp, sqrt, sinh, cosh, tanh # constants: # we measure length in lightyears, time in years, velocity in ly/yr a = 1.03 # =g of earth, exact 1.03227 c = 1.0 # speed of light # alternatively use a=9.81 and c = 300*10**6 for meters and seconds ################################################################### # missing math functions def arsinh(x): return log(x+sqrt(x*x+1)) def arcosh(x): return log(x+sqrt(x*x-1)) ################################################################### # get earth time from rocket time def t_T(T): return c/a*sinh(a*T/c) # get rocket time from earth time def T_t(t): return c/a*arsinh(a*t/c) # get distance from earth time def s_t(t): r = sqrt(1+(a*t/c)**2) return c*c/a*(r-1) # get distance from rocket time def s_T(T): return c*c/a*(cosh(a*T/c)-1) # get speed def v_t(t): return a*t/sqrt(1.0+(a*t/c)**2) def v_T(T): return c*tanh(a*T/c) # get acceleration observed by earth def a_t(t): return a/(sqrt(1.0+(a*t/c)**2))**3 # get gamma def gamma_t(t): return sqrt(1.0+(a*t/c)**2) def gamma_T(T): return cosh(a*T/c) # gamma from travelled distance def gamma_d(d): return 1.0+a*d/c**2 # earth time from distance def t_d(d): return sqrt((d/c)**2+2.0*d/a) # rocket time from distance def T_d(d): return c/a*arcosh(1.0+a*d/c**2) ########################################################### # newtonian movement def v_t_newton(t): return a*t def s_t_newton(t): return a*t*t/2.0 def v_d_newton(d): return sqrt(2.0*a*d) def t_d_newton(d): return sqrt(2.0*d/a) ########################################################### # fuel mass calculations # fuel mass M/m from rocket time def fuel_T(T): return exp(a*T/c)-1 # get M/m needed for flyby in distance d def fuel_flyby(d): T = T_d(d) #t = t_d(d) #print "d,T,t,M",d,T,t,fuel_T(T) return fuel_T(T) # get M/m for landing in distance d def fuel_landing(d): T = T_d(d/2.0) #t = 2.0*t_d(d/2.0) M1 = fuel_T(T) # fuel mass for slowing down m M2 = (M1+1.0)*fuel_T(T) # fuel mass for speeding up M1+m M = M2+M1 # total mass of fuel #print "d,T,t,M",d,2*T,t,M return M ################################################################### ################################################################### # test all functions def test(T=1.0): T = float(T) t = t_T(T) d = s_T(T) print "T,t",T,t_T(T) print "s_T,v_T ",s_T(T),v_T(T) print "s_t,v_t,a_t ",s_t(t),v_t(t),a_t(t) print "gamma T,t,d ",gamma_T(T),gamma_t(t),gamma_d(d) print "duration T,t",T_d(d),t_d(d) ########################################################## # rocket travels for T years system time def rocket_flies_for_T(T): print "rocket time ",T print "time on earth ",t_T(T) print "distance travelled ",s_T(T) print "velocity ",v_T(T) print "gamma ",gamma_T(T) print "acceleration observed ",a_t(t_T(T)) # spacetrip with landing def spacetrip_d(d): print "spacetrip: passenger landing in distance d" T,t = T_d(d/2.0),t_d(d/2.0) print "passenger ages for",2.0*T print "earth ages for ",2.0*t print "max. velocity ",v_T(T)