Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- dt = 0.01
- v0 = 379.9
- R_au = 149597871000
- G = 6.67408e-11
- M_earth = 5.972e24
- M_sun = 1.9885e30
- x0 = 6371000+10000
- xend = R_au-696340000
- a_icaris = 10.04
- def acc_earth(x):
- return -G*M_earth/x**2
- def acc_sun(x):
- return G*M_sun/(R_au-x)**2
- def acceleration(x):
- return a_icaris+acc_earth(x)+acc_sun(x)
- def leap_frog(x,v,a):
- global dt
- xnew = x+v*dt+0.5*a*dt**2
- anew = acceleration(xnew)
- vnew = v+0.5*(a+anew)*dt
- return xnew, vnew, anew
- def fly():
- x = x0
- v = v0
- a = acceleration(x)
- t = 0.0
- frm = 0
- while(x<xend):
- if(frm%6000==0):
- print(x/R_au,v,a)
- x,v,a = leap_frog(x,v,a)
- frm+=1
- t+=dt
- print(x/R_au,v, a)
- print(t/3600)
- if __name__ == '__main__':
- fly()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement