.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/fuelFlow.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_fuelFlow.py: Fuel Flow Calculation ======================== Example calculation of aircraft fuel flow in descent .. GENERATED FROM PYTHON SOURCE LINES 8-216 .. image-sg:: /auto_examples/images/sphx_glr_fuelFlow_001.png :alt: Descent Fuel Flow vs Altitude :srcset: /auto_examples/images/sphx_glr_fuelFlow_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none === Bada4Aircraft | BADA DUMMY | Mass: 65000 kg === FL Alt(ft) Cfg M FF (kg/s) --------------------------------------- 0 0 LD 0.201 0.852485 10 1000 LD 0.212 0.822006 20 2000 AP 0.279 0.378778 30 3000 CR 0.351 0.172248 40 4000 CR 0.357 0.166989 50 5000 CR 0.364 0.162016 60 6000 CR 0.420 0.151997 70 7000 CR 0.428 0.148105 80 8000 CR 0.436 0.144442 90 9000 CR 0.444 0.140994 100 10000 CR 0.541 0.134151 110 11000 CR 0.551 0.131689 120 12000 CR 0.561 0.129358 130 13000 CR 0.571 0.127143 140 14000 CR 0.582 0.125033 150 15000 CR 0.593 0.123014 160 16000 CR 0.604 0.121075 170 17000 CR 0.615 0.119203 180 18000 CR 0.627 0.117385 190 19000 CR 0.639 0.115608 200 20000 CR 0.651 0.113860 210 21000 CR 0.664 0.112127 220 22000 CR 0.677 0.110397 230 23000 CR 0.690 0.108656 240 24000 CR 0.703 0.106892 250 25000 CR 0.717 0.105090 260 26000 CR 0.731 0.103238 270 27000 CR 0.745 0.101320 280 28000 CR 0.760 0.099325 290 29000 CR 0.775 0.097236 300 30000 CR 0.790 0.095065 310 31000 CR 0.790 0.093420 320 32000 CR 0.790 0.091818 330 33000 CR 0.790 0.090260 340 34000 CR 0.790 0.088744 350 35000 CR 0.790 0.087271 360 36000 CR 0.790 0.085839 370 37000 CR 0.790 0.084911 380 38000 CR 0.790 0.084067 390 39000 CR 0.790 0.083261 400 40000 CR 0.790 0.082493 === Bada3Aircraft | BADA DUMMY | Mass: 58000 kg === FL Alt(ft) Cfg M FF (kg/s) --------------------------------------- 0 0 LD 0.222 0.609352 10 1000 LD 0.233 0.611392 20 2000 AP 0.300 0.332968 30 3000 CR 0.351 0.232042 40 4000 CR 0.357 0.227339 50 5000 CR 0.364 0.222637 60 6000 CR 0.420 0.217934 70 7000 CR 0.428 0.213232 80 8000 CR 0.436 0.208529 90 9000 CR 0.444 0.203826 100 10000 CR 0.523 0.199124 110 11000 CR 0.533 0.194421 120 12000 CR 0.543 0.189718 130 13000 CR 0.553 0.185016 140 14000 CR 0.563 0.180313 150 15000 CR 0.574 0.175610 160 16000 CR 0.585 0.170908 170 17000 CR 0.596 0.166205 180 18000 CR 0.607 0.161503 190 19000 CR 0.619 0.156800 200 20000 CR 0.631 0.152097 210 21000 CR 0.643 0.147395 220 22000 CR 0.655 0.142692 230 23000 CR 0.668 0.137989 240 24000 CR 0.681 0.133287 250 25000 CR 0.694 0.128584 260 26000 CR 0.708 0.123882 270 27000 CR 0.722 0.119179 280 28000 CR 0.737 0.114476 290 29000 CR 0.740 0.109774 300 30000 CR 0.740 0.105071 310 31000 CR 0.740 0.100368 320 32000 CR 0.740 0.095666 330 33000 CR 0.740 0.090963 340 34000 CR 0.740 0.086260 350 35000 CR 0.740 0.081558 360 36000 CR 0.740 0.076855 370 37000 CR 0.740 0.072153 380 38000 CR 0.752 0.067450 390 39000 CR 0.783 0.062747 400 40000 CR 0.816 0.058045 | .. code-block:: Python from math import sin import matplotlib.pyplot as plt import numpy as np from pyBADA import atmosphere as atm from pyBADA import constants as const from pyBADA import conversions as conv from pyBADA import utils from pyBADA.bada3 import Bada3Aircraft from pyBADA.bada4 import Bada4Aircraft # create an aircraft ACList = [ Bada4Aircraft(badaVersion="DUMMY", acName="Dummy-TWIN"), Bada3Aircraft(badaVersion="DUMMY", acName="J2M"), ] # deviation from ISA temperature deltaTemp = 0 # definition of altitude range fl_array = np.arange(0, 401, 10) altitude_array = conv.ft2m(fl_array * 100) # --- collect per-aircraft series here --- series = [] # list of dicts: {"label": str, "alt_ft": list[float], "ff": list[float]} for AC in ACList: # define aircraft mass - here as reference mass mass = AC.MREF # get the original speed schedule for descent for this aircraft [Vdes1, Vdes2, Mdes] = AC.flightEnvelope.getSpeedSchedule(phase="Descent") # crossover altitude crossAlt = atm.crossOver(cas=Vdes2, Mach=Mdes) label = f"({AC.BADAFamilyName}) {AC.acName.strip('_')} (BADA {getattr(AC, 'BADAVersion')}) {mass} kg" alt_ft_vals = [] ff_vals = [] print( f"\n=== {AC.__class__.__name__} | BADA {AC.BADAVersion} | Mass: {mass:.0f} kg ===" ) print( f"{'FL':>4} {'Alt(ft)':>8} {'Cfg':>3} {'M':>6} {'FF (kg/s)':>10}" ) print("-" * 39) for alt in altitude_array: # atmosphere properties theta, delta, sigma = atm.atmosphereProperties( h=alt, deltaTemp=deltaTemp ) # determine the speed acording to BADA ARPM [cas, speedUpdated] = AC.ARPM.descentSpeed( h=alt, mass=mass, theta=theta, delta=delta, deltaTemp=deltaTemp ) # general speed conversion [M, CAS, TAS] = atm.convertSpeed( v=conv.ms2kt(cas), speedType="CAS", theta=theta, delta=delta, sigma=sigma, ) # determine the aerodynamic configuration if necesary config = AC.flightEnvelope.getConfig( h=alt, phase="Descent", v=CAS, mass=mass, deltaTemp=deltaTemp ) # calculate Energy Share Factor depending if aircraft is flying constant M or CAS (based on crossover altitude) if alt < crossAlt: ESF = AC.esf( h=alt, flightEvolution="constCAS", M=M, deltaTemp=deltaTemp ) else: ESF = AC.esf( h=alt, flightEvolution="constM", M=M, deltaTemp=deltaTemp ) # ===== # BADA4 # ===== if AC.BADAFamily.BADA4: # ================================================================================= # for altitudes where aircraft descends on 3degree slope in AP and LD configuration # ================================================================================= if config == "AP" or config == "LD": gamma = -3.0 temp_const = (theta * const.temp_0) / ( theta * const.temp_0 - deltaTemp ) ROCD_gamma = sin(conv.deg2rad(gamma)) * TAS * (1 / temp_const) n = 1.0 [HLid, LG] = AC.flightEnvelope.getAeroConfig(config=config) CL = AC.CL(M=M, delta=delta, mass=mass, nz=n) CD = AC.CD(M=M, CL=CL, HLid=HLid, LG=LG) Drag = AC.D(M=M, delta=delta, CD=CD) Thrust = (ROCD_gamma * mass * const.g) * temp_const / ( ESF * TAS ) + Drag CT = AC.CT(Thrust=Thrust, delta=delta) ff = AC.ff( CT=CT, delta=delta, theta=theta, M=M, deltaTemp=deltaTemp ) # ============================================================= # for altitudes where aircraft descends in IDLE engine settings # ============================================================= else: ff = AC.ff( rating="LIDL", delta=delta, theta=theta, M=M, deltaTemp=deltaTemp, ) # [kg/s] # ===== # BADA3 # ===== elif AC.BADAFamily.BADA3: adaptedThrust = False if AC.engineType in ("PISTON", "ELECTRIC"): # PISTON and ELECTRIC uses LIDL throughout the whole descent phase config = "CR" adaptedThrust = True # ================================================================================= # for altitudes where aircraft descends on 3degree slope in AP and LD configuration # ================================================================================= if config in ("AP", "LD"): gamma = -3.0 temp_const = (theta * const.temp_0) / ( theta * const.temp_0 - deltaTemp ) ROCD_gamma = sin(conv.deg2rad(gamma)) * TAS * (1 / temp_const) n = 1.0 CL = AC.CL(sigma=sigma, mass=mass, tas=TAS, nz=n) CD = AC.CD(CL=CL, config=config) Drag = AC.D(sigma=sigma, tas=TAS, CD=CD) Thrust = AC.Thrust( rating="ADAPTED", v=TAS, config=config, h=alt, ROCD=ROCD_gamma, mass=mass, acc=0, deltaTemp=deltaTemp, Drag=Drag, ) ff = AC.ff( flightPhase="Descent", v=TAS, h=alt, T=Thrust, config=config, adapted=adaptedThrust, ) # ============================================================= # for altitudes where aircraft descends in IDLE engine settings # ============================================================= else: ff = AC.ff( v=TAS, h=alt, T=Thrust, flightPhase="Descent", config=config, ) fl = int(utils.proper_round(conv.m2ft(alt) / 100)) alt_ft = conv.m2ft(alt) print(f"{fl:>4d} {alt_ft:>8.0f} {config:>3} {M:>6.3f} {ff:>10.6f}") alt_ft_vals.append(alt_ft) ff_vals.append(float(ff)) series.append( { "label": label, "alt_ft": np.array(alt_ft_vals), "ff": np.array(ff_vals), } ) # --- PLOT: Fuel flow vs Altitude for all aircraft --- plt.figure(figsize=(8, 5)) for s in series: plt.plot(s["alt_ft"], s["ff"], label=s["label"]) plt.xlabel("Altitude (ft)") plt.ylabel("Fuel Flow (kg/s)") plt.title("Descent Fuel Flow vs Altitude") plt.grid(True, which="both", linestyle="--", linewidth=0.5) plt.legend() plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.283 seconds) .. _sphx_glr_download_auto_examples_fuelFlow.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: fuelFlow.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: fuelFlow.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: fuelFlow.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_