Advertisement
Guest User

Ikaris flight

a guest
Jan 21st, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4.  
  5. dt = 0.01
  6.  
  7. v0 = 379.9
  8. R_au = 149597871000
  9. G = 6.67408e-11
  10. M_earth = 5.972e24
  11. M_sun = 1.9885e30
  12.  
  13. x0 = 6371000+10000
  14. xend = R_au-696340000
  15.  
  16. a_icaris = 10.04
  17.  
  18. def acc_earth(x):
  19.     return -G*M_earth/x**2
  20.  
  21.  
  22. def acc_sun(x):
  23.     return G*M_sun/(R_au-x)**2
  24.  
  25. def acceleration(x):
  26.     return a_icaris+acc_earth(x)+acc_sun(x)
  27.  
  28. def leap_frog(x,v,a):
  29.     global dt
  30.     xnew = x+v*dt+0.5*a*dt**2
  31.     anew = acceleration(xnew)
  32.     vnew = v+0.5*(a+anew)*dt
  33.     return xnew, vnew, anew
  34.  
  35. def fly():
  36.     x = x0
  37.     v = v0
  38.     a = acceleration(x)
  39.     t = 0.0
  40.     frm = 0
  41.     while(x<xend):
  42.         if(frm%6000==0):
  43.             print(x/R_au,v,a)
  44.         x,v,a = leap_frog(x,v,a)
  45.         frm+=1
  46.         t+=dt
  47.  
  48.     print(x/R_au,v, a)
  49.     print(t/3600)
  50.  
  51. if __name__ == '__main__':
  52.     fly()
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement