Skip to content

Conversation

aakashsane
Copy link

@aakashsane aakashsane commented Oct 9, 2024

These changes enhance the existing vertical diffusivity used in EPBL with machine learned diffusivity that is constrained on a second moment closure. Using symbolic regression and least-squares fitting, a shape function ( g(\sigma) ) responds to changes in the surface forcing (Latitude, wind stress, surface buoyancy flux, boundary layer depth). g(\sigma) goes from zero to 1 and its skewness changes as per surface forcing conditions.

There are two options for the turbulent velocity scale: v0 and v0h.

The velocity scale, v0, is an approximation that depends on three inputs: Coriolis parameter f, ustar u*, and surface buoyancy flux BFlux. It agrees with diagnosed velocity scale from GLS scheme given by v0 = < { \kappa } max / h >, where h is boundary layer depth and angled brackets denote averaged data for a given forcing: B, u_, f. 
When v0 is multiplied with g(\sigma) and multiplied by the energetics based boundary layer depth h, i.e \nu = . g(\sigma) \cdot v_0 \cdot h, we get a diffusivity which is constrained on a second moment closure.

The second velocity scale, v0h, depends on ustar u*, surface buoyancy flux BFlux, and boundary layer depth. It agrees with diagnosed velocity scale from GLS scheme given by v0^h = { \kappa } max / h , where h is the boundary layer depth. v0^h agrees with convective velocity scaling under pure convection ( v0^h ~ (Bh)^(1/3) ).

When v0 or v0^h is multiplied with g(\sigma) and multiplied by the energetics based boundary layer depth h, i.e \nu = . g(\sigma) \cdot v_0 \cdot h, we get a diffusivity which is constrained on a second moment closure.

The Machine learned (ML) diffusivity is activated by using the logical flags:

  1. EPBL_EQD_DIFFUSIVITY_SHAPE
  2. EPBL_EQD_DIFFUSIVITY_VELOCITY
  3. EPBL_EQD_DIFFUSIVITY_VELOCITY_H

Logical flag 1 activates the new equation for shape function.
Logical flag 2 activates velocity scale v0
Logical flag 3 activates velocity scale v0^h

To use ML diffusivity, Logical flag 1 has to be set to ‘True’ and either logical flag 2 or 3 should be set to ‘True’. 2 and 3 both cannot be true or false.
The subroutines replace the default EPBL mixing coefficients of Reichl and Hallberg (2018).
The publications for OSBL machine learned diffusivity are: Sane et al. 2023 ( https://doi.org/10.1029/2023MS003890 ) and Sanę et al. 2025 (under preparation).

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 13.13131% with 86 lines in your changes missing coverage. Please review.

Project coverage is 37.52%. Comparing base (6eca7bb) to head (d365109).
Report is 129 commits behind head on dev/gfdl.

Files with missing lines Patch % Lines
...c/parameterizations/vertical/MOM_energetic_PBL.F90 13.13% 85 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           dev/gfdl     #737      +/-   ##
============================================
- Coverage     38.01%   37.52%   -0.49%     
============================================
  Files           299      305       +6     
  Lines         88063    91530    +3467     
  Branches      16547    17424     +877     
============================================
+ Hits          33475    34348     +873     
- Misses        48513    50757    +2244     
- Partials       6075     6425     +350     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@adcroft adcroft left a comment

Choose a reason for hiding this comment

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

I can't (shouldn't) make the final approval on this since I'm involved in the research, but there are some obvious things that need to be changed before someone else reviews the PR. Once these are cleaned up, my take is it will be smooth sailing.

You added several files that I think should not be included:

  • .testing/tc4/Makefile is generated by autoconf using the Makefile.in template
  • .testing/gen_data.dSYM/Contents.Info.plist - looks like something leftover from your a mac build process
  • .testing/gen_grid.dSYM/Contents.Info.plist - ditto

Please remove these files. I believe the only file you meant to submit changes for is MOM_energetic_PBL.F90. There's also a real variable with missing unit documentation which I added a separate inline comment for.

@adcroft
Copy link
Member

adcroft commented Nov 25, 2024

I've just been discussing with Bob, and we think we need to add a new version of get_param to solve a problem that has been highlighted by this PR, namely that we're adding 16 run-time parameters, for one scheme, when they could be a single line. We'll look into adding a vector default option and get back to this PR shortly.

@aakashsane
Copy link
Author

I have worked on the comments and updated the code. Please review the changes.

@aakashsane
Copy link
Author

I have worked on the comments and updated the code. Please review the changes and I will be happy to edit.

@aakashsane
Copy link
Author

aakashsane commented May 15, 2025

The code has been modified for efficiency. Number of divisions and unnecessary local variables have been removed.
In the subroutines, there were a total of 24 coefficients. They have been simplified to a total of 18 coefficients.

The non-dimensional variables p1 and p2 have been replaced with much easier to read variables: Eh and Lh. Eh is boundary layer depth (h) divided by Ekman depth (u_/f) and Lh is (hBflux)/(u_*^3). This makes the subroutines readable and in line with variables names in the upcoming manuscript.

@aakashsane aakashsane force-pushed the ML_diffusivity branch 2 times, most recently from d051627 to 6b15ff4 Compare May 16, 2025 03:05
@aakashsane aakashsane force-pushed the ML_diffusivity branch 2 times, most recently from a55e6dc to d365109 Compare May 17, 2025 19:19
Copy link
Member

@adcroft adcroft left a comment

Choose a reason for hiding this comment

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

This is getting close to ready. I was able to confirm that a squash merge is compatible with the latest dev/gfdl with no conflicts. The documentation of the PR (the PR message) is out-of-date, and will be again when you fix the runtime parameter names to fit the convention.

@aakashsane
Copy link
Author

The necessary changes have been made.

@aakashsane
Copy link
Author

I completed all the necessary edits.

@aakashsane aakashsane requested a review from Hallberg-NOAA May 28, 2025 23:45
Copy link
Member

@Hallberg-NOAA Hallberg-NOAA left a comment

Choose a reason for hiding this comment

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

Thank you, @aakashsane, for the substantial revisions to this PR. After inspecting the code again, it is much improved both in terms of clarity and I suspect efficiency. I am finding only a few spelling errors in a comment ("units iof buuyancy flux" on line 2842) that I would correct; I suppose that we can let that little thing slide for now!

These changes enhance the existing vertical diffusivity used in EPBL with machine learned diffusivity that is constrained on a second moment closure. Using symbolic regression and least-squares fitting, a shape function ( g(\sigma) ) responds to changes in the surface forcing (Latitude, wind stress, surface buoyancy flux, boundary layer depth). g(\sigma) goes from zero to 1 and its skewness changes as per surface forcing conditions.

There are two options for the turbulent velocity scale: v0 and v0h.

The velocity scale, v0, is an approximation that depends on three inputs: Coriolis parameter f, ustar u_*, and surface buoyancy flux BFlux. It agrees with diagnosed velocity scale from GLS scheme given by v0 = < { \kappa } max / h >, where h is boundary layer depth and angled brackets denote averaged data for a given forcing: B, u_*, f. 
When v0 is multiplied with g(\sigma) and multiplied by the energetics based boundary layer depth h, i.e \nu = . g(\sigma) \cdot v_0 \cdot h, we get a diffusivity which is constrained on a second moment closure.

The second velocity scale, v0h, depends on  ustar u_*, surface buoyancy flux BFlux, and boundary layer depth. It agrees with diagnosed velocity scale from GLS scheme given by v0^h =  { \kappa } max / h , where h is the boundary layer depth. v0^h agrees with convective velocity scaling under pure convection ( v0^h ~ (Bh)^(1/3) ).

When v0 or v0^h is multiplied with g(\sigma) and multiplied by the energetics based boundary layer depth h, i.e \nu = . g(\sigma) \cdot v_0 \cdot h, we get a diffusivity which is constrained on a second moment closure.

The Machine learned (ML) diffusivity is activated by using the logical flags:
1. EPBL_EQD_DIFFUSIVITY_SHAPE
2. EPBL_EQD_DIFFUSIVITY_VELOCITY
3. EPBL_EQD_DIFFUSIVITY_VELOCITY_H

Logical flag 1 activates the new equation for shape function.
Logical flag 2 activates velocity scale v0
Logical flag 3 activates velocity scale v0^h

To use ML diffusivity, Logical flag 1 has to be set to ‘True’ and either logical flag 2 or 3 should be set to ‘True’. 2 and 3 both cannot be true or false.
The subroutines replace the default EPBL mixing coefficients of Reichl and Hallberg (2018).
The publications for OSBL machine learned diffusivity are: Sane et al. 2023 ( https://doi.org/10.1029/2023MS003890 ) and Sanę et al. 2025.
@Hallberg-NOAA
Copy link
Member

This PR passed pipeline testing with the expected warnings about new runtime parameters at https://gitlab.gfdl.noaa.gov/ogrp/mom6ci/MOM6/-/pipelines/27608, and then it passed again with fewer new runtime parameters due to the addition of some appropriate do_not_log arguments in some of the newly added get_param() calls at https://gitlab.gfdl.noaa.gov/ogrp/mom6ci/MOM6/-/pipelines/27615. That minorly revised version also passed TC testing at https://github.com/Hallberg-NOAA/MOM6/tree/aakash-ML_diffusivity.

@adcroft
Copy link
Member

adcroft commented May 30, 2025

This has been merged. @Hallberg-NOAA made one further edit which makes it look like a new conflict which is why this did not close automatically.

@adcroft adcroft closed this May 30, 2025
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.

3 participants