Merge pull request #915 from martincmartin/main

Lunar: Add explanation of variables and code structure.
This commit is contained in:
Jeff Atwood
2024-06-02 13:33:26 -07:00
committed by GitHub
4 changed files with 33 additions and 3 deletions

View File

@@ -35,3 +35,33 @@ http://www.vintage-basic.net/games.html
#### Porting Notes
(please note any difficulties or challenges in porting here)
### LUNAR
Variables:
`A`: Altitude in miles. Up is positive.
`V`: Velocity in miles / sec. Down is positive.
`M`: Weight of capsule in pounds, both fuel and machine
`N`: Empty weight of capsule in pounds. So, weight of fuel is M - N.
`G`: Gravity in miles / sec^2, down is positive.
`Z`: Exhaust velocity in miles / sec
`L`: time in seconds since start of simulation.
`K`: Burn rate for this 10 second turn, pounds of fuel per sec
`T`: Time left in this 10 second turn, in seconds.
`S`: Burn time in this 10 second turn, input to subroutine 420.
Subroutines:
330, Apply updates from one call to subroutine 420.
370, If you started descending and ended ascending, figure out whether you hit the surface in between.
420, Compute new velocity and altitude using the Tsiolkovsky rocket equation for S seconds:
`Q`: Fraction of initial mass that's burnt, i.e. 1 - mf / mo, exactly what we need for the Taylor series of `ln` in the rocket equation. Local to this subroutine.
`J`: Final velocity after S seconds, down is positive. Return value.
`I`: Altitude after S seconds, up is positive. Return value.

View File

@@ -113,7 +113,7 @@ async function main()
print("\n");
a = 120;
v = 1;
m = 32500;
m = 33000;
n = 16500;
g = 1e-3;
z = 1.8;

View File

@@ -12,7 +12,7 @@
110 PRINT: PRINT: PRINT: PRINT "GOOD LUCK"
120 L=0
130 PRINT: PRINT "SEC","MI + FT","MPH","LB FUEL","BURN RATE":PRINT
140 A=120:V=1:M=32500:N=16500:G=1E-03:Z=1.8
140 A=120:V=1:M=33000:N=16500:G=1E-03:Z=1.8
150 PRINT L,INT(A);INT(5280*(A-INT(A))),3600*V,M-N,:INPUT K:T=10
160 IF M-N<1E-03 THEN 240
170 IF T<1E-03 THEN 150

View File

@@ -127,7 +127,7 @@ class SimulationClock:
class Capsule:
altitude: float = 120 # in miles above the surface
velocity: float = 1 # downward
m: float = 32500 # mass_with_fuel
m: float = 33000 # mass_with_fuel
n: float = 16500 # mass_without_fuel
g: float = 1e-3
z: float = 1.8