None Notebook

This notebook contains material from ND-Pyomo-Cookbook; content is available on Github. The text is released under the CC-BY-NC-ND-4.0 license, and code is released under the MIT license.

< 6.3 Path Planning for a Simple Car | Contents | Tag Index | 6.5 Ascent from Lunar Surface >

Open in Colab


6.4 Soft Landing Apollo 11 on the Moon

Keywords: optimal control, ipopt usage, dae, differential-algebraic equations, rescaling time

Landing a rocket on the surface of a planet was once a staple of science fiction, and then realized in the 1960's through multiple manned and unmanned landings on the moon. It's hard to overestimate the degree to which these missions inspired a new generation

NASA Michael Collins [Public domain]

Rocket Landing Videos (these never get old):

Inspired by these examples, this notebook uses Pyomo and a simple model of a rocket to compute a control policy for a soft landing. The parameters used correspond to the descent of the Apollo 11 Lunar Module to the moon on July 20, 1969.

6.4.1 Imports

6.4.2 Version 1: Vertical dynamics of a rocket with constant mass

For a rocket with a mass $m$ in vertical flight at altitude $h$, a momentum balance yields the model

\begin{align*} m\frac{d^2h}{dt^2} & = - m g + v_eu \\ \end{align*}

where $u$ is the mass flow of propellant and $v_e$ is the velocity of the exhaust relative to the rocket. In this first attempt at modeling and control we will neglect the change in rocket mass due to fuel burn.

LM_illustration_02.jpg: NASA Marshall Space Flight Center (NASA-MSFC)derivative work: Adert [Public domain]

The complete Apollo lunar module was composed of descent and ascent stages, each containing a rocket engine and associated fuel tanks. The descent stage carried the entire assembly to the lunar surface. The total mass $m$ in the above model therefore consists of the dry and fuel masses of both stages. For the purpose of analyzing the descent of the lunar module to the lunar surface, the 'dry' mass consists of the total mass of the ascent stage plus the dry mass of the descent stage.

The following data is for the Apollo 11 Lunar Module. First attempt at a solution

For this first attempt at a solution, we will choose an arbitrary value for the length of the landing mission. The integration will start with the initial conditions, and we'll see what happens.

This first attempt at a solution included no specification related to landing on the lunar surface. The solver reported a solution where the engine doesn't fire, and the lunar module crashes into the lunar surface at full speed about 66 seconds after the start of the descent mission. Land on the surface, not above or below the surface.

The mission crashed! It's clear now that we haven't fully specified the desired outcome of the mission. Let's start by specifying the final condition as being on the surface

$$h(t_f) = 0$$

This condition is implemented in Pyomo by fixing the terminal value of $h$.

The descent mission now finishes the descent at the lunar surface, but unfortunately arrives with sufficient velocity to still be considered a crash. Make that a soft landing

To ensure a soft landing, we also need to specify a terminal velocity. The terminal conditions are now

\begin{align*} h(t_f) & = 0 \\ v(t_f) & = 0 \end{align*}

These conditions are implement by fixing terminal values of the associated Pyomo variables.

The lunar module now is now successfully landing on the lunar surface, but the fuel flow requirement exceeds the maximum capacity of the descent engine. Restrict fuel flow to engine capacity

The next step is establish constraints on the control action by limiting fuel flow to the mass flow limits of the descent engine.

$$ 0 \leq u(t) \leq u_{max}$$

Since less thrust is available, we may need to extend the length of the landing mission to find a feasible solution to the optimization problem.

6.4.3 Version 2: Rescaled model

At this point, it's now clear the first version of this model has run into some serious problems:

Let's begin with the last issue. We will introduce an additional decision variable $T$ denoting the length of the mission. Time is then rescaled as

$$\tau = \frac{t}{T}\quad\implies\quad t =\tau T$$

The differential equation model then becomes

\begin{align*} \frac{m}{T^2}\frac{d^2h}{d\tau^2} & = - m g + v_eu \\ \end{align*}

The net result is that an additional variable, $T$, denoting the duration of the descent mission has been introduced into the optimization problem. How much fuel is burned?

Fuel consumption can be calculated as

\begin{align*} \mbox{fuel consumed} & = \int_0^T u(t)\,dt = T \int_0^1u(\tau)\,d\tau \end{align*} Minimize fuel consumption

$$\min_{u(\tau), T} T\int_0^1 u(\tau)\, d\tau$$

6.4.4 Version 3: Rocket model

The first version of the rocket model has run into a serious problem because it appears not to provide enough mass flow to the engine to prevent a crash landing. But that may be an artifact of the assumption of constant mass. For Apollo 11 Lunar Module, for example, the fuel in the descent engine comprises more than 50% of the total mass of the lander.

For the second version of the rocket model, we augment the model with a mass balance for fuel. This yields

\begin{align*} \frac{m(t)}{T^2}\frac{d^2h}{d\tau^2} & = - m(t)g + v_eu \\ \\ \frac{1}{T}\frac{dm}{d\tau} & = -u \end{align*}

At this point we need to worry about nonsensical answers to the optimization for minimum fuel. For this purpose we add upper and lower bounds on $T$ that should restrict the solver to meaningful solutions.

< 6.3 Path Planning for a Simple Car | Contents | Tag Index | 6.5 Ascent from Lunar Surface >

Open in Colab