OpenAP Trajectory Optimizer

Previously, the majority of flight optimizers mentioned in the literature remained closed-source, posing a significant drawback for the progress of scientific research.

The OpenAP trajectory optimizer (openap.top) seeks to address this issue by providing researchers with convenient access to the intricate yet effective direct collocation optimization approach. This optimizer can adjust to meteorological conditions and can be utilized in various flight phases either individually or in combination. It encompasses traditional fuel and cost index objectives, alongside climate metrics-based objectives that incorporate global warming or temperature potential.

Install

OpenAP.top uses cfgrib for integrating wind data, cartopy for plotting, and a few other libraries. I recommend using conda to install these dependencies. Following is an example how I set it up on my computer for testing.

  1. Create a new conda environment (openap-env), which avoids messing up the base conda environment:
    conda create -n openap-env python=3.10 -c conda-forge
    
  2. Use the openap environment
    conda activate openap-env
    
  3. Install dependent libraries:
    conda install cfgrib cartopy casadi scikit-learn -c conda-forge
    
  4. Install the most recent version of openap:
    pip install --upgrade git+https://github.com/junzis/openap
    
  5. Install the most recent version of openap-top:
    pip install --upgrade git+https://github.com/junzis/openap-top
    

Quick start

Example code to generate a fuel optimal flight between two airports:

from openap import top

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

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

You can specify different objective functions as:

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

The final flight object is a pandas DataFrame.

Use wind data

To enable wind in your optimizer, you must first download meteorological data in grib format from ECMWF, for example, the ERA5 data at https://doi.org/10.24381/cds.bd0915c6.

Then enable the wind for the defined optimizer.

Example code:

from openap import top
from openap.top import wind

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

fgrib = "path_to_the_wind_data.grib"
windfield = wind.read_grib(fgrib)
optimizer.enable_wind(windfield)

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

If your grib file includes multiple timestamps, make sure to filter the correct time in the previous windfield object (pandas DataFrame).

Example of an optimal flight:

Visualization of the previous flight using matplotlib and cartopy:

example_optimal_flight