Skip to content

Commit

Permalink
Merge pull request #915 from martincmartin/main
Browse files Browse the repository at this point in the history
Lunar: Add explanation of variables and code structure.
  • Loading branch information
coding-horror authored Jun 2, 2024
2 parents 25d54ab + a2215f4 commit 998110f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
30 changes: 30 additions & 0 deletions 59_Lunar_LEM_Rocket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion 59_Lunar_LEM_Rocket/javascript/lunar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion 59_Lunar_LEM_Rocket/lunar.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 59_Lunar_LEM_Rocket/python/lunar.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def advance(self, delta_t: float) -> None:
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
Expand Down

0 comments on commit 998110f

Please sign in to comment.