Skip to content

Alignment with legacy MATLAB code (AEIC v2.1)#106

Merged
ian-ross merged 7 commits into
MIT-LAE:mainfrom
ian-ross:matlab-alignment
Mar 5, 2026
Merged

Alignment with legacy MATLAB code (AEIC v2.1)#106
ian-ross merged 7 commits into
MIT-LAE:mainfrom
ian-ross:matlab-alignment

Conversation

@ian-ross

@ian-ross ian-ross commented Mar 3, 2026

Copy link
Copy Markdown
Member

This PR is a collection of changes needed to bring the legacy trajectory builder and the emissions code into line with the MATLAB AEIC v2.1 as part of the verification process described in #78.

(Tests are failing because I changed the way that trajectories are simulated, so all the golden test data will need to be regenerated, and I changed the EI_HCCO function to match the MATLAB code, which broke another test. We'll deal with those things later once we've got this working better.)

As of the point when I'm opening this PR, I think the trajectory simulation is OK. The remaining issues are all to do with emissions. I've attached a copy of the validation report (link at the bottom). Some comments follow.

Trajectory simulations

There are still a few small discrepancies in the trajectory fields. These arise from one of three sources:

  1. Unit issues in the MATLAB code: no consistent set of units is used, unit conversions are done with chains of conversion factors, etc., so there are rounding errors that add up over time.
  2. The MATLAB code appears to assume the Earth is a sphere for all great circle distance calculations. Again, this leads to small differences that accumulate along a trajectory.
  3. There are a few cases where the starting aircraft mass is a little different. I've not diagnosed that yet.

Emissions simulations

  • Of the emissions, CO₂, H₂O and SOₓ are now OK. I created a custom fuel file with the same CO₂ and H₂O emission indices as used in the MATLAB code to deal with this.
  • The other emissions values are all unacceptably different.
  • For HC and CO, I disabled the "ACRP low-thrust correction" in EI_HCCO since this does not seem to exist in the MATLAB code. That improves matters a little, and the temporal profiles of the HC and CO emissions are now more or less the same shape in the MATLAB and the Python results. However, there are differences between the outputs that I think are down to the MATLAB code not using the same engine data as the Python code.
  • The same goes for the NOₓ emissions: the shape of the profiles are more or less the same, but the scaling is different, pointing to different engine parameters between the two sets of simulations.
  • The PMvol and PMnvol profiles are completely different, which leads me to believe that Adi hasn't set the MATLAB simulations up to use the same methods as the Python code.

Engine parameter comparison

The Python code uses the emission indices given in the performance model file. The MATLAB code uses who knows what, but the table below shows emissions indices for CO, HC and NOₓ for the Python performance model and engine type CFM56-7B27 from the ENG_EI_UIDs_modeSN.txt file, which is the engine we have in the engine database spreadsheet we're using (and from which the Python performance model data was generated). I know nothing about this, to be honest, but the relative scaling of the emissions indices looks like it might explain the differences in the simulations.

Here, the modes are the slightly strange ordering used in this MATLAB engine data file, "M" is MATLAB, "P" is Python.

Mode CO M CO P HC M HC P NOₓ M NOₓ P
1 = Approach 1.4 2.82 0.1 0.05 11.0 9.09
2 = Climb 0.5 0.17 0.1 0.02 23.7 17.89
3 = Take-off 0.2 0.31 0.1 0.03 30.9 23.94
4 = Idle 17.9 29.39 1.7 1.54 4.8 4.36

If you squint at this table while viewing one of the emissions plots for HC, CO or NOₓ, you might be able to convince yourself that the differences are down to the differences in these indices. In particular, the idle index for NOₓ is similar between the two cases, and the NOₓ plots are close to identical for the descent phase, while the MATLAB code has emissions 20-30% greater during the other flight phases. That's pretty suggestive to me.

My question now would be: why are the performance numbers in our performance model completely different from what the MATLAB code would appear to be using? Is the data in the engine database extract that we have correct? These are quite significant differences.

Next steps

@aditeyashukla This is all down to you. Can you do the following:

  1. Identify definitively which engine parameters are being used in the MATLAB simulations and make the performance model used on the Python side use the same parameters.
  2. Make the MATLAB simulations use the same PMvol and PMnvol methods as the Python code.

Once you've done those things I'll come back to this.

validation-report-2026-03-03.pdf

@ian-ross

ian-ross commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

@aditeyashukla has fixed most of this:

  • The PMvol emissions were not being calculated in the MATLAB code for trajectory points at all, so we're omitting them from the comparison.
  • The MATLAB code does not implement the MEEM method for PMnvol emissions, so we're omitting those too.
  • The HC and CO emissions had an extra fuel flow correction in the MATLAB code. Without that, the comparison is much better. Not perfect, but it may be as good as we're going to get.

We're going to merge the PR as it is, and then reassess.

An updated validation report is attached.

validation-report-2026-03-05.pdf

@ian-ross ian-ross marked this pull request as ready for review March 5, 2026 20:43
@ian-ross ian-ross merged commit d819367 into MIT-LAE:main Mar 5, 2026
4 checks passed
@ian-ross ian-ross deleted the matlab-alignment branch March 5, 2026 20:43
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.

2 participants