Skip to content

Conservative scalar diffusion#378

Open
Thomas Bendall (tommbendall) wants to merge 13 commits intoMetOffice:mainfrom
tommbendall:TBendall/conservative_diffusion
Open

Conservative scalar diffusion#378
Thomas Bendall (tommbendall) wants to merge 13 commits intoMetOffice:mainfrom
tommbendall:TBendall/conservative_diffusion

Conversation

@tommbendall
Copy link
Copy Markdown
Contributor

@tommbendall Thomas Bendall (tommbendall) commented Mar 17, 2026

PR Summary

Sci/Tech Reviewer: Shusuke Nishimoto (@mo-snishimoto)
Code Reviewer: mo-marqh

Implements the conservative form of the Smagorinsky diffusion operator for scalars, and ensures that the diffusion coefficient is appropriately capped.

See Also

The test branch, showing the action of the upgrade macro and the changed KGOs, can be found here: tommbendall#10

Details

This PR:

  1. Adds a new kernel science/gungho/source/kernel/diffusion/diffusion_flux_kernel_mod.F90 to compute the mass flux associated with the diffusion operator
  2. Reorganises the science/gungho/source/algorithm/diffusion/smagorinsky_alg_mod.x90 algorithm to facilitate the new diffusion options
  3. Adds a kernel to cap the diffusion coefficient: science/gungho/source/kernel/diffusion/cap_diffusion_coeff_kernel_mod.F90
  4. Implements a single/double precision interface for science/gungho/source/kernel/transport/ffsl/fv_divergence_2d_kernel_mod.F90, so that it can be used at the r_def precision used in smagorinsky_alg_mod
  5. Adds new namelist options for diffusion: science/gungho/rose-meta/lfric-gungho/HEAD/rose-meta.conf

Documentation

Some documentation describing the approach can be found here: Conservative_Diffusion.pdf

Results

A selection of plots from tests with changed KGOs can be found in this PDF:
results_conservative_diffusion.pdf

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_conservative_diffusion/run2

Suite Information

Item Value
Suite Name test_conservative_diffusion/run2
Suite User thomas.bendall
Workflow Start 2026-03-25T20:18:04
Groups Run all
Dependency Reference Main Like
casim MetOffice/[email protected] True
jules MetOffice/[email protected] True
lfric_apps tommbendall/lfric_apps@TBendall/TestConservativeDiffusion False
lfric_core MetOffice/[email protected] True
moci MetOffice/[email protected] True
SimSys_Scripts MetOffice/[email protected] True
socrates MetOffice/[email protected] True
socrates-spectral MetOffice/[email protected] True
ukca MetOffice/[email protected] True

Task Information

✅ succeeded tasks - 1511

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)

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 enhancement New feature or request KGO This PR contains changes to KGO macro This PR contains a metadata upgrade macro labels Mar 17, 2026
@DanStoneMO
Copy link
Copy Markdown
Contributor

This will need a linked JEDI PR. I'll link it once ready.

@DanStoneMO DanStoneMO added the Linked Jedi This PR is linked to a Jedi PR - this will be managed by the DA team label Mar 26, 2026
=namelist:mixing=smag_l_calc: .true. ;
=namelist:mixing=max_diff_factor: .true.;
=namelist:mixing=conservative_diffusion: .true.;
=namelist:mixing=density_weighted: .true.;
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.

Suggest triggering this from conservative_diffusion, since it only applies if that is true

Copy link
Copy Markdown
Contributor

@DanStoneMO DanStoneMO left a comment

Choose a reason for hiding this comment

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

With the recent commits, JEDI now runs fine with this as-is. No linked PR is needed anymore

@DanStoneMO DanStoneMO removed the Linked Jedi This PR is linked to a Jedi PR - this will be managed by the DA team label Mar 26, 2026
@tommbendall
Copy link
Copy Markdown
Contributor Author

With the recent commits, JEDI now runs fine with this as-is. No linked PR is needed anymore

Yes -- apologies for the confusion! This is because the new options are now only triggered by using Smagorinsky mixing, which isn't used in global or DA configurations

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

Labels

enhancement New feature or request KGO This PR contains changes to KGO macro This PR contains a metadata upgrade macro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants