Advertisement
Kosheen

Safe landing

Feb 28th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. # code for safe landing
  2. # http://www.codeabbey.com/index/task_view/safe-landing
  3.  
  4. [spaceship_m, fuel_m, h0, v0] = [6000, 7000, 150000, 2000]
  5. #[spaceship_m, fuel_m, h0, v0] = [6000 7000 150000 2000]
  6. H = h0 /1000; V = v0 / 1000; g0 = 1.622; dt = 0.01; Vexhaust = 2800
  7. R = 1737.1 ;
  8. fuel_speed = [0, 100, 100, 100, 50, 50, 50, 50, 50, 50, 100, 100, 100]
  9. count = 0
  10. while (H > 0):
  11. H -= V*dt
  12. if count % 1000 == 0:
  13. i = count // 1000
  14. if i < len(fuel_speed) and fuel_m > 0:
  15. Mexaust = fuel_speed[i]
  16. dM = Mexaust * dt / 10
  17. else:
  18. Mexaust = 0
  19. fuel_m -= dM
  20. # каждые 10 секунд менять Mexaust, взяв его из списка
  21. # если топливо кончилось или нет больше элементов в списке
  22. # Mexaust = 0
  23.  
  24. g_current = g0 * R**2 / (R+H)**2
  25. #print (g_current)
  26. V = V + g_current*dt / 1000
  27. #V -= Vexhaust * dM / (fuel_m + spaceship_m)
  28. count += 1
  29.  
  30. print (V, H, count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement