Skip to content

TR-BDF2 Timestepper - #714

Open
Thomas Bendall (tommbendall) wants to merge 38 commits into
MetOffice:mainfrom
tommbendall:tr_bdf2
Open

TR-BDF2 Timestepper#714
Thomas Bendall (tommbendall) wants to merge 38 commits into
MetOffice:mainfrom
tommbendall:tr_bdf2

Conversation

@tommbendall

@tommbendall Thomas Bendall (tommbendall) commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Sci/Tech Reviewer: Alex Brown (@atb1995)
Code Reviewer: Pierre Siddall (@Pierre-siddall)

This PR adds a new timestepping scheme called TR-BDF2. Unlike the Semi-Implicit scheme currently used in Gungho, TR-BDF2 consists of two stages: TR (Trapezoidal) and BDF2 (Second-Order Backwards-Difference).
However both stages involve a Quasi-Newton outer/inner iteration like the Semi-Implicit scheme.

Because it contains two stages, the intention is that TR-BDF2 is used with a doubled timestep length. Physics schemes are called only once per the doubled timestep, reducing their cost. It is also possible to reduce the total number of inner iterations compared with the Semi-Implicit scheme, reducing the cost of the linear solver.

TR-BDF2 avoids the implicit off-centering of the Semi-Implicit scheme, which also improves the overall accuracy.

While this scheme will not be immediately adopted, it may be included in GC7 which is why I am lodging the code now.

The changes involved in this PR are:

  • introducing namelist settings for the new timestepper
  • renaming the inner_iterations setting to inner_iterations_si, and making
    this an array (so that it is possible to perform different numbers of inner
    iteration on each outer iteration)
  • passing the stepper enumerator through to the transport scheme, as this the
    TR and BDF steps require different timestep lengths
  • setting the tracer transport for TR-BDF2 to happen only in the BDF2 step
  • duplicating the dynamics W2 mass matrices. These contain the timestep, and
    different matrices are needed for the TR and BDF2 steps.
  • ensuring that the stepper enumerator is available through the argument list
    for any algorithm that calls the dynamics W2 mass matrices, such as rhs_alg
  • adding the TR-BDF2 timestepper in all its glory, with physics schemes and diagnostics
  • new tests in gungho_model and lfric_atm which use TR-BDF2
  • adding documentation(!) of all of the timestepping schemes

Is Blocked By #659

Key Diffs

Documentation

  • Plots from the new gungho_model and lfric_atm tests, compared with their Semi-Implicit
    equivalents can be found in this PDF:
    results_tr_bdf2.pdf
  • The maths of the scheme is documented in the repository's documentation, and I can
    provide reviewers with a path to view the compiled documentation through a browser

Code Quality Checklist

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • Comments have been included that aid understanding and enhance the readability of the code
  • My changes generate no new warnings
  • All automated checks in the CI pipeline have completed successfully

Testing

  • I have tested this change locally, using the LFRic Apps rose-stem suite
  • If any tests fail (rose-stem or CI) the reason is understood and acceptable (e.g. kgo changes)
  • I have added tests to cover new functionality as appropriate (e.g. system tests, unit tests, etc.)
  • Any new tests have been assigned an appropriate amount of compute resource and have been allocated to an appropriate testing group (i.e. the developer tests are for jobs which use a small amount of compute resource and complete in a matter of minutes)

trac.log

Test Suite Results - lfric_apps - test_tr_bdf2/run5

Suite Information

Item Value
Suite Name test_tr_bdf2/run5
Suite User thomas.bendall
Workflow Start 2026-08-17T10:03:08
Groups Run all', 'lfric_atm_weekly
Dependency Reference Main Like
casim MetOffice/casim@2026.07.1 True
jules MetOffice/jules@2026.07.1 True
lfric_apps tommbendall/lfric_apps@test_tr_bdf2 False
lfric_core tommbendall/lfric_core@932de27 True
moci MetOffice/moci@2026.07.1 True
SimSys_Scripts MetOffice/SimSys_Scripts@2026.07.1 True
socrates MetOffice/socrates@2026.07.1 True
socrates-spectral MetOffice/socrates-spectral@2026.07.1 True
ukca MetOffice/ukca@2026.07.1 True

Task Information

✅ succeeded tasks - 1714

Security Considerations

  • I have reviewed my changes for potential security issues
  • Sensitive data is properly handled (if applicable)
  • Authentication and authorisation are properly implemented (if applicable)

Performance Impact

  • Performance of the code has been considered and, if applicable, suitable performance measurements have been conducted

AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance of Generative AI tool name (e.g., Met Office Github Copilot Enterprise, Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the Simulation Systems AI policy (including attribution labels)

AI has been used to help draft the documentation.

Documentation

  • Where appropriate I have updated documentation related to this change and confirmed that it builds correctly

PSyclone Approval

  • If you have edited any PSyclone-related code (e.g. PSyKAl-lite, Kernel interface, optimisation scripts, LFRic data structure code) then please contact the TCD Team

Sci/Tech Review

  • I understand this area of code and the changes being added
  • The proposed changes correspond to the pull request description
  • Documentation is sufficient (do documentation papers need updating)
  • Sufficient testing has been completed

(Please alert the code reviewer via a tag when you have approved the SR)

Code Review

  • All dependencies have been resolved
  • Related Issues have been properly linked and addressed
  • CLA compliance has been confirmed
  • Code quality standards have been met
  • Tests are adequate and have passed
  • Documentation is complete and accurate
  • Security considerations have been addressed
  • Performance impact is acceptable

@tommbendall Thomas Bendall (tommbendall) added the documentation Improvements or additions to documentation label Aug 13, 2026

@thomasmelvin thomasmelvin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, i've made a few minor comments, mostly about the descriptions of namelist variables and the timestepping scheme (thanks for doing these!)

A more general question is could we get our existing siqn scheme from careful selection of choices in the TR-BDF2 scheme, i.e. making so that the step for the tr scheme is dt and for the bf2 to is 0. I think you default to the centred siqn scheme but maybe is possible a future change could be to unify these two schemes?

description=Off-centering parameter for the Semi-Implicit timestepping scheme
help=This controls the implicitness of the Semi-Implicit timestepping scheme.
=A value of 0.5 corresponds to a Crank-Nicolson scheme, while a value of 1.0
=corresponds to a fully implicit scheme. Values of 0.5 can be appropriate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? Most of the gungho orographic tests would run with alpha = 0.5 without any problems. I'm not sure we have tried physics runs with alpha 0.5. I would suggest getting rid of the last sentance

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tom, I was obviously confused about this point! Shallow water systems can suffer from orographic resonance with the centred scheme, which builds noise that can lead to an instability -- and I had assumed the compressible Euler equations did too. Out of interest I have now tried running the lfric_atm test-suite with alpha=0.5, and every job did actually complete!

I have removed this sentence and also edited the documentation

Comment thread science/gungho/rose-meta/lfric-gungho/HEAD/rose-meta.conf Outdated
Comment thread science/gungho/rose-meta/lfric-gungho/HEAD/rose-meta.conf Outdated
Like ENDGame, GungHo uses a default of :math:`n_o=2` outer iterations and
:math:`n_i=2` inner iterations, for a total of 4 linear solves per timestep.

Because the transport terms are only updated in the outer loop, using more

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is quite right, after all we also transport u in the outer loop but don't zero the momentum residual in the inner loop. I would say that the reason we zero the density and potential temperature residuals in the inner loop is that the solver updates the transport tendency for these terms (that are only updated in the inner loop) compared to the momentum equation where the solver updates the nonlinear forcing terms (principally the pressure gradient) that are updated in the inner loop

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow this got garbled between edits, thanks for pointing it out. I've tried to improve the explanation

Comment thread documentation/source/science_guide/timestepping/tr_bdf2.rst Outdated
Comment thread documentation/source/science_guide/timestepping/tr_bdf2.rst Outdated
Comment thread documentation/source/user_guide/timestepping/index.rst Outdated
@DanStoneMO

Copy link
Copy Markdown
Contributor

This will require a linked-JEDI PR. I've made changes at: https://github.com/MetOffice/lfric-jedi/pull/1332 though I've not been able to test them yet due to this PR's branch conflicting with main.

I'll approve once this is up-to-date and I can properly test.

@DanStoneMO DanStoneMO added the Linked Jedi This PR is linked to a Jedi PR - this will be managed by the DA team label Aug 19, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Hello Thomas Bendall (@tommbendall)!

Your CLA signature was found on the base branch, but you appear to have modified the CONTRIBUTORS.md file in this PR.

Please do not edit the CONTRIBUTORS.md file. If you have already signed the CLA, revert changes to the file and your signature will be picked up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-modified The CLA has been modified as part of this PR - added by GA documentation Improvements or additions to documentation enhancement New feature or request KGO This PR contains changes to KGO Linked Jedi This PR is linked to a Jedi PR - this will be managed by the DA team macro This PR contains a metadata upgrade macro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants