Skip to content

fix(fuel): rescale BADA fuel flow from the BADA4 LHV (43.217 MJ/kg) - #80

Merged
ramondalmau merged 4 commits into
devfrom
fix/fuel-energy-reference
Oct 22, 2026
Merged

ramondalmau merged 4 commits into
devfrom
fix/fuel-energy-reference

Conversation

@ramondalmau

Copy link
Copy Markdown
Collaborator

What this changes

BADA gives the fuel flow of a fuel with a given energy content (lower calorific value, LHV).
PyNEATS converts it to the fuel actually used:

fuel flow = BADA fuel flow x REFERENCE_Q_FUEL / q_fuel

q_fuel is the operator's calorific value, else the airport fuel file value, else the default
42.8 MJ/kg.

Before: REFERENCE_Q_FUEL = 43.13 MJ/kg, the Jet A value of the pycontrails library. BADA does
not use this value (audit A12). The documentation also said "no correction if the operator
gives no calorific value", but the code always corrects (audit A11).

After: REFERENCE_Q_FUEL = 43.217 MJ/kg, the value BADA4 itself uses.

Verification

  • pyBADA computes BADA4 fuel flow as energy flow / LHV of the aircraft file.
  • All 86 BADA4 models that PyNEATS can select (through its mapping tables) declare
    LHV = 43.217 MJ/kg (all jets, BADA 4.2), in both BADA folders we use.
  • A new test (tests/test_fuel_energy_reference.py) re-checks this against the BADA4 files
    every time the suite runs with BADA, so a future BADA release with another value fails.

Decision (Philippe Very and Ramon Dalmau, 2026-10-22)

  • Keep the correction, always applied (with the default 42.8 MJ/kg: x 1.0097).
  • Use the BADA4 value, 43.217 MJ/kg, for BADA4 and for BADA3 (BADA3 declares no value).
  • Piston aircraft (BADA4 value 43.71 MJ/kg) are not used in NEATS.
  • Document it: mrv-specification.md now states the always-applied correction.

Effect

Fleet before/after on the 4,959 sample flights:

  • fuel and CO2 +0.21 % (BADA4 +0.21 %, BADA3 +0.21 %), NOx +0.41 %;
  • per flight -0.6 % to +1.3 % (median +0.21 %; the iterative take-off mass stops within 1 %);
  • same failing flights, no flight changes BADA family.

Test data

  • All golden files regenerated with this code. Inputs derived from the default run (operator
    mass, fuel flow, efficiency, take-off mass cases) change too.
  • Per-flight totals: fuel/CO2 up to +0.25 %, NOx up to +0.44 %, contrail energy forcing
    -0.11 % to +0.39 %; nvPM up to +0.25 %, except one test case (hydrogen out of range:
    nvPM number +0.57 %, mass +0.76 %).
  • New open audit item I12: for one flight, the single-flight runner and the fleet runner
    give contrail results 0.1 % apart with identical inputs (a contrail ends a few minutes
    earlier). In the single-flight golden test only the contrail values now use a 0.5 %
    tolerance; everything else stays at 0.1 %.

Checks

Full test suite 330 passed (the one contrail tolerance failure is fixed; the golden pipeline
tests rerun: 8 passed). Independent review: no code defects. Audit A11/A12 resolved.

ramondalmau and others added 4 commits October 22, 2026 12:07
BADA gives the fuel flow of a fuel with a given lower calorific value;
PyNEATS rescales it to the actual fuel: ff = ff_BADA x REFERENCE_Q_FUEL /
q_fuel. REFERENCE_Q_FUEL was 43.13e6 J/kg, the pycontrails JetA value,
which BADA does not use (audit A12). The docs said no correction applies
without an AO q_fuel, but it always applies (audit A11).

Verification: pyBADA computes BADA4 fuel flow as energy flow / AC.LHV;
all 86 BADA4 models reachable through the PyNEATS mapping tables declare
LHV = 43.217e6 J/kg (all jets, BADA 4.2, both BADA folders).

Maintainer decision (Philippe Very, Ramon Dalmau, 2026-10-22):
- keep the rescaling, always applied (default q_fuel 42.8e6: x1.0097);
- REFERENCE_Q_FUEL = 43.217e6 J/kg (BADA4 LHV) for BADA4 and BADA3
  (BADA3 declares no LHV); piston models (43.71e6) are not used;
- document it.

Effect (fleet before/after, 4,959 sample flights): fuel and CO2 +0.21 %
(BADA4 and BADA3 alike), NOx +0.41 %; same failing flights.

Test: tests/test_fuel_energy_reference.py checks the constant, the model
default, and that every mapped BADA4 model declares this LHV (fails on
the previous code). Docs: mrv-specification.md; docstrings; audit A11/A12.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All golden outputs, and the inputs derived from the default run (operator
mass, fuel flow, efficiency and take-off mass test cases), regenerated
with scripts/create_golden_outputs.py on this branch, written in the
committed key order. Per-flight totals change by at most +0.25 % (fuel,
CO2), +0.44 % (NOx), +0.39 % (contrail energy forcing; min -0.11 %);
nvPM by at most +0.25 %, except FDX5067__tc_hydrogen_out_of_range
(nvPM number +0.57 %, nvPM mass +0.76 %). The remaining differences are environment noise in the CoCiP
radiation columns (the committed files were made on another machine:
per-flight fuel/CO2/NOx/nvPM totals already matched dev to 5e-14,
contrail energy forcing to 1.5e-4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…audit I12)

The golden outputs come from FleetRunner (CoCiP on the whole fleet); the
FlightRunner test runs one flight. With identical inputs, the contrails at
FDX5067 waypoints 48-49 end a few minutes apart in the two runs, and the
flight's contrails_ef_J and contrail EAGWP/CO2eq differ by 1.03e-3 (rtol
1e-3) once the A12 fuel change is applied (1.8e-6 on dev).

Only contrails_ef_J and the "Contrails" climate metrics are compared at
rtol 5e-3; everything else stays at 1e-3; FleetRunner tests unchanged.
Audit: new open item I12; three stale A11/A12 passages updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…folder

The CI BADA data repository may hold only some BADA4 models; a missing
model made the test fail. Check every mapped model that is present, and
skip with a message when none is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ramondalmau
ramondalmau merged commit 8d437f5 into dev Oct 22, 2026
6 checks passed
@ramondalmau
ramondalmau deleted the fix/fuel-energy-reference branch October 22, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant