7  πŸͺ€ Add-ons

7.1 BADA 4

The OpenAP library can also be used to interact with BADA performance models.

Important

In order to user this, you must first obtain a lincense and BADA4 data from EUROCONTROL.

The code for calculating drag, thrust, and fuel models from BADA4 are implemented in OpenAP. The interface is similar to the one used for the open-source OpenAP models.

To use the BADA4 models, you first need to import the module from addons, and then specify the path to the BADA4 tables on your local system.

from openap.addon import bada4

bada_path = "path/to/bada_4.x/tables"

7.1.1 Drag

In the following example, we show how to use the BADA4 models to calculate the drag of an aircraft at a specific flight condition with clean configuration.

drag = bada4.Drag("A320", bada_path)

drag.clean(mass=60000, tas=300, alt=12_000)  # kg, kt, ft -> N

Note that the aircraft type can be ICAO typecode like A320 or with subtypes like A320-231.

7.1.2 Thrust

To calculate the maximum thrust at climb conditions, you can use the following code:

thrust = bada4.Thrust("A320", bada_path)

thrust.climb(tas=250, alt=10_000)  # kg, kt, ft -> N

For max thrust at cruise conditions:

thrust.cruise(tas=350, alt=30_000)

For idle thrust:

thrust.idle(tas=250, alt=15_000)

7.1.3 Fuel

The fuel model interface is also similar to OpenAP’s own fuel flow model interfaces. An example:

fuel_bada = bada4.FuelFlow("A320", bada_path)

fuel_bada.enroute(mass=60000, tas=350, alt=35_000)  # kg, kt, ft -> kg/s

7.1.4 Vectorized calculations

Tip

The input parameters can be provided as list or numpy arrays. All the calcualtions are verctorized and hence extremly fast.

In the following example, we show how to calculate the fuel flow from a flight data file obtained from opensky state vectors. First, we read the data file and calculate the time step between each row.

import pandas as pd
import openap
from openap.addon import bada4

typecode = "A319"
fuel_bada = bada4.FuelFlow(typecode, bada_path)

df = pd.read_csv("path/to/your/fightdata.csv")
dt = df.timestamp.diff().bfill().dt.total_seconds()  # time step in seconds

# assume 85% of MTOW as initial mass
mass0 = openap.prop.aircraft(typecode)["mtow"] * 0.85

Then we calculate the fuel flow at each time step and sum the total fuel consumed.

# first pass to get an initial guess with reference mass
fuel_flow_initial_guess = fuel_bada.enroute(
    mass=mass0,
    tas=df.groundspeed,
    alt=df.altitude,
    vs=df.vertical_rate,
).flatten()

# correct the mass at each time step
mass = mass0 - (fuel_flow_initial_guess * dt).cumsum()

# second pass with corrected mass
fuel_flow = fuel_bada.enroute(
    mass=mass, tas=df.groundspeed, alt=df.altitude, vs=df.vertical_rate
).flatten()

total_fuel = sum(fuel_flow * dt)

The cacluation takes approximately 4.6 ms Β± 33.7 ΞΌs for a flight dataframe with ~ 7,000 rows on aRyzen 7 7840HS CPU.