Listing 1a 'launch.bas DECLARE SUB init () 'Draw screen graphics DECLARE SUB calcs () 'Common calculation DIM SHARED pi, t, x, y, u, v, ax, ay, at, atx, aty, vv, hv DIM SHARED ff, gc, ag, thr, m, inc, anc, an, er, rd, orbh DIM SHARED ca, sa, w, E, tp, mx, my, cx, cy, tx, ty, wx, wy DIM SHARED fm, blue, green, cyan, red, mag, yell, wh CALL init 'Prepare screen 'INITIAL VALUES pi = 3.14159: pi2 = pi / 2: erd = 6378: orbh = 6558 ag = .0098: gc = ag * erd * erd 'gravity accel. & constant t = 0: rd = erd: x = 0: y = rd 'launch position ax = 0: ay = -ag: u = .41: v = 0 'acceleration & velocity m = 2940321: f1 = 2149202 'mass(kgm) & Stage 1 fuel(kgm) tl = 3479020: thr = tl * .0098 'thrust(kgf) & thrust(kga) inc = pi2: anc = 0: an = pi2: st! = TIMER 'axis angles ft1 = 150: ff = f1 / ft1: LOCATE 1, 1 'burn time & fuel flow PRINT "Launch weight ="; CINT(m / 1000); "t, Thrust ="; PRINT CINT(tl / 1000); "t. Fuel flow ="; CINT(ff); "kg/s" PRINT "Stage 1 burning time = 150 secs." l1 = 6383: l2 = 6390: z1 = 34094: z2 = 38844: z3 = 40664 sl1 = 950: sl1 = 260: sl3 = 5: fm = 60 'some constants DO WHILE t < ft1: t = t + 1 'STAGE 1 LOOP DO: LOOP UNTIL TIMER > st!: st! = TIMER + .1 'delay loop IF rd < l1 THEN thr = z1 + 950 * (rd - erd) '3 sections for IF rd > l1 THEN thr = z2 + 260 * (rd - l1) 'thrust calcul- IF rd > l2 THEN thr = z3 + 5 * (rd - l2) 'ation at height inc = pi2 - t * .009 'incidence of rocket to horizon CALL calcs 'common calculation for all stages LOOP LINE (tp, 4700)-(tp, 5600), wh 'mark end of stage LINE (x, y)-(6380 * SIN(anc), 6380 * COS(anc)), wh: LOCATE 1 PRINT "Stage 1 burnout. Mass ="; CINT(m/1000); "t, Speed ="; PRINT CINT(w * 1000) / 1000; "km/s, Height ="; CINT(rd- erd) PRINT "Specific Energy = "; E; " " DO: LOOP WHILE INKEY$ = "" 'pause 'STAGE 1 SEPARATION m = m - 131250 - 3977 - 615 'drop Stage 1 & two interstages tl = 522650: thr1 = tl * .0098 'thrust(kgf & kga) f2 = 445115: ft2 = 360 'Stage 2 fuel(kgm) & burn time(secs) ff = f2 / ft2: t2 = ft1 + ft2 'fuel flow(kg/s) & end stage LOCATE 1, 1: mvt = .95 * thr1: thrf = 154 / 360 fm = 15: aimh = 6550 'force magnification & aim height PRINT "Dropping dry stage 1 (136 t) leaving "; CINT(m/1000); PRINT "t. S2 thrust ="; CINT(tl / 1000); "t " PRINT "Fuel flow ="; CINT(ff); "kg/s for 360 secs." coeffr = .00003: coeffv = .009 DO WHILE t < t2: t = t + 1 'STAGE 2 LOOP DO: LOOP UNTIL TIMER > st!: st! = TIMER + .1 'delay loop thr = thr1 + (rd - 6438) * thrf av = coeffr * (aimh - rd) - coeffv * vv 'Desired vert accel vt = m * (av - hv * hv / rd + ag) 'required vert. thrust IF vt > mvt THEN vt = mvt 'limit vert. thrust inc = ATN(vt / SQR(thr * thr - vt * vt)) 'angle to horizon CALL calcs LOOP LINE (tp, 4700)-(tp, 6200), wh 'mark end of stage LINE (x, y)-(6380 * SIN(anc), 6380 * COS(anc)), wh: LOCATE 1 PRINT "Stage 2 burnout. Mass ="; CINT(m/1000); "t, Speed ="; PRINT CINT(w * 1000) / 1000; "km/s ": PRINT "Height ="; CINT(rd - erd); "km, Energy = ";E;SPC(41); DO: LOOP WHILE INKEY$ = "" 'STAGE 2 SEPARATION m = m - 36326 - 3673 'drop Stage 2 & one interstage tl = 92627: thr = tl * .0098 'thrust(kgf & kga) f3 = 107056 'Stage 3 fuel(kgm) SI3 = 440: ff = tl / SI3 'Specific Impulse & fuel flow Eh = -.5 * gc / orbh 'orbital Specific Energy at orbh fm = 5: mvt = thr * .7: LOCATE 1, 1 'limit vertical thrust PRINT "Dropping dry stage 2 (37 t) leaving "; CINT(m /1000); PRINT "t. S3 thrust="; CINT(tl / 1000); "t" PRINT "Fuel flow ="; CINT(ff); PRINT "kg/s. Quits when circular orbital velocity achieved." coeffr = .001: coeffv = .05 DO: t = t + 1: f3 = f3 - ff 'STAGE 3 LOOP DO: LOOP UNTIL TIMER > st!: st! = TIMER + .1 'delay loop av = coeffr * (orbh - rd) - coeffv * vv 'Desired vert accel vt = m * (av - hv * hv / rd + ag): 'desired vertical thrust IF ABS(vt) > mvt THEN vt = mvt * SGN(vt) 'limit vertical inc = ATN(vt / SQR(thr * thr - vt * vt))'thrust, up or down IF t = 540 THEN m = m - 3000 'Launch Escape Tower dumped CALL calcs LOOP UNTIL E > Eh: LOCATE 1, 1 LINE (tp, 4700)-(tp, 6200), wh 'mark end of stage LINE (x, y)-(6380 * SIN(anc), 6380 * COS(anc)), wh PRINT " Orbital speed ="; CINT(w * 1000) / 1000; PRINT "km/s. Mass ="; CINT(m / 1000); "t."; PRINT " Fuel left ="; CINT(f3 / 1000); "t. " PRINT " Time since launch ="; t; "secs. Height ="; PRINT CINT(rd - erd); "km."; SPC(22); DO: LOOP WHILE INKEY$ = "" +++++++++++++++++++++++++++++++++++++++++++++++++++++ Listing 1b SUB calcs an = inc - anc: m = m - ff: at = thr / (m + ff / 2) atx = at * COS(an): aty = at * SIN(an) arx = atx + ax: ary = aty + ay u = u + arx: v = v + ary: x = x + u: y = y + v rd2 = x * x + y * y: rd = SQR(rd2): ag = gc / rd2 ax = -ag * x / rd: ay = -ag * y / rd w2 = u * u + v * v: w = SQR(w2): E = w2 / 2 - gc / rd sa = SIN(anc): ca = COS(anc) 'anc is angle around earth vv = u * sa + v * ca: hv = u * ca - v * sa 'vert. & hor. vel tp = t * 3 + 300: anc = ATN(x / y) 'time plot along x axis PSET (tp, 7550 + E * 45), red: PSET (x,y), wh 'energy & pos. PSET (tp, w * 225 + 4625), green 'velocity PSET (tp, m / 3333 + 4625), yell 'mass PSET (tp, (an + anc) * 1800 / pi + 4625), blue 'inclination PSET (tp, (rd - erd) * 5 + 4625), mag 'height IF t MOD 10 = 0 THEN 'blot out force diagram LINE (600, 6000)-STEP(mx, my), 0: LINE -STEP(10, 0), 0 LINE -STEP(cx, cy), 0: LINE -STEP(tx, ty), 0 LINE (600, 6050)-STEP(wx, wy), 0 mx = ax * m / fm: my = ay * m / fm cf = hv * hv * m / rd: cx = cf * sa / fm: cy = cf * ca / fm tx = atx * m / fm: ty = aty * m / fm wx = u * 60: wy = v * 60 'redraw force diagram LINE (600, 6000)-STEP(mx, my), yell: LINE -STEP(10,0), cyan LINE -STEP(cx, cy), cyan: LINE -STEP(tx, ty), red LINE (600, 6050)-STEP(wx, wy), green END IF k$ = INKEY$: IF k$ = CHR$(27) THEN END 'escape key IF k$ > "" THEN 'any other key DO: LOOP WHILE INKEY$ = "" 'pause END IF END SUB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Listing 1c SUB init 'SET UP SCREEN GRAPHICS SCREEN 12: CLS : WINDOW (0, 4460)-(3000, 6710): wh= 15 blue = 9:green = 10:cyan = 11:red= 12:mag= 13:yell= 14 LOCATE 4, 61: PRINT "2400 km downrange": LOCATE 5, 62 PRINT "180 km altitude": LOCATE 29, 9: PRINT "0"; LOCATE 29, 33: PRINT "5 Time , mins 10"; LOCATE 16, 11: PRINT "STAGE 1 STAGE 2" LOCATE 16, 51: PRINT "STAGE 3" COLOR red: LOCATE 20, 52: PRINT "Specific Energy" FOR n = 3 TO 6: LOCATE n *6 -11, 2: PRINT -n *10: NEXT COLOR green: LOCATE 21, 52: PRINT "Velocity km/s" FOR n = 0 TO 7: LOCATE 28 - n * 3, 6: PRINT n: NEXT COLOR mag: LOCATE 22, 52: PRINT "Height km" LOCATE 16, 68: PRINT "180" COLOR blue: LOCATE 23, 52: PRINT "Angle to horiz." LOCATE 16, 74: PRINT "90" COLOR yell: LOCATE 24, 52: PRINT "Mass tonnes" FOR n = 0 TO 3: LOCATE 28 - n * 4, 78: PRINT n: NEXT erd = 6378: st = 500 / erd: COLOR wh LINE (2400, 6130)-(2400, 6340), wh: PSET (0, erd), wh FOR a = .03 TO .48 STEP .02 LINE -(erd* SIN(a), erd* COS(a)), wh: NEXT FOR a = st TO 6 * st STEP st: c = COS(a): s = SIN(a) FOR rd = 6428 TO 6578 STEP 50 PSET (rd * s, rd * c), wh: NEXT: NEXT FOR yc = 4850 TO 6250 STEP 450 LINE (0, yc)-(30, yc), red: NEXT 'Energy FOR yc = 4670 TO 6350 STEP 45 LINE (0, yc)-(10, yc), red: NEXT FOR yc = 4625 TO 6250 STEP 225 LINE (300, yc)-(330, yc), green: NEXT 'Veloc FOR yc = 4625 TO 6350 STEP 22.5 LINE (300, yc)-(310, yc), green: NEXT FOR yc = 4625 TO 5525 STEP 300 LINE (2960, yc)-(3000, yc), yell: NEXT 'Mass FOR yc = 4655 TO 5495 STEP 30 LINE (2980, yc)-(3000, yc), yell: NEXT FOR yc = 4625 TO 5525 STEP 100 LINE (2830, yc)-(2880, yc), blue: NEXT'Angle FOR yc = 4625 TO 5525 STEP 50 LINE (2650, yc)-(2680, yc), mag: NEXT'Height FOR xc = 330 TO 2970 STEP 30 LINE (xc, 4625)-(xc, 4650), wh: NEXT 'Time FOR xc = 300 TO 3000 STEP 180 LINE (xc, 4625)-(xc, 4675), wh: NEXT LOCATE 1, 1: PRINT "Saturn V / Apollo 11 "; PRINT "Launch 9.32 AM. (Florida time) 16/7/1969." DO: LOOP WHILE INKEY$ = "" END SUB