Phys 124 - Spring
First Simulation Homework


You are expected to design a spacecraft which will land softly (i.e. with very small vertical velocity) 
on the surface of a planet (acceleration due to gravity g = 1 m/s2 ). The space craft is 
initially 100m above the surface and descending with a vertical speed of 10 m/s. 

The total mass of the spacecraft is 20 Kg, with 4 Kg of that as fuel. The engine can produce 
0.1 Newton-second of impulse per gram of fuel. (i.e. if you burn fuel at a rate 10 gram/sec, 
it will generate 1 N of force.) The engine is to be designed such that it will start at a height 
of 100m, and will produce a constant force until it lands or runs out of fuel. So, the only 
variable you can control is the force developed by the engine.

Construct the code which will simulate this process. The code should stop when the height
becomes less than or equal to zero. It should also check the remaining fuel and stop the
engine if there is no more fuel. 

You should submit 

  o your code 
  o the fuel consumption rate
  o the vertical velocity when height is zero
  o remaining fuel
  o a plot of height vs time

with a discussion of the problem in a pdf file as homework.

The plots I got look like

For too little force:

For just the right amount of force:

For too much force: (Notice that the spacecraft runs out of fuel.)

Some of the features for my code: import matplotlib.pyplot as plt import numpy as np ########################## # lunar landing plt.clf() n = 200 y=100. vy=-10. dt=0.1 t=0. py=[] pt=[] . . . py.append(y) pt.append(t) for i in range(1,n): m = . . . # update fuel mass if m < 0 : # if out of fuel, force is zero m=0 F=0 t = ... vy = ... y = ... if y <= 0 : # if y <= 0, you have landed/crashed break py.append(y) pt.append(t) print("m=",m," vy=",vy) # to see final fuel mass and velocity plt.plot(pt , py ) plt.xlabel("time (seconds)") plt.ylabel("Height (m)") plt.show()