HvrdlS

IFT-3 FUEL TILL ORBIT

Jul 8th, 2024
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.85 KB | None | 0 0
  1. clearscreen.
  2. on ag10 {
  3. abortflight().
  4. }
  5.  
  6. prep().
  7. fuel().
  8. countdown().
  9. flight().
  10.  
  11.  
  12. function inflightvars {
  13. set g to constant:g * body:mass / body:radius^2.
  14. set altit to alt:radar-h.
  15. if sep = 1 {
  16. set gravityturn to 90-(((ship:apoapsis/(TargetAp-10000))^0.9)*90).
  17. } else {
  18. set gravityturn to 90-((((ship:apoapsis/TargetAp)^0.85))*90).
  19. }
  20.  
  21. if ship:maxthrust > 0 {
  22. set twr to ship:mass * g / ship:availablethrust.
  23. } else if ship:maxthrust = 0 {
  24. set twr to 0.
  25. }
  26. }
  27.  
  28.  
  29. function printing {
  30. clearscreen.
  31. if ship:status = "Preflight" or ship:verticalspeed < 1 or altit >= h - 1 or altit <= h + 1{
  32. print "Time from test beginning: " + round(testtime,1) + " Seconds".
  33. if ti >= 0 {
  34. print "T-: " + round(ti,1) + " Seconds".
  35. set ti to (now1 - time:seconds)+10.
  36. }
  37. } else {
  38. print "T+: " + round(testtime,1) + " Seconds".
  39. }
  40.  
  41. print "Status: " + teststatus.
  42. print "Target apoapsis: " + TargetAp + " Meters".
  43. print "Target periapsis: " + TargetPe + " Meters".
  44. print "Azimuth: " + Azimuth.
  45. print "Time(KSC): " + time:clock.
  46. print "Press 10 to abort program".
  47. }
  48.  
  49.  
  50. function prep {
  51. ag1 on. // LOX vents on Booster off, Header Tank vents on Ship off.
  52. ag2 on. // CH4 vents on Ship and Booster off.
  53. ag3 on. // Engine chill vents on Booster off.
  54. ag4 on. // 3 engine chill vents on Ship off.
  55. ag6 on. // Ship and Booster LOX dump vent off.
  56. lights on.
  57. set teststatus to "Software preparations".
  58. set liftoff to 0.
  59. set TargetAp to 117500.
  60. set TargetPe to 20000.
  61. set Azimuth to 115.
  62. set FinalAzimuth to 90.
  63. set landingZone to latlng(0,-170).
  64. set PitchKickAlt to 500.
  65. set sec to 5.
  66. set minut to 51.
  67. set hour to 4.
  68. set clock to "04:51:05".
  69. set now1 to time:seconds + ((hour-time:hour)*60+minut-time:minute)*60+(sec-time:second).
  70. set ti to (now1 - time:seconds)+10.
  71. set steeringManager:maxstoppingtime to 0.03.
  72. set fte to ship:partstagged("fte").
  73. set ring to ship:partstagged("ring")[0].
  74. set bt to ship:partstagged("bts")[0].
  75. set rb1 to bt:resources.
  76. set rb2 to rb1[0].
  77. set rb3 to rb1[1].
  78. set rb2:enabled to true.
  79. set rb3:enabled to true.
  80. set hts to ship:partsnamed("externalTankRound").
  81. set rs1 to hts[0].
  82. set rs2 to hts[1].
  83. set rs3 to rs1:resources.
  84. set rs4 to rs2:resources.
  85. set rs5 to rs3[0].
  86. set rs6 to rs3[1].
  87. set rs7 to rs4[0].
  88. set rs8 to rs4[1].
  89. set rs5:enabled to true.
  90. set rs6:enabled to true.
  91. set rs7:enabled to true.
  92. set rs8:enabled to true.
  93. set h to alt:radar.
  94. set sep to 0.
  95. set eng1 to ship:partstagged("VectorS1")[0].
  96. set eng2 to ship:partstagged("VectorS2")[0].
  97. set eng3 to ship:partstagged("VectorS3")[0].
  98. set eng4 to ship:partstagged("VectorVac1")[0].
  99. set eng5 to ship:partstagged("VectorVac2")[0].
  100. set eng6 to ship:partstagged("VectorVac3")[0].
  101. set engList to list().
  102. set i to -1.
  103. until i >= 32 {
  104. set i to i + 1.
  105. engList:add(ship:partstagged("Vector" + i)[0]).
  106. }
  107.  
  108. for eng in engList { eng:shutdown. }
  109. inflightvars().
  110. set now to time:seconds.
  111. lock testtime to time:seconds - now.
  112. set teststatus to "Beginning fueling, time from beginning: " + round(testtime,1) + " Seconds".
  113. }
  114.  
  115. function fuel {
  116. ag1 off. // LOX vents on Booster on, Header Tank vents on Ship on.
  117. ag2 off. // CH4 vents on Ship and Booster on.
  118. until ag9 {
  119. printing().
  120. }
  121.  
  122. set rb2:enabled to false.
  123. set rb3:enabled to false.
  124. set rs5:enabled to false.
  125. set rs6:enabled to false.
  126. set rs7:enabled to false.
  127. set rs8:enabled to false.
  128. set teststatus to "Fueling finished, preparing for flight, time from beginning: " + round(testtime,1) + " Seconds".
  129. ag3 off. // Engine chill vents on Booster on.
  130. until ag9 {
  131. printing().
  132. }
  133.  
  134. toggle ag9.
  135. }
  136.  
  137.  
  138. function countdown {
  139. set rclock to time:clock.
  140. until rclock >= clock and rclock <= clock {
  141. printing().
  142. set rclock to time:clock.
  143. }
  144.  
  145. ag1 on.
  146. ag2 on.
  147. set topv to ship:facing:topvector.
  148. lock steering to lookdirup(up:vector,topv).
  149. set teststatus to "Countdown initiated, T-: " + round(ti,1) + " Seconds".
  150. until ti <= 2 {
  151. printing().
  152. }
  153.  
  154. set teststatus to "Ignition sequence initiated, T-: " + round(ti,1) + " Seconds".
  155. lock throttle to 0.05.
  156. set n to time:seconds.
  157. lock ti1 to time:seconds-n.
  158. lock throttle to min(0.5, ti1/1).
  159. ship:partstagged("Vector0")[0]:activate.
  160. ship:partstagged("Vector1")[0]:activate.
  161. ship:partstagged("Vector2")[0]:activate.
  162. ship:partstagged("Vector3")[0]:activate.
  163. ship:partstagged("Vector4")[0]:activate.
  164. ship:partstagged("Vector5")[0]:activate.
  165. ship:partstagged("Vector6")[0]:activate.
  166. ship:partstagged("Vector7")[0]:activate.
  167. ship:partstagged("Vector8")[0]:activate.
  168. ship:partstagged("Vector9")[0]:activate.
  169. ship:partstagged("Vector10")[0]:activate.
  170. ship:partstagged("Vector11")[0]:activate.
  171. ship:partstagged("Vector12")[0]:activate.
  172. set now2 to time:seconds.
  173. lock ti2 to time:seconds - now2.
  174. until ti2 > 1 {
  175. printing().
  176. }
  177.  
  178. ship:partstagged("Vector13")[0]:activate.
  179. ship:partstagged("Vector14")[0]:activate.
  180. ship:partstagged("Vector16")[0]:activate.
  181. ship:partstagged("Vector17")[0]:activate.
  182. ship:partstagged("Vector18")[0]:activate.
  183. ship:partstagged("Vector20")[0]:activate.
  184. ship:partstagged("Vector21")[0]:activate.
  185. ship:partstagged("Vector22")[0]:activate.
  186. ship:partstagged("Vector24")[0]:activate.
  187. ship:partstagged("Vector25")[0]:activate.
  188. ship:partstagged("Vector26")[0]:activate.
  189. ship:partstagged("Vector28")[0]:activate.
  190. ship:partstagged("Vector29")[0]:activate.
  191. ship:partstagged("Vector30")[0]:activate.
  192. ship:partstagged("Vector32")[0]:activate.
  193. set now2 to time:seconds.
  194. lock ti2 to time:seconds - now2.
  195. until ti2 > 1 {
  196. printing().
  197. }
  198.  
  199. set ti to 0.
  200. ship:partstagged("Vector15")[0]:activate.
  201. ship:partstagged("Vector19")[0]:activate.
  202. ship:partstagged("Vector23")[0]:activate.
  203. ship:partstagged("Vector27")[0]:activate.
  204. ship:partstagged("Vector31")[0]:activate.
  205. set now to time:seconds.
  206. lock testtime to time:seconds - now.
  207. set teststatus to "Full Ignition, T+: " + round(testtime,1) + " Seconds".
  208. set liftoff to 1.
  209. }
  210.  
  211.  
  212. function flight {
  213. until testtime > 1 {
  214. inflightvars().
  215. printing().
  216. }
  217.  
  218. set n to time:seconds.
  219. lock ti1 to time:seconds-n.
  220. lock throttle to min(0.85, 0.5+ti1/1).
  221. until ship:verticalspeed > 0.3 {
  222. inflightvars().
  223. printing().
  224. }
  225.  
  226. set teststatus to "Liftoff, T+: " + round(testtime,1) + " Seconds".
  227. lock steering to heading(52,86).
  228. until altit > pitchkickalt {
  229. inflightvars().
  230. printing().
  231. }
  232.  
  233. lock steering to heading(Azimuth, gravityturn, 90).
  234. set teststatus to "Roll and pitch program initiated, T+: " + round(testtime,1) + " Seconds".
  235. until altit > 2500 {
  236. inflightvars().
  237. printing().
  238. }
  239.  
  240. lock throttle to twr*1.5.
  241. set teststatus to "Throttle down, T+: " + round(testtime,1) + " Seconds".
  242. set oldq to ship:q.
  243. wait 0.1.
  244. set newq to ship:q.
  245. until newq < oldq {
  246. set oldq to ship:q.
  247. wait 0.1.
  248. set newq to ship:q.
  249. inflightvars().
  250. printing().
  251. }
  252.  
  253. set teststatus to "Max-Q, " + round(newq*constant:atmtokpa, 3) + " kPa, " + "T+: " + round(testtime,1) + " Seconds".
  254. set n to time:seconds.
  255. lock ti1 to time:seconds - n.
  256. until ti1 > 20 {
  257. inflightvars().
  258. printing().
  259. }
  260.  
  261. lock throttle to twr*2.4.
  262. set teststatus to "Throttle up, T+: " + round(testtime,1) + " Seconds".
  263. until altit > 25000 {
  264. inflightvars().
  265. printing().
  266. }
  267.  
  268. ag4 off. // 3 engine chill vents on Ship on.
  269. lock throttle to twr*1.8.
  270. set teststatus to "Throttle down before MECO, T+: " + round(testtime,1) + " Seconds".
  271. until altit > 33500 {
  272. inflightvars().
  273. printing().
  274. }
  275.  
  276. set teststatus to "Shutdown sequence initiating, T+: " + round(testtime,1) + " Seconds".
  277. set thrott to throttle.
  278. set n to time:seconds.
  279. lock ti1 to time:seconds-now.
  280. lock throttle to max(0.2, max(thrott,(1.8-ti1)/2)).
  281. ship:partstagged("Vector16")[0]:shutdown.
  282. ship:partstagged("Vector18")[0]:shutdown.
  283. ship:partstagged("Vector20")[0]:shutdown.
  284. ship:partstagged("Vector24")[0]:shutdown.
  285. ship:partstagged("Vector26")[0]:shutdown.
  286. ship:partstagged("Vector28")[0]:shutdown.
  287. ship:partstagged("Vector32")[0]:shutdown.
  288. set n to time:seconds.
  289. lock ti1 to time:seconds - n.
  290. until ti1 > 0.5 {
  291. inflightvars().
  292. printing().
  293. }
  294.  
  295. ship:partstagged("Vector14")[0]:shutdown.
  296. ship:partstagged("Vector22")[0]:shutdown.
  297. ship:partstagged("Vector30")[0]:shutdown.
  298. set n to time:seconds.
  299. lock ti1 to time:seconds - n.
  300. until ti1 > 0.3 {
  301. inflightvars().
  302. printing().
  303. }
  304.  
  305. ship:partstagged("Vector13")[0]:shutdown.
  306. ship:partstagged("Vector17")[0]:shutdown.
  307. ship:partstagged("Vector21")[0]:shutdown.
  308. ship:partstagged("Vector25")[0]:shutdown.
  309. ship:partstagged("Vector29")[0]:shutdown.
  310. set n to time:seconds.
  311. lock ti1 to time:seconds - n.
  312. until ti1 > 0.4 {
  313. inflightvars().
  314. printing().
  315. }
  316.  
  317.  
  318. ship:partstagged("Vector15")[0]:shutdown.
  319. ship:partstagged("Vector19")[0]:shutdown.
  320. ship:partstagged("Vector23")[0]:shutdown.
  321. ship:partstagged("Vector27")[0]:shutdown.
  322. ship:partstagged("Vector31")[0]:shutdown.
  323. set n to time:seconds.
  324. lock ti1 to time:seconds - n.
  325. until ti1 > 0.4 {
  326. inflightvars().
  327. printing().
  328. }
  329.  
  330. ship:partstagged("Vector4")[0]:shutdown.
  331. ship:partstagged("Vector6")[0]:shutdown.
  332. ship:partstagged("Vector8")[0]:shutdown.
  333. ship:partstagged("Vector10")[0]:shutdown.
  334. ship:partstagged("Vector12")[0]:shutdown.
  335. set n to time:seconds.
  336. lock ti1 to time:seconds - n.
  337. until ti1 > 0.2 {
  338. inflightvars().
  339. printing().
  340. }
  341.  
  342. ship:partstagged("Vector3")[0]:shutdown.
  343. ship:partstagged("Vector5")[0]:shutdown.
  344. ship:partstagged("Vector7")[0]:shutdown.
  345. ship:partstagged("Vector9")[0]:shutdown.
  346. ship:partstagged("Vector11")[0]:shutdown.
  347. lock throttle to 1.
  348. set ship:partstagged("Vector0")[0]:thrustlimit to 50.
  349. set ship:partstagged("Vector1")[0]:thrustlimit to 50.
  350. set ship:partstagged("Vector2")[0]:thrustlimit to 50.
  351. set n to time:seconds.
  352. lock ti1 to time:seconds - n.
  353. until ti1 > 4 {
  354. inflightvars().
  355. printing().
  356. }
  357.  
  358. set teststatus to "Vacuum engines are ignited, T+: " + round(testtime,1) + " Seconds".
  359. set eng4:thrustlimit to 5.
  360. set eng5:thrustlimit to 5.
  361. set eng6:thrustlimit to 5.
  362. eng4:activate.
  363. eng5:activate.
  364. eng6:activate.
  365. set n to time:seconds.
  366. lock ti1 to time:seconds - n.
  367. until ti1 > 1 {
  368. inflightvars().
  369. printing().
  370. }
  371.  
  372. set teststatus to "Sea level engines are ignited, separation, T+: " + round(testtime,1) + " Seconds".
  373. set sthr to 5.
  374. set eng1:thrustlimit to sthr.
  375. set eng2:thrustlimit to sthr.
  376. set eng3:thrustlimit to sthr.
  377. eng1:activate.
  378. eng2:activate.
  379. eng3:activate.
  380. set n to time:seconds.
  381. set ti1 to time:seconds - n.
  382. set sthr to min(1, ti1/1).
  383. set vacthr to min(1, ti1/0.5).
  384. ring:getmodule("ModuleDecouple"):doevent("Отделить").
  385. lock steering to heading(FinalAzimuth, gravityturn, 90).
  386. set sep to 1.
  387. rcs on.
  388. until ti1 > 1 {
  389. set eng4:thrustlimit to vacthr.
  390. set eng5:thrustlimit to vacthr.
  391. set eng6:thrustlimit to vacthr.
  392. set ti1 to time:seconds - n.
  393. set sthr to min(1, ti1/1).
  394. set vacthr to min(1, ti1/0.5).
  395. inflightvars().
  396. printing().
  397. }
  398.  
  399. set teststatus to "All six engines are on full power, T+: " + round(testtime,1) + " Seconds".
  400. set eng1:thrustlimit to 100.
  401. set eng2:thrustlimit to 100.
  402. set eng3:thrustlimit to 100.
  403. set eng4:thrustlimit to 100.
  404. set eng5:thrustlimit to 100.
  405. set eng6:thrustlimit to 100.
  406. set n to time:seconds.
  407. lock ti1 to time:seconds - n.
  408. until ti1 > 10 {
  409. inflightvars().
  410. printing().
  411. }
  412.  
  413. lock throttle to 1*twr.
  414. set teststatus to "Throttle down of all engines, T+: " + round(testtime,1) + " Seconds".
  415. until ship:periapsis > 0 {
  416. inflightvars().
  417. printing().
  418. }
  419.  
  420. set teststatus to "Periapsis starts to rise, vacuum engines shutdown, T+: " + round(testtime,1) + " Seconds".
  421. eng4:shutdown.
  422. eng5:shutdown.
  423. eng6:shutdown.
  424. until impactpos():lng > landingZone:lng - 5 and impactpos():lng < landingZone:lng + 5 {
  425. inflightvars().
  426. printing().
  427. }
  428.  
  429. set teststatus to "SECO-1, dumping fuel, starting experiments, T+: " + round(testtime,1) + " Seconds".
  430. lock throttle to 0.
  431. wait 0.1.
  432. eng1:shutdown.
  433. eng2:shutdown.
  434. wait 0.2.
  435. eng3:shutdown.
  436. set ship:control:fore to -1.
  437. set n to time:seconds.
  438. lock ti1 to time:seconds - n.
  439. until ti1 > 1 {
  440. inflightvars().
  441. printing().
  442. }
  443.  
  444. set ship:control:fore to 0.
  445. }
  446.  
  447.  
  448. function impactpos {
  449. if addons:tr:hasimpact {
  450. return addons:tr:impactpos.
  451. } else {
  452. return ship:geoposition.
  453. }
  454. }
  455.  
  456. function detanking {
  457. print "Test status: " + teststatus.
  458. fte[0]:getmodule("ModuleResourceDrain"):doaction("слить",true).
  459. fte[1]:getmodule("ModuleResourceDrain"):doaction("слить",true).
  460. fte[2]:getmodule("ModuleResourceDrain"):doaction("слить",true).
  461. ag3 on.
  462. ag1 off.
  463. ag2 off.
  464. ag6 off. // Ship and Booster dump vents on.
  465. for eng in engList { eng:shutdown. }
  466. eng1:shutdown.
  467. eng2:shutdown.
  468. eng3:shutdown.
  469. eng4:shutdown.
  470. eng5:shutdown.
  471. eng6:shutdown.
  472. wait 1.
  473. toggle ag9.
  474. set teststatus to "Detanking, T+ " + testtime + " Seconds".
  475. until ship:liquidfuel < 200 and ship:oxidizer < 200 {
  476. printing().
  477. }
  478.  
  479. set teststatus to "Vehicle has been detanked, T+: " + round(testtime,1) + " Seconds".
  480. ag1 on.
  481. ag2 on.
  482. ag6 on.
  483. }
  484.  
  485.  
  486. function abortflight {
  487. set teststatus to "Abort, T+: " + round(testtime,1) + " Seconds".
  488. if liftoff = 1 {
  489. ag7 on. // FTS on Booster.
  490. ag8 on. // FTS on Ship.
  491. } else if liftoff = 0 and ship:availablethrust > 0 {
  492. set n to time:seconds.
  493. lock ti1 to time:seconds - n.
  494. set thr to throttle.
  495. lock throttle to max(0, thr-(ti1/2*thr)).
  496. ship:partstagged("Vector16")[0]:shutdown.
  497. ship:partstagged("Vector18")[0]:shutdown.
  498. ship:partstagged("Vector20")[0]:shutdown.
  499. ship:partstagged("Vector24")[0]:shutdown.
  500. ship:partstagged("Vector26")[0]:shutdown.
  501. ship:partstagged("Vector28")[0]:shutdown.
  502. ship:partstagged("Vector32")[0]:shutdown.
  503. wait 0.5.
  504. ship:partstagged("Vector14")[0]:shutdown.
  505. ship:partstagged("Vector22")[0]:shutdown.
  506. ship:partstagged("Vector30")[0]:shutdown.
  507. wait 0.3.
  508. ship:partstagged("Vector13")[0]:shutdown.
  509. ship:partstagged("Vector17")[0]:shutdown.
  510. ship:partstagged("Vector21")[0]:shutdown.
  511. ship:partstagged("Vector25")[0]:shutdown.
  512. ship:partstagged("Vector29")[0]:shutdown.
  513. wait 0.4.
  514. ship:partstagged("Vector15")[0]:shutdown.
  515. ship:partstagged("Vector19")[0]:shutdown.
  516. ship:partstagged("Vector23")[0]:shutdown.
  517. ship:partstagged("Vector27")[0]:shutdown.
  518. ship:partstagged("Vector31")[0]:shutdown.
  519. wait 0.4.
  520. ship:partstagged("Vector4")[0]:shutdown.
  521. ship:partstagged("Vector6")[0]:shutdown.
  522. ship:partstagged("Vector8")[0]:shutdown.
  523. ship:partstagged("Vector10")[0]:shutdown.
  524. ship:partstagged("Vector12")[0]:shutdown.
  525. wait 0.2.
  526. ship:partstagged("Vector3")[0]:shutdown.
  527. ship:partstagged("Vector5")[0]:shutdown.
  528. ship:partstagged("Vector7")[0]:shutdown.
  529. ship:partstagged("Vector9")[0]:shutdown.
  530. ship:partstagged("Vector11")[0]:shutdown.
  531. wait 0.2.
  532. ship:partstagged("Vector0")[0]:shutdown.
  533. ship:partstagged("Vector1")[0]:shutdown.
  534. ship:partstagged("Vector2")[0]:shutdown.
  535. lock throttle to 0.
  536. set teststatus to "Detanking".
  537. detanking().
  538. } else {
  539. set teststatus to "Abort, T+" + testtime + " Seconds".
  540. detanking().
  541. }
  542. }
Add Comment
Please, Sign In to add comment