def elliptical_transfer( f_POD, f_target, Theta, e_trans, a_trans, e_target, a_target, T_target, T_target0, e_POD, a_POD, T_POD, T_POD0, mu, return_path_option = 0, ): """Elliptical transfer. Requires: f_POD: true anomaly of planet of departure at time of transfer; f_target: true anomaly of target planet at time of transfer; Theta: difference between target orbit and orbit of departure longitude of perihelion; e_trans: transfer orbit eccentricity; a_trans: transfer orbit semi-major axis; e_target: target orbit eccentricity; a_target: target orbit semi-major axis; T_target: target orbit period; T_target0: target orbit period advance at epoch; e_POD: planet of departure orbit eccentricity; a_POD: planet of departure orbit seim-major axis; T_POD: planet of departure orbit period; T_POD0: planet of departure period advnace at epoch; mu: standard gravitational parameter of central body; return_path_option: set 1 for yes and 0 for no. """ lower = (a_target < a_POD) # Kind is either 0 for raising orbit and 1 for lowering orbit. f_TOA = OT.f_elliptic_transfer(f_POD, Theta, e_trans, a_trans, e_target, a_target, return_path_option, lower) # True anomaly of transfer on arrival. T_trans = OT.t_of_M_a(a_trans, mu, OT.M_of_E(e_trans, OT.E_of_f(e_trans, f_TOA))-np.cos(return_path_option*np.pi)*np.pi*lower) # Transfer time. f_PTOA = OT.f_of_E( e_target, OT.E_of_M( e_target, OT.M_of_t( T_target, T_target0 + t + T_trans) ) ) # Target planet true anomaly on arrival. if abs(f_PTOA-(f_TOA+f_POD-np.cos(lower*np.pi)*Theta-np.pi*lower)) < 0.5*np.pi/180: f_PODOA = OT.f_of_E( e_POD, OT.E_of_M( e_POD, OT.M_of_t( T_POD, T_POD0 + t + T_trans) ) ) # Earth true anomaly on Mars arrival for Hohmann transfer. if lower == 0: #print 'Date of outbound transfer [Julian Day Number]: \n' + str(JDN) output = 'OT.transfer_plot('+str(f_POD) +', ' + str(f_PODOA) +', '+str(f_target)+', '+str(f_TOA+f_POD-np.cos(lower*np.pi)*Theta-np.pi*lower)+', '+str(Theta)+', '+ str(a_trans)+', '+str(e_trans)+',' +str(a_POD)+','+ str(e_POD)+', '+str(a_target)+', '+str(e_target)+', '+str(JDN)+')' else: #print 'Date of return transfer [Julian Day Number]: \n' + str(JDN) output = 'OT.plot_return('+str(f_M) +', ' + str(f_PODOA) +', '+str(f_E)+', '+str(f_TOA+f_M+Theta-np.pi)+', '+str(Theta)+', '+ str(a_trans)+', '+str(e_trans)+',' +str(Mars.a)+','+ str(Mars.e)+', '+str(Earth.a)+', '+str(Earth.e)+', '+str(JDN)+')' return np.array([JDN, JDN+T_trans/86400, T_trans, a_trans, e_trans, a_target, e_target, a_POD, e_POD, f_E, f_M, f_TOA, f_PTOA, f_PODOA, return_path_option, lower])
# Mars Period Advance at Epoch E = OT.E_of_f( Mars.e, fM0 ) M = OT.M_of_E( Mars.e, E) T_M0 = OT.t_of_M_T( Mars.T, M ) out_transfers = np.zeros([16]) return_transfers = np.zeros([16]) # Loop to solve for trajectories. for t in xrange(0, t_max + step, step): JDN = (JDN0*86400+t)/86400 # Julian Day Number #print JDN # Planet positions over time. f_E = OT.f_of_E( Earth.e, OT.E_of_M( Earth.e, OT.M_of_t( Earth.T, T_E0 + t ) ) ) # Earth True anomaly given period advance from epoch f_M = OT.f_of_E( Mars.e, OT.E_of_M( Mars.e, OT.M_of_t( Mars.T, T_M0 + t ) ) ) # Mars True anomaly given period advance from epoch ########################################## ######## Hohmann Transfer Options ######## f_MH = f_E - Theta + np.pi # Mars true anomaly on arrival for Hohmann transfer. R_MH = Mars.a*(1 - Mars.e**2)/(1 + Mars.e*np.cos(f_MH)) # Radial distance to Mars for Hohmann transfer. R_EH = Earth.a*(1 - Earth.e**2)/(1 + Earth.e*np.cos(f_E)) # Radial distance to Earth for Hohmann transfer. a_H = (R_MH + R_EH) / 2 e_H = (R_MH - R_EH) / (R_MH + R_EH) T_H = np.pi*(a_H**3/muSun)**(1/2) f_MHA = OT.f_of_E( Mars.e, OT.E_of_M( Mars.e, OT.M_of_t( Mars.T, T_M0 + t + T_H) ) ) # Mars true anomaly after desired Hohmann transfer time.