DEFDBL a-z DECLARE SUB effes (x, y, u, v, mu, fu, fv) ' This program is a minimal solution version of THREEBOD.BAS CLS PRINT " " PRINT " " PRINT "Astrophysics with a PC : RESTRICTED THREEBODY PROBLEM" PRINT "-----------------------------------------------------" PRINT " " PRINT "------------ Minimal solution program ---------------" PRINT "Input of initial conditions and parameters : ');" PRINT "" INPUT "Mass parameter mu : ", mu INPUT "Initial conditions : x(0) : ", x INPUT " y(0) : ", y INPUT " u(0) : ", u INPUT " v(0) : ", v INPUT "Time step : ", dt CLS t = dt n% = 20 ni% = 1 DO ' Main cycle computes blocks of 20 iterations and then ' asks the user whether to continue or not CLS PRINT " i t x y u" &_ " v " PRINT " " ' next FOR-cycle computes 20 new iterations FOR i% = 1 TO n% ' next block computes half step values of Cauchy method x1 = x + .5 * dt * u y1 = y + .5 * dt * v CALL effes(x, y, u, v, mu, fu, fv) u1 = u + .5 * dt * fu v1 = v + .5 * dt * fv ' next block computes new state i+1 of Cauchy method x = x + dt * u1 y = y + dt * v1 CALL effes(x1, y1, u1, v1, mu, fu, fv) u = u + dt * fu v = v + dt * fv ' new state is shown on screen PRINT USING "###### ######.#### ###.####### ###.#######" &_ " ###.####### ###.#######"; ni%; t; x; y; u; v t = t + dt ni% = ni% + 1 NEXT i% ' Ask user whether to continue or not PRINT "Continue (y/n) ?" DO ch$ = LCASE$(INKEY$) LOOP UNTIL (ch$ = "y") OR (ch$ = "n") PRINT " " LOOP UNTIL ch$ = "n" END SUB effes (x, y, u, v, mu, fu, fv) ' ' computes the right hand sides (fu and fv) of the differential ' equations for the components of the velocity for input values ' of x,y,u,v and mu ' r1 = SQR((x - mu) * (x - mu) + y * y) r2 = SQR((x + 1 - mu) * (x + 1 - mu) + y * y) fu = -(1 - mu) * (x - mu) / r1 ^ 3 - mu * (x + 1 - mu) _ / r2 ^ 3 + x + 2 * v fv = -(1 - mu) * y / r1 ^ 3 - mu * y / r2 ^ 3 + y - 2 * u r1 = SQR((x - mu) * (x - mu) + y * y) r2 = SQR((x + 1 - mu) * (x + 1 - mu) + y * y) fu = -(1 - mu) * (x - mu) / r1 ^ 3 - mu * (x + 1 - mu) _ / r2 ^ 3 + x + 2 * v fv = -(1 - mu) * y / r1 ^ 3 - mu * y / r2 ^ 3 + y - 2 * u END SUB