None Notebook

This notebook contains material from CBE30338; content is available on Github.

< 7.1 Simulation and Optimal Control in Pharmacokinetics | Contents | Tag Index | 7.3 Simulation in Pyomo >

Open in Colab

Download

7.2 Soft Landing a Rocket

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

Eagle In Lunar Orbit - GPN-2000-001210

NASA Michael Collins [Public domain] via Wikimedia Commons

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.

7.2.1 Required Installations

7.2.1.1 Google Colab

The following cell installs the necessary packages and solvers on Google Colab. This installation must be done for each Google Colab session.

MacOS

On MacOS, replace the above cell with the following text to perform a one-time installation.

!pip install -q pyomo
!curl https://ampl.com/dl/open/ipopt/ipopt-osx.zip --output ipopt-osx.zip --silent
!unzip -o -q ipopt-osx
ipopt_executable = './ipopt'

7.2.1.2 Windows PC

Pyomo can be installed by executing

!pip install -q pyomo

into a Jupyter notebook cell. An ipopt binary executable is available from ampl.com. More specific instructions for a one-tme installation on Windows PC will be forthcoming.

7.2.2 Python Initializations

7.2.3 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-IT

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.

7.2.3.1 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.

7.2.3.2 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.

7.2.3.3 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.

7.2.3.4 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.

7.2.4 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.

7.2.4.1 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*}

7.2.4.2 Minimize fuel consumption.

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

7.2.5 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.

< 7.1 Simulation and Optimal Control in Pharmacokinetics | Contents | Tag Index | 7.3 Simulation in Pyomo >

Open in Colab

Download