7 πͺ€ Add-ons
7.1 BADA 4
The OpenAP library can also be used to interact with BADA performance models.
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
= "path/to/bada_4.x/tables" bada_path
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.
= bada4.Drag("A320", bada_path)
drag
=60000, tas=300, alt=12_000) # kg, kt, ft -> N drag.clean(mass
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:
= bada4.Thrust("A320", bada_path)
thrust
=250, alt=10_000) # kg, kt, ft -> N thrust.climb(tas
For max thrust at cruise conditions:
=350, alt=30_000) thrust.cruise(tas
For idle thrust:
=250, alt=15_000) thrust.idle(tas
7.1.3 Fuel
The fuel model interface is also similar to OpenAPβs own fuel flow model interfaces. An example:
= bada4.FuelFlow("A320", bada_path)
fuel_bada
=60000, tas=350, alt=35_000) # kg, kt, ft -> kg/s fuel_bada.enroute(mass
7.1.4 Vectorized calculations
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
= "A319"
typecode = bada4.FuelFlow(typecode, bada_path)
fuel_bada
= pd.read_csv("path/to/your/fightdata.csv")
df = df.timestamp.diff().bfill().dt.total_seconds() # time step in seconds
dt
# assume 85% of MTOW as initial mass
= openap.prop.aircraft(typecode)["mtow"] * 0.85 mass0
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_bada.enroute(
fuel_flow_initial_guess =mass0,
mass=df.groundspeed,
tas=df.altitude,
alt=df.vertical_rate,
vs
).flatten()
# correct the mass at each time step
= mass0 - (fuel_flow_initial_guess * dt).cumsum()
mass
# second pass with corrected mass
= fuel_bada.enroute(
fuel_flow =mass, tas=df.groundspeed, alt=df.altitude, vs=df.vertical_rate
mass
).flatten()
= sum(fuel_flow * dt) total_fuel
The cacluation takes approximately 4.6 ms Β± 33.7 ΞΌs
for a flight dataframe with ~ 7,000 rows on aRyzen 7 7840HS
CPU.