The optimization module

Two years after the OpenAP model is published, I managed to create the first open-source trajectory optimizer for aviation research, called OpenAP-TOP. TOP is acronym for Trajectory Optimizer, and it is fully built on top of OpenAP python library.

TOP uses direct collocation implemented by Casadi for the optimization, with uses IPOPT under the hood.

You can follow the user guide to set up this trajectory optimizer.

Generating optimal trajectories

TOP provides different ways of generation basic optimal trajectories, including fuel optimal, climate optimal (based on climate metrics), cost-index optimal. For example, you can generate these types of trajectories quickly with the following code:

from openap import top

optimizer = top.CompleteFlight("A320", "EHAM", "LGAV", m0=0.85)

flight = optimizer.trajectory(objective="fuel")
flight = optimizer.trajectory(objective="ci:30")
flight = optimizer.trajectory(objective="gwp100")
flight = optimizer.trajectory(objective="gtp100")

You can include wind data in your trajectory optimization. To do so, you must have install the cfgrib package (ideally from conda-forge). Here are some example code:

from openap import top
from openap.top import wind

optimizer = top.CompleteFlight("A320", "EHAM", "LGAV", m0=0.85)

# load wind grib data (for example, obtained from ECMWF ERA5 renalysis)
fgrib = "path_to_the_wind_data.grib"
windfield = wind.read_grib(fgrib)
optimizer.enable_wind(windfield)

flight = optimizer.trajectory(objective="fuel")

Advanced objective functions

Currently, I am developing new ways to incorporate complex objective functions, for example, a 3D gird of discreet costs.

You can following the following two jupyter notebook to see how it will work:

Note, this is still at a preliminary stage, and a lot of fine tunning is needed to make the code more robust.

Meta class for OpenAP

In order to be able to use Casadi, all OpenAP modules are re-implemented to enable the symbolic computations from Casadi. Now you can use OpenAP in two different ways, where the default option expect an scalar or array-like input, for example:

from opeanp import Thrust

thrust = Thrust("a320")
T = thrust.cruise(tas, alt)  # expect tas and alt to be scalar or array-like input

If you want to use OpenAP in your Casadi compatible code, you can do:

from openap.casadi import Thrust

thrust = Thrust("a320")
T = thrust.cruise(tas, alt)  # expect tas and alt to symbolic

To implement this, I relied on the meta class pattern to override all the core functions, you can take a look at the code here and here.

Citation

If you use this tool, please consider citing the following:

@article{sun2022openap,
  title={Openap.top: Open flight trajectory optimization for air transport and sustainability research},
  author={Sun, Junzi},
  journal={Aerospace},
  volume={9},
  number={7},
  pages={383},
  year={2022},
  publisher={MDPI}
}