DEFDBL a-z
CLS
PRINT "Astrophysics with a PC : UNIVERSE MODEL"
PRINT "---------------------------------------"
PRINT " "
PRINT "------ Minimal solution program -------"
PRINT " "
PRINT "Input of the parameters : "
INPUT "sigma(o) : ", s
INPUT "q(o) : ", q
PRINT " "
' this FOR computes the past (era% = 0)
' and the future (era% = 1)
FOR era% = 0 TO 1
x = 0
y = 1
z = 1
ctn% = 1
'select the time step
IF era% = 0 THEN
dx = -.02
PRINT "Computations for the past"
ELSE
dx = .02
PRINT "Computations for the future"
END IF
' display heading of table of results
PRINT " "
PRINT " x y z"
count% = 0
PRINT USING "####.#### ####.#### ####.####"; x; y; z
' main cycle of the iterative procedure
DO
' decrease time step if function y is too steep
IF ABS(z) > 2 THEN dx = .01 * dx / ABS(dx)
' results at half the step
x12 = x + .5 * dx
y12 = y + .5 * dx * z
' check if scale factor y12 is still positive
IF y12 > 0 THEN
z12 = z + .5 * dx * (-s / y / y + (s - q) * y)
' results for the full step
x = x + dx
y = y + dx * z12
' check if scale factor y1 is still positive
IF y > 0 THEN
z = z + dx * (-s / y12 / y12 + (s - q) * y12)
count% = count% + 1
' show results of newly computed iteration
' on screen
PRINT USING "####.#### ####.#### " &_
"####.####"; x; y; z
' offer the possibility to stop the actual era
' every 15 iterations
IF (count% + 1) MOD 15 = 0 THEN
PRINT "Continue (y/n) ?"
DO
answer$ = LCASE$(INKEY$)
LOOP UNTIL (answer$ = "y") OR (answer$ = "n")
SELECT CASE answer$
CASE "y"
ctn% = 1
CASE "n"
ctn% = 0
END SELECT
END IF
ELSE 'this ELSE is reached when y1 was negative
IF era% = 0 THEN
PRINT "Model starts from Big Bang"
ELSE
PRINT "Model ends in a Collapse"
END IF
PRINT "Press any key to continue"
DO
LOOP WHILE INKEY$ = ""
ctn% = 0
END IF
ELSE 'this ELSE is reached when y12 was negative
IF era% = 0 THEN
PRINT "Model starts from Big Bang"
ELSE
PRINT "Model ends in a Collapse"
END IF
PRINT "Press any key to continue"
DO
LOOP WHILE INKEY$ = ""
ctn% = 0
END IF
LOOP UNTIL ctn% = 0
NEXT era%
PRINT "Press any key to stop the program"
DO
LOOP WHILE INKEY$ = ""
END