Terminate


The terminate equation successfully terminates the current simulation, i.e. no error condition is indicated. A string argument is used to indicate the reason for successful termination, which can be reported back to the user in some appropriate way by the simulation tool. Terminate is most commonly used to give a more appropriate stopping criteria for terminating a simulation than a fixed point in time.






1 Celestial Body

This example illustrates a Rocket landing on the moon. The class CelestialBody can be used to store information about celestial bodies such as the earth and the moon.



2 Rocket

The class Rocket embodies the equations of vertical motion for a rocket which is influenced by an external gravitational force field gravity, and the force thrust from the rocket motor, acting in the opposite direction to the gravitational force.



3 MoonLanding

We can use terminate to stop the simulation when the lander touches the surface in order to avoid the lander descending into the interior of the moon. This is the case for the version of the MoonLanding class below.



4 Simulation of MoonLanding

Now we simulate the MoonLanding example during the time interval {0, 230}, since the Rocket reaches the surface of the moon at time 200, the simulation is terminated.



Then we plot the simulation. It is possible to plot all the different variables of Apollo




Diagram 1: Altitude of the Apollo rocket over the lunar surface




Diagram 2: Thrust from the rocket motor, with an initial high thrust f1 followed by a lower thrust f2.




Diagram 3: Rocket mass decreases when the fuel is consumed




Diagram 4: Gradually increasing gravity when the rocket approaches the lunar surface




Diagram 5: Vertical velocity relative to the lunar surface