import numpy as np import matplotlib.pyplot as plt import scipy.integrate as ode import matplotlib.animation as anim g_const=6.67408e-11 m_maa=5.9722e+24 gm=g_const*m_maa*1.e-9 r_maa=6371. v1=np.sqrt(gm/r_maa)*1. v1=9. print (v1) y0=[6578.,0.,0.,v1] ###--- POSSIBLE OPTIONS FOR INTAGRATION --------- ###--- Just uncomment the lines for the options you need ###--- and comment out the ones you don't. #-1-------- first option for integration ------ #def func(y,t): # dy=np.zeros_like(y) # r3=np.sqrt(y[0]**2+y[1]**2)**3 # dy[0]=y[2] # dy[1]=y[3] # dy[2]=-gm*y[0]/r3 # dy[3]=-gm*y[1]/r3 # return dy #time=np.linspace(0,600000,num=1000) #res=ode.odeint(func,y0,time) #-1-------- end of the first option for integration ------ ##-2---------- second option for integration ----- def func(t,y): dy=np.zeros_like(y) r3=np.sqrt(y[0]**2+y[1]**2)**3 dy[0]=y[2] dy[1]=y[3] dy[2]=-gm*y[0]/r3 dy[3]=-gm*y[1]/r3 return dy t0=0. dt=1. nt=200000 r = ode.ode(func) r.set_initial_value(y0, t0) res = [] t = [] it=0 while r.successful() and np.sqrt(r.y[0]**2+r.y[1]**2) > r_maa and it