Advertisement
Guest User

ACorbit

a guest
Aug 2nd, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. PARAMETER Targetheight. // Prograde burn only!
  2. PARAMETER Targetheightx.
  3. SET SMA TO (APOAPSIS + 600000 + PERIAPSIS + 600000)/2.
  4. SET SMAF TO (Targetheight + 600000 + APOAPSIS + 600000)/2. // APOAPSIS MAY HAS TO BE CHANGED TO PERIAPSIS!!!!!!
  5. SET Transfer1 TO SQRT(3531600000000*((2/(APOAPSIS + 600000))-(1/SMA))).
  6. SET Transfer2 TO SQRT(3531600000000*((2/(APOAPSIS + 600000))-(1/SMAF))).
  7. print transfer1.
  8. print transfer2.
  9. SET APKM TO ROUND(APOAPSIS/1000).
  10. SET TARKM TO ROUND(Targetheight/1000).
  11. SET PEKM TO ROUND(PERIAPSIS/1000).
  12. SET DeltaVneeded TO Transfer2-Transfer1.
  13.  
  14. //node creation
  15.  
  16. SET n to NODE(TIME:SECONDS + ETA:APOAPSIS, 0, 0, DeltaVneeded).
  17. ADD n.
  18.  
  19. SET n TO NEXTNODE.
  20. LOCK STEERING TO n:BURNVECTOR.
  21.  
  22. //calculations of burn time
  23.  
  24. SET a0 TO maxthrust / mass.
  25.  
  26. SET eIsp TO 0.
  27. LIST engines IN my_engines.
  28. FOR eng IN my_engines {
  29. SET eIsp TO eIsp + eng:maxthrust / maxthrust * eng:isp.
  30. }
  31.  
  32. SET Ve TO eIsp * 9.80665.
  33.  
  34. SET final_mass TO mass*CONSTANT():e^(-1*n:BURNVECTOR:MAG/Ve).
  35.  
  36. SET a1 TO maxthrust / final_mass.
  37.  
  38. SET t TO n:BURNVECTOR:MAG / ((a0 + a1) / 2).
  39.  
  40. SET start_time TO TIME:SECONDS + n:ETA - t/2.
  41. SET end_time TO TIME:SECONDS + n:ETA + t/2 - 0.5.
  42.  
  43. WAIT UNTIL TIME:SECONDS >= start_time.
  44. LOCK throttle TO 1.
  45. WAIT UNTIL TIME:SECONDS >= end_time.
  46. LOCK throttle TO 0.
  47.  
  48. remove n.
  49. unlock steering.
  50. unlock throttle.
  51.  
  52.  
  53. WAIT 10.
  54. HUDTEXT ("We are go", 15, 2, 50, WHITE, false).
  55.  
  56.  
  57. //
  58. // AP INCREASE
  59. //
  60.  
  61. SET SMA2 TO (APOAPSIS + 600000 + PERIAPSIS + 600000)/2.
  62. SET SMAF2 TO (Targetheightx + 600000 + APOAPSIS + 600000)/2.
  63. SET Transfer3 TO SQRT(3531600000000*((2/(APOAPSIS + 600000))-(1/SMA2))).
  64. SET Transfer4 TO SQRT(3531600000000*((2/(APOAPSIS + 600000))-(1/SMAF2))).
  65. print transfer3.
  66. print transfer4.
  67. SET APKM2 TO ROUND(APOAPSIS/1000).
  68. SET TARKM2 TO ROUND(Targetheightx/1000).
  69. SET PEKM2 TO ROUND(PERIAPSIS/1000).
  70. SET DeltaVneeded2 TO Transfer4 - Transfer3.
  71. Print (DeltaVneeded2) + " DeltaV needed to go into " + TARKM2 + "Km by " + APKM2 + "Km orbit".
  72. HUDTEXT(ROUND(DeltaVneeded2) + " DeltaV needed to go into " + TARKM2 + "Km by " + APKM2 + "Km orbit", 15, 2, 50, WHITE, false).
  73.  
  74.  
  75. //node creation
  76.  
  77. SET m to NODE(TIME:SECONDS + ETA:APOAPSIS, 0, 0, DeltaVneeded2).
  78. ADD m.
  79.  
  80. SET m TO NEXTNODE.
  81. LOCK STEERING TO m:BURNVECTOR.
  82.  
  83. //calculations of burn time
  84.  
  85. SET a2 TO maxthrust / mass.
  86.  
  87. SET eIsp2 TO 0.
  88. LIST engines IN my_engines.
  89. FOR eng IN my_engines {
  90. SET eIsp2 TO eIsp2 + eng:maxthrust / maxthrust * eng:isp.
  91. }
  92.  
  93. SET Ve2 TO eIsp2 * 9.80665.
  94.  
  95. SET final_mass2 TO mass*CONSTANT():e^(-1*m:BURNVECTOR:MAG/Ve2).
  96.  
  97. SET a3 TO maxthrust / final_mass2.
  98.  
  99. SET t2 TO m:BURNVECTOR:MAG / ((a2 + a3) / 2).
  100.  
  101. SET start_time2 TO TIME:SECONDS + m:ETA - t2/1.75.
  102. SET end_time2 TO TIME:SECONDS + m:ETA + t2/2 - 1.
  103.  
  104. WAIT UNTIL TIME:SECONDS >= start_time2.
  105. LOCK throttle TO 1.
  106. WAIT UNTIL TIME:SECONDS >= end_time2.
  107. LOCK throttle TO 0.
  108.  
  109. if TargetHeightx >= periapsis {
  110. set throt to 0. // variable to hold current throttle value
  111. set scalefactor to 1.2. // scalefactor is some value based on the power of your engine
  112. lock throttle to thrott. // lock the throttle to follow the value of the variable
  113. until periapsis + 200 >= TargetHeightx {
  114. set thrott to min(((TargetHeightx - periapsis)/Targetheightx) * scalefactor, 0.01). // use min to prevent it going completely to zero
  115. wait 0.01. // wait one tick before recalculating
  116. }
  117. }
  118.  
  119. lock throttle to 0. // kill throttle
  120.  
  121. Remove m.
  122. unlock steering.
  123. unlock throttle.
  124.  
  125. LOCK STEERING TO PROGRADE.
  126. WAIT 10.
  127. STAGE.
  128. WAIT 3.
  129. LOCK STEERING TO RETROGRADE.
  130. WAIT 10.
  131. RUN ADORBIT(88624, 749500).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement